|
@@ -14,19 +14,22 @@
|
|
|
</button>
|
|
|
<view class="authorize-info">{{wxPhoneData? '****************' : ''}}</view> -->
|
|
|
<!-- <view class="authorize-login" @click="getUserInfo">登录</view> -->
|
|
|
- <button
|
|
|
- class="authorize-login"
|
|
|
- open-type="getUserInfo"
|
|
|
- @getuserinfo="getUserinfoWechat" withCredentials="true" >
|
|
|
- 登录
|
|
|
- </button>
|
|
|
+ <!-- #ifdef MP-WEIXIN -->
|
|
|
+ <button
|
|
|
+ class="authorize-login"
|
|
|
+ open-type="getUserInfo"
|
|
|
+ @getuserinfo="getUserinfoWechat" withCredentials="true" >
|
|
|
+ 登录
|
|
|
+ </button>
|
|
|
+ <!-- #endif -->
|
|
|
+ <!-- #ifdef APP-PLUS -->
|
|
|
+ <button
|
|
|
+ class="authorize-login"
|
|
|
+ @click="getUserinfoApp">
|
|
|
+ 登录3
|
|
|
+ </button>
|
|
|
+ <!-- #endif -->
|
|
|
<view @click="showAgreement = true" class="agreement">点击登录视为同意<text class="underline">平台服务协议</text></view>
|
|
|
- <!-- <button
|
|
|
- class="authorize-login"
|
|
|
- open-type="getUserInfo"
|
|
|
- @click="getUserinfoApp">
|
|
|
- 登录
|
|
|
- </button> -->
|
|
|
</view>
|
|
|
{{tipxx}}
|
|
|
<u-top-tips ref="uTips"></u-top-tips>
|
|
@@ -183,102 +186,115 @@
|
|
|
// })
|
|
|
// }
|
|
|
// },
|
|
|
- getUserinfoWechat(data) {
|
|
|
- uni.getProvider({
|
|
|
- service: 'oauth',
|
|
|
- success: (res) => {
|
|
|
- if (~res.provider.indexOf('weixin')) {
|
|
|
- uni.login({
|
|
|
- provider: 'weixin',
|
|
|
- success: (res2) => {
|
|
|
- let wxLoginData = {
|
|
|
- code: res2.code,
|
|
|
- encryptedData: data.detail.encryptedData,
|
|
|
- iv: data.detail.iv,
|
|
|
- rawData: data.detail.rawData,
|
|
|
- signature: data.detail.signature,
|
|
|
+ // #ifdef MP-WEIXIN
|
|
|
+ getUserinfoWechat(data) {
|
|
|
+ uni.getProvider({
|
|
|
+ service: 'oauth',
|
|
|
+ success: (res) => {
|
|
|
+ if (~res.provider.indexOf('weixin')) {
|
|
|
+ uni.login({
|
|
|
+ provider: 'weixin',
|
|
|
+ success: (res2) => {
|
|
|
+ let wxLoginData = {
|
|
|
+ code: res2.code,
|
|
|
+ encryptedData: data.detail.encryptedData,
|
|
|
+ iv: data.detail.iv,
|
|
|
+ rawData: data.detail.rawData,
|
|
|
+ signature: data.detail.signature,
|
|
|
+ }
|
|
|
+ uni.setStorage({
|
|
|
+ key: 'wxLoginData',
|
|
|
+ data: wxLoginData
|
|
|
+ })
|
|
|
+ this.wxLoginData = wxLoginData
|
|
|
+ this.getUserInfo()
|
|
|
+ },
|
|
|
+ fail: () => {
|
|
|
+ console.log(33333, error)
|
|
|
+ this.$refs.uTips.show({
|
|
|
+ title: '微信登录授权失败',
|
|
|
+ type: 'warning',
|
|
|
+ })
|
|
|
}
|
|
|
- uni.setStorage({
|
|
|
- key: 'wxLoginData',
|
|
|
- data: wxLoginData
|
|
|
- })
|
|
|
- this.wxLoginData = wxLoginData
|
|
|
- this.getUserInfo()
|
|
|
- },
|
|
|
- fail: () => {
|
|
|
- console.log(33333, error)
|
|
|
- this.$refs.uTips.show({
|
|
|
- title: '微信登录授权失败',
|
|
|
- type: 'warning',
|
|
|
- })
|
|
|
- }
|
|
|
- })
|
|
|
- } else {
|
|
|
- this.$refs.uTips.show({
|
|
|
- title: '请先安装微信或升级版本',
|
|
|
- type: 'warning',
|
|
|
- })
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ this.$refs.uTips.show({
|
|
|
+ title: '请先安装微信或升级版本',
|
|
|
+ type: 'warning',
|
|
|
+ })
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- });
|
|
|
- },
|
|
|
- // 获取登录权限
|
|
|
- // getUserinfoApp() {
|
|
|
- // uni.getProvider({
|
|
|
- // service: 'oauth',
|
|
|
- // success: (res) => {
|
|
|
- // if (~res.provider.indexOf('weixin')) {
|
|
|
- // uni.login({
|
|
|
- // provider: 'weixin',
|
|
|
- // success: (res2) => {
|
|
|
- // uni.getUserInfo({
|
|
|
- // provider: 'weixin',
|
|
|
- // success: (info) => {
|
|
|
- // uni.setStorage({
|
|
|
- // key: 'wxLoginData',
|
|
|
- // data: {
|
|
|
- // code: res2.code,
|
|
|
- // encryptedData: info.encryptedData,
|
|
|
- // iv: info.iv,
|
|
|
- // rawData: info.rawData,
|
|
|
- // signature: info.signature,
|
|
|
- // }
|
|
|
- // })
|
|
|
- // this.wxLoginData = uni.getStorageSync("wxLoginData")
|
|
|
- // console.log(1111111,this.wxLoginData&&this.wxLoginData.rawData)
|
|
|
- // this.userNmae = JSON.parse(this.wxLoginData.rawData).nickName
|
|
|
- // this.getUserInfo()
|
|
|
- // // this.$refs.uTips.show({
|
|
|
- // // title: '获取角色信息成功',
|
|
|
- // // type: 'success',
|
|
|
- // // })
|
|
|
- // },
|
|
|
- // fail: (error) => {
|
|
|
- // console.log(2222, error)
|
|
|
- // this.$refs.uTips.show({
|
|
|
- // title: '微信登录授权失败',
|
|
|
- // type: 'warning',
|
|
|
- // })
|
|
|
- // }
|
|
|
- // })
|
|
|
- // },
|
|
|
- // fail: () => {
|
|
|
- // console.log(33333, error)
|
|
|
- // this.$refs.uTips.show({
|
|
|
- // title: '微信登录授权失败',
|
|
|
- // type: 'warning',
|
|
|
- // })
|
|
|
- // }
|
|
|
- // })
|
|
|
- // } else {
|
|
|
- // this.$refs.uTips.show({
|
|
|
- // title: '请先安装微信或升级版本',
|
|
|
- // type: 'warning',
|
|
|
- // })
|
|
|
- // }
|
|
|
- // }
|
|
|
- // });
|
|
|
- // },
|
|
|
+ });
|
|
|
+ },
|
|
|
+ //#endif
|
|
|
+
|
|
|
+ // #ifdef APP-PLUS
|
|
|
+ // 获取登录权限
|
|
|
+ getUserinfoApp() {
|
|
|
+ console.log('app enter')
|
|
|
+ uni.getProvider({
|
|
|
+ service: 'oauth',
|
|
|
+ success: (res) => {
|
|
|
+ console.log('success', res)
|
|
|
+ if (~res.provider.indexOf('weixin')) {
|
|
|
+ console.log('res.provider,weixin',~res.provider.indexOf('weixin'))
|
|
|
+ uni.login({
|
|
|
+ provider: 'weixin',
|
|
|
+ success: (res2) => {
|
|
|
+ console.log('res2',res2)
|
|
|
+ uni.getUserInfo({
|
|
|
+ provider: 'weixin',
|
|
|
+ success: (info) => {
|
|
|
+ console.log('info')
|
|
|
+ uni.setStorage({
|
|
|
+ key: 'wxLoginData',
|
|
|
+ data: {
|
|
|
+ code: res2.code,
|
|
|
+ encryptedData: info.encryptedData,
|
|
|
+ iv: info.iv,
|
|
|
+ rawData: info.rawData,
|
|
|
+ signature: info.signature,
|
|
|
+ }
|
|
|
+ })
|
|
|
+ this.wxLoginData = uni.getStorageSync("wxLoginData")
|
|
|
+ console.log(1111111,this.wxLoginData&&this.wxLoginData.rawData)
|
|
|
+ this.userNmae = JSON.parse(this.wxLoginData.rawData).nickName
|
|
|
+ this.getUserInfo()
|
|
|
+ // this.$refs.uTips.show({
|
|
|
+ // title: '获取角色信息成功',
|
|
|
+ // type: 'success',
|
|
|
+ // })
|
|
|
+ },
|
|
|
+ fail: (error) => {
|
|
|
+ console.log(2222, error)
|
|
|
+ this.$refs.uTips.show({
|
|
|
+ title: '微信登录授权失败',
|
|
|
+ type: 'warning',
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ fail: () => {
|
|
|
+ console.log(33333, error)
|
|
|
+ this.$refs.uTips.show({
|
|
|
+ title: '微信登录授权失败',
|
|
|
+ type: 'warning',
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ console.log('请先安装微信或升级版本')
|
|
|
+ this.$refs.uTips.show({
|
|
|
+ title: '请先安装微信或升级版本',
|
|
|
+ type: 'warning',
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ console.log('app end')
|
|
|
+ },
|
|
|
+ //#endif
|
|
|
+
|
|
|
// 发请求获取个人数据
|
|
|
getUserInfo() {
|
|
|
NET.request(API.WxLogin, {
|