|
|
@@ -77,6 +77,10 @@ Component({
|
|
|
* 点击"立即开始探索"按钮
|
|
|
*/
|
|
|
onStart() {
|
|
|
+ console.log('===========================================');
|
|
|
+ console.log('🚀 调用了 onStart 方法(立即开始探索)');
|
|
|
+ console.log('===========================================');
|
|
|
+
|
|
|
// 标记已访问
|
|
|
wx.setStorageSync('hasVisitedWelcome', true);
|
|
|
|
|
|
@@ -167,7 +171,7 @@ Component({
|
|
|
async getStoreId() {
|
|
|
try {
|
|
|
console.log('🏪 开始获取店铺 ID...');
|
|
|
- const defaultStoreId = 'Zr65KGWXHx';
|
|
|
+ const defaultStoreId = 'pkPdAnLAUZ'; // 超级门店ID
|
|
|
const configuredStoreId =
|
|
|
wx.getStorageSync('storeId') ||
|
|
|
getApp().globalData.storeId ||
|
|
|
@@ -185,7 +189,7 @@ Component({
|
|
|
*/
|
|
|
async getStoreInfo() {
|
|
|
try {
|
|
|
- const defaultStoreId = 'Zr65KGWXHx';
|
|
|
+ const defaultStoreId = 'pkPdAnLAUZ'; // 超级门店ID
|
|
|
const effectiveStoreId =
|
|
|
wx.getStorageSync('storeId') ||
|
|
|
getApp().globalData.storeId ||
|
|
|
@@ -205,7 +209,7 @@ Component({
|
|
|
}
|
|
|
} catch (e) {
|
|
|
console.error('获取店铺信息失败:', e);
|
|
|
- return { id: wx.getStorageSync('storeId') || 'Zr65KGWXHx', name: '' };
|
|
|
+ return { id: wx.getStorageSync('storeId') || 'pkPdAnLAUZ', name: '' };
|
|
|
}
|
|
|
},
|
|
|
|
|
|
@@ -213,28 +217,22 @@ Component({
|
|
|
* 跳转到 H5 主页
|
|
|
*/
|
|
|
async navigateToHome() {
|
|
|
+ console.log('===========================================');
|
|
|
+ console.log('======= navigateToHome 被调用 =======');
|
|
|
+ console.log('===========================================');
|
|
|
+
|
|
|
const currentUser = Parse.User.current();
|
|
|
let userInfo = wx.getStorageSync("userLogin");
|
|
|
|
|
|
- // 如果用户未登录,显示提示让用户选择
|
|
|
+ console.log('当前用户:', currentUser ? '已登录' : '未登录');
|
|
|
+ console.log('userInfo:', userInfo);
|
|
|
+
|
|
|
+ // 如果用户未登录,直接进入游客模式(简化流程)
|
|
|
if (!currentUser || userInfo == '') {
|
|
|
- console.log('⚠️ 用户未登录,显示登录提示');
|
|
|
+ console.log('⚠️ 用户未登录,直接进入游客模式');
|
|
|
|
|
|
- wx.showModal({
|
|
|
- title: '温馨提示',
|
|
|
- content: '登录后可以体验更多功能,是否立即登录?',
|
|
|
- confirmText: '立即登录',
|
|
|
- cancelText: '先随便看看',
|
|
|
- success: (res) => {
|
|
|
- if (res.confirm) {
|
|
|
- // 用户选择登录
|
|
|
- login.loginNow();
|
|
|
- } else {
|
|
|
- // 用户选择稍后登录,跳转到游客模式
|
|
|
- this.navigateToHomeAsGuest();
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
+ // 直接进入游客模式,不显示提示框
|
|
|
+ this.navigateToHomeAsGuest();
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
@@ -346,31 +344,49 @@ Component({
|
|
|
// 标记为游客模式
|
|
|
wx.setStorageSync('isGuestMode', true);
|
|
|
|
|
|
+ // ✅ 游客默认使用超级门店ID,确保有数据
|
|
|
+ const superStoreId = 'pkPdAnLAUZ'; // 超级门店ID
|
|
|
+
|
|
|
+ // 设置超级门店ID到存储
|
|
|
+ wx.setStorageSync('storeId', superStoreId);
|
|
|
+ getApp().globalData.storeId = superStoreId;
|
|
|
+
|
|
|
+ console.log('✅ 游客使用超级门店ID:', superStoreId);
|
|
|
+
|
|
|
// 获取店铺信息
|
|
|
const store = await this.getStoreInfo();
|
|
|
- const storeId = store && store.id ? store.id : null;
|
|
|
- const storeName = store && store.name ? store.name : '';
|
|
|
+ const storeId = store && store.id ? store.id : superStoreId;
|
|
|
+ const storeName = store && store.name ? store.name : '超级门店';
|
|
|
+
|
|
|
+ console.log('✅ 店铺信息:', { id: storeId, name: storeName });
|
|
|
|
|
|
// 构建 H5 URL(游客模式,不传 token)
|
|
|
let h5Url = `https://app.fmode.cn/dev/pobingfeng/owner/nav/home?`;
|
|
|
|
|
|
- if (storeId) {
|
|
|
- h5Url += `storeId=${storeId}&`;
|
|
|
- }
|
|
|
+ h5Url += `storeId=${storeId}&`;
|
|
|
|
|
|
// 添加游客模式标识
|
|
|
h5Url += `guestMode=true`;
|
|
|
|
|
|
console.log('🌐 游客模式 H5 URL:', h5Url);
|
|
|
+ console.log('');
|
|
|
+ console.log('⚠️⚠️⚠️ 重要提示 ⚠️⚠️⚠️');
|
|
|
+ console.log('如果H5页面显示的不是超级门店,说明H5端没有正确使用URL中的storeId参数!');
|
|
|
+ console.log('H5端需要确保:');
|
|
|
+ console.log('1. 从URL中读取 storeId 参数');
|
|
|
+ console.log('2. 优先使用URL传递的 storeId,不要被其他逻辑覆盖');
|
|
|
+ console.log('3. 不要使用localStorage缓存的旧门店ID');
|
|
|
+ console.log('');
|
|
|
+ console.log('请复制以下URL在浏览器中测试:');
|
|
|
+ console.log(h5Url);
|
|
|
+ console.log('===========================================');
|
|
|
|
|
|
// 编码后的 URL
|
|
|
const encodedUrl = encodeURIComponent(h5Url);
|
|
|
|
|
|
// 跳转
|
|
|
let webViewPath = `/common-page/pages/web-view/index?path=${encodedUrl}`;
|
|
|
- if (storeId) {
|
|
|
- webViewPath += `&storeId=${storeId}`;
|
|
|
- }
|
|
|
+ webViewPath += `&storeId=${storeId}`;
|
|
|
if (storeName) {
|
|
|
webViewPath += `&storeName=${encodeURIComponent(storeName)}`;
|
|
|
}
|
|
|
@@ -413,7 +429,20 @@ Component({
|
|
|
* 跳转到案例展示页面
|
|
|
*/
|
|
|
async navigateToCases() {
|
|
|
- await this.navigateToH5Page('owner/nav/cases');
|
|
|
+ console.log('===========================================');
|
|
|
+ console.log('🏠 调用了 navigateToCases 方法(案例展示)');
|
|
|
+ console.log('===========================================');
|
|
|
+
|
|
|
+ // 案例展示允许游客访问,直接跳转
|
|
|
+ const currentUser = Parse.User.current();
|
|
|
+
|
|
|
+ if (!currentUser) {
|
|
|
+ console.log('游客访问案例展示');
|
|
|
+ wx.setStorageSync('isGuestMode', true);
|
|
|
+ await this.navigateToH5PageAsGuest('owner/nav/cases');
|
|
|
+ } else {
|
|
|
+ await this.navigateToH5Page('owner/nav/cases');
|
|
|
+ }
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
@@ -421,14 +450,62 @@ Component({
|
|
|
* @param {string} productId - 可选的产品ID,用于直接跳转到特定产品详情
|
|
|
*/
|
|
|
async navigateToProducts(productId = null) {
|
|
|
+ console.log('===========================================');
|
|
|
+ console.log('📦 调用了 navigateToProducts 方法(产品中心)');
|
|
|
+ console.log('===========================================');
|
|
|
+
|
|
|
+ // 产品中心允许游客访问,直接跳转
|
|
|
+ const currentUser = Parse.User.current();
|
|
|
const params = productId ? { productId } : {};
|
|
|
- await this.navigateToH5Page('owner/nav/products', params);
|
|
|
+
|
|
|
+ if (!currentUser) {
|
|
|
+ console.log('游客访问产品中心');
|
|
|
+ wx.setStorageSync('isGuestMode', true);
|
|
|
+ await this.navigateToH5PageAsGuest('owner/nav/products', params);
|
|
|
+ } else {
|
|
|
+ await this.navigateToH5Page('owner/nav/products', params);
|
|
|
+ }
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 跳转到方案定制/AI推荐页面
|
|
|
*/
|
|
|
async navigateToConsultation() {
|
|
|
+ console.log('===========================================');
|
|
|
+ console.log('======= 点击咨询/方案定制 =======');
|
|
|
+ console.log('===========================================');
|
|
|
+
|
|
|
+ // 方案定制需要登录
|
|
|
+ const currentUser = Parse.User.current();
|
|
|
+ const isGuestMode = wx.getStorageSync('isGuestMode');
|
|
|
+
|
|
|
+ console.log('当前用户:', currentUser ? '已登录' : '未登录');
|
|
|
+ console.log('游客模式:', isGuestMode);
|
|
|
+
|
|
|
+ if (!currentUser || isGuestMode) {
|
|
|
+ console.log('⚠️ 游客尝试访问咨询功能,显示登录提示');
|
|
|
+
|
|
|
+ wx.showModal({
|
|
|
+ title: '需要登录',
|
|
|
+ content: '方案定制和咨询功能需要登录后使用,是否立即登录?',
|
|
|
+ confirmText: '立即登录',
|
|
|
+ cancelText: '取消',
|
|
|
+ success: (res) => {
|
|
|
+ if (res.confirm) {
|
|
|
+ console.log('用户选择:立即登录');
|
|
|
+ login.loginNow();
|
|
|
+ } else {
|
|
|
+ console.log('用户选择:取消');
|
|
|
+ // 用户取消,不做任何操作
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ // ✅ 重要:直接返回,不继续执行后面的跳转
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ console.log('✅ 用户已登录,跳转到咨询页面');
|
|
|
await this.navigateToH5Page('owner/nav/consultation');
|
|
|
},
|
|
|
|
|
|
@@ -448,6 +525,16 @@ Component({
|
|
|
// 检查是否是游客模式
|
|
|
const isGuestMode = wx.getStorageSync('isGuestMode');
|
|
|
|
|
|
+ // 定义允许游客访问的页面
|
|
|
+ const guestAllowedPages = [
|
|
|
+ 'owner/nav/home', // 首页
|
|
|
+ 'owner/nav/products', // 产品中心
|
|
|
+ 'owner/nav/cases' // 案例展示
|
|
|
+ ];
|
|
|
+
|
|
|
+ // 检查当前页面是否允许游客访问
|
|
|
+ const isGuestAllowed = guestAllowedPages.some(page => pagePath.includes(page));
|
|
|
+
|
|
|
if ((!currentUser || userInfo == '') && !isGuestMode) {
|
|
|
// 未登录且不是游客模式,提示用户
|
|
|
wx.showModal({
|
|
|
@@ -460,17 +547,43 @@ Component({
|
|
|
// 用户选择登录
|
|
|
login.loginNow();
|
|
|
} else {
|
|
|
- // 用户选择游客模式,继续访问
|
|
|
- wx.setStorageSync('isGuestMode', true);
|
|
|
- this.navigateToH5PageAsGuest(pagePath, extraParams);
|
|
|
+ // 用户选择游客模式
|
|
|
+ if (isGuestAllowed) {
|
|
|
+ // 如果是允许游客访问的页面,继续访问
|
|
|
+ wx.setStorageSync('isGuestMode', true);
|
|
|
+ this.navigateToH5PageAsGuest(pagePath, extraParams);
|
|
|
+ } else {
|
|
|
+ // 如果不允许游客访问,提示需要登录
|
|
|
+ wx.showToast({
|
|
|
+ title: '此功能需要登录',
|
|
|
+ icon: 'none'
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- // 如果是游客模式,使用游客访问
|
|
|
+ // 如果是游客模式,检查是否允许访问
|
|
|
if (isGuestMode || !currentUser) {
|
|
|
+ if (!isGuestAllowed) {
|
|
|
+ // 游客不允许访问此页面
|
|
|
+ wx.showModal({
|
|
|
+ title: '需要登录',
|
|
|
+ content: '此功能需要登录后使用,是否立即登录?',
|
|
|
+ confirmText: '立即登录',
|
|
|
+ cancelText: '取消',
|
|
|
+ success: (res) => {
|
|
|
+ if (res.confirm) {
|
|
|
+ login.loginNow();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 游客访问允许的页面
|
|
|
this.navigateToH5PageAsGuest(pagePath, extraParams);
|
|
|
return;
|
|
|
}
|
|
|
@@ -587,17 +700,26 @@ Component({
|
|
|
console.log(`======= 游客模式跳转 H5: ${pagePath} =======`);
|
|
|
console.log('===========================================');
|
|
|
|
|
|
+ // ✅ 游客默认使用超级门店ID,确保有数据
|
|
|
+ const superStoreId = 'pkPdAnLAUZ'; // 超级门店ID
|
|
|
+
|
|
|
+ // 确保使用超级门店ID
|
|
|
+ wx.setStorageSync('storeId', superStoreId);
|
|
|
+ getApp().globalData.storeId = superStoreId;
|
|
|
+
|
|
|
+ console.log('✅ 游客使用超级门店ID:', superStoreId);
|
|
|
+
|
|
|
// 获取店铺信息
|
|
|
const store = await this.getStoreInfo();
|
|
|
- const storeId = store && store.id ? store.id : null;
|
|
|
- const storeName = store && store.name ? store.name : '';
|
|
|
+ const storeId = store && store.id ? store.id : superStoreId;
|
|
|
+ const storeName = store && store.name ? store.name : '超级门店';
|
|
|
+
|
|
|
+ console.log('✅ 店铺信息:', { id: storeId, name: storeName });
|
|
|
|
|
|
// 构建 H5 URL(游客模式,不传 token)
|
|
|
let h5Url = `https://app.fmode.cn/dev/pobingfeng/${pagePath}?`;
|
|
|
|
|
|
- if (storeId) {
|
|
|
- h5Url += `storeId=${storeId}&`;
|
|
|
- }
|
|
|
+ h5Url += `storeId=${storeId}&`;
|
|
|
|
|
|
// 添加游客模式标识
|
|
|
h5Url += `guestMode=true`;
|
|
|
@@ -613,15 +735,16 @@ Component({
|
|
|
}
|
|
|
|
|
|
console.log('🌐 游客模式 H5 URL:', h5Url);
|
|
|
+ console.log('');
|
|
|
+ console.log('⚠️ 如果H5显示的不是超级门店,请检查H5端是否正确读取了URL中的storeId参数');
|
|
|
+ console.log('');
|
|
|
|
|
|
// 编码后的 URL
|
|
|
const encodedUrl = encodeURIComponent(h5Url);
|
|
|
|
|
|
// 最终的小程序页面路径
|
|
|
let webViewPath = `/common-page/pages/web-view/index?path=${encodedUrl}`;
|
|
|
- if (storeId) {
|
|
|
- webViewPath += `&storeId=${storeId}`;
|
|
|
- }
|
|
|
+ webViewPath += `&storeId=${storeId}`;
|
|
|
if (storeName) {
|
|
|
webViewPath += `&storeName=${encodeURIComponent(storeName)}`;
|
|
|
}
|