<!--扫描二维码页面-->
<template>
    <view id="saoCode">
        <web-view :src="baseUrl+'admin/#/codeHtml?code='+code+'&type='+type"></web-view>
    </view>
</template>
<script>
	import { config } from '@/api/request/config.js'
    export default {
        name: "saoCode",
        data() {
            return {
				baseUrl:config.base_url,
                code:"",
                type:"",
                subId:"",
				pageType:2,
            }
        },

      onLoad(option) {
        let self = this;
        if(option.q){
          let text = decodeURIComponent(option.q)
          let list = text.split("?")[1].split("&");
          for(let i=0;i<list.length;i++){
            let newList = list[i].split("=");
            if(newList[0] == 'code'){
              self.code = newList[1];
            }else if(newList[0] == 'type'){
              self.type = newList[1];
            }else if(newList[0] == 'subId'){
              self.subId = newList[1];
            }
          }
          if(!uni.getStorageSync('token')){
            uni.setStorageSync('saoCode',this.code);
            uni.setStorageSync('saoType',this.type);
            uni.setStorageSync('saoSubId',this.subId);
            uni.redirectTo({
              url: '/pages/login',
            });
          }else{
            if(this.type==7){//培训课程
              uni.redirectTo({
                url: '/pages/pages_patrolInspector/courseQRcode?code='+this.code,
              });
            }else if(this.type==8){//化学品柜
              uni.redirectTo({
                url: '/pages/pages_patrolInspector/chemicalCabinetQRcode?code='+this.code,
              });
            }else if(this.type==9){//化学品
              uni.redirectTo({
                url: '/pages/pages_patrolInspector/chemicalDetail?code='+this.code,
              });
            }else if(this.type==11){//化学品身份识别验证
              uni.redirectTo({
                url: '/pages/pages_patrolInspector/identityVerify?code='+this.code+'&subId='+this.subId,
              });
            }
          }
        }else{
          this.code = uni.getStorageSync('saoCode');
          this.type = uni.getStorageSync('saoType');
          this.type = uni.getStorageSync('saoSubId');
          uni.removeStorageSync('saoCode');
          uni.removeStorageSync('saoType');
          uni.removeStorageSync('saoSubId');
          if(this.type==7){//培训课程
            uni.redirectTo({
              url: '/pages/pages_patrolInspector/courseQRcode?code='+this.code,
            });
          }else if(this.type==8){//化学品柜
            uni.redirectTo({
              url: '/pages/pages_patrolInspector/chemicalCabinetQRcode?code='+this.code,
            });
          }else if(this.type==9){//化学品
            uni.redirectTo({
              url: '/pages/pages_patrolInspector/chemicalDetail?code='+this.code,
            });
          }else if(this.type==11){//化学品身份识别验证
              uni.redirectTo({
                url: '/pages/pages_patrolInspector/identityVerify?code='+this.code+'&subId='+this.subId,
              });
            }
        }
      },
      mounted(){

      },

      methods:{

      },
    }
</script>

<style lang="stylus" scoped>
    #saoCode{
        overflow scroll
    }
</style>
