From 7ffd5c26bac096e053324a917a73b4b3df1601db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E9=A3=9E=E6=B4=8B?= <15778543+xufeiyang6017@user.noreply.gitee.com> Date: Mon, 26 Jan 2026 09:45:41 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E8=A7=84=E6=A0=BC?= =?UTF-8?q?=E6=8E=92=E5=BA=8F=E5=8A=9F=E8=83=BD=EF=BC=8C=E6=8C=89=E7=85=A7?= =?UTF-8?q?=E5=87=80=E9=87=8D/=E6=AF=9B=E9=87=8D=E5=88=86=E7=B1=BB?= =?UTF-8?q?=E5=B9=B6=E6=8C=89=E6=95=B0=E5=80=BC=E8=8C=83=E5=9B=B4=E6=8E=92?= =?UTF-8?q?=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/evaluate1/index.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/pages/evaluate1/index.js b/pages/evaluate1/index.js index c83e6a5..cb960df 100644 --- a/pages/evaluate1/index.js +++ b/pages/evaluate1/index.js @@ -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: '', // 清除之前的错误