【类 型】:feat

【原  因】:
【过  程】:从接口拿订单数据 同时进行 ‘订单快照’ 字段的 序列化 并且把sku spu的图片路径 补全 ps:完整的访问路径
【影  响】:

# 类型 包含:
# feat:新功能(feature)
# fix:修补bug
# docs:文档(documentation)
# style: 格式(不影响代码运行的变动)
# refactor:重构(即不是新增功能,也不是修改bug的代码变动)
# test:增加测试
# chore:构建过程或辅助工具的变动
This commit is contained in:
sszdot 2024-12-18 12:14:30 +08:00
parent 001e703b75
commit a1feb8bb4b

View File

@ -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
}