fix:孔夫子搜索errType=102时检测到登录过期后清除session跳转登录页
This commit is contained in:
parent
e50391ff45
commit
ad8010bbd3
@ -1343,6 +1343,23 @@ export default {
|
|||||||
searchFacet(keyword, { phpsessid, dataType: 1 })
|
searchFacet(keyword, { phpsessid, dataType: 1 })
|
||||||
]).then(([productsData, onSaleFacet, soldFacet]) => {
|
]).then(([productsData, onSaleFacet, soldFacet]) => {
|
||||||
this.isLoading = false
|
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) {
|
if (productsData && productsData.total > 0) {
|
||||||
// 在售商品列表(最多12条)
|
// 在售商品列表(最多12条)
|
||||||
const list = (productsData.list || []).slice(0, 12)
|
const list = (productsData.list || []).slice(0, 12)
|
||||||
@ -2564,6 +2581,23 @@ export default {
|
|||||||
searchFacet(keyword, { phpsessid, dataType: 1 })
|
searchFacet(keyword, { phpsessid, dataType: 1 })
|
||||||
]).then(([productsData, onSaleFacet, soldFacet]) => {
|
]).then(([productsData, onSaleFacet, soldFacet]) => {
|
||||||
this.noIsbnLoading = false
|
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 authorSet = new Set()
|
||||||
const publisherSet = new Set()
|
const publisherSet = new Set()
|
||||||
@ -2649,6 +2683,23 @@ export default {
|
|||||||
author: this.noIsbnAuthor
|
author: this.noIsbnAuthor
|
||||||
}).then((productsData) => {
|
}).then((productsData) => {
|
||||||
this.noIsbnLoading = false
|
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) {
|
if (productsData && productsData.total > 0) {
|
||||||
const list = (productsData.list || []).slice(0, 12)
|
const list = (productsData.list || []).slice(0, 12)
|
||||||
this.noIsbnProductList = list.map(item => {
|
this.noIsbnProductList = list.map(item => {
|
||||||
|
|||||||
@ -113,9 +113,12 @@ export function searchFacet(keyword, options = {}) {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
const totalFound = parseInt(res.data.data.totalFoundText || res.data.data.matchInfo?.totalFound || 0, 10)
|
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 {
|
} else {
|
||||||
resolve({ newCount: 0, oldCount: 0, totalFound: 0 })
|
resolve({ newCount: 0, oldCount: 0, totalFound: 0, loginRequired: false })
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
fail: (err) => {
|
fail: (err) => {
|
||||||
@ -186,7 +189,7 @@ export function fetchItems(token, params = {}, onProgress) {
|
|||||||
* 搜索孔夫子在售商品(需要登录Cookie)
|
* 搜索孔夫子在售商品(需要登录Cookie)
|
||||||
* @param {string} keyword ISBN或书名
|
* @param {string} keyword ISBN或书名
|
||||||
* @param {object} options {phpsessid, page}
|
* @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}
|
* list中每项: {id, title, author, press, priceText, imgBigUrl, shopName, qualityText, pubDateText, postage}
|
||||||
*/
|
*/
|
||||||
export function searchProducts(keyword, options = {}) {
|
export function searchProducts(keyword, options = {}) {
|
||||||
@ -231,13 +234,18 @@ export function searchProducts(keyword, options = {}) {
|
|||||||
if (itemResp) {
|
if (itemResp) {
|
||||||
resolve({
|
resolve({
|
||||||
total: itemResp.total || 0,
|
total: itemResp.total || 0,
|
||||||
list: itemResp.list || []
|
list: itemResp.list || [],
|
||||||
|
loginRequired: false
|
||||||
})
|
})
|
||||||
} else {
|
} 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 {
|
} else {
|
||||||
resolve({ total: 0, list: [] })
|
resolve({ total: 0, list: [], loginRequired: false })
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
fail: (err) => {
|
fail: (err) => {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user