123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- <!--扫描二维码页面-->
- <template>
- <view id="saoCode">
- <web-view v-if="webViewType" :src="baseUrl+'admin/#/codeHtml?code='+code+'&type='+type"></web-view>
- </view>
- </template>
- <script>
- import {
- config
- } from '@/api/request/config.js'
- import {
- chemicalAioVerifyScanLogin,chemicalAioVerifyAppletLogin
- } from '@/api/basicsModules/index.js'
- export default {
- name: "saoCode",
- data() {
- return {
- webViewType:false,
- baseUrl: config.base_url,
- code: "",
- type: "",
- }
- },
- onLoad(option) {
- let self = this;
- if (option.q) {
- let text = decodeURIComponent(option.q)
- console.log('text',text)
- let list = text.split("?")[1].split("&");
- let codeData = {};
- console.log('codeData',codeData)
- list.forEach((item) => {
- codeData[item.split("=")[0]] = item.split("=")[1];
- })
- if (!uni.getStorageSync('token')) {
- uni.setStorageSync('codeData', codeData);
- uni.redirectTo({
- url: '/pages/login/login',
- });
- } else {
- if (codeData.type == 11) {
- //化学品终端-扫码登录
- this.chemicalAioVerifyScanLogin(codeData.code, codeData.subId, codeData.macId);
- }else if (codeData.type == 12) {
- //化学品终端-双人认证
- this.chemicalAioVerifyAppletLogin(codeData.doorId, codeData.subId, codeData.macId, codeData.code);
- }
- }
- } else {
- let codeData = uni.getStorageSync('codeData');
- uni.removeStorageSync('codeData');
- if (codeData.type == 11) {
- //化学品终端-扫码登录
- this.chemicalAioVerifyScanLogin(codeData.code, codeData.subId, codeData.macId);
- }else if (codeData.type == 12) {
- //化学品终端-双人认证
- this.chemicalAioVerifyAppletLogin(codeData.doorId, codeData.subId, codeData.macId, codeData.code);
- }
- }
- },
- mounted() {
- },
- methods: {
- //化学品终端-扫码登录
- async chemicalAioVerifyScanLogin(code, subId, macId) {
- const {
- data
- } = await chemicalAioVerifyScanLogin({
- code: code,
- subId: subId,
- userId: uni.getStorageSync('userId'),
- macId: macId
- });
- uni.showToast({
- mask: true,
- icon: "none",
- position: "center",
- title: data.message,
- duration: 2000
- });
- setTimeout(function() {
- uni.redirectTo({
- url: '/pages/mine/mine',
- });
- }, 2000);
- },
- //化学品终端-双人认证
- async chemicalAioVerifyAppletLogin(doorId, subId, macId, code) {
- const {
- data
- } = await chemicalAioVerifyAppletLogin({
- doorId: doorId,
- subId: subId,
- macId: macId,
- code: code,
- userId: uni.getStorageSync('userId'),
- });
- uni.showToast({
- mask: true,
- icon: "none",
- position: "center",
- title: data.message,
- duration: 2000
- });
- setTimeout(function() {
- uni.redirectTo({
- url: '/pages/mine/mine',
- });
- }, 2000);
- },
- },
- }
- </script>
- <style lang="stylus" scoped>
- #saoCode {
- overflow scroll
- }
- </style>
|