| | |
| | | uni.login({ |
| | | success: res => { |
| | | if (res.code) { |
| | | uni.setStorageSync('code', res.code); |
| | | this.apiLogin(res.code); |
| | | } else { |
| | | uni.showToast({ |
| | |
| | | uni.showLoading({ |
| | | title: '加载中...' |
| | | }); |
| | | wx.request({ |
| | | url: `https://api.weixin.qq.com/sns/jscode2session?appid=wx4a62fc1684c429a9&secret=ee90afe376cdcec2fdd947c0a4db961a&js_code=${code}&grant_type=authorization_code`, |
| | | success(res) { |
| | | uni.setStorageSync('openid', res.data.openid); |
| | | uni.showToast({ |
| | | title: '成功获取测试openid', |
| | | icon: 'none' |
| | | }); |
| | | } |
| | | }); |
| | | // wx.request({ |
| | | // url: `https://api.weixin.qq.com/sns/jscode2session?appid=wx4a62fc1684c429a9&secret=ee90afe376cdcec2fdd947c0a4db961a&js_code=${code}&grant_type=authorization_code`, |
| | | // success(res) { |
| | | // uni.setStorageSync('openid', res.data.openid); |
| | | // uni.showToast({ |
| | | // title: '成功获取测试openid', |
| | | // icon: 'none' |
| | | // }); |
| | | // } |
| | | // }); |
| | | this.$nextTick(() => { |
| | | apiLoginWx({ code: uni.getStorageSync('openid') }).then(res => { |
| | | uni.hideLoading(); |
| | | apiLoginWx({ code: code }).then(res => { |
| | | if (res.code != 1) { |
| | | this.$u.toast('恭喜您,登录成功!'); |
| | | this.$u.toast('登录成功'); |
| | | // 登陆成功,存储相关信息 |
| | | setToken(res.access_token); |
| | | setRefreshToken(res.refresh_token); |
| | |
| | | this.setUserTabbar(res.data.type); |
| | | uni.setStorageSync('roleType', res.data.type); |
| | | setCustomerId(res.data.customerid); |
| | | uni.hideLoading(); |
| | | //跳转页面 |
| | | this.$nextTick(() => { |
| | | redirectHome(); |
| | |
| | | }, |
| | | bindWxConfirm() { |
| | | uni.navigateTo({ |
| | | url: `/pages/login/wxLogin?code=${uni.getStorageSync('openid')}` |
| | | url: `/pages/login/wxLogin?code=${uni.getStorageSync('code')}` |
| | | }); |
| | | this.bindWxModelShow = false; |
| | | }, |