shish 7 месяцев назад
Родитель
Сommit
75eb97daff
1 измененных файлов с 12 добавлено и 20 удалено
  1. 12 20
      ghsPad/src/pages/home/components/selectFlowerGrid.vue

+ 12 - 20
ghsPad/src/pages/home/components/selectFlowerGrid.vue

@@ -79,10 +79,19 @@ export default {
                 const dataToUse = (newData && newData.length > 0) ? newData : []
                 this.flowerList = dataToUse
                 this.flowerList.forEach(item => {
-                    if (!this.numList[item.id]) {
-                        this.numList[item.id] = 0
-                    }
+                   this.numList[item.id] = 0
                 })
+                let saveInfo = uni.getStorageSync("xj")
+                if (!this.$util.isEmpty(saveInfo)) {
+                    saveInfo.forEach((item) => {
+                        let hasList = item.list ? item.list : []
+                        if (!this.$util.isEmpty(hasList)) {
+                            hasList.forEach((hasItem) => {
+                                this.numList[hasItem.id] = hasItem.num
+                            })
+                        }
+                    })
+                }
             },
             deep: true,
             immediate: true
@@ -90,7 +99,6 @@ export default {
         customData:{
             handler(newData){
                 this.unitPrice = newData.unitPrice?parseFloat(newData.unitPrice):0
-                this.initXjData()
             },
             deep: true,
             immediate: true
@@ -100,22 +108,6 @@ export default {
         this.calculateScrollHeight()
     },
     methods: {
-        initXjData() {
-            this.flowerList.forEach(item => {
-                this.numList[item.id] = 0
-            })
-            let saveInfo = uni.getStorageSync("xj")
-            if (!this.$util.isEmpty(saveInfo)) {
-                saveInfo.forEach((item, index) => {
-                    let hasList = item.list ? item.list : []
-                    if (!this.$util.isEmpty(hasList)) {
-                        hasList.forEach((hasItem) => {
-                            this.numList[hasItem.id] = hasItem.num
-                        })
-                    }
-                })
-            }
-        },
         // 计算滚动区域高度
         calculateScrollHeight() {
             // 总高度 - 头部高度 - 底部按钮高度