Compare commits
3 Commits
249c440d61
...
fbc48066f6
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fbc48066f6 | ||
|
|
d7971b148e | ||
|
|
c3eeb0c3bc |
@ -418,8 +418,30 @@ export default {
|
||||
user_id: uni.getStorageSync("userId"),
|
||||
id: this.secondId,
|
||||
}).then((res) => {
|
||||
// 深拷贝接口数据,避免引用问题
|
||||
const commodityList = JSON.parse(JSON.stringify(res.commodity_list));
|
||||
// 过滤掉commodity_goods_info_list为空的数据,并为每个infoItem设置isShow属性
|
||||
const filteredList = res.commodity_list.filter(item => {
|
||||
// 确保item有commodity_info_list属性
|
||||
if (item.commodity_info_list && Array.isArray(item.commodity_info_list)) {
|
||||
// 过滤掉commodity_goods_info_list为空的infoItem
|
||||
item.commodity_info_list = item.commodity_info_list.filter(infoItem =>
|
||||
infoItem.commodity_goods_info_list &&
|
||||
Array.isArray(infoItem.commodity_goods_info_list) &&
|
||||
infoItem.commodity_goods_info_list.length > 0
|
||||
);
|
||||
// 只有当过滤后的infoItem列表不为空时,才保留该item
|
||||
return item.commodity_info_list.length > 0;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
// 为过滤后的数据中的每个infoItem设置isShow属性
|
||||
filteredList.forEach((item) => {
|
||||
item.commodity_info_list.forEach((infoItem) => {
|
||||
infoItem.isShow = false;
|
||||
});
|
||||
});
|
||||
// 深拷贝过滤后的数据,避免引用问题
|
||||
const commodityList = JSON.parse(JSON.stringify(filteredList));
|
||||
commodityList.forEach((tagItem) => { // 重命名外层变量,避免嵌套冲突
|
||||
tagItem.commodity_info_list.forEach((infoItem) => { // 内层变量重命名
|
||||
// 初始化isShow为响应式属性
|
||||
|
||||
@ -175,25 +175,25 @@ export default {
|
||||
// 根据ad_code解析省市区信息
|
||||
parseAdCode(adCode) {
|
||||
if (!adCode) return;
|
||||
|
||||
|
||||
// 提取省级ad_code(前2位)
|
||||
const provinceCode = adCode.toString().substring(0, 2) + '0000';
|
||||
// 提取市级ad_code(前4位)
|
||||
const cityCode = adCode.toString().substring(0, 4) + '00';
|
||||
// 区县级ad_code(完整6位)
|
||||
const districtCode = adCode.toString();
|
||||
|
||||
|
||||
// 查找省份信息
|
||||
const province = this.pro.find(item => item.ad_code == provinceCode);
|
||||
if (province) {
|
||||
this.confirmProv = province;
|
||||
|
||||
|
||||
// 获取对应城市列表并查找城市信息
|
||||
this.getCity(provinceCode).then(() => {
|
||||
const city = this.city.find(item => item.ad_code == cityCode);
|
||||
if (city) {
|
||||
this.confirmCity = city;
|
||||
|
||||
|
||||
// 获取对应区县列表并查找区县信息
|
||||
this.getBuss(cityCode).then(() => {
|
||||
const district = this.buss.find(item => item.ad_code == districtCode);
|
||||
@ -410,7 +410,7 @@ export default {
|
||||
// 先执行数据获取方法
|
||||
Promise.all([this.getPro(), this.getClassify()]).then(() => {
|
||||
// 数据获取完成后再进行赋值操作
|
||||
if(options.itemObj){
|
||||
if (options.itemObj) {
|
||||
this.itemObj = JSON.parse(options.itemObj)
|
||||
this.store_name = this.itemObj.merchant_name
|
||||
this.address = this.itemObj.address
|
||||
@ -422,12 +422,12 @@ export default {
|
||||
if (this.itemObj.ad_code) {
|
||||
this.parseAdCode(this.itemObj.ad_code);
|
||||
}
|
||||
this.imgList = this.itemObj.facade_photo.split(",").map(item => ({ url: this.picUrl + item }))
|
||||
this.imgList2 = this.itemObj.facade_photo.split(",")
|
||||
this.imgList3 = this.itemObj.interior_photo.split(",").map(item => ({ url: this.picUrl + item }))
|
||||
this.imgList4 = this.itemObj.interior_photo.split(",")
|
||||
this.imgList5 = this.itemObj.license_photo.split(",").map(item => ({ url: this.picUrl + item }))
|
||||
this.imgList6 = this.itemObj.license_photo.split(",")
|
||||
this.imgList = this.itemObj.facade_photo ? this.itemObj.facade_photo.split(",").map(item => ({ url: this.picUrl + item })) : []
|
||||
this.imgList2 = this.itemObj.facade_photo ? this.itemObj.facade_photo.split(",") : []
|
||||
this.imgList3 = this.itemObj.interior_photo ? this.itemObj.interior_photo.split(",").map(item => ({ url: this.picUrl + item })) : []
|
||||
this.imgList4 = this.itemObj.interior_photo ? this.itemObj.interior_photo.split(",") : []
|
||||
this.imgList5 = this.itemObj.license_photo?.split(",").map(item => ({ url: this.picUrl + item }))
|
||||
this.imgList6 = this.itemObj.license_photo?.split(",")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user