|
|
|
@ -239,6 +239,28 @@ Page({ |
|
|
|
|
|
|
|
console.log('提取的规格和价格:', specifications); |
|
|
|
|
|
|
|
// 对规格进行排序
|
|
|
|
specifications.sort((a, b) => { |
|
|
|
// 解析两个规格
|
|
|
|
const specA = this.parseSpecification(a.name); |
|
|
|
const specB = this.parseSpecification(b.name); |
|
|
|
|
|
|
|
// 如果有一个规格解析失败,保持原顺序
|
|
|
|
if (!specA || !specB) { |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
// 1. 按类型排序:净重在前,毛重在后
|
|
|
|
if (specA.type !== specB.type) { |
|
|
|
return specA.type === '净重' ? -1 : 1; |
|
|
|
} |
|
|
|
|
|
|
|
// 2. 按规格最小值排序:从小到大
|
|
|
|
return specA.min - specB.min; |
|
|
|
}); |
|
|
|
|
|
|
|
console.log('排序后的规格:', specifications); |
|
|
|
|
|
|
|
this.setData({ |
|
|
|
specifications: specifications, |
|
|
|
error: '', // 清除之前的错误
|
|
|
|
|