用户权限授权修改

This commit is contained in:
limqhz
2021-05-27 22:43:12 +08:00
parent 68e4dd0eaa
commit 87236f1f89
13 changed files with 121 additions and 289 deletions

View File

@@ -268,20 +268,24 @@ Page({
// 授权微信
getUserInfo(e) {
app.$pay.payWxLoing(e.detail).then(res => {
wx.showToast({
title: '绑定成功',
duration: 2000,
})
this.setData({
isWxLogin: false
})
}, err => {
this.setData({
isWxLogin: false
})
})
wx.getUserProfile({
desc: '用于完善会员资料',
success: (res) => {
app.$pay.payWxLoing(res).then(res => {
wx.showToast({
title: '绑定成功',
duration: 2000,
})
this.setData({
isWxLogin: false
})
}, err => {
this.setData({
isWxLogin: false
})
})
}
});
}
})

View File

@@ -307,21 +307,24 @@ Page({
// 授权微信
getUserInfo(e) {
console.log(e.detail);
app.$pay.payWxLoing(e.detail).then(res => {
wx.showToast({
title: '绑定成功',
duration: 2000,
})
this.setData({
isWxLogin: false
})
}, err => {
this.setData({
isWxLogin: false
})
})
wx.getUserProfile({
desc: '用于完善会员资料',
success: (res) => {
app.$pay.payWxLoing(res).then(res => {
wx.showToast({
title: '绑定成功',
duration: 2000,
})
this.setData({
isWxLogin: false
})
}, err => {
this.setData({
isWxLogin: false
})
})
}
});
},
// 选中支付方式
@@ -330,4 +333,4 @@ Page({
payType: e.currentTarget.dataset.type
})
}
})
})

View File

@@ -217,19 +217,23 @@ Page({
// 授权微信
getUserInfo(e) {
app.$pay.payWxLoing(e.detail).then(res => {
wx.showToast({
title: '绑定成功',
duration: 2000,
})
this.setData({
isWxLogin: false
})
}, err => {
this.setData({
isWxLogin: false
})
})
wx.getUserProfile({
desc: '用于完善会员资料',
success: (res) => {
app.$pay.payWxLoing(res).then(res => {
wx.showToast({
title: '绑定成功',
duration: 2000,
})
this.setData({
isWxLogin: false
})
}, err => {
this.setData({
isWxLogin: false
})
})
}
});
}
})
})

View File

@@ -121,42 +121,52 @@ Page({
showUnclickMask: true
})
let that = this;
wx.login({
success: function(res) {
app.$api.memberLoginWX({
avatar: e.detail.userInfo.avatarUrl,
code: res.code,
nickname: e.detail.userInfo.nickName
}).then(res => {
wx.setStorageSync('information', res.information);
if (!res.authorization) {
wx.redirectTo({
url: '/pages/register/index?codeType=' + 1,
wx.getUserProfile({
desc: '用于完善会员资料',
success: (res) => {
wx.login({
success: function(r){
app.$api.memberLoginWX({
avatar: res.userInfo.avatarUrl,
code: r.code,
nickname: res.userInfo.nickName
}).then(res => {
wx.setStorageSync('information', res.information);
if (!res.authorization) {
wx.redirectTo({
url: '/pages/register/index?codeType=' + 1,
})
return;
}
wx.setStorageSync('accessToken', res.authorization.accessToken);
let route = wx.getStorageSync('history');
wx.removeStorageSync('history');
if (!route || route == '/pages/login/index') {
return wx.redirectTo({
url: '/pages/mine/index',
})
}
wx.redirectTo({
url: route,
})
}, err => {
that.setData({
showUnclickMask: false
})
});
},
fail: function(res) {
that.setData({
showUnclickMask: false
})
return;
}
wx.setStorageSync('accessToken', res.authorization.accessToken);
let route = wx.getStorageSync('history');
wx.removeStorageSync('history');
if (!route || route == '/pages/login/index') {
return wx.redirectTo({
url: '/pages/mine/index',
})
}
wx.redirectTo({
url: route,
})
}, err => {
that.setData({
showUnclickMask: false
})
});
},
})
},
fail: function(res) {
fail: (res) => {
that.setData({
showUnclickMask: false
})
},
})
},
})
})

View File

@@ -7,9 +7,8 @@
<view class='line-between-text'>快速微信登录</view>
</view>
<view class='wechat-btn'>
<button open-type='getUserInfo' bindgetuserinfo='wxLogin' ></button>
<image src='../../images/47@3x.png' bindtap='wxLogin'></image>
</view>
</view>
<view class='unclick-mask' wx:if="{{showUnclickMask}}"></view>
<view class='unclick-mask' wx:if="{{showUnclickMask}}"></view>

View File

@@ -153,19 +153,23 @@ Page({
// 授权微信
getUserInfo(e) {
app.$pay.payWxLoing(e.detail).then(res => {
wx.showToast({
title: '绑定成功',
duration: 2000,
})
this.setData({
isWxLogin: false
})
}, err => {
this.setData({
isWxLogin: false
})
})
wx.getUserProfile({
desc: '用于完善会员资料',
success: (res) => {
app.$pay.payWxLoing(res).then(res => {
wx.showToast({
title: '绑定成功',
duration: 2000,
})
this.setData({
isWxLogin: false
})
}, err => {
this.setData({
isWxLogin: false
})
})
}
});
}
})
})