|
@@ -169,14 +169,19 @@ Page({
|
|
|
currentTitle: title
|
|
currentTitle: title
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
- // 调用微信 API 设置标题
|
|
|
|
|
- wx.setNavigationBarTitle({
|
|
|
|
|
- title: title,
|
|
|
|
|
- success: () => {},
|
|
|
|
|
- fail: (err) => {
|
|
|
|
|
- console.error('❌ 标题设置失败:', err);
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ // 延迟调用微信 API 设置标题,确保页面已准备好
|
|
|
|
|
+ setTimeout(() => {
|
|
|
|
|
+ wx.setNavigationBarTitle({
|
|
|
|
|
+ title: title,
|
|
|
|
|
+ success: () => {
|
|
|
|
|
+ console.log('✅ web-view 标题设置成功:', title);
|
|
|
|
|
+ },
|
|
|
|
|
+ fail: (err) => {
|
|
|
|
|
+ console.warn('⚠️ web-view 标题设置失败(可忽略):', err.errMsg);
|
|
|
|
|
+ // 不影响主流程,静默失败
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }, 100);
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
startTitlePolling: function () {
|
|
startTitlePolling: function () {
|
|
@@ -195,29 +200,46 @@ Page({
|
|
|
*/
|
|
*/
|
|
|
loadAndSetStoreTitle: async function (storeId = '', storeName = '') {
|
|
loadAndSetStoreTitle: async function (storeId = '', storeName = '') {
|
|
|
try {
|
|
try {
|
|
|
- let finalName = storeName;
|
|
|
|
|
|
|
+ let finalTitle = storeName;
|
|
|
|
|
|
|
|
- if (!finalName) {
|
|
|
|
|
|
|
+ if (!finalTitle) {
|
|
|
// 如果没有传入名字,按传入的 storeId 精确查询;再不行按 company 兜底
|
|
// 如果没有传入名字,按传入的 storeId 精确查询;再不行按 company 兜底
|
|
|
if (storeId) {
|
|
if (storeId) {
|
|
|
const q = new Parse.Query('ShopStore');
|
|
const q = new Parse.Query('ShopStore');
|
|
|
const s = await q.get(storeId);
|
|
const s = await q.get(storeId);
|
|
|
- if (s) finalName = s.get('storeName') || '';
|
|
|
|
|
|
|
+ if (s) {
|
|
|
|
|
+ // 优先使用门店地址,如果没有地址则使用门店名称
|
|
|
|
|
+ const address = s.get('address');
|
|
|
|
|
+ const name = s.get('storeName');
|
|
|
|
|
+ finalTitle = address || name || '';
|
|
|
|
|
+
|
|
|
|
|
+ console.log('📍 web-view 门店信息:', {
|
|
|
|
|
+ id: storeId,
|
|
|
|
|
+ name: name,
|
|
|
|
|
+ address: address,
|
|
|
|
|
+ displayTitle: finalTitle
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
- if (!finalName) {
|
|
|
|
|
|
|
+ if (!finalTitle) {
|
|
|
const storeQuery = new Parse.Query('ShopStore');
|
|
const storeQuery = new Parse.Query('ShopStore');
|
|
|
storeQuery.equalTo('company', company);
|
|
storeQuery.equalTo('company', company);
|
|
|
storeQuery.ascending('score');
|
|
storeQuery.ascending('score');
|
|
|
storeQuery.limit(1);
|
|
storeQuery.limit(1);
|
|
|
const store = await storeQuery.first();
|
|
const store = await storeQuery.first();
|
|
|
- if (store) finalName = store.get('storeName') || '';
|
|
|
|
|
|
|
+ if (store) {
|
|
|
|
|
+ // 优先使用门店地址,如果没有地址则使用门店名称
|
|
|
|
|
+ const address = store.get('address');
|
|
|
|
|
+ const name = store.get('storeName');
|
|
|
|
|
+ finalTitle = address || name || '';
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if (!finalName) return;
|
|
|
|
|
|
|
+ if (!finalTitle) return;
|
|
|
|
|
|
|
|
// 使用统一的设置标题方法
|
|
// 使用统一的设置标题方法
|
|
|
- this.setNavigationTitle(finalName);
|
|
|
|
|
|
|
+ this.setNavigationTitle(finalTitle);
|
|
|
} catch (e) {
|
|
} catch (e) {
|
|
|
console.error('设置 web-view 标题失败:', e);
|
|
console.error('设置 web-view 标题失败:', e);
|
|
|
}
|
|
}
|