|
|
@@ -687,6 +687,7 @@
|
|
|
</div>
|
|
|
|
|
|
<script src="https://res.wx.qq.com/open/js/jweixin-1.6.0.js"></script>
|
|
|
+ <script src="lifeAiFetch.js"></script>
|
|
|
<script>
|
|
|
(function () {
|
|
|
'use strict';
|
|
|
@@ -710,14 +711,14 @@
|
|
|
|
|
|
/**
|
|
|
* 暂无承载数据时更多推荐:POST …/ai/multimodal-services/api/v1/search/global/store-recommend
|
|
|
- * 与 shareIndex.html / shareCheckInUndefined.html 一致。
|
|
|
+ * HTTPS 页(尤其 iOS 微信)须走同源 alienStore;见 lifeAiFetch.js。可用 URL 参数 lifeAiBase 覆盖。
|
|
|
*/
|
|
|
- var API_LIFE_AI_BASE = 'http://183.252.196.135:9100';
|
|
|
var STORE_GLOBAL_RECOMMEND_PATH =
|
|
|
'/ai/multimodal-services/api/v1/search/global/store-recommend';
|
|
|
var DEFAULT_REC_USER_LAT = 38.925747;
|
|
|
var DEFAULT_REC_USER_LNG = 121.662531;
|
|
|
var DEFAULT_REC_USER_CITY = '大连市';
|
|
|
+ var cachedRecommendStoreId = '';
|
|
|
|
|
|
var COMMENT_PAGE_NUM = 1;
|
|
|
var COMMENT_PAGE_SIZE = 20;
|
|
|
@@ -1897,6 +1898,15 @@
|
|
|
/**
|
|
|
* getDeleteFlagById 要求 query 参数名为 id,值为店铺 storeId(与后端约定一致)。
|
|
|
*/
|
|
|
+ function rememberRecommendStoreIdFromGetOne(res) {
|
|
|
+ if (!res || typeof res !== 'object') return;
|
|
|
+ var d = res.data;
|
|
|
+ if (d && typeof d === 'object' && d.storeId != null) {
|
|
|
+ var sid = String(d.storeId).trim();
|
|
|
+ if (sid) cachedRecommendStoreId = sid;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
function resolveStoreIdForDeleteFlagApi() {
|
|
|
var sid =
|
|
|
getMergedParam('storeId').trim() ||
|
|
|
@@ -1917,6 +1927,9 @@
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ if (!sid && cachedRecommendStoreId) {
|
|
|
+ sid = cachedRecommendStoreId;
|
|
|
+ }
|
|
|
return sid;
|
|
|
}
|
|
|
|
|
|
@@ -1929,6 +1942,7 @@
|
|
|
var path = '/store/info/getOne?' + qs.toString();
|
|
|
return apiFetch(path)
|
|
|
.then(function (res) {
|
|
|
+ rememberRecommendStoreIdFromGetOne(res);
|
|
|
return res;
|
|
|
})
|
|
|
.catch(function (e) {
|
|
|
@@ -2012,62 +2026,51 @@
|
|
|
}
|
|
|
|
|
|
function normalizeClosedStoreRecommendList(res) {
|
|
|
- if (!res || typeof res !== 'object') return [];
|
|
|
- var raw = res.data != null ? res.data : res.result;
|
|
|
- if (Array.isArray(raw)) return raw;
|
|
|
- if (raw && typeof raw === 'object') {
|
|
|
- if (Array.isArray(raw.list)) return raw.list;
|
|
|
- if (Array.isArray(raw.records)) return raw.records;
|
|
|
- if (Array.isArray(raw.rows)) return raw.rows;
|
|
|
- if (Array.isArray(raw.content)) return raw.content;
|
|
|
- if (Array.isArray(raw.stores)) return raw.stores;
|
|
|
- if (Array.isArray(raw.storeList)) return raw.storeList;
|
|
|
- if (Array.isArray(raw.storeVos)) return raw.storeVos;
|
|
|
- if (Array.isArray(raw.items)) return raw.items;
|
|
|
- }
|
|
|
- if (Array.isArray(res.list)) return res.list;
|
|
|
- if (Array.isArray(res.records)) return res.records;
|
|
|
+ if (typeof LifeAiFetch !== 'undefined' && LifeAiFetch.extractRecommendList) {
|
|
|
+ return LifeAiFetch.extractRecommendList(res);
|
|
|
+ }
|
|
|
return [];
|
|
|
}
|
|
|
|
|
|
+ function getDynRecommendUserLocation() {
|
|
|
+ if (typeof LifeAiFetch !== 'undefined' && LifeAiFetch.getMergedRecommendUserLocation) {
|
|
|
+ return LifeAiFetch.getMergedRecommendUserLocation(getMergedParam, {
|
|
|
+ lat: DEFAULT_REC_USER_LAT,
|
|
|
+ lng: DEFAULT_REC_USER_LNG,
|
|
|
+ city: DEFAULT_REC_USER_CITY
|
|
|
+ });
|
|
|
+ }
|
|
|
+ return {
|
|
|
+ userLat: DEFAULT_REC_USER_LAT,
|
|
|
+ userLng: DEFAULT_REC_USER_LNG,
|
|
|
+ userCity: DEFAULT_REC_USER_CITY
|
|
|
+ };
|
|
|
+ }
|
|
|
+
|
|
|
function fetchShareClosedStoreRecommend(storeIdStr) {
|
|
|
- var latRaw = (q('userLat') || q('latitude') || q('lat') || q('weidu')).trim();
|
|
|
- var lngRaw = (q('userLng') || q('longitude') || q('lon') || q('jingdu')).trim();
|
|
|
- var userLat =
|
|
|
- latRaw !== '' && !isNaN(Number(latRaw)) ? Number(latRaw) : DEFAULT_REC_USER_LAT;
|
|
|
- var userLng =
|
|
|
- lngRaw !== '' && !isNaN(Number(lngRaw)) ? Number(lngRaw) : DEFAULT_REC_USER_LNG;
|
|
|
-
|
|
|
- var page = parseInt(q('page') || '1', 10);
|
|
|
- var pageSize = parseInt(q('pageSize') || '10', 10);
|
|
|
+ var loc = getDynRecommendUserLocation();
|
|
|
+ var page = parseInt(getMergedParam('page') || q('page') || '1', 10);
|
|
|
+ var pageSize = parseInt(getMergedParam('pageSize') || q('pageSize') || '10', 10);
|
|
|
if (isNaN(page) || page < 1) page = 1;
|
|
|
if (isNaN(pageSize) || pageSize < 1) pageSize = 10;
|
|
|
|
|
|
- var userCityRaw = (q('userCity') || q('city') || '').trim();
|
|
|
- var userCity = userCityRaw !== '' ? userCityRaw : DEFAULT_REC_USER_CITY;
|
|
|
-
|
|
|
var body = {
|
|
|
page: page,
|
|
|
pageSize: pageSize,
|
|
|
storeId: String(storeIdStr || ''),
|
|
|
- userCity: userCity,
|
|
|
- userLat: userLat,
|
|
|
- userLng: userLng
|
|
|
+ userCity: loc.userCity,
|
|
|
+ userLat: loc.userLat,
|
|
|
+ userLng: loc.userLng
|
|
|
};
|
|
|
|
|
|
- return fetch(API_LIFE_AI_BASE + STORE_GLOBAL_RECOMMEND_PATH, {
|
|
|
- method: 'POST',
|
|
|
- mode: 'cors',
|
|
|
- credentials: 'omit',
|
|
|
- headers: {
|
|
|
- Accept: 'application/json',
|
|
|
- 'Content-Type': 'application/json;charset=UTF-8'
|
|
|
- },
|
|
|
- body: JSON.stringify(body)
|
|
|
- }).then(function (res) {
|
|
|
- if (!res.ok) throw new Error('HTTP ' + res.status);
|
|
|
- return res.json();
|
|
|
- });
|
|
|
+ if (typeof LifeAiFetch !== 'undefined' && LifeAiFetch.fetchLifeAiPostJson) {
|
|
|
+ return LifeAiFetch.fetchLifeAiPostJson(
|
|
|
+ API_BASE,
|
|
|
+ STORE_GLOBAL_RECOMMEND_PATH,
|
|
|
+ body
|
|
|
+ );
|
|
|
+ }
|
|
|
+ return Promise.reject(new Error('LifeAiFetch unavailable'));
|
|
|
}
|
|
|
|
|
|
function renderShareClosedRecommended(list) {
|
|
|
@@ -2143,6 +2146,7 @@
|
|
|
|
|
|
var coverIm = card.querySelector('img.closed-rec-card__cover');
|
|
|
if (coverIm) {
|
|
|
+ applyMediaNoReferrer(coverIm);
|
|
|
coverIm.src = imgUrl;
|
|
|
coverIm.onerror = function () {
|
|
|
this.onerror = null;
|
|
|
@@ -2168,7 +2172,17 @@
|
|
|
renderShareClosedRecommended(list);
|
|
|
})
|
|
|
.catch(function (e) {
|
|
|
- console.error(e);
|
|
|
+ console.error('[store-recommend]', e);
|
|
|
+ if (
|
|
|
+ typeof LifeAiFetch !== 'undefined' &&
|
|
|
+ LifeAiFetch.isPageHttps() &&
|
|
|
+ LifeAiFetch.isIosWxBrowser()
|
|
|
+ ) {
|
|
|
+ console.warn(
|
|
|
+ '[store-recommend] iOS HTTPS 页需通过同源 alienStore 访问 AI 推荐;请确认网关已放行匿名 POST ' +
|
|
|
+ STORE_GLOBAL_RECOMMEND_PATH
|
|
|
+ );
|
|
|
+ }
|
|
|
renderShareClosedRecommended([]);
|
|
|
});
|
|
|
}
|