Browse Source

解决页面数据加载慢问题

master
wanghongjun 2 years ago
parent
commit
0d3838156a
  1. 6
      api/goods.js
  2. 17
      pages/category/index.vue
  3. 17
      pages/index/index.vue

6
api/goods.js

@ -7,6 +7,7 @@ const api = {
detail: 'goods/detail', detail: 'goods/detail',
specData: 'goods/specData', specData: 'goods/specData',
nbgoods:'tes/api/goods/conditioninquiry', nbgoods:'tes/api/goods/conditioninquiry',
goodImageUrl:'tes/api/goods/conditioninquiryImage',
souser:"tes/api/Goods/searchUsers", souser:"tes/api/Goods/searchUsers",
sogoods: "AgencyAddress/order/searchGoods" sogoods: "AgencyAddress/order/searchGoods"
} }
@ -36,6 +37,11 @@ export const nbgoods = (data) => {
return request.post(api.nbgoods, data ) return request.post(api.nbgoods, data )
} }
// 商品单个获取图片
export const nbgoodsImage = (data) => {
return request.post(api.goodImageUrl, data )
}
// 搜索委托方 // 搜索委托方
export const souser = (data) => { export const souser = (data) => {
return request.post(api.souser, data ) return request.post(api.souser, data )

17
pages/category/index.vue

@ -158,7 +158,7 @@
// SettingModel.data(false), // SettingModel.data(false),
// //
// CategoryApi.list() // CategoryApi.list()
this.getAllGoods() //this.getAllGoods()
]) ])
.then(result => { .then(result => {
// //
@ -210,15 +210,28 @@
// //
bindData(rd){ async bindData(rd){
GoodsApi.nbgoods(rd).then(res=>{ GoodsApi.nbgoods(rd).then(res=>{
this.list = res.data.data this.list = res.data.data
this.page=res.data.current_page this.page=res.data.current_page
console.log("res",res) console.log("res",res)
this.getHomeListImage()
}); });
// //
//this.initList(this.list) //this.initList(this.list)
}, },
async getHomeListImage() {
this.list.forEach((item, key) => {
if (item.goods_image === "") {
GoodsApi.nbgoodsImage({"id": item.id}).then(res2 => {
if (res2.code === 200) {
this.list[key].goods_image = res2.data.data[0].goods_image;
this.list[key].gdimg = pako.inflateRaw(base64ToUint8Array(res2.data.data[0].goods_image), {to: 'string'})
}
})
}
})
},
// //
initList(newList) { initList(newList) {

17
pages/index/index.vue

@ -209,7 +209,7 @@
}) })
.catch(() => app.mescroll.endErr()) .catch(() => app.mescroll.endErr())
// //
await app.getHomeListImage()
}, },
// //
@ -217,11 +217,22 @@
newList.data.forEach(item => { newList.data.forEach(item => {
// //
item.price = numberWithCommas(item.price) item.price = numberWithCommas(item.price)
item.gdimg = pako.inflateRaw(base64ToUint8Array(item.goods_image), {to: 'string'}) item.gdimg = item.goods_image === "" ? '' : pako.inflateRaw(base64ToUint8Array(item.goods_image), {to: 'string'})
}) })
return newList return newList
}, },
async getHomeListImage() {
this.gdlist.data.forEach((item,key) => {
if (item.goods_image === "") {
Gapi.nbgoodsImage({"id": item.id}).then(res2=>{
if (res2.code === 200) {
this.gdlist.data[key].goods_image = res2.data.data[0].goods_image;
this.gdlist.data[key].gdimg = pako.inflateRaw(base64ToUint8Array(res2.data.data[0].goods_image), {to: 'string'})
}
})
}
})
},
// //
onRefreshList() { onRefreshList() {
this.gdlist = getEmptyPaginateObj() this.gdlist = getEmptyPaginateObj()

Loading…
Cancel
Save