|
|
@ -24,7 +24,8 @@ Page({ |
|
|
userTags: [], |
|
|
userTags: [], |
|
|
needPhoneAuth: false, // 是否需要重新授权手机号
|
|
|
needPhoneAuth: false, // 是否需要重新授权手机号
|
|
|
locationInfo: '', // 位置信息
|
|
|
locationInfo: '', // 位置信息
|
|
|
hasLocationAuth: false // 是否已经授权位置
|
|
|
hasLocationAuth: false, // 是否已经授权位置
|
|
|
|
|
|
isInPersonnel: false // 用户手机号是否在personnel表中
|
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
onLoad() { |
|
|
onLoad() { |
|
|
@ -93,6 +94,33 @@ Page({ |
|
|
// 先使用本地存储的用户类型更新标签,后续会被服务器返回的最新值覆盖
|
|
|
// 先使用本地存储的用户类型更新标签,后续会被服务器返回的最新值覆盖
|
|
|
this.updateUserTags(userId, user.type) |
|
|
this.updateUserTags(userId, user.type) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 检查用户手机号是否在personnel表中
|
|
|
|
|
|
this.checkPhoneInPersonnel() |
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
// 检查用户手机号是否在personnel表中
|
|
|
|
|
|
checkPhoneInPersonnel() { |
|
|
|
|
|
const userInfo = this.data.userInfo |
|
|
|
|
|
const phoneNumber = userInfo.phoneNumber |
|
|
|
|
|
|
|
|
|
|
|
if (!phoneNumber) { |
|
|
|
|
|
this.setData({ isInPersonnel: false }) |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
console.log('开始检查手机号是否在personnel表中:', phoneNumber) |
|
|
|
|
|
|
|
|
|
|
|
// 引入API服务
|
|
|
|
|
|
const API = require('../../utils/api.js') |
|
|
|
|
|
|
|
|
|
|
|
API.checkPhoneInPersonnel(phoneNumber).then(isInPersonnel => { |
|
|
|
|
|
console.log('用户手机号是否在personnel表中:', isInPersonnel) |
|
|
|
|
|
this.setData({ isInPersonnel }) |
|
|
|
|
|
}).catch(err => { |
|
|
|
|
|
console.error('检查personnel表失败:', err) |
|
|
|
|
|
this.setData({ isInPersonnel: false }) |
|
|
|
|
|
}) |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
// 更新用户标签
|
|
|
// 更新用户标签
|
|
|
@ -168,6 +196,9 @@ Page({ |
|
|
this.syncUserTypeFromServer(userId, serverUserInfo.type) |
|
|
this.syncUserTypeFromServer(userId, serverUserInfo.type) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 重新检查用户手机号是否在personnel表中
|
|
|
|
|
|
this.checkPhoneInPersonnel() |
|
|
|
|
|
|
|
|
console.log('用户信息已更新,昵称:', updatedUserInfo.name, '手机号:', updatedUserInfo.phoneNumber, '身份:', serverUserInfo.type) |
|
|
console.log('用户信息已更新,昵称:', updatedUserInfo.name, '手机号:', updatedUserInfo.phoneNumber, '身份:', serverUserInfo.type) |
|
|
} |
|
|
} |
|
|
}).catch(err => { |
|
|
}).catch(err => { |
|
|
@ -187,15 +218,18 @@ Page({ |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
app.globalData.userInfo = updatedUserInfo |
|
|
app.globalData.userInfo = updatedUserInfo |
|
|
wx.setStorageSync('userInfo', updatedUserInfo) |
|
|
wx.setStorageSync('userInfo', updatedUserInfo) |
|
|
this.setData({ userInfo: updatedUserInfo }) |
|
|
this.setData({ userInfo: updatedUserInfo }) |
|
|
|
|
|
|
|
|
// 同步更新用户身份信息(当前身份由数据库决定)
|
|
|
// 同步更新用户身份信息(当前身份由数据库决定)
|
|
|
if (serverUserInfo.type) { |
|
|
if (serverUserInfo.type) { |
|
|
this.syncUserTypeFromServer(userId, serverUserInfo.type) |
|
|
this.syncUserTypeFromServer(userId, serverUserInfo.type) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 重新检查用户手机号是否在personnel表中
|
|
|
|
|
|
this.checkPhoneInPersonnel() |
|
|
|
|
|
|
|
|
console.log('用户信息已更新(备选方案):', updatedUserInfo) |
|
|
console.log('用户信息已更新(备选方案):', updatedUserInfo) |
|
|
} |
|
|
} |
|
|
}).catch(validateErr => { |
|
|
}).catch(validateErr => { |
|
|
console.error('从服务器获取用户信息失败(包括备选方案):', validateErr) |
|
|
console.error('从服务器获取用户信息失败(包括备选方案):', validateErr) |
|
|
|