Browse Source

Merge branch 'bug/订货单添加产品问题' into 德莱宝待更新,与楚楚正式同步

xiaohaizhao 1 year ago
parent
commit
95395ea3f2

+ 4 - 0
packageA/favorites/index.js

@@ -284,7 +284,11 @@ Page({
             icon: "none"
           });
           if (res.msg != '成功') return;
+          this.setData({
+            results: this.data.results.filter(v => v != item.sa_favoritesid)
+          })
           this.getList(true)
+          this.computeSum();
           getApp().globalData.getFavoriteCount()
         })
       }

+ 10 - 5
packageA/market/detail.js

@@ -39,10 +39,9 @@ Page({
 		this.setData({
 			userrole: wx.getStorageSync('userrole')
 		})
-		this.getDetail(true);
 	},
 	/* 获取详情 */
-	getDetail(init = false) {
+	getDetail(init = false, getCustom = true) {
 		let content = this.data.content;
 		if (sys_enterpriseid) content.sys_enterpriseid = sys_enterpriseid;
 		_Http.basic({
@@ -79,7 +78,7 @@ Page({
 				itemCount: ['specRows', 'cheekRows', 'materialRows', 'colorRows'].filter(v => res.data[v].length).length
 			});
 			//是否定制
-			if (item.iscustomsize == 1) this.selectComponent("#customMade").init(item);
+			if (getCustom && item.iscustomsize == 1) this.selectComponent("#customMade").init(item);
 		})
 	},
 	/* 预览媒体 */
@@ -147,7 +146,6 @@ Page({
 		})
 		this.getDetail(valuename == "spec")
 	},
-
 	clickBut() {
 		this.data.detail.tradefield.length >= 2 ? wx.showToast({
 			title: '请选择加入产品领域',
@@ -288,5 +286,12 @@ Page({
 			detail: "Collect"
 		})
 		wx.navigateBack();
-	}
+	},
+	onShow() {
+		this.setData({
+			favoriteCount: getApp().globalData.favoriteCount,
+			badge: getApp().globalData.collectCount,
+		})
+		this.getDetail(true, this.data.loading);
+	},
 })

+ 1 - 0
packageA/orderForm/detail.js

@@ -341,6 +341,7 @@ Page({
 					title: res.msg,
 					icon: "none"
 				});
+				this.getDetail(true)
 				resolve(res)
 			})
 		})

+ 10 - 2
pages/index/collect/modules/custom.js

@@ -43,8 +43,16 @@ Component({
           };
           //是否为定制项
           custom = this.selectComponent("#customMade").getResult(true);
-          if (typeof custom == "boolean") return resolve(false);
-          getApp().globalData.customizedProduct(item, custom).then(res => resolve(true))
+          let count = setInterval(() => {
+            if (custom != 'wait') {
+              if (typeof custom == "boolean") return resolve(false);
+              getApp().globalData.customizedProduct(item, custom).then(res => resolve(true))
+              clearInterval(count)
+            } else {
+              custom = this.selectComponent("#customMade").getResult(true);
+            }
+          }, 100);
+
         } else {
           resolve(false);
           this.setData({

+ 34 - 22
pages/index/collect/modules/customMade/index.js

@@ -17,7 +17,9 @@ Component({
   },
   externalClasses: ["external-custom-box", "external-custom-label", "external-custom-stepper-box", "external-explain", "external-active", "external-custom-option"],
   data: {
-    list: []
+    list: [],
+    focus: false,
+    isSubmit: false
   },
   methods: {
     init(data, prefix = '') {
@@ -42,26 +44,35 @@ Component({
       });
       this.getResult();
     },
-    getResult(isSubmit) {
-      let obj = {};
-      let breakOff = false;
-      this.data.list.filter(v => {
-        if (breakOff) return;
-        if (v.type == '自定义') {
-          if (!v.value) v.value = 0;
-          if (v.value < v.min) v.value = v.min;
-        }
-        obj[v.key] = v.value || '';
-        if (isSubmit && !obj[v.key]) {
-          wx.showToast({
-            title: `请完成定制"${v.label}"选项`,
-            icon: "none"
-          })
-          breakOff = true;
-        }
-      })
-      this.triggerEvent("onChange", breakOff ? false : obj)
-      return breakOff ? false : obj
+    onFocus(e) {
+      this.data.focus = true;
+    },
+    getResult(isSubmit = false) {
+      if (isSubmit && this.data.focus) {
+        this.data.isSubmit = isSubmit;
+        return "wait"
+      } else {
+        let obj = {};
+        let breakOff = false;
+        this.data.list.filter(v => {
+          if (breakOff) return;
+          if (v.type == '自定义') {
+            if (!v.value) v.value = 0;
+            if (v.value < v.min) v.value = v.min;
+          }
+          obj[v.key] = v.value || '';
+          if (isSubmit && !obj[v.key]) {
+            wx.showToast({
+              title: `请完成定制"${v.label}"选项`,
+              icon: "none"
+            })
+            breakOff = true;
+          }
+        })
+        this.triggerEvent("onChange", breakOff ? false : obj)
+        this.data.isSubmit = false;
+        return breakOff ? false : obj
+      }
     },
     /* 定制步进器 */
     changeStepper(e) {
@@ -76,6 +87,7 @@ Component({
         item.value -= 1
       } else {
         item.value = (e.detail.value - 0).toFixed(item.decimalplaces);
+        this.data.focus = false;
       }
       item.value = item.value - 0;
       if (item.value > item.max) item.value = item.max;
@@ -83,7 +95,7 @@ Component({
       this.setData({
         [`list[${index}]`]: item
       })
-      this.getResult();
+      this.getResult(this.data.isSubmit);
     },
   }
 })

+ 1 - 1
pages/index/collect/modules/customMade/index.wxml

@@ -13,7 +13,7 @@
 		</navigator>
 	</block>
 	<view class="stepper-box external-custom-stepper-box" wx:elif="{{item.type=='自定义'}}">
-		<van-stepper value="{{item.value||0}}" data-item="{{item}}" data-index="{{index}}" input-width="60px" min="{{item.min}}" max="{{item.max}}" decimal-length="{{ item.decimalplaces }}" bind:plus='changeStepper' bind:blur='changeStepper' bind:minus='changeStepper' />
+		<van-stepper value="{{item.value||0}}" data-item="{{item}}" data-index="{{index}}" input-width="60px" min="{{item.min}}" max="{{item.max}}" decimal-length="{{ item.decimalplaces }}" bind:focus='onFocus' bind:plus='changeStepper' bind:blur='changeStepper' bind:minus='changeStepper' />
 		<view class="explain external-explain">{{item.min+'mm ~ '+ item.max}}mm,<text wx:if="{{item.decimalplaces}}">保留{{item.decimalplaces}}位小数</text><text wx:else>不保留小数</text></view>
 	</view>
 </view>