|
|
|
@ -188,14 +188,26 @@ |
|
|
|
}, |
|
|
|
filters: { |
|
|
|
sliceMsg(val) { |
|
|
|
var name = '' |
|
|
|
if (!val) return '0' |
|
|
|
let priceList = val |
|
|
|
if (typeof(val) == 'string') { |
|
|
|
let newObj = JSON.parse(val) |
|
|
|
for (let as in newObj) { |
|
|
|
name = newObj[as].specPrice |
|
|
|
try { |
|
|
|
priceList = JSON.parse(val) |
|
|
|
} catch (e) { |
|
|
|
return '0' |
|
|
|
} |
|
|
|
} |
|
|
|
return name; |
|
|
|
if (Array.isArray(priceList)) { |
|
|
|
const firstPrice = priceList[0] || {} |
|
|
|
return firstPrice.specPrice != null && firstPrice.specPrice !== '' ? firstPrice.specPrice : '0' |
|
|
|
} |
|
|
|
if (typeof(priceList) == 'object') { |
|
|
|
for (let as in priceList) { |
|
|
|
const item = priceList[as] || {} |
|
|
|
return item.specPrice != null && item.specPrice !== '' ? item.specPrice : '0' |
|
|
|
} |
|
|
|
} |
|
|
|
return '0'; |
|
|
|
}, |
|
|
|
}, |
|
|
|
onShow() { |
|
|
|
@ -353,6 +365,23 @@ |
|
|
|
url:url |
|
|
|
}) |
|
|
|
}, |
|
|
|
normalizeProductPage(result) { |
|
|
|
let page = result || {} |
|
|
|
if (page.data && typeof(page.data) == 'object') { |
|
|
|
page = page.data |
|
|
|
} |
|
|
|
if (Array.isArray(page)) { |
|
|
|
return { |
|
|
|
records: page, |
|
|
|
pages: 1 |
|
|
|
} |
|
|
|
} |
|
|
|
const records = page.records || page.list || page.content || page.rows || [] |
|
|
|
return { |
|
|
|
records: Array.isArray(records) ? records : [], |
|
|
|
pages: page.pages || page.totalPage || page.totalPages || 1 |
|
|
|
} |
|
|
|
}, |
|
|
|
//点击分类获取商品列表 |
|
|
|
getShareList(type) { |
|
|
|
let data = {} |
|
|
|
@ -377,12 +406,16 @@ |
|
|
|
pageSize: isRecommend ? '1000' : '10' |
|
|
|
} |
|
|
|
} |
|
|
|
let that = this |
|
|
|
this.tui.request("/app/product/getShareList", "POST", data, false, false).then((res) => { |
|
|
|
if (res.code == 200) { |
|
|
|
const records = res.result.records || [] |
|
|
|
const goodsList = isRecommend ? records.filter(item => item.isPush == 1) : records |
|
|
|
this.pages = isRecommend ? 1 : (res.result.pages || 1) |
|
|
|
const page = this.normalizeProductPage(res.result) |
|
|
|
const goodsList = (isRecommend ? page.records.filter(item => item.isPush == 1) : page.records).filter(item => item && typeof(item) == 'object').map(item => { |
|
|
|
return { |
|
|
|
...item, |
|
|
|
isShow: false |
|
|
|
} |
|
|
|
}) |
|
|
|
this.pages = isRecommend ? 1 : page.pages |
|
|
|
if (type == 'search') { |
|
|
|
this.shopList = [] |
|
|
|
if (this.pageNum == 1) { |
|
|
|
@ -390,9 +423,6 @@ |
|
|
|
} else { |
|
|
|
this.shopList1 = [...this.shopList1, ...goodsList] |
|
|
|
} |
|
|
|
for(let i=0;i<this.shopList1.length;i++){ |
|
|
|
this.shopList1[i].isShow = false |
|
|
|
} |
|
|
|
} else { |
|
|
|
this.shopList1 = [] |
|
|
|
if (this.pageNum == 1) { |
|
|
|
@ -400,9 +430,6 @@ |
|
|
|
} else { |
|
|
|
this.shopList = [...this.shopList, ...goodsList] |
|
|
|
} |
|
|
|
for(let i=0;i<this.shopList.length;i++){ |
|
|
|
this.shopList[i].isShow = false |
|
|
|
} |
|
|
|
} |
|
|
|
this.status = this.pageNum >= this.pages ? 'nomore' : 'loadmore' |
|
|
|
} else { |
|
|
|
|