| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141 |
- 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()
- try {
- let finalStoreId = options && options.storeId ? options.storeId : '';
- // 支持从 scene 读取(小程序码 getwxacodeunlimit 传参)
- if (!finalStoreId && options && options.scene) {
- const sceneStr = decodeURIComponent(options.scene);
- console.log('🎯 scene 参数:', sceneStr);
- if (sceneStr) {
- const pairs = sceneStr.split('&');
- for (const p of pairs) {
- const [k, v] = p.split('=');
- if (k === 'storeId' && v) {
- finalStoreId = v;
- break;
- }
- }
- }
- }
- if (finalStoreId) {
- wx.setStorageSync('storeId', finalStoreId);
- getApp().globalData.storeId = finalStoreId;
- console.log('✅ 已设置店铺 ID:', finalStoreId);
- } else {
- console.log('ℹ️ 未传入店铺 ID,继续使用默认值');
- }
- } catch (e) {
- console.error('设置店铺 ID 失败:', e);
- }
- // ✅ 立即加载并设置店铺名称作为页面标题
- 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 {
- // 计算当前有效的店铺 ID
- const defaultStoreId = 'Zr65KGWXHx';
- const effectiveStoreId = wx.getStorageSync('storeId') || getApp().globalData.storeId || defaultStoreId;
-
- // 查询指定的店铺
- const storeQuery = new Parse.Query('ShopStore');
- storeQuery.equalTo('objectId', effectiveStoreId);
- const store = await storeQuery.first();
-
- if (store) {
- const storeName = store.get('storeName');
-
- if (storeName) {
- // ✅ 立即同步设置导航栏标题
- wx.setNavigationBarTitle({
- title: storeName,
- success: () => {},
- fail: (err) => {
- console.error('❌❌❌ 引导页标题设置失败:', err);
- }
- });
- }
- }
- } catch (error) {
- console.error('❌ 加载店铺信息失败:', error);
- }
- }
- })
|