|
|
@ -18,22 +18,67 @@ Page({ |
|
|
title: '加载中...', |
|
|
title: '加载中...', |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
// 获取用户手机号
|
|
|
// 获取用户手机号 - 增强版,增加更多获取途径和调试信息
|
|
|
const users = wx.getStorageSync('users') || {}; |
|
|
const users = wx.getStorageSync('users') || {}; |
|
|
const userId = wx.getStorageSync('userId'); |
|
|
const userId = wx.getStorageSync('userId'); |
|
|
let userPhone = null; |
|
|
let userPhone = null; |
|
|
|
|
|
|
|
|
// 尝试从users中获取手机号
|
|
|
// 添加调试信息,显示当前存储的用户信息
|
|
|
if (userId && users[userId] && users[userId].phoneNumber) { |
|
|
console.log('调试信息 - 登录用户:', { |
|
|
userPhone = users[userId].phoneNumber; |
|
|
userId: userId, |
|
|
} else { |
|
|
users: users, |
|
|
// 尝试从全局用户信息获取
|
|
|
userInfo: wx.getStorageSync('userInfo'), |
|
|
|
|
|
phoneNumber: wx.getStorageSync('phoneNumber'), |
|
|
|
|
|
phone: wx.getStorageSync('phone') |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
// 尝试从users中获取手机号(支持不同的键名)
|
|
|
|
|
|
if (userId && users[userId]) { |
|
|
|
|
|
if (users[userId].phoneNumber) { |
|
|
|
|
|
userPhone = users[userId].phoneNumber; |
|
|
|
|
|
console.log('从users[userId].phoneNumber获取到手机号:', userPhone); |
|
|
|
|
|
} else if (users[userId].phone) { |
|
|
|
|
|
userPhone = users[userId].phone; |
|
|
|
|
|
console.log('从users[userId].phone获取到手机号:', userPhone); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 如果还没有获取到,尝试从全局用户信息获取
|
|
|
|
|
|
if (!userPhone) { |
|
|
const userInfo = wx.getStorageSync('userInfo'); |
|
|
const userInfo = wx.getStorageSync('userInfo'); |
|
|
if (userInfo && userInfo.phoneNumber) { |
|
|
if (userInfo) { |
|
|
userPhone = userInfo.phoneNumber; |
|
|
if (userInfo.phoneNumber) { |
|
|
} else { |
|
|
userPhone = userInfo.phoneNumber; |
|
|
// 尝试从直接存储的phoneNumber获取
|
|
|
console.log('从userInfo.phoneNumber获取到手机号:', userPhone); |
|
|
|
|
|
} else if (userInfo.phone) { |
|
|
|
|
|
userPhone = userInfo.phone; |
|
|
|
|
|
console.log('从userInfo.phone获取到手机号:', userPhone); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 如果还没有获取到,尝试从直接存储获取(支持不同的键名)
|
|
|
|
|
|
if (!userPhone) { |
|
|
|
|
|
if (wx.getStorageSync('phoneNumber')) { |
|
|
userPhone = wx.getStorageSync('phoneNumber'); |
|
|
userPhone = wx.getStorageSync('phoneNumber'); |
|
|
|
|
|
console.log('从storage.phoneNumber获取到手机号:', userPhone); |
|
|
|
|
|
} else if (wx.getStorageSync('phone')) { |
|
|
|
|
|
userPhone = wx.getStorageSync('phone'); |
|
|
|
|
|
console.log('从storage.phone获取到手机号:', userPhone); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 如果还没有获取到,尝试从更多可能的存储位置获取
|
|
|
|
|
|
if (!userPhone) { |
|
|
|
|
|
const loginInfo = wx.getStorageSync('loginInfo'); |
|
|
|
|
|
if (loginInfo) { |
|
|
|
|
|
if (loginInfo.phoneNumber) { |
|
|
|
|
|
userPhone = loginInfo.phoneNumber; |
|
|
|
|
|
console.log('从loginInfo.phoneNumber获取到手机号:', userPhone); |
|
|
|
|
|
} else if (loginInfo.phone) { |
|
|
|
|
|
userPhone = loginInfo.phone; |
|
|
|
|
|
console.log('从loginInfo.phone获取到手机号:', userPhone); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|