userArea动态化: 存储/读取/可编辑, 不再硬编码13003000000
This commit is contained in:
parent
57249ab3e8
commit
e4b396dc4b
@ -244,7 +244,15 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
<view class="form-section" v-if="isLoggedIn">
|
||||||
|
<view class="section-title">
|
||||||
|
<text class="title-text">搜索区域</text>
|
||||||
|
</view>
|
||||||
|
<view class="form-section-body">
|
||||||
|
<input class="form-input" v-model="kongfzUserArea" placeholder="区域代码,默认13003000000" @blur="saveUserArea" />
|
||||||
|
<text class="form-hint">孔夫子API搜索区域代码,登录后可修改</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
<view class="bottom-placeholder"></view>
|
<view class="bottom-placeholder"></view>
|
||||||
</scroll-view>
|
</scroll-view>
|
||||||
</view>
|
</view>
|
||||||
@ -821,6 +829,7 @@ export default {
|
|||||||
rememberPassword: false,
|
rememberPassword: false,
|
||||||
blockedList: '',
|
blockedList: '',
|
||||||
kongfzToken: '',
|
kongfzToken: '',
|
||||||
|
kongfzUserArea: '',
|
||||||
savedAccountList: [],
|
savedAccountList: [],
|
||||||
|
|
||||||
// 定价策略
|
// 定价策略
|
||||||
@ -842,10 +851,12 @@ export default {
|
|||||||
// 恢复登录状态
|
// 恢复登录状态
|
||||||
const savedToken = uni.getStorageSync('kongfz_phpsessid')
|
const savedToken = uni.getStorageSync('kongfz_phpsessid')
|
||||||
const savedName = uni.getStorageSync('kongfz_shop_name')
|
const savedName = uni.getStorageSync('kongfz_shop_name')
|
||||||
|
const savedArea = uni.getStorageSync('kongfz_user_area')
|
||||||
if (savedToken && savedName) {
|
if (savedToken && savedName) {
|
||||||
this.kongfzToken = savedToken
|
this.kongfzToken = savedToken
|
||||||
this.shopName = savedName
|
this.shopName = savedName
|
||||||
this.shopRegion = uni.getStorageSync('kongfz_shop_region') || '孔夫子旧书网'
|
this.shopRegion = uni.getStorageSync('kongfz_shop_region') || '孔夫子旧书网'
|
||||||
|
this.kongfzUserArea = savedArea || '13003000000'
|
||||||
this.isLoggedIn = true
|
this.isLoggedIn = true
|
||||||
}
|
}
|
||||||
// 恢复记住的账号
|
// 恢复记住的账号
|
||||||
@ -987,13 +998,14 @@ export default {
|
|||||||
|
|
||||||
// 2. 搜索孔夫子 - 获取在售商品信息
|
// 2. 搜索孔夫子 - 获取在售商品信息
|
||||||
const phpsessid = this.kongfzToken || uni.getStorageSync('kongfz_phpsessid') || ''
|
const phpsessid = this.kongfzToken || uni.getStorageSync('kongfz_phpsessid') || ''
|
||||||
|
const userArea = this.kongfzUserArea || uni.getStorageSync('kongfz_user_area') || '13003000000'
|
||||||
// 排序参数:7=总价从低到高(含运费) 5=书价从低到高
|
// 排序参数:7=总价从低到高(含运费) 5=书价从低到高
|
||||||
const sortType = this.sortBy === 'book' ? '5' : '7'
|
const sortType = this.sortBy === 'book' ? '5' : '7'
|
||||||
// 并行请求:商品列表 + 品相统计(在售)+ 品相统计(已售)
|
// 并行请求:商品列表 + 品相统计(在售)+ 品相统计(已售)
|
||||||
Promise.all([
|
Promise.all([
|
||||||
searchProducts(keyword, { phpsessid, sortType }),
|
searchProducts(keyword, { phpsessid, sortType, userArea }),
|
||||||
searchFacet(keyword, { phpsessid, dataType: 0 }),
|
searchFacet(keyword, { phpsessid, dataType: 0, userArea }),
|
||||||
searchFacet(keyword, { phpsessid, dataType: 1 })
|
searchFacet(keyword, { phpsessid, dataType: 1, userArea })
|
||||||
]).then(([productsData, onSaleFacet, soldFacet]) => {
|
]).then(([productsData, onSaleFacet, soldFacet]) => {
|
||||||
this.isLoading = false
|
this.isLoading = false
|
||||||
if (productsData && productsData.total > 0) {
|
if (productsData && productsData.total > 0) {
|
||||||
@ -1354,14 +1366,20 @@ export default {
|
|||||||
this.shopName = ''
|
this.shopName = ''
|
||||||
this.shopRegion = ''
|
this.shopRegion = ''
|
||||||
this.kongfzToken = ''
|
this.kongfzToken = ''
|
||||||
|
this.kongfzUserArea = ''
|
||||||
uni.removeStorageSync('kongfz_phpsessid')
|
uni.removeStorageSync('kongfz_phpsessid')
|
||||||
uni.removeStorageSync('kongfz_shop_name')
|
uni.removeStorageSync('kongfz_shop_name')
|
||||||
uni.removeStorageSync('kongfz_shop_region')
|
uni.removeStorageSync('kongfz_shop_region')
|
||||||
|
uni.removeStorageSync('kongfz_user_area')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
saveUserArea() {
|
||||||
|
uni.setStorageSync('kongfz_user_area', this.kongfzUserArea)
|
||||||
|
},
|
||||||
|
|
||||||
// 加载已保存账号列表
|
// 加载已保存账号列表
|
||||||
loadSavedAccounts() {
|
loadSavedAccounts() {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@ -190,13 +190,13 @@ export function fetchItems(token, params = {}, onProgress) {
|
|||||||
* 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 = {}) {
|
||||||
const { phpsessid = '', page = 1, sortType = '' } = options
|
const { phpsessid = '', page = 1, sortType = '', userArea = '13003000000' } = options
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const reqData = {
|
const reqData = {
|
||||||
dataType: 0,
|
dataType: 0,
|
||||||
keyword: keyword,
|
keyword: keyword,
|
||||||
page: page,
|
page: page,
|
||||||
userArea: '13003000000'
|
userArea: userArea
|
||||||
}
|
}
|
||||||
if (sortType) {
|
if (sortType) {
|
||||||
reqData.sortType = sortType
|
reqData.sortType = sortType
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user