
<style scoped> 
input{-webkit-appearance:none;} 
.comp-login {height:100%;height:100vh;padding:0;margin:0;
    background-image:url('http://image.supercarrier8.com/h5_key/MyReward-backgroundTop.png');
  background-repeat:no-repeat;
  background-size:100% 100%; 
}
.Capital_Title{height: 2rem;color:#fff;line-height: 2rem;padding-top: 1rem;}
.Capital_Title .Capital_Title_Left{float:left;font-weight: bold;}
.Capital_Title .Capital_Title_Left span{margin-left: 0.8rem;padding-top: 0.3rem;
padding-left: 1.3rem;background: url('http://image.supercarrier8.com/h5_key/icon-selectMode.png');background-repeat: no-repeat;background-position: 0 center;background-size: 1.1rem 1.1rem;}
.Capital_Title .Capital_Title_Right{float: right;padding-right: 1rem;}
.Capital_Title .Capital_Title_Right img{width: 0.3rem;}
.ScanWriteOff{position: relative;background:#fff;height: 80%;width: 90%;margin-left: 1rem;margin-right: 1rem;border-radius: 0.3rem;margin-top: 2rem;}
.CenterPower{position: relative;padding-top:22%;text-align: center;}
.CenterPower div{position: relative;top: -4.5rem;left: 4.8rem;font-size: 0.7rem;color:#fff;}
.txtSearch{background-color:#F3F6FF;border: none;text-indent: 1rem;flex: 1;-webkit-box-flex: 1;-ms-flex: 1;border-radius: 0;height:100%;}
.btnSearch{background:#3B8AFC;color:#fff;border: none;width:3.8rem;border-radius: 0;height:100%;}
.WriteOffSearch{width: 88%;background-color:#F3F6FF;text-align: center;font-size: 1.2rem !important;line-height:3rem;height: 3rem;overflow:hidden;display: -webkit-box;display: -ms-flexbox;display: flex;margin: 0 auto;margin-top:18%;border-radius: 0.4rem;overflow: hidden;}
.auditPopu{position: fixed;text-align: center;top:50%;margin-top:-10rem;min-height: 15.4rem;width: 74%;background: rgba(255, 255, 255, 1);margin-left:13%;border-radius: 0.2rem;}
.auditPopu img{display: block;margin: 0 auto;}
.auditPopu .successImg{width: 5rem;height: 5rem;margin-top: 2rem;}
.auditPopu h3{color:#3A8AFB;}
.auditPopu p{width:86%;margin: 0 auto; margin-top:2.5rem;}
.auditPopu p button{border: 0.1rem solid#3A8AFB;width: 70%;background:#fff;color:#3A8AFB;height: 2rem;line-height: 2rem;}
.auditPopu .closeImg{width: 2rem;height: 2rem;position: absolute;bottom: -3.2rem;margin-left:-1rem;left: 50%;}
.mask {position: fixed;top: 0;left: 0;height: 100%;width: 100%;background: rgba(0, 0, 0, 0.5);}
input[type=button],button, input[type=submit], input[type=file], button {cursor:pointer;outline:0px; -webkit-appearance:none; }

</style>
<template>     
  <div class="container comp-login jfBaseSize" v-cloak v-bind:style="vh?'height:100vh':'height: 100%;'"> 
      <div class="Capital_Title">
           <div class="Capital_Title_Left"><span>核销管理</span></div> 
           <div class="Capital_Title_Right" @click="goPage('Key_Wcord')">
              <span>查看核销记录</span>
              <span class="total">({{WriteOffCount}})
              <img src="http://image.supercarrier8.com/h5_key/icon-arrowWhite.png"/>
              </span></div>
      </div>
      <div class="ScanWriteOff">
          <div class="CenterPower" @click="scan()">
            <img src="http://image.supercarrier8.com/h5_key/scan_writeoff.png" style="width: 64%;"/>
            <!-- <div>扫码核销</div> -->
          </div>
          <div class="WriteOffSearch">
            <input type="text" class="txtSearch" v-model="VerificationCode" placeholder="输入核销码"/>
            <input type="button" value="查询" class="btnSearch" @click="query('')"/>
          </div>
      </div>

       <div class="mask" v-show="isShow.IsshowMask"></div>
       <div class="auditPopu" v-show="isShow.IsshowAudit">
          <img class="successImg" src="http://image.supercarrier8.com/h5_key/icon-OK.png" alt="success">
          <h3>
           核销成功!
          </h3>
          <p>
           <button>继续核销</button>
          </p>
    </div>
 <ReturnHome ref="returnhome"></ReturnHome>
  </div>
</template>
<script>
import { Toast } from 'mint-ui';
import channelHelper from "@/assets/js/channelHelper.js";
import { base64 } from "@/assets/js/cryptoHelper";
	import ReturnHome from "@/components/channel/temp001/ReturnHome";
import { debug } from 'util';
import wx from "weixin-js-sdk";
import '@/assets/js/libs/js.cookie';
import { Indicator } from 'mint-ui';
export default {
  name: "Key_WriteOffEnter",
  components: {ReturnHome},
  provide(){       
     return{           
        goPage:this.goPage       
     }   
  },
  props: ["comp", "cfg", "selectedPage"],
  data() {
    return {
       isShow:{
        IsshowMask:false,
        IsshowAudit:false
      },
      code: "",
      errMsg: "",
      vh:false,
      WriteOffCount:0,
      VerificationCode:""
    };
  },
  methods: {
    scan() {
        let that = this;
        wx.scanQRCode({
            needResult: 1, // 默认为0，扫描结果由微信处理，1则直接返回扫描结果，
            scanType: ["qrCode", "barCode"], // 可以指定扫二维码还是一维码，默认二者都有
            success: function(res) {
                let result = _.trim(res.resultStr); // 当needResult 为 1 时，扫码返回的结果
                if(result!="")
                {
                  that.VerificationCode=result;
                }else{
                  Toast("扫码错误，请重新扫码！");
                }
                /**调用查询逻辑 */
                that.query();
            },
            fail: function(e) {
               alert(JSON.stringify(e));
            }
        });
     },
     querySuccess(VerificationCode){
        var locationto=this.$parent;
        var that = this;
        sessionStorage.setItem("VerificationCode",that.VerificationCode);
        locationto.changeSelectedPage("Key_WInfo");//跳转到核销详细
     },
     query(){
        var that = this;
        var eno = that.sup8.context.enterpriseno;
        var url = "/channel/GetVerifyCodeInfo";
        var dataParams = {
            VerificationCode:that.VerificationCode,
            UserToken:channelHelper.GetUserToken(),
            EnterpriseNo: eno,
            LanguageType:channelHelper.GetLanguageType()
        };
        var cbError=function(){Indicator.close();}
        var cbSuccess = function(res){
          Indicator.close();
            if (res.flag){
                that.querySuccess(that.VerificationCode);
            }
            else
            {
               Toast(res.msg);
            }
        };
        //请求后端
        channelHelper.CommonCallService(url,dataParams,cbSuccess,cbError,null,null);
     },EnterIn(result){
        var that = this;
        var eno = that.sup8.context.enterpriseno;
        var url = "/channel/SubmitVerifyCode";
        var dataParams = {
            VerificationCode:result,
            UserToken:channelHelper.GetUserToken(),
            EnterpriseNo: eno,
            LanguageType:channelHelper.GetLanguageType()
        };
        var cbError=function(){Indicator.close();}
        var cbSuccess = function(res){
          Indicator.close();
            if (res.flag){
             that.isShow.IsshowMask=true;
             that.isShow.IsshowAudit=true;
            }
            else
            {
               Toast(res.msg);
            }
        };
        //请求后端
        channelHelper.CommonCallService(url,dataParams,cbSuccess,cbError,null,null);
    },
     goPage(pagetype){
        this.$parent.changeSelectedPage(pagetype);
     },LoadWriteOffCount(){
        var that = this;
        var eno = that.sup8.context.enterpriseno;
        var url = "/channel/GetVerifyCount";
        var dataParams = {
            UserToken:channelHelper.GetUserToken(),
            EnterpriseNo: eno,
            LanguageType:channelHelper.GetLanguageType()
        };
        var cbError=function(){Indicator.close();}
        var cbSuccess = function(res){
          Indicator.close();
            if (res.flag){
                that.WriteOffCount=res.data.TotalVerifyCount;
            }
        };
        //请求后端
        channelHelper.CommonCallService(url,dataParams,cbSuccess,cbError,null,null);
      }
  },
  watch: {
  },
  created: function() {
     Indicator.close(); 
     this.LoadWriteOffCount();
  },
  mounted: function() {
      //如果登录了则自动跳转到首页
      // if(localStorage.getItem("loginInfo")!=null)
      // {
      //     //var loginInfo=JSON.parse(localStorage.getItem("loginInfo"));
      //     this.login(true);
      // }
      var that=this;
      var isDesign = location.pathname.indexOf('design');
      if (!(isDesign>-1)) {
          that.$set(that,'vh',true);
      }else{
          that.$set(that,'vh',false);
      }
      setTimeout(()=>{
        let offsetHeight = document.body.offsetHeight;
        let scrollHeight = document.body.scrollHeight;
        this.height = scrollHeight>offsetHeight?scrollHeight+"px":offsetHeight+"px";
      },1000);
  }
};
</script>

