From f29dfb68a705ab9f37ed924fc82d6fd414c1c78c Mon Sep 17 00:00:00 2001 From: wzp <2040239371@qq.com> Date: 星期一, 21 十一月 2022 17:01:45 +0800 Subject: [PATCH] 最新 --- assetMgtH5/pages/login/login.vue | 134 ++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 132 insertions(+), 2 deletions(-) diff --git a/assetMgtH5/pages/login/login.vue b/assetMgtH5/pages/login/login.vue index 8c3b35f..cfb849f 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,12 +16,134 @@ 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.zhongyishutong.xyz/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> -<style lang="scss"> +<style> </style> -- Gitblit v1.9.1