const Parse = getApp().Parse; const company = getApp().globalData.company; const getTabs = require("../../../utils/getTabs") const login = require("../../../utils/login"); const dateF = require("../../../utils/date") Page({ /** * 页面的初始数据 */ data: { }, /** * 生命周期函数--监听页面加载 */ onLoad: async function (options) { // login.loginNow() // ✅ 立即加载并设置店铺名称作为页面标题 await this.loadAndSetStoreTitle() }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { console.log('📌 引导页 onReady'); }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { wx.reLaunch({ url: '/index', }); }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { let uid = Parse.User.current().id return { title: '分享', // path: `index?invite=${uid}`, path: `index`, imageUrl: '', } }, /** * 加载店铺信息并设置页面标题 */ loadAndSetStoreTitle: async function () { try { console.log('==========================================='); console.log('======= 引导页:开始设置页面标题 ======='); console.log('==========================================='); // 查询 ShopStore 表,获取第一个店铺 const storeQuery = new Parse.Query('ShopStore'); storeQuery.equalTo('company', company); storeQuery.ascending('score'); storeQuery.limit(1); console.log('🔍 正在查询 ShopStore 表...'); const store = await storeQuery.first(); if (store) { const storeName = store.get('storeName'); console.log('🏪 查询到店铺信息:', { storeId: store.id, storeName: storeName }); if (storeName) { // ✅ 立即同步设置导航栏标题 console.log('🎯 立即设置标题为:', storeName); wx.setNavigationBarTitle({ title: storeName, success: () => { console.log('✅✅✅ 引导页标题设置成功:', storeName); console.log('==========================================='); }, fail: (err) => { console.error('❌❌❌ 引导页标题设置失败:', err); console.log('==========================================='); } }); } else { console.warn('⚠️ 店铺信息中没有 storeName 字段'); console.log('📋 店铺所有字段:', store.attributes); console.log('==========================================='); } } else { console.warn('⚠️ 未找到店铺信息'); console.log('💡 请检查:'); console.log(' 1. ShopStore 表是否有数据'); console.log(' 2. company 是否正确:', company); console.log('==========================================='); } } catch (error) { console.error('❌ 加载店铺信息失败:', error); console.log('==========================================='); } } })