第三方绑定
This commit is contained in:
parent
5f233b8e06
commit
16115ba111
@ -454,6 +454,19 @@ export default {
|
||||
//获取默认头像
|
||||
getDefaultAvatar(){
|
||||
return vm.$u.post("member/getDefaultAvatar")
|
||||
},
|
||||
// 第三方账号绑定【微信|QQ】
|
||||
bindingThird({ openid, type }) {
|
||||
return vm.$u.post("auth/memberBindThird", {
|
||||
third_openid: openid,
|
||||
third_type: type,
|
||||
})
|
||||
},
|
||||
// 解绑
|
||||
unbindingThird({ type }) {
|
||||
return vm.$u.post("auth/memberUnbindThird", {
|
||||
third_type: type,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,11 +2,11 @@
|
||||
<view class="binding">
|
||||
<view class="binding-item" v-for="(item, index) in bangdingList" :key="index">
|
||||
<view class="title">{{ item.title }}</view>
|
||||
<view class="btn unbundling-btn" @click="unbinding" v-if="0">
|
||||
<view class="btn unbundling-btn" @click="unbinding(item.type)" v-if="userInfo[item.name]">
|
||||
<image src="/static/image/mine/44.png"></image>
|
||||
<text>解绑</text>
|
||||
</view>
|
||||
<view class="btn bundling-btn" @click="binding(item.provider)" v-else>
|
||||
<view class="btn bundling-btn" @click="binding(item.provider, item.type)" v-else>
|
||||
<image src="/static/image/mine/43.png"></image>
|
||||
<text>绑定</text>
|
||||
</view>
|
||||
@ -17,29 +17,61 @@
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
userInfo: '',
|
||||
bangdingList: [
|
||||
{
|
||||
title: 'QQ',
|
||||
provider: 'qq'
|
||||
provider: 'qq', // uni 登录 provider
|
||||
type: 'qq', // 后台需要解绑的参数名 type
|
||||
name: 'member_qqopenid', // 后台返回是否绑定的字段名
|
||||
},
|
||||
{
|
||||
title: '微信',
|
||||
provider: 'weixin'
|
||||
provider: 'weixin',
|
||||
type: 'wechat',
|
||||
name: 'member_wxopenid',
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
this.getMemberInfo();
|
||||
},
|
||||
methods: {
|
||||
binding(provider) {
|
||||
getMemberInfo() {
|
||||
this.$u.api.getMemberInfo().then(res => {
|
||||
if (res.errCode == 0) {
|
||||
this.userInfo = res.data.MemberArray;
|
||||
}
|
||||
})
|
||||
},
|
||||
binding(provider, type) {
|
||||
uni.login({
|
||||
provider: provider,
|
||||
success: function (loginRes) {
|
||||
console.log(loginRes.authResult);
|
||||
success: (loginRes) => {
|
||||
console.log(loginRes);
|
||||
uni.getUserInfo({
|
||||
provider: provider,
|
||||
success: (res) => {
|
||||
console.log(res.userInfo.openId);
|
||||
this.$u.api.bindingThird({
|
||||
openid: res.userInfo.openId,
|
||||
type: type
|
||||
}).then(res => {
|
||||
this.$u.toast(res.message);
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
fail: (e) => {
|
||||
console.log(e);
|
||||
}
|
||||
});
|
||||
},
|
||||
unbinding() {
|
||||
|
||||
unbinding(type) {
|
||||
this.$u.api.unbindingThird({ type: type }).then(res => {
|
||||
this.$u.toast(res.message);
|
||||
})
|
||||
}
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user