用户权限授权修改
This commit is contained in:
@@ -1,104 +0,0 @@
|
|||||||
// pages/authorizedMask/authorizedMask.js
|
|
||||||
const app = getApp();
|
|
||||||
Component({
|
|
||||||
/**
|
|
||||||
* 组件的属性列表
|
|
||||||
*/
|
|
||||||
properties: {
|
|
||||||
isSetting: {
|
|
||||||
type: Boolean,
|
|
||||||
value: false
|
|
||||||
},
|
|
||||||
content: {
|
|
||||||
type: String,
|
|
||||||
value: '使用小程序需要您授权登录'
|
|
||||||
},
|
|
||||||
isCancel: {
|
|
||||||
type: Boolean,
|
|
||||||
value: false
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* Only: 只有一個
|
|
||||||
* TwainCance: 兩個帶取消
|
|
||||||
* */
|
|
||||||
type: {
|
|
||||||
type: String,
|
|
||||||
value: 'Only'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 组件的初始数据
|
|
||||||
*/
|
|
||||||
data: {
|
|
||||||
showBox: true,
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 组件的方法列表
|
|
||||||
*/
|
|
||||||
methods: {
|
|
||||||
stopSlide() {
|
|
||||||
return;
|
|
||||||
},
|
|
||||||
|
|
||||||
wxTap() {
|
|
||||||
this.setData({
|
|
||||||
showBox: false
|
|
||||||
})
|
|
||||||
},
|
|
||||||
// 微信登录
|
|
||||||
wxLogin(e) {
|
|
||||||
if (e.detail.errMsg === 'getUserInfo:fail auth deny') {
|
|
||||||
this.setData({
|
|
||||||
showBox: true
|
|
||||||
})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
this.setData({
|
|
||||||
showBox: false
|
|
||||||
})
|
|
||||||
let that = this;
|
|
||||||
wx.login({
|
|
||||||
success: function(res) {
|
|
||||||
if (res.code) {
|
|
||||||
app.$api.login({
|
|
||||||
avatar: e.detail.userInfo.avatarUrl,
|
|
||||||
code: res.code,
|
|
||||||
nickname: e.detail.userInfo.nickName,
|
|
||||||
}).then(res => {
|
|
||||||
wx.setStorageSync('access_token', res.data.accessToken);
|
|
||||||
wx.setStorageSync('userInfo', e.detail.userInfo);
|
|
||||||
that.triggerEvent('loginSuccess', {}, {});
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
wx.showToast({
|
|
||||||
title: '登录失败',
|
|
||||||
icon: 'none',
|
|
||||||
})
|
|
||||||
}
|
|
||||||
},
|
|
||||||
fail: function(res) {
|
|
||||||
wx.showToast({
|
|
||||||
title: '登录失败',
|
|
||||||
icon: 'none',
|
|
||||||
})
|
|
||||||
},
|
|
||||||
})
|
|
||||||
},
|
|
||||||
// 取消
|
|
||||||
cance() {
|
|
||||||
this.triggerEvent('cance', {}, {});
|
|
||||||
},
|
|
||||||
|
|
||||||
// 打开设置
|
|
||||||
setSuccess: function (e) {
|
|
||||||
this.triggerEvent('setsuccess', e.detail, {});
|
|
||||||
// if (e.detail.authSetting["scope.userLocation"]) {//如果打开了地理位置,就会为true
|
|
||||||
// this.setData({
|
|
||||||
// showFlag: true
|
|
||||||
// })
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
{
|
|
||||||
"component": true,
|
|
||||||
"usingComponents": {}
|
|
||||||
}
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
<!--pages/authorizedMask/authorizedMask.wxml-->
|
|
||||||
<view class='auth-bg' catchtouchmove='stopSlide'>
|
|
||||||
<view class='auth-box' wx:if="{{showBox}}">
|
|
||||||
<!-- wx:if="{{type == 'TwainCance'}}" -->
|
|
||||||
<view class='close' bindtap='cance' wx:if="{{isCancel}}">
|
|
||||||
<image src='../../images/23@3x.png'></image>
|
|
||||||
</view>
|
|
||||||
<view class='message'>{{content}}</view>
|
|
||||||
<view class='btn-bg' wx:if="{{type == 'Only'}}">
|
|
||||||
<button open-type="getUserInfo" bindgetuserinfo="wxLogin" wx:if="{{!isSetting}}">授权登录</button>
|
|
||||||
<button open-type="openSetting" bindopensetting="setSuccess" wx:if="{{isSetting}}" >进入授权管理</button>
|
|
||||||
</view>
|
|
||||||
<!-- <view class='btn-bg btn-tow' wx:if="{{showBox}}">
|
|
||||||
<button open-type="openSetting" wx:if="{{isSetting}}">进入授权管理</button>
|
|
||||||
</view> -->
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
@@ -1,67 +0,0 @@
|
|||||||
/* pages/authorizedMask/authorizedMask.wxss */
|
|
||||||
|
|
||||||
.auth-bg {
|
|
||||||
position: fixed;
|
|
||||||
top: 0;
|
|
||||||
left: 0;
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
|
||||||
width: 100vw;
|
|
||||||
height: 100vh;
|
|
||||||
background: rgba(0, 0, 0, 0.6);
|
|
||||||
z-index: 1001;
|
|
||||||
}
|
|
||||||
|
|
||||||
.auth-box {
|
|
||||||
position: relative;
|
|
||||||
width: 70%;
|
|
||||||
height: 350rpx;
|
|
||||||
background: #252330;
|
|
||||||
border-radius: 10rpx;
|
|
||||||
color: #989898;
|
|
||||||
}
|
|
||||||
|
|
||||||
.message {
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
|
||||||
height: 250rpx;
|
|
||||||
/* border-bottom: 2rpx solid #EBEEF5; */
|
|
||||||
font-size: 28rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn-bg>button {
|
|
||||||
width: 60%;
|
|
||||||
height: 70rpx;
|
|
||||||
line-height: 70rpx;
|
|
||||||
font-size: 26rpx;
|
|
||||||
color: #252330;
|
|
||||||
border-radius: 35rpx;
|
|
||||||
background: #ffc129;
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn-bg.btn-tow {
|
|
||||||
display: flex;
|
|
||||||
}
|
|
||||||
|
|
||||||
button::after {
|
|
||||||
border: none;
|
|
||||||
border-radius: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.close {
|
|
||||||
position: absolute;
|
|
||||||
top: 0;
|
|
||||||
right: 0;
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
|
||||||
width: 60rpx;
|
|
||||||
height: 60rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.close>image {
|
|
||||||
width: 26rpx;
|
|
||||||
height: 26rpx;
|
|
||||||
}
|
|
||||||
@@ -66,7 +66,7 @@ Component({
|
|||||||
|
|
||||||
// 点击获取个人信息
|
// 点击获取个人信息
|
||||||
openUserInfo(e) {
|
openUserInfo(e) {
|
||||||
this.triggerEvent('getuserinfo', e.detail, {});
|
this.triggerEvent('getuserinfo', e, {});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
<button wx:if="{{showCancel}}" bindtap='cancel'>{{cancelBtnTitle}}</button>
|
<button wx:if="{{showCancel}}" bindtap='cancel'>{{cancelBtnTitle}}</button>
|
||||||
<view class='line' wx:if="{{showCancel}}"></view>
|
<view class='line' wx:if="{{showCancel}}"></view>
|
||||||
<button open-type='openSetting' wx:if="{{isAuth}}" bindopensetting="openSetting">{{confirmBtnTitle}}</button>
|
<button open-type='openSetting' wx:if="{{isAuth}}" bindopensetting="openSetting">{{confirmBtnTitle}}</button>
|
||||||
<button open-type='getUserInfo' wx:elif="{{isUserInfo}}" bindgetuserinfo="openUserInfo">{{confirmBtnTitle}}</button>
|
<button wx:elif="{{isUserInfo}}" bindtap="openUserInfo">{{confirmBtnTitle}}</button>
|
||||||
<button wx:else bindtap='confirm'>{{confirmBtnTitle}}</button>
|
<button wx:else bindtap='confirm'>{{confirmBtnTitle}}</button>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|||||||
@@ -268,11 +268,13 @@ Page({
|
|||||||
|
|
||||||
// 授权微信
|
// 授权微信
|
||||||
getUserInfo(e) {
|
getUserInfo(e) {
|
||||||
app.$pay.payWxLoing(e.detail).then(res => {
|
wx.getUserProfile({
|
||||||
|
desc: '用于完善会员资料',
|
||||||
|
success: (res) => {
|
||||||
|
app.$pay.payWxLoing(res).then(res => {
|
||||||
wx.showToast({
|
wx.showToast({
|
||||||
title: '绑定成功',
|
title: '绑定成功',
|
||||||
duration: 2000,
|
duration: 2000,
|
||||||
|
|
||||||
})
|
})
|
||||||
this.setData({
|
this.setData({
|
||||||
isWxLogin: false
|
isWxLogin: false
|
||||||
@@ -283,5 +285,7 @@ Page({
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -307,12 +307,13 @@ Page({
|
|||||||
|
|
||||||
// 授权微信
|
// 授权微信
|
||||||
getUserInfo(e) {
|
getUserInfo(e) {
|
||||||
console.log(e.detail);
|
wx.getUserProfile({
|
||||||
app.$pay.payWxLoing(e.detail).then(res => {
|
desc: '用于完善会员资料',
|
||||||
|
success: (res) => {
|
||||||
|
app.$pay.payWxLoing(res).then(res => {
|
||||||
wx.showToast({
|
wx.showToast({
|
||||||
title: '绑定成功',
|
title: '绑定成功',
|
||||||
duration: 2000,
|
duration: 2000,
|
||||||
|
|
||||||
})
|
})
|
||||||
this.setData({
|
this.setData({
|
||||||
isWxLogin: false
|
isWxLogin: false
|
||||||
@@ -322,6 +323,8 @@ Page({
|
|||||||
isWxLogin: false
|
isWxLogin: false
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
// 选中支付方式
|
// 选中支付方式
|
||||||
|
|||||||
@@ -217,11 +217,13 @@ Page({
|
|||||||
|
|
||||||
// 授权微信
|
// 授权微信
|
||||||
getUserInfo(e) {
|
getUserInfo(e) {
|
||||||
app.$pay.payWxLoing(e.detail).then(res => {
|
wx.getUserProfile({
|
||||||
|
desc: '用于完善会员资料',
|
||||||
|
success: (res) => {
|
||||||
|
app.$pay.payWxLoing(res).then(res => {
|
||||||
wx.showToast({
|
wx.showToast({
|
||||||
title: '绑定成功',
|
title: '绑定成功',
|
||||||
duration: 2000,
|
duration: 2000,
|
||||||
|
|
||||||
})
|
})
|
||||||
this.setData({
|
this.setData({
|
||||||
isWxLogin: false
|
isWxLogin: false
|
||||||
@@ -232,4 +234,6 @@ Page({
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
})
|
})
|
||||||
@@ -121,12 +121,15 @@ Page({
|
|||||||
showUnclickMask: true
|
showUnclickMask: true
|
||||||
})
|
})
|
||||||
let that = this;
|
let that = this;
|
||||||
|
wx.getUserProfile({
|
||||||
|
desc: '用于完善会员资料',
|
||||||
|
success: (res) => {
|
||||||
wx.login({
|
wx.login({
|
||||||
success: function(res) {
|
success: function(r){
|
||||||
app.$api.memberLoginWX({
|
app.$api.memberLoginWX({
|
||||||
avatar: e.detail.userInfo.avatarUrl,
|
avatar: res.userInfo.avatarUrl,
|
||||||
code: res.code,
|
code: r.code,
|
||||||
nickname: e.detail.userInfo.nickName
|
nickname: res.userInfo.nickName
|
||||||
}).then(res => {
|
}).then(res => {
|
||||||
wx.setStorageSync('information', res.information);
|
wx.setStorageSync('information', res.information);
|
||||||
if (!res.authorization) {
|
if (!res.authorization) {
|
||||||
@@ -159,4 +162,11 @@ Page({
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
fail: (res) => {
|
||||||
|
that.setData({
|
||||||
|
showUnclickMask: false
|
||||||
|
})
|
||||||
|
},
|
||||||
|
})
|
||||||
|
},
|
||||||
})
|
})
|
||||||
@@ -7,7 +7,6 @@
|
|||||||
<view class='line-between-text'>快速微信登录</view>
|
<view class='line-between-text'>快速微信登录</view>
|
||||||
</view>
|
</view>
|
||||||
<view class='wechat-btn'>
|
<view class='wechat-btn'>
|
||||||
<button open-type='getUserInfo' bindgetuserinfo='wxLogin' ></button>
|
|
||||||
<image src='../../images/47@3x.png' bindtap='wxLogin'></image>
|
<image src='../../images/47@3x.png' bindtap='wxLogin'></image>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|||||||
@@ -153,11 +153,13 @@ Page({
|
|||||||
|
|
||||||
// 授权微信
|
// 授权微信
|
||||||
getUserInfo(e) {
|
getUserInfo(e) {
|
||||||
app.$pay.payWxLoing(e.detail).then(res => {
|
wx.getUserProfile({
|
||||||
|
desc: '用于完善会员资料',
|
||||||
|
success: (res) => {
|
||||||
|
app.$pay.payWxLoing(res).then(res => {
|
||||||
wx.showToast({
|
wx.showToast({
|
||||||
title: '绑定成功',
|
title: '绑定成功',
|
||||||
duration: 2000,
|
duration: 2000,
|
||||||
|
|
||||||
})
|
})
|
||||||
this.setData({
|
this.setData({
|
||||||
isWxLogin: false
|
isWxLogin: false
|
||||||
@@ -168,4 +170,6 @@ Page({
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
})
|
})
|
||||||
@@ -23,7 +23,7 @@ export function pay(body) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function payWxLoing(body) {
|
export function payWxLoing(body) {
|
||||||
console.log(body)
|
console.log(body.userInfo)
|
||||||
|
|
||||||
const app = getApp();
|
const app = getApp();
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user