From a1feb8bb4b3a1b1bd2e51fd08e09ecf2c47f275b Mon Sep 17 00:00:00 2001 From: sszdot Date: Wed, 18 Dec 2024 12:14:30 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E7=B1=BB=20=20=E5=9E=8B=E3=80=91?= =?UTF-8?q?=EF=BC=9Afeat=20=E3=80=90=E5=8E=9F=20=20=E5=9B=A0=E3=80=91?= =?UTF-8?q?=EF=BC=9A=20=E3=80=90=E8=BF=87=20=20=E7=A8=8B=E3=80=91=EF=BC=9A?= =?UTF-8?q?=E4=BB=8E=E6=8E=A5=E5=8F=A3=E6=8B=BF=E8=AE=A2=E5=8D=95=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=20=E5=90=8C=E6=97=B6=E8=BF=9B=E8=A1=8C=20=E2=80=98?= =?UTF-8?q?=E8=AE=A2=E5=8D=95=E5=BF=AB=E7=85=A7=E2=80=99=20=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=E7=9A=84=20=E5=BA=8F=E5=88=97=E5=8C=96=20=E5=B9=B6?= =?UTF-8?q?=E4=B8=94=E6=8A=8Asku=20spu=E7=9A=84=E5=9B=BE=E7=89=87=E8=B7=AF?= =?UTF-8?q?=E5=BE=84=20=E8=A1=A5=E5=85=A8=20ps:=E5=AE=8C=E6=95=B4=E7=9A=84?= =?UTF-8?q?=E8=AE=BF=E9=97=AE=E8=B7=AF=E5=BE=84=20=E3=80=90=E5=BD=B1=20=20?= =?UTF-8?q?=E5=93=8D=E3=80=91=EF=BC=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # 类型 包含: # feat:新功能(feature) # fix:修补bug # docs:文档(documentation) # style: 格式(不影响代码运行的变动) # refactor:重构(即不是新增功能,也不是修改bug的代码变动) # test:增加测试 # chore:构建过程或辅助工具的变动 --- store/index.js | 59 +++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 49 insertions(+), 10 deletions(-) diff --git a/store/index.js b/store/index.js index 330fc71..a586cc4 100644 --- a/store/index.js +++ b/store/index.js @@ -168,18 +168,57 @@ const store = new Vuex.Store({ state, commit }) { - await uni.$u.http.get('/Api/Check/getOrderList', { - header:{ - 'Token': state.userInfo.token, - } - }).then(res => { + try { + // 请求订单列表 + const res = await uni.$u.http.get('/Api/Check/getOrderList', { + header: { + 'Token': state.userInfo.token + } + }) + if (res.data.status === 1) { - //更新数据 - commit('setOrderList', res.data.orderList) + // 对订单列表处理 + const orderList = res.data.orderList.map(item => { + let tempPS + + try { + // 解析 product_snapshot 字段 + tempPS = JSON.parse(item.product_snapshot) + } catch (error) { + console.error(`product_snapshot 解析失败: ${error.message}`) + tempPS = [] + } + + // 遍历 product_snapshot 数组 + tempPS = tempPS.map(spu => { + // 给 spu_photo 添加完整路径 + spu.spu_photo = spu.spu_photo.map(photo => spuPath + photo) + + // 遍历 sku_arr,给 sku_photo 添加完整路径 + spu.sku_arr = spu.sku_arr.map(sku => { + sku.sku_photo = sku.sku_photo.map(photo => skuPath + + photo) + return sku + }) + + return spu + }) + + return { + ...item, + product_snapshot: tempPS + } + }) + + // 提交更新到 Vuex 的状态 + commit('setOrderList', orderList) } else { - commit('setSiteList', []) + commit('setOrderList', []) } - }) + } catch (error) { + console.error(`获取订单列表失败: ${error.message}`) + commit('setOrderList', []) + } }, //获取站点列表 async fetchSiteList({ @@ -306,7 +345,7 @@ const store = new Vuex.Store({ state, commit }) { - await uni.$u.http.get('/Api/Normal/getShopCon', { + await uni.$u.http.get('/Api/Normal/getShopCon', { params: { shop_id: state.shop_id }