Commit e231f5f1 authored by youjie's avatar youjie

no message

parent 73b2bbce
...@@ -95,16 +95,19 @@ ...@@ -95,16 +95,19 @@
AccountName:'', AccountName:'',
shareUnionId:'', shareUnionId:'',
loading:true, loading:true,
currentWxUserAuth:{} currentWxUserAuth:{},
getUserWxInfo:null
}); });
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() {
data.loading = false
//新的获取用户资料 //新的获取用户资料
wx.getUserProfile({ wx.getUserProfile({
desc: "用于完善资料", // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写 desc: "用于完善资料", // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
success: (info) => { success: (info) => {
data.getUserWxInfo = info
uni.setStorageSync('userWxInfo',info) uni.setStorageSync('userWxInfo',info)
wx.login({ wx.login({
//成功放回 //成功放回
...@@ -112,7 +115,6 @@ ...@@ -112,7 +115,6 @@
uni.showLoading({ uni.showLoading({
title:'尝试授权登陆' title:'尝试授权登陆'
}) })
console.log(res.code,'---')
methods.loginByOpenCode(res.code) methods.loginByOpenCode(res.code)
} }
}) })
...@@ -127,6 +129,7 @@ ...@@ -127,6 +129,7 @@
}, },
loginByOpenCode(Code){ loginByOpenCode(Code){
getWeChatOpenId({Code}).then(r=>{ getWeChatOpenId({Code}).then(r=>{
uni.hideLoading()
uni.setStorageSync('wxUserAuthInfo',r.Data) uni.setStorageSync('wxUserAuthInfo',r.Data)
data.currentWxUserAuth=r.Data data.currentWxUserAuth=r.Data
if(r.Data.unionid){ if(r.Data.unionid){
...@@ -135,14 +138,18 @@ ...@@ -135,14 +138,18 @@
}).catch(e=>{}) }).catch(e=>{})
}, },
addFriend(){ addFriend(){
data.loading = false let msg = {
uni.showLoading() WeChatImg: data.getUserWxInfo.userInfo.avatarUrl,
SetFriend({ WeChatName: data.getUserWxInfo.userInfo.nickName,
OldUnionId: data.shareUnionId, OldUnionId: data.shareUnionId,
NewUnionId: data.currentWxUserAuth.unionid //'oV5Rm1J_MpkEVvE0VPEicwCDG1Zo' NewUnionId: data.currentWxUserAuth.unionid
}).then(res=>{ }
uni.showLoading()
SetFriend(msg).then(res=>{
if (res.Code==1) { if (res.Code==1) {
methods.setUserLoginByUnionId(data.currentWxUserAuth.unionid) uni.hideLoading()
data.loading = true
methods.setUserLoginByUnionId(data.currentWxUserAuth.unionid,data.getUserWxInfo.userInfo.nickName,data.getUserWxInfo.userInfo.avatarUrl)
}else{ }else{
uni.hideLoading() uni.hideLoading()
data.loading = true data.loading = true
...@@ -152,15 +159,33 @@ ...@@ -152,15 +159,33 @@
icon: "none", icon: "none",
}); });
},2000) },2000)
uni.showModal({
title: '提示',
// 'OldUnionId='+msg.OldUnionId+'&NewUnionId='+msg.NewUnionId+'&Name='+msg.WeChatName+'&WeChatImg='+msg.WeChatImg
content: JSON.stringify(msg),
success: function (res) {
if (res.confirm) {
} else if (res.cancel) {
}
}
});
} }
}); });
}, },
setUserLoginByUnionId(uid){ setUserLoginByUnionId(uid,wname,wimage){
loginByUnionId({uid}).then(r=>{ loginByUnionId({uid,wname,wimage}).then(r=>{
if(r.Code!=1){ if(r.Code!=1){
uni.hideLoading() uni.hideLoading()
data.loading = true data.loading = true
setTimeout(()=>{
uni.showToast({
title: r.Message,
icon: "none",
});
},2000)
} }
if(r.Data && r.Data.length>0){ if(r.Data && r.Data.length>0){
uni.setStorageSync("ErpStus",r.Data) uni.setStorageSync("ErpStus",r.Data)
...@@ -211,6 +236,14 @@ ...@@ -211,6 +236,14 @@
} }
uni.hideLoading() uni.hideLoading()
data.loading = true data.loading = true
if(r.Code!=1){
setTimeout(()=>{
uni.showToast({
title: r.Message,
icon: "none",
});
},2000)
}
}).catch(e=>{ }).catch(e=>{
uni.hideLoading() uni.hideLoading()
...@@ -238,6 +271,10 @@ ...@@ -238,6 +271,10 @@
}) })
}, },
}; };
let that = methods
onMounted(()=>{
});
return { return {
...toRefs(data), ...toRefs(data),
...methods ...methods
...@@ -254,18 +291,6 @@ ...@@ -254,18 +291,6 @@
url:'/pages/login/login' url:'/pages/login/login'
}) })
} }
// uni.showModal({
// title: 'options',
// content: JSON.stringify(options),
// success: function (res) {
// if (res.confirm) {
// } else if (res.cancel) {
// }
// }
// });
}, },
onShow(){ onShow(){
this.getData() this.getData()
......
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