|
|
@@ -458,11 +458,12 @@ Page({
|
|
|
* 支持所有类型的二维码:
|
|
|
* 1. 推广员二维码: ?scanCount=0&storeId=xxx&userId=xxx
|
|
|
* 2. 产品二维码: ?scanCount=0&storeId=xxx&productId=xxx
|
|
|
- * 3. 活动海报二维码: activityId作为qrCode参数值
|
|
|
- * 4. 异业合作伙伴二维码(移动端 / PC端统一): ?scanCount=xxx&storeId=xxx&partnerId=xxx
|
|
|
- * 5. 员工邀请二维码(移动端): ?scanCount=0&storeId=xxx&employeeId=xxx
|
|
|
- * 6. 我的二维码(老板): ?scanCount=0&storeId=xxx&ownerId=xxx
|
|
|
- * 7. 我的二维码(员工): ?scanCount=0&storeId=xxx&employeeId=xxx
|
|
|
+ * 3. 案例二维码: ?scanCount=0&storeId=xxx&caseId=xxx
|
|
|
+ * 4. 活动海报二维码: activityId作为qrCode参数值
|
|
|
+ * 5. 异业合作伙伴二维码(移动端 / PC端统一): ?scanCount=xxx&storeId=xxx&partnerId=xxx
|
|
|
+ * 6. 员工邀请二维码(移动端): ?scanCount=0&storeId=xxx&employeeId=xxx
|
|
|
+ * 7. 我的二维码(老板): ?scanCount=0&storeId=xxx&ownerId=xxx
|
|
|
+ * 8. 我的二维码(员工): ?scanCount=0&storeId=xxx&employeeId=xxx
|
|
|
*/
|
|
|
checkAndHandleScan(options) {
|
|
|
const {
|
|
|
@@ -472,6 +473,7 @@ Page({
|
|
|
partnerId,
|
|
|
storeId,
|
|
|
productId,
|
|
|
+ caseId,
|
|
|
userId, // 推广员二维码使用userId
|
|
|
activityId
|
|
|
} = options;
|
|
|
@@ -530,6 +532,10 @@ Page({
|
|
|
console.log('产品ID (productId):', productId);
|
|
|
}
|
|
|
|
|
|
+ if (caseId) {
|
|
|
+ console.log('案例ID (caseId):', caseId);
|
|
|
+ }
|
|
|
+
|
|
|
console.log('===========================================');
|
|
|
|
|
|
// 保存到临时存储,用于后续跳转和统计
|
|
|
@@ -544,6 +550,9 @@ Page({
|
|
|
if (productId) {
|
|
|
wx.setStorageSync('scan_productId', productId);
|
|
|
}
|
|
|
+ if (caseId) {
|
|
|
+ wx.setStorageSync('scan_caseId', caseId);
|
|
|
+ }
|
|
|
wx.setStorageSync('need_scan_redirect', true);
|
|
|
} else if (partnerId) {
|
|
|
// 理论上异业二维码现在也必须带 storeId,这里仅作为兜底保护
|
|
|
@@ -574,6 +583,7 @@ Page({
|
|
|
const partnerId = wx.getStorageSync('scan_partnerId');
|
|
|
const userId = wx.getStorageSync('scan_userId');
|
|
|
const productId = wx.getStorageSync('scan_productId');
|
|
|
+ const caseId = wx.getStorageSync('scan_caseId');
|
|
|
|
|
|
// 清除临时存储
|
|
|
wx.removeStorageSync('scan_storeId');
|
|
|
@@ -585,6 +595,7 @@ Page({
|
|
|
wx.removeStorageSync('scan_partnerId');
|
|
|
wx.removeStorageSync('scan_userId');
|
|
|
wx.removeStorageSync('scan_productId');
|
|
|
+ wx.removeStorageSync('scan_caseId');
|
|
|
wx.removeStorageSync('need_scan_redirect');
|
|
|
|
|
|
if (!storeId) {
|
|
|
@@ -603,6 +614,7 @@ Page({
|
|
|
if (partnerId) console.log('合作伙伴 ID (partnerId):', partnerId);
|
|
|
if (userId) console.log('推广员 ID (userId):', userId);
|
|
|
if (productId) console.log('产品 ID (productId):', productId);
|
|
|
+ if (caseId) console.log('案例 ID (caseId):', caseId);
|
|
|
console.log('===========================================');
|
|
|
|
|
|
// 设置店铺 ID 到全局和本地存储
|
|
|
@@ -657,6 +669,13 @@ Page({
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
+ // 如果有案例ID,直接跳转到案例详情的 H5 页面
|
|
|
+ if (caseId) {
|
|
|
+ console.log('🎯 检测到案例ID,跳转到案例详情页');
|
|
|
+ await this.redirectToCaseDetail(storeId, caseId, partnerId);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
// 获取默认首页路径并跳转
|
|
|
let url = getApp().globalData.rootPage || getApp().globalData.defaultTabBar.list[0].pagePath;
|
|
|
url += `?storeId=${storeId}`;
|
|
|
@@ -805,6 +824,73 @@ Page({
|
|
|
}
|
|
|
},
|
|
|
|
|
|
+ /**
|
|
|
+ * 跳转到案例详情的 H5 页面
|
|
|
+ * @param {string} storeId - 店铺 ID
|
|
|
+ * @param {string} caseId - 案例 ID
|
|
|
+ * @param {string} partnerId - 可选的合作伙伴 ID
|
|
|
+ */
|
|
|
+ async redirectToCaseDetail(storeId, caseId, partnerId = null) {
|
|
|
+ try {
|
|
|
+ console.log('===========================================');
|
|
|
+ console.log('======= 跳转到案例详情页 =======');
|
|
|
+ console.log('店铺 ID:', storeId);
|
|
|
+ console.log('案例 ID:', caseId);
|
|
|
+ if (partnerId) console.log('合作伙伴 ID:', partnerId);
|
|
|
+ console.log('===========================================');
|
|
|
+
|
|
|
+ const currentUser = Parse.User.current();
|
|
|
+ if (!currentUser) {
|
|
|
+ console.error('❌ 用户未登录,无法跳转');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ const token = currentUser.getSessionToken();
|
|
|
+ if (!token) {
|
|
|
+ console.error('❌ 无法获取 Session Token');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 构建案例详情的 H5 URL
|
|
|
+ let h5Url = `https://app.fmode.cn/dev/pobingfeng/owner/nav/cases?storeId=${storeId}&token=${token}&caseId=${encodeURIComponent(caseId)}`;
|
|
|
+
|
|
|
+ // 如果有合作伙伴ID,也添加到URL中
|
|
|
+ if (partnerId) {
|
|
|
+ h5Url += `&partnerId=${partnerId}`;
|
|
|
+ }
|
|
|
+
|
|
|
+ console.log('🌐 H5 URL:', h5Url);
|
|
|
+
|
|
|
+ // 编码 URL
|
|
|
+ const encodedUrl = encodeURIComponent(h5Url);
|
|
|
+
|
|
|
+ // 构建 web-view 页面路径
|
|
|
+ let webViewPath = `/common-page/pages/web-view/index?path=${encodedUrl}&storeId=${storeId}`;
|
|
|
+
|
|
|
+ console.log('📄 web-view 页面路径:', webViewPath.substring(0, 100) + '...');
|
|
|
+ console.log('===========================================');
|
|
|
+
|
|
|
+ wx.redirectTo({
|
|
|
+ url: webViewPath,
|
|
|
+ success: () => {
|
|
|
+ console.log('✅ 跳转到案例详情页成功');
|
|
|
+ },
|
|
|
+ fail: (err) => {
|
|
|
+ console.error('❌ 跳转失败:', err);
|
|
|
+ // 如果 redirectTo 失败,尝试 reLaunch
|
|
|
+ wx.reLaunch({
|
|
|
+ url: webViewPath,
|
|
|
+ fail: (err2) => {
|
|
|
+ console.error('❌ reLaunch 也失败:', err2);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } catch (error) {
|
|
|
+ console.error('❌ 跳转到案例详情页失败:', error);
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
/**
|
|
|
* 记录扫码统计信息
|
|
|
* @param {Object} params - 扫码参数对象
|