<template>
	<view>
    <mumu-get-qrcode @success='qrcodeSucess' @error="qrcodeError" ></mumu-get-qrcode>
	</view>
</template>

<script>
import mumuGetQrcode from '@/uni_modules/mumu-getQrcode/components/mumu-getQrcode/mumu-getQrcode.vue'
import {getDeviceInfoFromQrcode} from "@/api/device/device";
	export default {
    components: {
      mumuGetQrcode
    },
		data() {
			return {
				
			}
		},
		methods: {
      qrcodeSucess(data) {
        getDeviceInfoFromQrcode(data).then(res=>{
          if(res.data != null){
            let imei = res.data.imei;
            let ccid = res.data.ccid;
            uni.redirectTo({
              url: '/pages/weitiandi/device/index?id='+imei+'&ccid='+ccid
            });
          }
        });
      },
      qrcodeError(err) {
        console.log(err)
        uni.showModal({
          title: '摄像头授权失败',
          content: '摄像头授权失败，请检测当前浏览器是否有摄像头权限。',
          success: () => {
            uni.navigateBack({})
          }
        })
      },
		}
	}
</script>

<style>

</style>
