From ad8010bbd37fca3e438c2dbca55cf74eb16de276 Mon Sep 17 00:00:00 2001 From: "97694732@qq.com" Date: Mon, 15 Jun 2026 10:44:50 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E5=AD=94=E5=A4=AB=E5=AD=90=E6=90=9C?= =?UTF-8?q?=E7=B4=A2errType=3D102=E6=97=B6=E6=A3=80=E6=B5=8B=E5=88=B0?= =?UTF-8?q?=E7=99=BB=E5=BD=95=E8=BF=87=E6=9C=9F=E5=90=8E=E6=B8=85=E9=99=A4?= =?UTF-8?q?session=E8=B7=B3=E8=BD=AC=E7=99=BB=E5=BD=95=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/upload/upload.vue | 51 +++++++++++++++++++++++++++++++++++++++++ utils/kongfz.js | 20 +++++++++++----- 2 files changed, 65 insertions(+), 6 deletions(-) diff --git a/pages/upload/upload.vue b/pages/upload/upload.vue index 6288ce2..126a0cb 100644 --- a/pages/upload/upload.vue +++ b/pages/upload/upload.vue @@ -1343,6 +1343,23 @@ export default { searchFacet(keyword, { phpsessid, dataType: 1 }) ]).then(([productsData, onSaleFacet, soldFacet]) => { this.isLoading = false + + // 检测孔夫子登录过期 + if (productsData.loginRequired || onSaleFacet.loginRequired || soldFacet.loginRequired) { + uni.showModal({ + title: '系统提示', + content: '孔夫子登录已过期,请重新登录', + confirmText: '去登录', + success: (modalRes) => { + if (modalRes.confirm) { + uni.removeStorageSync('kongfz_phpsessid') + uni.navigateTo({ url: '/pages/login/login' }) + } + } + }) + return + } + if (productsData && productsData.total > 0) { // 在售商品列表(最多12条) const list = (productsData.list || []).slice(0, 12) @@ -2564,6 +2581,23 @@ export default { searchFacet(keyword, { phpsessid, dataType: 1 }) ]).then(([productsData, onSaleFacet, soldFacet]) => { this.noIsbnLoading = false + + // 检测孔夫子登录过期 + if (productsData.loginRequired || onSaleFacet.loginRequired || soldFacet.loginRequired) { + uni.showModal({ + title: '系统提示', + content: '孔夫子登录已过期,请重新登录', + confirmText: '去登录', + success: (modalRes) => { + if (modalRes.confirm) { + uni.removeStorageSync('kongfz_phpsessid') + uni.navigateTo({ url: '/pages/login/login' }) + } + } + }) + return + } + // 收集作者和出版社选项 const authorSet = new Set() const publisherSet = new Set() @@ -2649,6 +2683,23 @@ export default { author: this.noIsbnAuthor }).then((productsData) => { this.noIsbnLoading = false + + // 检测孔夫子登录过期 + if (productsData.loginRequired) { + uni.showModal({ + title: '系统提示', + content: '孔夫子登录已过期,请重新登录', + confirmText: '去登录', + success: (modalRes) => { + if (modalRes.confirm) { + uni.removeStorageSync('kongfz_phpsessid') + uni.navigateTo({ url: '/pages/login/login' }) + } + } + }) + return + } + if (productsData && productsData.total > 0) { const list = (productsData.list || []).slice(0, 12) this.noIsbnProductList = list.map(item => { diff --git a/utils/kongfz.js b/utils/kongfz.js index 679879d..4d6f6c6 100644 --- a/utils/kongfz.js +++ b/utils/kongfz.js @@ -113,9 +113,12 @@ export function searchFacet(keyword, options = {}) { } }) const totalFound = parseInt(res.data.data.totalFoundText || res.data.data.matchInfo?.totalFound || 0, 10) - resolve({ newCount, oldCount, totalFound }) + resolve({ newCount, oldCount, totalFound, loginRequired: false }) + } else if (res.data && res.data.errType === '102') { + console.warn('孔夫子统计需要重新登录(errType=102)') + resolve({ newCount: 0, oldCount: 0, totalFound: 0, loginRequired: true }) } else { - resolve({ newCount: 0, oldCount: 0, totalFound: 0 }) + resolve({ newCount: 0, oldCount: 0, totalFound: 0, loginRequired: false }) } }, fail: (err) => { @@ -186,7 +189,7 @@ export function fetchItems(token, params = {}, onProgress) { * 搜索孔夫子在售商品(需要登录Cookie) * @param {string} keyword ISBN或书名 * @param {object} options {phpsessid, page} - * @returns {Promise<{total: number, list: Array}>} + * @returns {Promise<{total: number, list: Array, loginRequired: boolean}>} * list中每项: {id, title, author, press, priceText, imgBigUrl, shopName, qualityText, pubDateText, postage} */ export function searchProducts(keyword, options = {}) { @@ -231,13 +234,18 @@ export function searchProducts(keyword, options = {}) { if (itemResp) { resolve({ total: itemResp.total || 0, - list: itemResp.list || [] + list: itemResp.list || [], + loginRequired: false }) } else { - resolve({ total: 0, list: [] }) + resolve({ total: 0, list: [], loginRequired: false }) } + } else if (res.data && res.data.errType === '102') { + // errType 102 = 需要登录 + console.warn('孔夫子搜索需要重新登录(errType=102)') + resolve({ total: 0, list: [], loginRequired: true }) } else { - resolve({ total: 0, list: [] }) + resolve({ total: 0, list: [], loginRequired: false }) } }, fail: (err) => {