|
@@ -21,7 +21,7 @@
|
|
|
<!-- #endif -->
|
|
|
<!-- #ifdef APP-PLUS -->
|
|
|
<button class="authorize-login" @click="getUserinfoApp">
|
|
|
- 登录3
|
|
|
+ 登录9
|
|
|
</button>
|
|
|
<!-- #endif -->
|
|
|
<view @click="showAgreement = true" class="agreement">点击登录视为同意<text class="underline">平台服务协议</text></view>
|
|
@@ -230,55 +230,59 @@
|
|
|
getUserinfoApp() {
|
|
|
let that = this
|
|
|
console.log('app enter')
|
|
|
- uni.login({
|
|
|
- provider: 'weixin',
|
|
|
- success: (res2) => {
|
|
|
- console.log('res2', res2)
|
|
|
- uni.getUserInfo({
|
|
|
- provider: 'weixin',
|
|
|
- success: (info) => {
|
|
|
- console.log('info',info)
|
|
|
- uni.setStorage({
|
|
|
- key: 'wxLoginData',
|
|
|
- data: {
|
|
|
- nickName: info.userInfo.nickName,
|
|
|
- gender: info.userInfo.gender,
|
|
|
- avatarUrl: info.userInfo.avatarUrl,
|
|
|
- unionId: info.userInfo.unionId,
|
|
|
- openId:info.userInfo.openId
|
|
|
- // code: res2.code,
|
|
|
- // encryptedData: info.encryptedData,
|
|
|
- // iv: info.iv,
|
|
|
- // rawData: info.rawData,
|
|
|
- // signature: info.signature,
|
|
|
- }
|
|
|
- })
|
|
|
- that.wxLoginData = uni.getStorageSync("wxLoginData")
|
|
|
- console.log(1111111, that.wxLoginData)
|
|
|
- // that.userNmae = JSON.parse(that.wxLoginData.rawData).nickName
|
|
|
- that.getUserInfo(0)
|
|
|
- this.$refs.uTips.show({
|
|
|
- title: '获取角色信息成功',
|
|
|
- type: 'success',
|
|
|
- })
|
|
|
- },
|
|
|
- fail: (error) => {
|
|
|
- console.log(2222, error)
|
|
|
- that.$refs.uTips.show({
|
|
|
- title: '微信登录授权失败',
|
|
|
- type: 'warning',
|
|
|
- })
|
|
|
- }
|
|
|
- })
|
|
|
- },
|
|
|
- fail: (error) => {
|
|
|
- console.log(33333, error)
|
|
|
- that.$refs.uTips.show({
|
|
|
- title: '微信登录授权失败',
|
|
|
- type: 'warning',
|
|
|
- })
|
|
|
- }
|
|
|
- })
|
|
|
+ try {
|
|
|
+ uni.login({
|
|
|
+ provider: 'weixin',
|
|
|
+ success: (res2) => {
|
|
|
+ console.log('res2', res2)
|
|
|
+ uni.getUserInfo({
|
|
|
+ provider: 'weixin',
|
|
|
+ success: (info) => {
|
|
|
+ console.log('info',info)
|
|
|
+ uni.setStorage({
|
|
|
+ key: 'wxLoginData',
|
|
|
+ data: {
|
|
|
+ nickName: info.userInfo.nickName,
|
|
|
+ gender: info.userInfo.gender,
|
|
|
+ avatarUrl: info.userInfo.avatarUrl,
|
|
|
+ unionId: info.userInfo.unionId,
|
|
|
+ openId:info.userInfo.openId
|
|
|
+ // code: res2.code,
|
|
|
+ // encryptedData: info.encryptedData,
|
|
|
+ // iv: info.iv,
|
|
|
+ // rawData: info.rawData,
|
|
|
+ // signature: info.signature,
|
|
|
+ }
|
|
|
+ })
|
|
|
+ that.wxLoginData = uni.getStorageSync("wxLoginData")
|
|
|
+ console.log(1111111, that.wxLoginData)
|
|
|
+ // that.userNmae = JSON.parse(that.wxLoginData.rawData).nickName
|
|
|
+ that.getUserInfo(0)
|
|
|
+ this.$refs.uTips.show({
|
|
|
+ title: '获取角色信息成功',
|
|
|
+ type: 'success',
|
|
|
+ })
|
|
|
+ },
|
|
|
+ fail: (error) => {
|
|
|
+ console.log(2222, error)
|
|
|
+ that.$refs.uTips.show({
|
|
|
+ title: '微信登录授权失败',
|
|
|
+ type: 'warning',
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ fail: (error) => {
|
|
|
+ console.log(33333, error)
|
|
|
+ that.$refs.uTips.show({
|
|
|
+ title: '微信登录授权失败',
|
|
|
+ type: 'warning',
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } catch(e) {
|
|
|
+ console.log('是否调登录',e.message)
|
|
|
+ }
|
|
|
// uni.getProvider({
|
|
|
// service: 'oauth',
|
|
|
// success: (res) => {
|