|
|
@ -17,6 +17,8 @@ Page({ |
|
|
district: '', |
|
|
district: '', |
|
|
detail: '' |
|
|
detail: '' |
|
|
}, |
|
|
}, |
|
|
|
|
|
// 是否从货源详情页进入(携带产品ID)
|
|
|
|
|
|
isFromGoodsDetail: false, |
|
|
// 货物信息
|
|
|
// 货物信息
|
|
|
goodsInfo: { |
|
|
goodsInfo: { |
|
|
weight: '', // 重量(kg)
|
|
|
weight: '', // 重量(kg)
|
|
|
@ -155,7 +157,10 @@ Page({ |
|
|
// 初始化地址选择器数据
|
|
|
// 初始化地址选择器数据
|
|
|
this.initRegionData(); |
|
|
this.initRegionData(); |
|
|
|
|
|
|
|
|
// 如果从商品详情页跳转过来,获取商品信息
|
|
|
// 如果从商品详情页或货源详情页跳转过来,设置标志并获取商品信息
|
|
|
|
|
|
if (options.goodsId || options.goodsInfo || options.goodsData) { |
|
|
|
|
|
this.setData({ isFromGoodsDetail: true }); |
|
|
|
|
|
|
|
|
if (options.goodsId) { |
|
|
if (options.goodsId) { |
|
|
this.loadGoodsInfo(options.goodsId); |
|
|
this.loadGoodsInfo(options.goodsId); |
|
|
} |
|
|
} |
|
|
@ -164,10 +169,15 @@ Page({ |
|
|
if (options.goodsInfo) { |
|
|
if (options.goodsInfo) { |
|
|
try { |
|
|
try { |
|
|
const goodsInfo = JSON.parse(options.goodsInfo); |
|
|
const goodsInfo = JSON.parse(options.goodsInfo); |
|
|
|
|
|
let weight = goodsInfo.grossWeight || ''; |
|
|
|
|
|
if (!weight && goodsInfo.netWeight && goodsInfo.quantity) { |
|
|
|
|
|
// 计算总重量:净重(斤) * 件数 / 2(换算为公斤)
|
|
|
|
|
|
weight = (parseFloat(goodsInfo.netWeight) * parseInt(goodsInfo.quantity)) / 2; |
|
|
|
|
|
} |
|
|
this.setData({ |
|
|
this.setData({ |
|
|
selectedGoods: goodsInfo, |
|
|
selectedGoods: goodsInfo, |
|
|
'goodsInfo.weight': goodsInfo.grossWeight || '', |
|
|
'goodsInfo.weight': weight, |
|
|
'goodsInfo.quantity': 1 |
|
|
'goodsInfo.quantity': goodsInfo.quantity || 1 |
|
|
}); |
|
|
}); |
|
|
} catch (e) { |
|
|
} catch (e) { |
|
|
console.error('解析货源信息失败:', e); |
|
|
console.error('解析货源信息失败:', e); |
|
|
@ -192,10 +202,16 @@ Page({ |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
let weight = goodsData.grossWeight || ''; |
|
|
|
|
|
if (!weight && goodsData.netWeight && goodsData.quantity) { |
|
|
|
|
|
// 计算总重量:净重(斤) * 件数 / 2(换算为公斤)
|
|
|
|
|
|
weight = (parseFloat(goodsData.netWeight) * parseInt(goodsData.quantity)) / 2; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
this.setData({ |
|
|
this.setData({ |
|
|
selectedGoods: goodsData, |
|
|
selectedGoods: goodsData, |
|
|
'goodsInfo.weight': goodsData.grossWeight || '', |
|
|
'goodsInfo.weight': weight, |
|
|
'goodsInfo.quantity': 1 |
|
|
'goodsInfo.quantity': goodsData.quantity || 1 |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
// 设置出发地为商品所在地
|
|
|
// 设置出发地为商品所在地
|
|
|
@ -216,6 +232,7 @@ Page({ |
|
|
console.error('解析货源信息失败:', e); |
|
|
console.error('解析货源信息失败:', e); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// 加载历史记录(在设置完 selectedGoods 后)
|
|
|
// 加载历史记录(在设置完 selectedGoods 后)
|
|
|
this.loadHistoryRecords(); |
|
|
this.loadHistoryRecords(); |
|
|
@ -266,6 +283,12 @@ Page({ |
|
|
this.setData({ |
|
|
this.setData({ |
|
|
'goodsInfo.weight': goodsItem.grossWeight |
|
|
'goodsInfo.weight': goodsItem.grossWeight |
|
|
}); |
|
|
}); |
|
|
|
|
|
} else if (goodsItem.netWeight && goodsItem.quantity) { |
|
|
|
|
|
// 计算总重量:净重(斤) * 件数 / 2(换算为公斤)
|
|
|
|
|
|
const totalWeight = (parseFloat(goodsItem.netWeight) * parseInt(goodsItem.quantity)) / 2; |
|
|
|
|
|
this.setData({ |
|
|
|
|
|
'goodsInfo.weight': totalWeight |
|
|
|
|
|
}); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
|