瀏覽代碼

修复修改定制品参数引发的bug

xiaohaizhao 1 年之前
父節點
當前提交
8021c4124d
共有 1 個文件被更改,包括 16 次插入3 次删除
  1. 16 3
      packageA/activity/selectProduct/index.js

+ 16 - 3
packageA/activity/selectProduct/index.js

@@ -44,12 +44,25 @@ Page({
     item = getItem(item);
     item = getItem(item, 'newOldPrice', 'oldprice');
     return new Promise((resolve) => {
-      let index = this.data.list.findIndex(v => v[this.data.idname] == item[this.data.idname]);
+      let index = this.data.list.findIndex(v => v[this.data.idname] == item[this.data.idname]),
+        resultList = this.data.resultList,
+        result = this.data.result;
       if (index != -1) this.data.list[index] = item;
-      if (item.pitchOn) this.data.result.push(item[this.data.idname])
+      let i = resultList.findIndex(v => v[this.data.idname] == item[this.data.idname]);
+      if (item.pitchOn) {
+        if (i == -1) {
+          resultList.push(item);
+          result.push(item[this.data.idname])
+        } else {
+          resultList[i] = item;
+        }
+      } else {
+        resultList[i] = item;
+      }
       this.setData({
         list: this.data.list,
-        result: this.data.result
+        result,
+        resultList
       })
       resolve(true)
     })