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

修改绑定

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