diff --git a/api/goods.js b/api/goods.js index de153bc..af1c993 100644 --- a/api/goods.js +++ b/api/goods.js @@ -7,6 +7,7 @@ const api = { detail: 'goods/detail', specData: 'goods/specData', nbgoods:'tes/api/goods/conditioninquiry', + goodImageUrl:'tes/api/goods/conditioninquiryImage', souser:"tes/api/Goods/searchUsers", sogoods: "AgencyAddress/order/searchGoods" } @@ -36,6 +37,11 @@ export const nbgoods = (data) => { return request.post(api.nbgoods, data ) } +// 商品单个获取图片 +export const nbgoodsImage = (data) => { + return request.post(api.goodImageUrl, data ) +} + // 搜索委托方 export const souser = (data) => { return request.post(api.souser, data ) diff --git a/pages/category/index.vue b/pages/category/index.vue index e2f83bf..61177da 100644 --- a/pages/category/index.vue +++ b/pages/category/index.vue @@ -158,7 +158,7 @@ // SettingModel.data(false), // 获取分类列表 // CategoryApi.list() - this.getAllGoods() + //this.getAllGoods() ]) .then(result => { // 初始化分类模板设置 @@ -210,15 +210,28 @@ // 绑定数据 - bindData(rd){ + async bindData(rd){ GoodsApi.nbgoods(rd).then(res=>{ - this.list = res.data.data - this.page=res.data.current_page - console.log("res",res) + this.list = res.data.data + this.page=res.data.current_page + console.log("res",res) + this.getHomeListImage() }); // //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) { diff --git a/pages/index/index.vue b/pages/index/index.vue index e301fd2..e626d59 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -209,7 +209,7 @@ }) .catch(() => app.mescroll.endErr()) // 标的列表 - + await app.getHomeListImage() }, // 初始化订单列表数据 @@ -217,11 +217,22 @@ newList.data.forEach(item => { // 处理价格表现形式 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 }, - + 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() { this.gdlist = getEmptyPaginateObj()