Browse Source

简化pages/index/index.js中的console调试日志,移除过多的测试消息

pull/6/head
徐飞洋 2 months ago
parent
commit
2ae77e9946
  1. 166
      pages/index/index.js

166
pages/index/index.js

@ -246,8 +246,6 @@ Page({
}, },
onLoad() { onLoad() {
console.log('首页初始化')
// 获取系统信息,处理iOS特定兼容性 // 获取系统信息,处理iOS特定兼容性
const systemInfo = wx.getSystemInfoSync(); const systemInfo = wx.getSystemInfoSync();
const isIOS = systemInfo.system.toLowerCase().includes('ios'); const isIOS = systemInfo.system.toLowerCase().includes('ios');
@ -258,7 +256,6 @@ Page({
this.setData({ this.setData({
isIOS: true isIOS: true
}); });
console.log('iOS设备检测到,启用兼容模式');
} }
const savedBtnTop = wx.getStorageSync('sidebarBtnTop'); const savedBtnTop = wx.getStorageSync('sidebarBtnTop');
@ -299,8 +296,6 @@ Page({
categorySectionHeight: categoryHeight, categorySectionHeight: categoryHeight,
totalHeaderHeight: totalHeight totalHeaderHeight: totalHeight
}); });
console.log('搜索区域高度:', searchHeight, '分类区域高度:', categoryHeight, '总高度:', totalHeight);
} }
}); });
}, 500); }, 500);
@ -335,9 +330,6 @@ Page({
}, },
onShow: function () { onShow: function () {
console.log('===== onShow 执行 =====');
console.log('onShow - 进入时的isSearchBarFullyHidden:', this.data.isSearchBarFullyHidden);
if (typeof this.getTabBar === 'function' && this.getTabBar()) { if (typeof this.getTabBar === 'function' && this.getTabBar()) {
this.getTabBar().setData({ this.getTabBar().setData({
selected: 0 selected: 0
@ -348,8 +340,6 @@ Page({
app.globalData.showTabBar = true; app.globalData.showTabBar = true;
const savedBtnHidden = wx.getStorageSync('sidebarBtnHidden'); const savedBtnHidden = wx.getStorageSync('sidebarBtnHidden');
console.log('onShow - savedBtnHidden:', savedBtnHidden);
console.log('onShow - isPageHidden:', this.data.isPageHidden);
// 只有在返回时才恢复按钮状态(刷新页面不恢复) // 只有在返回时才恢复按钮状态(刷新页面不恢复)
if (this.data.isPageHidden) { if (this.data.isPageHidden) {
@ -364,8 +354,6 @@ Page({
lastScrollTop: 0 lastScrollTop: 0
}); });
console.log('onShow - 设置后的isSearchBarFullyHidden:', this.data.isSearchBarFullyHidden);
this.checkAndRestoreLoginStatus() this.checkAndRestoreLoginStatus()
}, },
@ -690,25 +678,14 @@ Page({
} }
const filteredGoods = this.applyFilters(updatedGoods, false) const filteredGoods = this.applyFilters(updatedGoods, false)
console.log('===== 筛选结果 =====')
console.log('当前选中的分类:', this.data.selectedCategory)
console.log('filteredGoods 数量:', filteredGoods.length)
console.log('filteredGoods[0]:', filteredGoods[0] ? JSON.stringify(filteredGoods[0], null, 2) : 'N/A')
if (filteredGoods.length > 0) {
console.log('filteredGoods[0].category:', filteredGoods[0] ? filteredGoods[0].category : 'N/A')
}
if (filteredGoods.length > 1) {
console.log('filteredGoods[1].category:', filteredGoods[1] ? filteredGoods[1].category : 'N/A')
}
this.setData({ this.setData({
goods: updatedGoods, goods: updatedGoods,
filteredGoods: filteredGoods, filteredGoods: filteredGoods,
loadingMore: false, loadingMore: false,
isLoading: false, isLoading: false,
isRefreshing: false, // 确保下拉刷新状态被重置 isRefreshing: false,
page: this.data.page + 1, page: this.data.page + 1,
// 更新缓存时间戳
lastDataTimestamp: new Date().getTime() lastDataTimestamp: new Date().getTime()
}) })
}, },
@ -794,8 +771,6 @@ Page({
insertAdSlots: function(goods) { insertAdSlots: function(goods) {
if (!goods || goods.length === 0) return goods if (!goods || goods.length === 0) return goods
console.log('insertAdSlots 被调用,商品数量:', goods.length)
const adSlot1 = { const adSlot1 = {
id: 'ad_slot_1', id: 'ad_slot_1',
name: '广告位1', name: '广告位1',
@ -814,12 +789,7 @@ Page({
isAd: true isAd: true
} }
const result = [adSlot1, adSlot2, ...goods] return [adSlot1, adSlot2, ...goods]
console.log('插入广告后的商品数量:', result.length)
console.log('第一个商品:', result[0])
console.log('第二个商品:', result[1])
return result
}, },
// 广告点击事件处理 // 广告点击事件处理
@ -856,16 +826,11 @@ Page({
// 加载商品分类列表 // 加载商品分类列表
loadCategories: function() { loadCategories: function() {
console.log('===== 开始加载分类 =====');
API.getProductCategories().then(categories => { API.getProductCategories().then(categories => {
console.log('加载分类成功, categories:', JSON.stringify(categories));
if (categories && categories.length > 0) { if (categories && categories.length > 0) {
this.setData({ this.setData({
categories: categories categories: categories
}); });
console.log('分类列表已设置到data, categories:', this.data.categories);
} else {
console.log('分类列表为空,使用默认分类');
} }
}).catch(err => { }).catch(err => {
console.error('加载分类失败:', err); console.error('加载分类失败:', err);
@ -887,9 +852,8 @@ Page({
if (!isLoadMore && !forceRefresh && if (!isLoadMore && !forceRefresh &&
this.data.categoryQueryCache[cacheKey] && this.data.categoryQueryCache[cacheKey] &&
(now - this.data.lastDataTimestamp) < this.data.cacheValidDuration) { (now - this.data.lastDataTimestamp) < this.data.cacheValidDuration) {
console.log('使用缓存数据,cacheKey:', cacheKey); // 使用缓存数据
const cachedGoods = this.data.categoryQueryCache[cacheKey]; const cachedGoods = this.data.categoryQueryCache[cacheKey];
// 更新timestamp以确保缓存有效
this.setData({ lastDataTimestamp: now }); this.setData({ lastDataTimestamp: now });
this.processCachedGoods(cachedGoods, isLoadMore); this.processCachedGoods(cachedGoods, isLoadMore);
return; return;
@ -916,20 +880,10 @@ Page({
.then(res => { .then(res => {
wx.hideLoading(); wx.hideLoading();
console.log('===== API 返回的完整数据 =====');
console.log('res:', res);
console.log('res.products:', res.products);
if (res.products && res.products.length > 0) {
console.log('第一个商品的完整字段:', JSON.stringify(res.products[0], null, 2));
console.log('第一个商品的所有键:', Object.keys(res.products[0]));
}
if (res.success && res.products) { if (res.success && res.products) {
const totalGoods = res.total || 0; const totalGoods = res.total || 0;
const totalPages = res.totalPages || Math.ceil(totalGoods / this.data.pageSize); const totalPages = res.totalPages || Math.ceil(totalGoods / this.data.pageSize);
const hasMoreData = page < totalPages && res.products.length > 0; const hasMoreData = page < totalPages && res.products.length > 0;
// 如果返回的商品数量小于每页数量,说明没有更多数据了
const actualHasMoreData = res.products.length >= this.data.pageSize && page < totalPages; const actualHasMoreData = res.products.length >= this.data.pageSize && page < totalPages;
// 更新缓存(加载更多时追加数据) // 更新缓存(加载更多时追加数据)
@ -961,14 +915,14 @@ Page({
this.setData({ this.setData({
loadingMore: false, loadingMore: false,
isLoading: false, isLoading: false,
isRefreshing: false // 确保下拉刷新状态被重置 isRefreshing: false
}) })
}) })
}, },
// 处理缓存的商品数据 // 处理缓存的商品数据
processCachedGoods: function(cachedGoods, isLoadMore) { processCachedGoods: function(cachedGoods, isLoadMore) {
console.log('processCachedGoods 被调用, isLoadMore:', isLoadMore);
// 处理商品数据格式并去重 // 处理商品数据格式并去重
const goodsMap = new Map(); const goodsMap = new Map();
@ -1115,29 +1069,15 @@ Page({
// 应用筛选条件 // 应用筛选条件
applyFilters: function(goods, shouldSort = true) { applyFilters: function(goods, shouldSort = true) {
console.log('===== applyFilters 开始 =====');
console.log('输入商品数量:', goods.length);
console.log('搜索关键词:', this.data.searchKeyword);
console.log('选中分类:', this.data.selectedCategory);
let filtered = [...goods] let filtered = [...goods]
if (this.data.selectedCategory !== '全部') { if (this.data.selectedCategory !== '全部') {
const category = this.data.selectedCategory const category = this.data.selectedCategory
console.log('应用分类筛选:', category);
filtered = filtered.filter(item => item.isAd || (item.category === category)) filtered = filtered.filter(item => item.isAd || (item.category === category))
console.log('分类筛选后数量:', filtered.length);
} }
if (this.data.searchKeyword) { if (this.data.searchKeyword) {
const keyword = this.data.searchKeyword.toLowerCase() const keyword = this.data.searchKeyword.toLowerCase()
console.log('应用关键词搜索:', keyword);
console.log('筛选前商品示例:', filtered.slice(0, 3).map(item => ({
name: item.name,
productName: item.productName,
spec: item.spec,
region: item.region
})));
const originalLength = filtered.length; const originalLength = filtered.length;
filtered = filtered.filter(item => { filtered = filtered.filter(item => {
@ -1149,13 +1089,13 @@ Page({
const yolkMatch = (item.yolk || '').toLowerCase().includes(keyword); const yolkMatch = (item.yolk || '').toLowerCase().includes(keyword);
const match = item.isAd || nameMatch || productNameMatch || specMatch || regionMatch || grossWeightMatch || yolkMatch; const match = item.isAd || nameMatch || productNameMatch || specMatch || regionMatch || grossWeightMatch || yolkMatch;
if (!match && originalLength <= 5) { // 只为小数据集打印详细信息 if (!match && originalLength <= 5) {
console.log('商品未匹配:', item.name, '| name:', item.name, '| productName:', item.productName, '| spec:', item.spec, '| region:', item.region); // 只为小数据集打印详细信息
console.log('商品未匹配:', item.name);
} }
return match; return match;
}) })
console.log('搜索筛选后数量:', filtered.length);
} }
if (this.data.selectedRegion !== '全国') { if (this.data.selectedRegion !== '全国') {
@ -1203,20 +1143,12 @@ Page({
// 瀑布流布局 - 淘宝风格左右交替 // 瀑布流布局 - 淘宝风格左右交替
distributeToColumns: function(goods) { distributeToColumns: function(goods) {
if (!goods || goods.length === 0) { if (!goods || goods.length === 0) {
console.log('distributeToColumns: 商品列表为空')
return { leftColumnGoods: [], rightColumnGoods: [] } return { leftColumnGoods: [], rightColumnGoods: [] }
} }
console.log('distributeToColumns 开始分发,总商品数:', goods.length)
const leftColumn = [] const leftColumn = []
const rightColumn = [] const rightColumn = []
// 统计广告和普通商品
const adCount = goods.filter(item => item.isAd).length
const productCount = goods.filter(item => !item.isAd).length
console.log('广告数量:', adCount, '普通商品数量:', productCount)
for (let i = 0; i < goods.length; i += 2) { for (let i = 0; i < goods.length; i += 2) {
const currentRow = Math.floor(i / 2) const currentRow = Math.floor(i / 2)
const isEvenRow = currentRow % 2 === 0 const isEvenRow = currentRow % 2 === 0
@ -1224,20 +1156,14 @@ Page({
if (i < goods.length) { if (i < goods.length) {
const item = { ...goods[i], isLong: isEvenRow } const item = { ...goods[i], isLong: isEvenRow }
leftColumn.push(item) leftColumn.push(item)
console.log(`左列添加[${i}]:`, item.isAd ? '广告' : item.name, 'isLong:', item.isLong)
} }
if (i + 1 < goods.length) { if (i + 1 < goods.length) {
const item = { ...goods[i + 1], isLong: !isEvenRow } const item = { ...goods[i + 1], isLong: !isEvenRow }
rightColumn.push(item) rightColumn.push(item)
console.log(`右列添加[${i+1}]:`, item.isAd ? '广告' : item.name, 'isLong:', item.isLong)
} }
} }
console.log('分发结果 - 左列:', leftColumn.length, '右列:', rightColumn.length)
console.log('左列商品:', leftColumn.filter(i => !i.isAd).length, '广告:', leftColumn.filter(i => i.isAd).length)
console.log('右列商品:', rightColumn.filter(i => !i.isAd).length, '广告:', rightColumn.filter(i => i.isAd).length)
return { leftColumnGoods: leftColumn, rightColumnGoods: rightColumn } return { leftColumnGoods: leftColumn, rightColumnGoods: rightColumn }
}, },
@ -1313,10 +1239,9 @@ Page({
// 搜索输入(带防抖) // 搜索输入(带防抖)
onSearchInput: function(e) { onSearchInput: function(e) {
const keyword = e.detail.value const keyword = e.detail.value
console.log('===== 搜索输入 =====');
console.log('搜索关键词:', keyword);
console.log('当前商品数量:', this.data.goods.length);
console.log('当前筛选商品数量:', this.data.filteredGoods.length);
this.setData({ this.setData({
searchKeyword: keyword searchKeyword: keyword
@ -1329,9 +1254,7 @@ Page({
// 设置新的定时器,300ms防抖 // 设置新的定时器,300ms防抖
const timer = setTimeout(() => { const timer = setTimeout(() => {
console.log('===== 执行搜索 =====');
console.log('搜索关键词:', this.data.searchKeyword);
console.log('商品数据:', this.data.goods.slice(0, 3)); // 只显示前3个商品用于调试
this.searchGoods() this.searchGoods()
}, 300) }, 300)
@ -1393,7 +1316,7 @@ Page({
goodsCache: [] goodsCache: []
}); });
console.log('地区选择:清除缓存并重新加载数据,地区:', region);
this.loadGoods(false, true); // 强制刷新 this.loadGoods(false, true); // 强制刷新
}, },
@ -1433,7 +1356,7 @@ Page({
}); });
// 强制刷新:从数据库重新加载数据 // 强制刷新:从数据库重新加载数据
console.log('筛选操作:清除缓存并重新加载数据,分类:', category);
this.loadGoods(false, true); // 第二个参数true表示强制刷新 this.loadGoods(false, true); // 第二个参数true表示强制刷新
}, },
@ -1760,7 +1683,7 @@ Page({
if (e.detail.errMsg === 'getPhoneNumber:fail no permission') { if (e.detail.errMsg === 'getPhoneNumber:fail no permission') {
// 如果是测试模式,跳过真实授权流程 // 如果是测试模式,跳过真实授权流程
if (this.data.testMode) { if (this.data.testMode) {
console.log('进入测试模式,跳过真实手机号授权')
await this.simulateLoginForTest() await this.simulateLoginForTest()
return return
} }
@ -1781,7 +1704,7 @@ Page({
const existingUserInfo = wx.getStorageSync('userInfo') const existingUserInfo = wx.getStorageSync('userInfo')
if (existingOpenid && existingUserId && existingUserInfo && existingUserInfo.phoneNumber) { if (existingOpenid && existingUserId && existingUserInfo && existingUserInfo.phoneNumber) {
console.log('用户已登录且手机号有效,直接完成身份设置')
// 直接完成身份设置,跳过重复授权 // 直接完成身份设置,跳过重复授权
const currentUserType = this.data.pendingUserType || this.data.currentUserType || 'buyer' const currentUserType = this.data.pendingUserType || this.data.currentUserType || 'buyer'
this.finishSetUserType(currentUserType) this.finishSetUserType(currentUserType)
@ -1799,10 +1722,10 @@ Page({
try { try {
if (e.detail.errMsg === 'getPhoneNumber:ok') { if (e.detail.errMsg === 'getPhoneNumber:ok') {
// 用户同意授权,实际处理授权流程 // 用户同意授权,实际处理授权流程
console.log('用户同意授权获取手机号')
// 同时请求位置授权 // 同时请求位置授权
console.log('同时请求位置授权');
wx.authorize({ wx.authorize({
scope: 'scope.userLocation', scope: 'scope.userLocation',
success() { success() {
@ -1812,7 +1735,7 @@ Page({
success(res) { success(res) {
const latitude = res.latitude; const latitude = res.latitude;
const longitude = res.longitude; const longitude = res.longitude;
console.log('登录时获取位置成功:', { latitude, longitude });
// 存储位置信息到本地 // 存储位置信息到本地
wx.setStorageSync('userLocation', { latitude, longitude }); wx.setStorageSync('userLocation', { latitude, longitude });
// 位置获取成功提示 // 位置获取成功提示
@ -1835,7 +1758,7 @@ Page({
}, },
fail() { fail() {
// 位置授权失败,不影响登录流程 // 位置授权失败,不影响登录流程
console.log('登录时位置授权被拒绝');
// 位置授权失败提示 // 位置授权失败提示
wx.showToast({ wx.showToast({
title: '位置授权已拒绝', title: '位置授权已拒绝',
@ -1857,7 +1780,7 @@ Page({
throw new Error('获取登录code失败') throw new Error('获取登录code失败')
} }
console.log('获取登录code成功:', loginRes.code)
// 2. 使用code换取openid // 2. 使用code换取openid
const openidRes = await API.getOpenid(loginRes.code) const openidRes = await API.getOpenid(loginRes.code)
@ -1865,17 +1788,17 @@ Page({
// 改进错误处理逻辑,更宽容地处理服务器返回格式,增加详细日志 // 改进错误处理逻辑,更宽容地处理服务器返回格式,增加详细日志
let openid = null; let openid = null;
let userId = null; let userId = null;
console.log('openidRes完整响应:', JSON.stringify(openidRes));
if (openidRes && typeof openidRes === 'object') { if (openidRes && typeof openidRes === 'object') {
// 适配服务器返回格式:{success: true, code: 200, message: '获取openid成功', data: {openid, userId}} // 适配服务器返回格式:{success: true, code: 200, message: '获取openid成功', data: {openid, userId}}
if (openidRes.data && typeof openidRes.data === 'object') { if (openidRes.data && typeof openidRes.data === 'object') {
console.log('识别到标准服务器返回格式,从data字段提取信息');
openid = openidRes.data.openid || openidRes.data.OpenID || null; openid = openidRes.data.openid || openidRes.data.OpenID || null;
userId = openidRes.data.userId || null; userId = openidRes.data.userId || null;
} else { } else {
// 尝试从响应对象中直接提取openid,适配其他可能的格式 // 尝试从响应对象中直接提取openid,适配其他可能的格式
console.log('尝试从根对象直接提取openid');
openid = openidRes.openid || openidRes.OpenID || null; openid = openidRes.openid || openidRes.OpenID || null;
userId = openidRes.userId || null; userId = openidRes.userId || null;
} }
@ -1887,7 +1810,7 @@ Page({
throw new Error(`获取openid失败: 服务器返回数据格式可能不符合预期,请检查服务器配置。响应数据为: ${JSON.stringify(openidRes)}`); throw new Error(`获取openid失败: 服务器返回数据格式可能不符合预期,请检查服务器配置。响应数据为: ${JSON.stringify(openidRes)}`);
} }
console.log('获取openid成功:', openid)
// 3. 存储openid和session_key // 3. 存储openid和session_key
wx.setStorageSync('openid', openid) wx.setStorageSync('openid', openid)
@ -1902,15 +1825,15 @@ Page({
// 优先使用从服务器响应data字段中提取的userId // 优先使用从服务器响应data字段中提取的userId
if (userId) { if (userId) {
wx.setStorageSync('userId', userId) wx.setStorageSync('userId', userId)
console.log('使用从服务器data字段提取的userId:', userId)
} else if (openidRes && openidRes.userId) { } else if (openidRes && openidRes.userId) {
wx.setStorageSync('userId', openidRes.userId) wx.setStorageSync('userId', openidRes.userId)
console.log('使用服务器根对象中的userId:', openidRes.userId)
} else { } else {
// 生成临时userId // 生成临时userId
const tempUserId = 'user_' + Date.now() const tempUserId = 'user_' + Date.now()
wx.setStorageSync('userId', tempUserId) wx.setStorageSync('userId', tempUserId)
console.log('生成临时userId:', tempUserId)
} }
// 4. 上传手机号加密数据到服务器解密 // 4. 上传手机号加密数据到服务器解密
@ -1919,7 +1842,7 @@ Page({
openid: openid openid: openid
} }
console.log('准备上传手机号加密数据到服务器')
const phoneRes = await API.uploadPhoneNumberData(phoneData) const phoneRes = await API.uploadPhoneNumberData(phoneData)
// 改进手机号解密结果的处理逻辑 // 改进手机号解密结果的处理逻辑
@ -1940,11 +1863,7 @@ Page({
// 如果有手机号冲突且没有返回手机号,使用实际返回的手机号 // 如果有手机号冲突且没有返回手机号,使用实际返回的手机号
const finalPhoneNumber = phoneNumber const finalPhoneNumber = phoneNumber
console.log('手机号解密结果:', {
phoneNumber: finalPhoneNumber,
hasPhoneConflict: hasPhoneConflict,
isNewPhone: isNewPhone
})
// 5. 获取用户微信名称和头像 // 5. 获取用户微信名称和头像
let userProfile = null; let userProfile = null;
@ -1956,7 +1875,7 @@ Page({
fail: reject fail: reject
}); });
}); });
console.log('获取用户信息成功:', userProfile);
} catch (err) { } catch (err) {
console.warn('获取用户信息失败:', err); console.warn('获取用户信息失败:', err);
// 如果获取失败,使用默认值 // 如果获取失败,使用默认值
@ -1990,7 +1909,7 @@ Page({
} }
// 保存用户信息并等待上传完成 // 保存用户信息并等待上传完成
console.log('开始保存用户信息并上传到服务器...')
const uploadResult = await this.saveUserInfo(tempUserInfo, currentUserType) const uploadResult = await this.saveUserInfo(tempUserInfo, currentUserType)
console.log('用户信息保存并上传完成') console.log('用户信息保存并上传完成')
@ -2074,14 +1993,13 @@ Page({
try { try {
// 1. 模拟微信登录,生成测试用的code // 1. 模拟微信登录,生成测试用的code
const mockCode = 'test_code_' + Date.now() const mockCode = 'test_code_' + Date.now()
console.log('模拟获取登录code:', mockCode)
// 2. 模拟获取openid和userId // 2. 模拟获取openid和userId
const mockOpenid = 'test_openid_' + Date.now() const mockOpenid = 'test_openid_' + Date.now()
const mockUserId = 'test_user_' + Date.now() const mockUserId = 'test_user_' + Date.now()
console.log('模拟获取openid:', mockOpenid)
console.log('模拟获取userId:', mockUserId)
// 3. 存储测试数据 // 3. 存储测试数据
wx.setStorageSync('openid', mockOpenid) wx.setStorageSync('openid', mockOpenid)
@ -2089,7 +2007,7 @@ Page({
// 4. 模拟手机号解密结果 // 4. 模拟手机号解密结果
const mockPhoneNumber = null const mockPhoneNumber = null
console.log('模拟手机号解密成功:', mockPhoneNumber)
// 5. 创建模拟用户信息 // 5. 创建模拟用户信息
const mockUserInfo = { const mockUserInfo = {
@ -2117,10 +2035,10 @@ Page({
} }
// 8. 保存用户信息并等待上传完成 // 8. 保存用户信息并等待上传完成
console.log('测试模式开始保存用户信息...')
// 在测试模式下也会上传用户信息到服务器,用于连通性测试 // 在测试模式下也会上传用户信息到服务器,用于连通性测试
await this.saveUserInfo(mockUserInfo, currentUserType) await this.saveUserInfo(mockUserInfo, currentUserType)
console.log('测试模式用户信息保存完成')
wx.hideLoading() wx.hideLoading()
@ -2377,7 +2295,7 @@ Page({
// 确保存储操作成功 // 确保存储操作成功
try { try {
wx.setStorageSync('users', users) wx.setStorageSync('users', users)
console.log('用户信息已成功保存到本地存储')
} catch (e) { } catch (e) {
console.error('保存用户信息到本地存储失败:', e) console.error('保存用户信息到本地存储失败:', e)
} }
@ -2386,19 +2304,19 @@ Page({
const app = getApp() const app = getApp()
app.globalData.userInfo = userInfo app.globalData.userInfo = userInfo
app.globalData.userType = type app.globalData.userType = type
console.log('用户信息已保存到全局变量:', userInfo)
// 额外保存一份单独的userInfo到本地存储,便于checkPhoneAuthSetting方法检查 // 额外保存一份单独的userInfo到本地存储,便于checkPhoneAuthSetting方法检查
try { try {
wx.setStorageSync('userInfo', userInfo) wx.setStorageSync('userInfo', userInfo)
console.log('单独的userInfo已保存')
} catch (e) { } catch (e) {
console.error('保存单独的userInfo失败:', e) console.error('保存单独的userInfo失败:', e)
} }
// 上传用户信息到服务器 // 上传用户信息到服务器
// 在测试模式下也上传用户信息,用于连通性测试 // 在测试模式下也上传用户信息,用于连通性测试
console.log('准备上传用户信息到服务器进行测试...')
// 确保测试数据包含服务器所需的所有字段 // 确保测试数据包含服务器所需的所有字段
const completeUserInfo = { const completeUserInfo = {
@ -2838,7 +2756,7 @@ Page({
} }
// 7. 保存用户信息并等待上传完成 // 7. 保存用户信息并等待上传完成
console.log('开始保存用户信息并上传到服务器...')
await this.uploadUserInfoToServer(userInfo, userId, currentUserType) await this.uploadUserInfoToServer(userInfo, userId, currentUserType)
console.log('用户信息保存并上传完成') console.log('用户信息保存并上传完成')

Loading…
Cancel
Save