|
|
@@ -671,7 +671,7 @@
|
|
|
* 进入页仅用 querySecondGoodsDetailWithOutJWT 判断商品是否存在(不用其 data 渲染页面):
|
|
|
* POST {API_BASE_SECOND}/recommend/querySecondGoodsDetailWithOutJWT
|
|
|
* body:goodsId、longitude、latitude、phoneId
|
|
|
- * 不存在/已下架/删除或 msg=暂无承载数据 → shareUndefined;存在 → applyFromUrl + 留言
|
|
|
+ * goodsStatus 不为 3 → shareUndefined;goodsStatus 为 3 → applyFromUrl + 留言
|
|
|
*/
|
|
|
/**
|
|
|
* 唤起 App 落地:二手商品详情(与 pages.json 路径一致)
|
|
|
@@ -1845,108 +1845,38 @@
|
|
|
);
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 存在性接口:msg 为「暂无承载数据」即无商品(即使 code=200);
|
|
|
- * 有有效 data 再看 deleteFlag;不用 goodsStatus 数值。
|
|
|
- */
|
|
|
- function isDetailResponseGoodsUnavailable(res) {
|
|
|
- if (!res || typeof res !== 'object') return true;
|
|
|
- if (isNoCarryingDataMsg(res)) {
|
|
|
- return true;
|
|
|
- }
|
|
|
+ /** 从 querySecondGoodsDetailWithOutJWT 返回中解析 goodsStatus(兼容 data 嵌套) */
|
|
|
+ function pickGoodsStatusFromDetailResponse(res) {
|
|
|
+ if (!res || typeof res !== 'object') return null;
|
|
|
var d = pickSecondGoodsDetailData(res);
|
|
|
- if (hasSecondGoodsDetailPayload(d)) {
|
|
|
- return isDetailDataExplicitlyDeleted(d);
|
|
|
- }
|
|
|
- var msg = res.msg != null ? String(res.msg) : '';
|
|
|
- if (isMsgIndicateGoodsGone(msg)) {
|
|
|
- return true;
|
|
|
+ var candidates = [];
|
|
|
+ if (d && d.goodsStatus != null) candidates.push(d.goodsStatus);
|
|
|
+ if (res.goodsStatus != null) candidates.push(res.goodsStatus);
|
|
|
+ var raw = res.data != null ? res.data : res.result;
|
|
|
+ if (raw && typeof raw === 'object' && !Array.isArray(raw) && raw.goodsStatus != null) {
|
|
|
+ candidates.push(raw.goodsStatus);
|
|
|
+ }
|
|
|
+ var i;
|
|
|
+ for (i = 0; i < candidates.length; i++) {
|
|
|
+ var v = candidates[i];
|
|
|
+ if (v != null && String(v).trim() !== '') return v;
|
|
|
}
|
|
|
- if (isSecondGoodsExistOk(res)) {
|
|
|
- return false;
|
|
|
- }
|
|
|
- return true;
|
|
|
+ return null;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 调试 querySecondGoodsDetailWithOutJWT:微信内异步 alert 常被拦截,用页面弹层兜底。
|
|
|
- * URL 加 apiDebug=0 可关闭。
|
|
|
- */
|
|
|
- function isSecondGoodsApiDebugOn() {
|
|
|
- if (q('apiDebug') === '0') return false;
|
|
|
- return true;
|
|
|
+ /** 仅 goodsStatus === 3 视为可展示;缺省或其它值均进不可用页 */
|
|
|
+ function isGoodsStatusAvailable(gs) {
|
|
|
+ if (gs == null || String(gs).trim() === '') return false;
|
|
|
+ return Number(gs) === 3 || String(gs).trim() === '3';
|
|
|
}
|
|
|
|
|
|
- function showSecondGoodsDetailDebugPanel(title, payload, onClose) {
|
|
|
- if (!isSecondGoodsApiDebugOn()) {
|
|
|
- if (typeof onClose === 'function') onClose();
|
|
|
- return;
|
|
|
- }
|
|
|
- var text;
|
|
|
- try {
|
|
|
- text =
|
|
|
- typeof payload === 'string'
|
|
|
- ? payload
|
|
|
- : JSON.stringify(payload, null, 2);
|
|
|
- } catch (serErr) {
|
|
|
- text = String(payload);
|
|
|
- }
|
|
|
- if (text.length > 16000) {
|
|
|
- text = text.slice(0, 16000) + '\n…(已截断)';
|
|
|
- }
|
|
|
-
|
|
|
- var old = document.getElementById('secondGoodsApiDebug');
|
|
|
- if (old) old.remove();
|
|
|
-
|
|
|
- var wrap = document.createElement('div');
|
|
|
- wrap.id = 'secondGoodsApiDebug';
|
|
|
- wrap.setAttribute('role', 'dialog');
|
|
|
- wrap.style.cssText =
|
|
|
- 'position:fixed;inset:0;z-index:99999;background:rgba(0,0,0,.72);' +
|
|
|
- 'padding:10px;box-sizing:border-box;display:flex;align-items:center;justify-content:center;';
|
|
|
-
|
|
|
- var card = document.createElement('div');
|
|
|
- card.style.cssText =
|
|
|
- 'background:#fff;border-radius:10px;width:100%;max-width:520px;max-height:88vh;' +
|
|
|
- 'display:flex;flex-direction:column;overflow:hidden;';
|
|
|
-
|
|
|
- var head = document.createElement('div');
|
|
|
- head.style.cssText =
|
|
|
- 'padding:10px 12px;font-size:14px;font-weight:700;border-bottom:1px solid #eee;';
|
|
|
- head.textContent = title;
|
|
|
-
|
|
|
- var pre = document.createElement('pre');
|
|
|
- pre.style.cssText =
|
|
|
- 'margin:0;padding:10px 12px;overflow:auto;font-size:11px;line-height:1.45;' +
|
|
|
- 'flex:1;white-space:pre-wrap;word-break:break-all;';
|
|
|
- pre.textContent = text;
|
|
|
-
|
|
|
- var btn = document.createElement('button');
|
|
|
- btn.type = 'button';
|
|
|
- btn.textContent = '关闭';
|
|
|
- btn.style.cssText =
|
|
|
- 'margin:10px 12px 12px;padding:10px;border:0;border-radius:6px;' +
|
|
|
- 'background:#F47D1F;color:#fff;font-size:15px;';
|
|
|
- btn.onclick = function () {
|
|
|
- wrap.remove();
|
|
|
- if (typeof onClose === 'function') onClose();
|
|
|
- };
|
|
|
-
|
|
|
- card.appendChild(head);
|
|
|
- card.appendChild(pre);
|
|
|
- card.appendChild(btn);
|
|
|
- wrap.appendChild(card);
|
|
|
- document.body.appendChild(wrap);
|
|
|
-
|
|
|
- console.log('[querySecondGoodsDetailWithOutJWT]', title, payload);
|
|
|
-
|
|
|
- setTimeout(function () {
|
|
|
- try {
|
|
|
- window.alert(title + '\n(详情见页面白色弹层,点「关闭」继续)');
|
|
|
- } catch (alertErr) {
|
|
|
- showFabToast(title, 4000);
|
|
|
- }
|
|
|
- }, 80);
|
|
|
+ /**
|
|
|
+ * 存在性接口:以 goodsStatus 为准,不为 3(含缺失)→ 跳转 shareUndefined。
|
|
|
+ */
|
|
|
+ function isDetailResponseGoodsUnavailable(res) {
|
|
|
+ if (!res || typeof res !== 'object') return true;
|
|
|
+ if (!isSecondGoodsExistOk(res)) return true;
|
|
|
+ return !isGoodsStatusAvailable(pickGoodsStatusFromDetailResponse(res));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -1994,65 +1924,25 @@
|
|
|
body: formStr
|
|
|
})
|
|
|
.then(function (res) {
|
|
|
- if (!res.ok) {
|
|
|
- var err = new Error('HTTP ' + res.status);
|
|
|
- err.httpStatus = res.status;
|
|
|
- err.requestUrl = detailUrl;
|
|
|
- throw err;
|
|
|
- }
|
|
|
+ if (!res.ok) throw new Error('HTTP ' + res.status);
|
|
|
return res.json();
|
|
|
})
|
|
|
.then(function (res) {
|
|
|
redirectCtx = redirectCtx || {};
|
|
|
var d = pickSecondGoodsDetailData(res);
|
|
|
- var debugPayload = {
|
|
|
- requestUrl: detailUrl,
|
|
|
- requestBody: formBody,
|
|
|
- response: res
|
|
|
- };
|
|
|
-
|
|
|
if (isDetailResponseGoodsUnavailable(res)) {
|
|
|
+ var gs = pickGoodsStatusFromDetailResponse(res);
|
|
|
console.warn(
|
|
|
- '[querySecondGoodsDetailWithOutJWT] unavailable',
|
|
|
+ '[querySecondGoodsDetailWithOutJWT] unavailable goodsStatus=',
|
|
|
+ gs,
|
|
|
res && res.code,
|
|
|
res && res.msg,
|
|
|
d
|
|
|
);
|
|
|
- return new Promise(function (resolve) {
|
|
|
- showSecondGoodsDetailDebugPanel(
|
|
|
- 'querySecondGoodsDetailWithOutJWT(将跳转不可用页)',
|
|
|
- debugPayload,
|
|
|
- function () {
|
|
|
- redirectToShareUndefined(null, redirectCtx);
|
|
|
- resolve({ redirected: true, exists: false });
|
|
|
- }
|
|
|
- );
|
|
|
- });
|
|
|
+ redirectToShareUndefined(gs, redirectCtx);
|
|
|
+ return { redirected: true, exists: false };
|
|
|
}
|
|
|
-
|
|
|
- showSecondGoodsDetailDebugPanel(
|
|
|
- 'querySecondGoodsDetailWithOutJWT 返回',
|
|
|
- debugPayload
|
|
|
- );
|
|
|
return { redirected: false, exists: true };
|
|
|
- })
|
|
|
- .catch(function (e) {
|
|
|
- showSecondGoodsDetailDebugPanel(
|
|
|
- 'querySecondGoodsDetailWithOutJWT 请求失败',
|
|
|
- {
|
|
|
- message: e && e.message ? e.message : String(e),
|
|
|
- requestUrl: detailUrl,
|
|
|
- requestBody: formBody,
|
|
|
- pageProtocol: location.protocol,
|
|
|
- apiBaseSecond: API_BASE_SECOND,
|
|
|
- hint:
|
|
|
- location.protocol === 'https:' &&
|
|
|
- /^http:\/\//i.test(String(API_BASE_SECOND))
|
|
|
- ? 'HTTPS 页面请求 HTTP 接口可能被 iOS/微信拦截(混合内容)'
|
|
|
- : ''
|
|
|
- }
|
|
|
- );
|
|
|
- throw e;
|
|
|
});
|
|
|
}
|
|
|
|
|
|
@@ -2113,14 +2003,6 @@
|
|
|
}
|
|
|
|
|
|
if (!goodsId) {
|
|
|
- showSecondGoodsDetailDebugPanel(
|
|
|
- '未调用 querySecondGoodsDetailWithOutJWT',
|
|
|
- {
|
|
|
- reason: 'URL 缺少 goodsId / id / sourceId',
|
|
|
- search: location.search,
|
|
|
- hash: location.hash
|
|
|
- }
|
|
|
- );
|
|
|
applyFromUrl();
|
|
|
return;
|
|
|
}
|