From 276a64cb577fd6e79e616983b4e8b6f34c6e3f12 Mon Sep 17 00:00:00 2001 From: xiayt <x1027869635@gmail.com> Date: Sun, 24 Oct 2021 15:49:08 +0800 Subject: [PATCH] feat: 埋、扫一扫 --- package.json | 92 ++++++++++++++++++++++++++++++++++++++++++++++---------------------------------------------- public/index.html | 37 +++++++++++++++++++++++++++++-------- src/App.vue | 3 +++ src/main.js | 2 -- src/views/Home/Home.vue | 7 ++++++- src/views/Home/component/HomeScan.vue | 32 +++++++++++++------------------- src/views/Service/ServiceKQ.vue | 20 ++++++++++++++++---- 7 files changed, 113 insertions(+), 80 deletions(-) diff --git a/package.json b/package.json index 320c72c..4112e0d 100644 --- a/package.json +++ b/package.json @@ -1,47 +1,47 @@ { - "name": "sxh_personal_center", - "version": "0.1.0", - "private": true, - "scripts": { - "serve": "vue-cli-service serve", - "dev": "vue-cli-service serve", - "build": "vue-cli-service build" - }, - "dependencies": { - "@aligov/jssdk-mgop": "^3.1.7", - "axios": "^0.19.2", - "core-js": "^3.6.4", - "dayjs": "^1.10.7", - "html2canvas": "^1.3.2", - "js-base64": "^3.6.0", - "less-loader": "^6.1.2", - "moment": "^2.29.1", - "node-sass": "^4.14.1", - "postcss-px-to-viewport": "^1.1.1", - "qrcodejs2": "0.0.2", - "qs": "^6.9.3", - "sass-loader": "^8.0.0", - "vant": "^2.12.26", - "vconsole": "^3.6.1", - "vue": "^2.6.11", - "vue-imgcut": "^1.0.8", - "vue-router": "^3.1.6", - "vuex": "^3.1.3", - "weixin-js-sdk": "^1.6.0" - }, - "devDependencies": { - "@vue/cli-plugin-babel": "^4.3.0", - "@vue/cli-service": "^4.3.0", - "babel-plugin-import": "^1.13.3", - "postcss-import": "^11.0.0", - "postcss-loader": "^2.0.8", - "postcss-url": "^7.2.1", - "style-loader": "^2.0.0", - "vue-template-compiler": "^2.6.11" - }, - "browserslist": [ - "> 1%", - "last 2 versions", - "not dead" - ] -} + "name": "sxh_personal_center", + "version": "0.1.0", + "private": true, + "scripts": { + "serve": "vue-cli-service serve", + "dev": "vue-cli-service serve", + "build": "vue-cli-service build" + }, + "dependencies": { + "@aligov/jssdk-mgop": "^3.1.7", + "axios": "^0.19.2", + "core-js": "^3.6.4", + "dayjs": "^1.10.7", + "html2canvas": "^1.3.2", + "js-base64": "^3.6.0", + "less-loader": "^6.1.2", + "moment": "^2.29.1", + "node-sass": "^4.14.1", + "postcss-px-to-viewport": "^1.1.1", + "qrcodejs2": "0.0.2", + "qs": "^6.9.3", + "sass-loader": "^8.0.0", + "vant": "^2.12.26", + "vconsole": "^3.6.1", + "vue": "^2.6.11", + "vue-imgcut": "^1.0.8", + "vue-router": "^3.1.6", + "vuex": "^3.1.3", + "weixin-js-sdk": "^1.6.0" + }, + "devDependencies": { + "@vue/cli-plugin-babel": "^4.3.0", + "@vue/cli-service": "^4.3.0", + "babel-plugin-import": "^1.13.3", + "postcss-import": "^11.0.0", + "postcss-loader": "^2.0.8", + "postcss-url": "^7.2.1", + "style-loader": "^2.0.0", + "vue-template-compiler": "^2.6.11" + }, + "browserslist": [ + "> 1%", + "last 2 versions", + "not dead" + ] +} \ No newline at end of file diff --git a/public/index.html b/public/index.html index dc4d747..5d38461 100644 --- a/public/index.html +++ b/public/index.html @@ -1,18 +1,39 @@ <!DOCTYPE html> <html lang="en"> - <head> + +<head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0,minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"> - <meta name="format-detection" content="telephone=yes"/> + <meta name="format-detection" content="telephone=yes" /> <link rel="icon" href="<%= BASE_URL %>favicon.ico"> <title></title> - </head> - <body> + <!-- 埋点 --> + <script src="https://d.alicdn.com/alilog/mlog/aplus.js?id=202951085"></script> + <script> + (function(w, d, s, q, i) { + w[q] = w[q] || []; + var f = d.getElementsByTagName(s)[0], + j = d.createElement(s); + j.async = true; + j.id = 'beacon-aplus'; + j.src = 'https://d.alicdn.com/alilog/mlog/aplus.js?id=202951085'; + f.parentNode.insertBefore(j, f); + })(window, document, 'script', 'aplus_queue') + </script> +</head> + +<body> <noscript> - <strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong> - </noscript> + <strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. + Please enable it to continue.</strong> + </noscript> <div id="app"></div> - <script src="https://webapi.amap.com/maps?v=1.4.15&key=61af1988b71a634a59a0de29409baeb8"></script> + <!-- 地图 --> + <script src="https://webapi.amap.com/maps?v=1.4.15&key=61af1988b71a634a59a0de29409baeb8"></script> + <!-- 政务中台JSAPI --> + <script src="//assets.zjzwfw.gov.cn/assets/ZWJSBridge/1.0.1/zwjsbridge.js"></script> + </body> -</html> + +</html> \ No newline at end of file diff --git a/src/App.vue b/src/App.vue index 9297d08..f406aa8 100644 --- a/src/App.vue +++ b/src/App.vue @@ -10,6 +10,9 @@ <script> export default { mounted () { + ZWJSBridge.onReady(() => { + console.log('初始化完成后,执行bridge方法') + }) }, methods: { } diff --git a/src/main.js b/src/main.js index 56e9910..22acd62 100644 --- a/src/main.js +++ b/src/main.js @@ -7,8 +7,6 @@ import store from './store' import Moment from 'moment' Vue.prototype.Moment = Moment; -import yxAxios from '@/https/yxAxios' -Vue.prototype.yxAxios = yxAxios; import { mgop } from '@aligov/jssdk-mgop'; Vue.prototype.mgop = mgop; diff --git a/src/views/Home/Home.vue b/src/views/Home/Home.vue index 9ee7959..f01b35a 100644 --- a/src/views/Home/Home.vue +++ b/src/views/Home/Home.vue @@ -69,7 +69,12 @@ export default { }, mounted () { - + aplus_queue.push({ + 'action': 'aplus.sendPV', + 'arguments': [{ + is_auto: false + }] + }) this.checkAuth() }, methods: { diff --git a/src/views/Home/component/HomeScan.vue b/src/views/Home/component/HomeScan.vue index 351cf96..560d761 100644 --- a/src/views/Home/component/HomeScan.vue +++ b/src/views/Home/component/HomeScan.vue @@ -8,25 +8,19 @@ export default { methods: { saoYiSao () { - let isLogin = this.checkLogin() - if (!isLogin) return; - if (process.env.NODE_ENV === "production" && this.common.isWeiXin()) { - location.href = `http://sao315.com/w/api/saoyisao?redirect_uri=https://payment.myjxt.com/center/%23/MyClassList`; - } else { - this.$router.push({ name: 'MyClassList', query: { qrresult: '188' } }) - } - }, - // 判断是否已登录 - checkLogin () { - if (process.env.NODE_ENV != "production") return true; - const userInfo = JSON.parse(sessionStorage.getItem('userInfo')) - if (!userInfo?.phone) { - sessionStorage.setItem('prePage', 'Home' + sessionStorage.getItem('publicName')); - sessionStorage.setItem('prePageQuery', JSON.stringify({ showTab: this.$route.query.showTab })); - this.$router.push({ name: 'LoginPublic', query: { publicName: sessionStorage.getItem('publicName') } }) - return false; - } - return true; + ZWJSBridge.scan({ + "type": "qrCode" + }).then(res => { + console.log(res) + const qrcode = res.qrcode + if(qrcode.length>10){ + this.$toast.fail('请扫描正确的基地码') + return; + } + this.$router.push({ name: 'MyClassList', query: { qrresult: res.qrcode } }) + }).catch(err => { + console.log(err) + }) }, } } diff --git a/src/views/Service/ServiceKQ.vue b/src/views/Service/ServiceKQ.vue index a55b170..29f5fff 100644 --- a/src/views/Service/ServiceKQ.vue +++ b/src/views/Service/ServiceKQ.vue @@ -14,6 +14,12 @@ export default { mounted () { console.log('xst mounted') + aplus_queue.push({ + 'action': 'aplus.sendPV', + 'arguments': [{ + is_auto: false + }] + }) this.checkAuth() }, @@ -27,14 +33,20 @@ export default { if (centerNo) { this.centerNo = centerNo sessionStorage.setItem('centerNo', centerNo); + console.log(111) this.getUserInfo() } else { + console.log(222) const sUserAgent = window.navigator.userAgent.toLowerCase() const dtdreamweb = sUserAgent.indexOf("dtdreamweb") > -1 const miniprogram = sUserAgent.indexOf("miniprogram") > -1 && sUserAgent.indexOf("alipay") > -1 if (dtdreamweb) { + console.log(333) alert('浙里办') - window.location.href = `https://puser.zjzwfw.gov.cn/sso/mobile.do?action=oauth&scope=1&servicecode=hswsy`; + // window.location.href = `https://puser.zjzwfw.gov.cn/sso/mobile.do?action=oauth&scope=1&servicecode=hswsy`; + this.centerNo = '20210930160466993660' + sessionStorage.setItem('centerNo', '20210930160466993660'); + this.getUserInfo() } // else if (miniprogram) { // alert('支付宝') @@ -52,9 +64,9 @@ export default { getUserInfo: function () { this.mgop({ api: 'mgop.sz.hswsy.getPortalUserByNum', // 必须 - host: 'https://mapi.zjzwfw.gov.cn/', - dataType: 'JSON', - type: 'GET', + // host: 'https://mapi.zjzwfw.gov.cn/', + // dataType: 'JSON', + // type: 'GET', appKey: 'fuxgnukl+2001895516+edccpx', // 必须 headers: { // 'isTestUrl': '1' -- libgit2 0.21.0