|
|
|
@ -28,24 +28,19 @@ Page({ |
|
|
|
logisticsPersonnel: [ |
|
|
|
{ |
|
|
|
id: 1, |
|
|
|
name: '张三', |
|
|
|
name: '张顺玟', |
|
|
|
position: '物流经理', |
|
|
|
experience: 5, |
|
|
|
phone: '13800138000' |
|
|
|
phone: '15528115321', |
|
|
|
description: '拥有5年专业物流管理经验,擅长整车运输和零担拼车方案设计,对鸡蛋的运输要求有深入了解,能够为客户提供高效、安全的物流解决方案。' |
|
|
|
}, |
|
|
|
{ |
|
|
|
id: 2, |
|
|
|
name: '李四', |
|
|
|
name: '刘敏', |
|
|
|
position: '物流经理', |
|
|
|
experience: 3, |
|
|
|
phone: '13900139000' |
|
|
|
}, |
|
|
|
{ |
|
|
|
id: 3, |
|
|
|
name: '王五', |
|
|
|
position: '物流经理', |
|
|
|
experience: 2, |
|
|
|
phone: '13700137000' |
|
|
|
experience: 5, |
|
|
|
phone: '19123901316', |
|
|
|
description: '5年物流行业经验,专注于配送路线优化,熟悉各种车型的载重和体积限制,能够根据货物特性制定最适合的运输方案,确保货物安全准时送达。' |
|
|
|
} |
|
|
|
], |
|
|
|
// 选中的货源信息
|
|
|
|
@ -865,9 +860,18 @@ Page({ |
|
|
|
// 计算运费
|
|
|
|
calculateFreight: function () { |
|
|
|
// 验证输入
|
|
|
|
if (!this.data.origin.province || !this.data.destination.province) { |
|
|
|
if (!this.data.origin.province || !this.data.origin.city || !this.data.destination.province || !this.data.destination.city) { |
|
|
|
wx.showToast({ |
|
|
|
title: '请完整填写出发地和目的地信息', |
|
|
|
icon: 'none' |
|
|
|
}); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
// 检查详细地址
|
|
|
|
if (!this.data.origin.detail || !this.data.destination.detail) { |
|
|
|
wx.showToast({ |
|
|
|
title: '请填写完整的出发地和目的地', |
|
|
|
title: '请填写详细地址', |
|
|
|
icon: 'none' |
|
|
|
}); |
|
|
|
return; |
|
|
|
@ -1018,7 +1022,7 @@ Page({ |
|
|
|
convertAddressToCoordinates: function (origin, destination) { |
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
// 转换出发地地址
|
|
|
|
const convertOrigin = new Promise((resolveOrigin) => { |
|
|
|
const convertOrigin = new Promise((resolveOrigin, rejectOrigin) => { |
|
|
|
// 如果出发地已经有经纬度,直接返回
|
|
|
|
if (origin.latitude && origin.longitude) { |
|
|
|
resolveOrigin(origin); |
|
|
|
@ -1028,7 +1032,7 @@ Page({ |
|
|
|
// 构建出发地完整地址
|
|
|
|
const originAddress = `${origin.province}${origin.city}${origin.district}${origin.detail}`; |
|
|
|
if (!originAddress) { |
|
|
|
resolveOrigin(origin); |
|
|
|
rejectOrigin(new Error('出发地地址不能为空,请输入地址或使用手动选择位置')); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
@ -1049,18 +1053,18 @@ Page({ |
|
|
|
}); |
|
|
|
} else { |
|
|
|
console.error('出发地地址转换失败:', res.data); |
|
|
|
resolveOrigin(origin); |
|
|
|
rejectOrigin(new Error('出发地地址无效,请检查输入或使用手动选择位置')); |
|
|
|
} |
|
|
|
}, |
|
|
|
fail: function (err) { |
|
|
|
console.error('出发地地址转换失败:', err); |
|
|
|
resolveOrigin(origin); |
|
|
|
rejectOrigin(new Error('出发地地址转换失败,请稍后重试')); |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
// 转换目的地地址
|
|
|
|
const convertDestination = new Promise((resolveDestination) => { |
|
|
|
const convertDestination = new Promise((resolveDestination, rejectDestination) => { |
|
|
|
// 如果目的地已经有经纬度,直接返回
|
|
|
|
if (destination.latitude && destination.longitude) { |
|
|
|
resolveDestination(destination); |
|
|
|
@ -1070,7 +1074,7 @@ Page({ |
|
|
|
// 构建目的地完整地址
|
|
|
|
const destinationAddress = `${destination.province}${destination.city}${destination.district}${destination.detail}`; |
|
|
|
if (!destinationAddress) { |
|
|
|
resolveDestination(destination); |
|
|
|
rejectDestination(new Error('目的地地址不能为空,请输入地址或使用手动选择位置')); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
@ -1091,18 +1095,27 @@ Page({ |
|
|
|
}); |
|
|
|
} else { |
|
|
|
console.error('目的地地址转换失败:', res.data); |
|
|
|
resolveDestination(destination); |
|
|
|
rejectDestination(new Error('目的地地址无效,请检查输入或使用手动选择位置')); |
|
|
|
} |
|
|
|
}, |
|
|
|
fail: function (err) { |
|
|
|
console.error('目的地地址转换失败:', err); |
|
|
|
resolveDestination(destination); |
|
|
|
rejectDestination(new Error('目的地地址转换失败,请稍后重试')); |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
// 等待两个地址转换完成
|
|
|
|
Promise.all([convertOrigin, convertDestination]).then(([originWithCoords, destinationWithCoords]) => { |
|
|
|
// 验证两个地址都有经纬度
|
|
|
|
if (!originWithCoords.latitude || !originWithCoords.longitude) { |
|
|
|
reject(new Error('出发地地址无效,请检查输入')); |
|
|
|
return; |
|
|
|
} |
|
|
|
if (!destinationWithCoords.latitude || !destinationWithCoords.longitude) { |
|
|
|
reject(new Error('目的地地址无效,请检查输入')); |
|
|
|
return; |
|
|
|
} |
|
|
|
resolve({ originWithCoords, destinationWithCoords }); |
|
|
|
}).catch(err => { |
|
|
|
reject(err); |
|
|
|
@ -1207,8 +1220,14 @@ Page({ |
|
|
|
} |
|
|
|
|
|
|
|
// 检查是否有出发地和目的地信息
|
|
|
|
if (!this.data.origin.province || !this.data.destination.province) { |
|
|
|
wx.showToast({ title: '请选择出发地和目的地', icon: 'none' }); |
|
|
|
if (!this.data.origin.province || !this.data.origin.city || !this.data.destination.province || !this.data.destination.city) { |
|
|
|
wx.showToast({ title: '请完整填写出发地和目的地信息', icon: 'none' }); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
// 检查详细地址
|
|
|
|
if (!this.data.origin.detail || !this.data.destination.detail) { |
|
|
|
wx.showToast({ title: '请填写详细地址', icon: 'none' }); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
@ -1300,7 +1319,7 @@ Page({ |
|
|
|
this.setData({ loading: false }); |
|
|
|
console.error('地址转换失败:', err); |
|
|
|
wx.showToast({ |
|
|
|
title: '地址转换失败,请稍后重试', |
|
|
|
title: err.message || '地址转换失败,请检查输入', |
|
|
|
icon: 'none' |
|
|
|
}); |
|
|
|
}); |
|
|
|
|