|
|
|
@ -96,54 +96,20 @@ Page({
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
fresh() {
|
|
|
|
|
wx.getSystemInfo({
|
|
|
|
|
success(res) {
|
|
|
|
|
if (res.environment) {
|
|
|
|
|
// 企业微信环境
|
|
|
|
|
wx.qy.login({
|
|
|
|
|
success: function (res) {
|
|
|
|
|
http("/qywx/userDepartmentRefresh", "post", {
|
|
|
|
|
code: res.code
|
|
|
|
|
}).then(res => {
|
|
|
|
|
console.log(res)
|
|
|
|
|
if(res.success){
|
|
|
|
|
wx.showToast({
|
|
|
|
|
title: '刷新成功',
|
|
|
|
|
icon: 'none',
|
|
|
|
|
duration: 3000
|
|
|
|
|
})
|
|
|
|
|
this.userlogin()
|
|
|
|
|
} else {
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
} else {
|
|
|
|
|
// 微信·环境
|
|
|
|
|
wx.showToast({
|
|
|
|
|
title: '请在企业微信中打开\r\n以获取企业架构',
|
|
|
|
|
icon: 'none',
|
|
|
|
|
duration: 3000
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
userlogin() {
|
|
|
|
|
let that = this
|
|
|
|
|
wx.login({
|
|
|
|
|
success: res => {
|
|
|
|
|
this.setData({
|
|
|
|
|
that.setData({
|
|
|
|
|
code: res.code
|
|
|
|
|
})
|
|
|
|
|
http("/user/login", "post", {
|
|
|
|
|
code: res.code
|
|
|
|
|
}).then(res => {
|
|
|
|
|
if (res.msg === "未注册!") {
|
|
|
|
|
let that = this
|
|
|
|
|
}).then(loginRes => {
|
|
|
|
|
if (loginRes.code === 10008) {
|
|
|
|
|
wx.getSystemInfo({
|
|
|
|
|
success(res) {
|
|
|
|
|
if (res.environment) {
|
|
|
|
|
success(sysRes) {
|
|
|
|
|
if (sysRes.environment) {
|
|
|
|
|
console.log('企业微信环境')
|
|
|
|
|
// 企业微信环境
|
|
|
|
|
that.getUserProfile()
|
|
|
|
@ -160,34 +126,7 @@ Page({
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
} else {
|
|
|
|
|
getApp().globalData.token = res.data.token
|
|
|
|
|
this.setData({
|
|
|
|
|
user_avatar: res.data.user.avatar,
|
|
|
|
|
user_name: res.data.user.name,
|
|
|
|
|
user_tip: '欢迎来到星途~',
|
|
|
|
|
userInfo: res.data.user
|
|
|
|
|
})
|
|
|
|
|
wx.setStorage({
|
|
|
|
|
key: 'user',
|
|
|
|
|
data: res.data.user
|
|
|
|
|
})
|
|
|
|
|
wx.setStorage({
|
|
|
|
|
key: 'token',
|
|
|
|
|
data: res.data.token
|
|
|
|
|
})
|
|
|
|
|
if (this.data.userInfo.departmentName===''||this.data.userInfo.departmentName===null) {
|
|
|
|
|
this.fresh()
|
|
|
|
|
} else {
|
|
|
|
|
wx.qy.login({
|
|
|
|
|
success: function (res) {
|
|
|
|
|
http("/qywx/userDepartmentRefresh", "post", {
|
|
|
|
|
code: res.code
|
|
|
|
|
}).then(res => {
|
|
|
|
|
console.log(res)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
that.setUserInfo(loginRes.data)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
@ -225,14 +164,14 @@ Page({
|
|
|
|
|
let that = this
|
|
|
|
|
let param = {
|
|
|
|
|
userinfo: {
|
|
|
|
|
iv: this.data.iv,
|
|
|
|
|
encryptedData: this.data.encryptedData
|
|
|
|
|
iv: that.data.iv,
|
|
|
|
|
encryptedData: that.data.encryptedData
|
|
|
|
|
},
|
|
|
|
|
phone: {
|
|
|
|
|
iv: e.detail.iv,
|
|
|
|
|
encryptedData: e.detail.encryptedData
|
|
|
|
|
},
|
|
|
|
|
code: this.data.code
|
|
|
|
|
code: that.data.code
|
|
|
|
|
}
|
|
|
|
|
http("/user/register", "post", param).then(res => {
|
|
|
|
|
// wx.showToast({
|
|
|
|
@ -240,7 +179,55 @@ Page({
|
|
|
|
|
// icon: 'none',
|
|
|
|
|
// duration: 2000
|
|
|
|
|
// })
|
|
|
|
|
this.userlogin()
|
|
|
|
|
console.log("注册============",res)
|
|
|
|
|
that.setUserInfo(res.data)
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
// 将用户信息嵌入页面、全局和缓存
|
|
|
|
|
setUserInfo(userInfo){
|
|
|
|
|
let that = this
|
|
|
|
|
getApp().globalData.token = userInfo.token
|
|
|
|
|
that.setData({
|
|
|
|
|
user_avatar: userInfo.avatar,
|
|
|
|
|
user_name: userInfo.name,
|
|
|
|
|
user_tip: '欢迎来到星途~',
|
|
|
|
|
userInfo: userInfo
|
|
|
|
|
})
|
|
|
|
|
wx.setStorageSync('user', userInfo)
|
|
|
|
|
wx.setStorageSync('token', userInfo.token)
|
|
|
|
|
if ( userInfo.main_department===null) {
|
|
|
|
|
that.dpRefresh()
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
dpRefresh() {
|
|
|
|
|
let that = this
|
|
|
|
|
wx.getSystemInfo({
|
|
|
|
|
success(sysRes) {
|
|
|
|
|
if (sysRes.environment) {
|
|
|
|
|
// 企业微信环境
|
|
|
|
|
wx.qy.login({
|
|
|
|
|
success: function (qyRes) {
|
|
|
|
|
http("/qywx/userDepartmentRefresh", "post", {
|
|
|
|
|
code: qyRes.code
|
|
|
|
|
}).then(res => {
|
|
|
|
|
if(res.success){
|
|
|
|
|
that.setData({
|
|
|
|
|
userInfo: res.data
|
|
|
|
|
})
|
|
|
|
|
wx.setStorageSync('user', res.data)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
} else {
|
|
|
|
|
// 微信·环境
|
|
|
|
|
wx.showToast({
|
|
|
|
|
title: '请在企业微信中打开\r\n以获取企业架构',
|
|
|
|
|
icon: 'none',
|
|
|
|
|
duration: 3000
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
colse() {
|
|
|
|
|