From 1f478b4b033d518f6de21f931d828d2a175b2a3e Mon Sep 17 00:00:00 2001 From: wzp <2880584989@qq.com> Date: 星期二, 08 三月 2022 13:40:51 +0800 Subject: [PATCH] 最新版本,修复bug --- assetMgtH5/pages/login/login.vue | 131 +++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 129 insertions(+), 2 deletions(-) diff --git a/assetMgtH5/pages/login/login.vue b/assetMgtH5/pages/login/login.vue index c50603f..ae81d25 100644 --- a/assetMgtH5/pages/login/login.vue +++ b/assetMgtH5/pages/login/login.vue @@ -1,6 +1,14 @@ <template> <view> - 鍝堝搱鍝堝搱鍝堝搱鎴栨垨鎴栨垨鎴栨垨鎴� + <u-toast ref="uToast"></u-toast> + + <view class="" v-if="loginFlag"> + 鐧婚檰寮傚父锛歿{loginText}} + </view> + + <view class="text-xl" v-if="workFlag"> + 璇蜂娇鐢ㄤ紒涓氬井淇″鎴风鎵爜鎵撳紑锛� + </view> </view> </template> @@ -8,11 +16,130 @@ export default { data() { return { + loginFlag: false, + loginText: "", + workFlag:false, + code: 0, + state: 0, + status: "0", + flag: true, + number: "", + number2: "" } }, + async onLoad(options) { + try { + //http://asset.mengdong.icu/h5/?status=1&number=6688898 + this.status = options.status; + console.log('status=' + this.status); + if (this.status === "1") { + this.number = options.number; + this.flag = false + this.navToCode(); + } + } catch (e) { + + } + + if (this.flag) { + this.code = options.code; + this.state = options.state; + + await this.login(this.code); + + if (!this.loginFlag) { + await this.getUserInfo(); + let json = this.state.split("^"); + + if (json[0] === "share") { + this.number = json[1]; + setTimeout(() => { + this.navToShare(); + }, 0) + } else { + this.navTo(); + } + } + + + + } + + }, methods: { - + navTo() { + uni.switchTab({ + url: "../index/index?state=" + this.state + }) + }, + navToShare() { + uni.reLaunch({ + url: "../assets/repairInfo?number=" + this.number + }) + }, + + navToCode() { + + var ua = window.navigator.userAgent.toLowerCase(); + if ((ua.match(/MicroMessenger/i) == 'micromessenger') && (ua.match(/wxwork/i) == 'wxwork')) { + //鐢熶骇 + window.location.href =`http://open.weixin.qq.com/connect/oauth2/authorize?appid=ww9516eee214a997e5&redirect_uri=http://uat.mengdong.icu/h5/&response_type=code&state=share^${this.number}&scope=snsapi_userinfo@asset#wechat_redirect`; + + //娴嬭瘯 + // window.location.href =`http://open.weixin.qq.com/connect/oauth2/authorize?appid=wwb3c45e4348576dc2&redirect_uri=http://asset.mengdong.icu/h5/&response_type=code&state=share^${this.number}&scope=snsapi_userinfo@asset#wechat_redirect`; + } else if (ua.match(/micromessenger/i) == 'micromessenger') { + this.workFlag=true; + } + + }, + + //鐧婚檰 + async login(code) { + await this.$http.get('/h5login', { + params: { + code: code + } + }) + .then(res => { + // debugger; + console.log(res.data) + if (res.data.code === 0) { + // this.$refs.uToast.show({ + // type: 'success', + // message: "鐧婚檰鎴愬姛" + // }); + + this.token = res.data.token; + console.log('token=' + this.token); + this.value1 = this.token; + uni.setStorageSync('token', this.token); + } else { + this.loginFlag = true; + this.loginText = res.data.msg; + } + + }).catch(err => { + this.loginFlag = true; + this.loginText = '寮傚父' + err; + console.log('閿欒', err.data) + }) + }, + + async getUserInfo() { + await this.$http.get('/assets/approval/getUserDetail') + .then(res => { + // debugger; + if (res.data.code === 0) { + let data = res.data.data; + uni.setStorageSync('user', data); + console.log('濮撳悕锛�' + data.userName) + console.log('user=', data) + } + }).catch(err => { + console.log('閿欒', err.data) + }) + }, } } </script> -- Gitblit v1.9.1