Commit 9211b7d4 authored by 罗超's avatar 罗超

修改绑定

parent 19ea2576
......@@ -48,7 +48,7 @@
<text>{{AccountName?AccountName:'**'}}的亲友团</text>
</view>
<view class="title">
{{nickName?nickName:'**'}}邀请您加入亲友团
{{nickName?nickName:''}}邀请您加入亲友团
</view>
<view v-if="loading" class="addChild-buttom" @click="getUserProfile">
立即加入
......@@ -93,22 +93,15 @@
options:null,
nickName:'',
AccountName:'',
OldUnionId:'',
shareUnionId:'',
loading:true,
form:{
OldUnionId:'',
NewUnionId:''
},
msg: {
Unionid:''
}
currentWxUserAuth:{}
});
const pages = getCurrentPages() // 获取栈实例
const currentRoute = pages[pages.length - 1].route; // 获取当前页面路由
const methods = {
getUserProfile() {
//新的获取用户资料
var that = this;
wx.getUserProfile({
desc: "用于完善资料", // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
success: (info) => {
......@@ -119,7 +112,7 @@
uni.showLoading({
title:'尝试授权登陆'
})
that.loginByOpenCode(res.code)
methods.loginByOpenCode(res.code)
}
})
},
......@@ -134,32 +127,33 @@
loginByOpenCode(Code){
getWeChatOpenId({Code}).then(r=>{
uni.setStorageSync('wxUserAuthInfo',r.Data)
data.userAuth=r.Data
data.currentWxUserAuth=r.Data
if(r.Data.unionid){
that.addFriend(r)
methods.addFriend(r)
}
}).catch(e=>{})
},
addFriend(r){
data.form = {
OldUnionId: data.OldUnionId,
NewUnionId: uni.getStorageSync('wxUserAuthInfo').unionid
}
data.loading = false
uni.showLoading()
let res = SetFriend(data.form);
if (res.Code==1) {
let res = SetFriend({
OldUnionId: data.shareUnionId,
NewUnionId: data.currentWxUserAuth.unionid
}).then(r=>{
if (r.Code==1) {
uni.hideLoading()
data.loading = true
that.setUserLoginByUnionId(r.Data.unionid)
methods.setUserLoginByUnionId(data.currentWxUserAuth.unionid)
}else{
uni.hideLoading()
data.loading = true
uni.showToast({
title: res.Message,
title: r.Message,
icon: "none",
});
}
});
},
setUserLoginByUnionId(uid){
loginByUnionId({uid}).then(r=>{
......@@ -169,7 +163,16 @@
r.Data.forEach(x=>{
account.push(x.ClassInAccount)
})
that.setAccountsLogin(`'${account.join("','")}'`)
if(account.length>0){
methods.setAccountsLogin(`'${account.join("','")}'`)
}else{
uni.removeStorageSync('userInfo')
uni.removeStorageSync('users')
uni.setStorageSync('erpUserInfo',r.Data[0])
uni.reLaunch({
url:'/pages/index/index'
})
}
}
}).catch(x=>{
uni.hideLoading()
......@@ -197,6 +200,8 @@
url:'/pages/index/index'
})
}else if(erpStus){
uni.removeStorageSync('userInfo')
uni.removeStorageSync('users')
uni.setStorageSync('erpUserInfo',x[0])
uni.reLaunch({
url:'/pages/index/index'
......@@ -209,70 +214,46 @@
})
},
async getData() {
// uni.showLoading()
let res = await GetUserInfoByUnionId(data.msg);
uni.showLoading()
let res = await GetUserInfoByUnionId({
Unionid:data.shareUnionId
});
if (res.Code==1) {
// uni.hideLoading()
data.nickName = res.Data.WeChatName
}else{
// uni.hideLoading()
uni.showToast({
title: res.Message,
icon: "none",
});
}
uni.showModal({
title: '提示res',
content: JSON.stringify(res.Data),
success: function (res) {
if (res.confirm) {
} else if (res.cancel) {
}
}
});
uni.hideLoading()
},
};
let that = methods;
onMounted(() => {
var url = ctx.$scope.$page.fullPath;
data.OldUnionId = decodeURIComponent(url.split('=')[1])
data.AccountName = decodeURIComponent(url.split('=')[2])
data.msg.Unionid = data.OldUnionId
uni.showModal({
title: 'ctx',
content: JSON.stringify(ctx.$scope.$page.fullPath),
success: function (res) {
if (res.confirm) {
} else if (res.cancel) {
}
}
});
});
return {
...toRefs(data),
...methods
};
},
onLoad(options) {
uni.showModal({
title: 'options',
content: JSON.stringify(options),
success: function (res) {
if (res.confirm) {
console.log(options)
if(options.AccountName && options.unionId){
this.AccountName=options.AccountName
this.shareUnionId=options.unionId
this.getData()
}
// uni.showModal({
// title: 'options',
// content: JSON.stringify(options),
// success: function (res) {
// if (res.confirm) {
} else if (res.cancel) {
// } else if (res.cancel) {
}
}
});
// }
// }
// });
},
onShow(){
......
......@@ -257,15 +257,17 @@
let msg = {
Id: item.Id
}
let res = RemoveMyChild(msg);
if (res.Code==1) {
RemoveMyChild(msg).then(r=>{
if (r.Code==1) {
uni.hideLoading()
data.dataList = []
//data.dataList = []
data.msg.pageIndex = 1
that.getData()
methods.getData()
}else{
uni.hideLoading()
}
});
} else if (res.cancel) {
uni.showToast({
title:'已取消',
......@@ -336,11 +338,11 @@
this.wxUserAuthInfo = uni.getStorageSync('wxUserAuthInfo')
this.erpUserInfo = uni.getStorageSync('erpUserInfo')
this.getData()
// let path=`/pages/FriendsAndRelatives/addFriendsAndRelatives?unionId=${this.wxUserAuthInfo.unionid}&AccountName=${this.erpUserInfo.AccountName}`
// console.log(path)
// uni.navigateTo({
// url:path
// })
let path=`/pages/FriendsAndRelatives/addFriendsAndRelatives?unionId=${this.wxUserAuthInfo.unionid}&AccountName=${this.erpUserInfo.AccountName}`
console.log(path)
uni.navigateTo({
url:path
})
},
onReachBottom() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment