Ver Fonte

促销活动添加定制产品逻辑

xiaohaizhao há 1 ano atrás
pai
commit
1f522b8860

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

@@ -27,6 +27,26 @@ Page({
       idname: options.idname || this.data.idname
     });
     this.getList()
+    getApp().globalData.customizedProduct = this.customizedProduct.bind(this);
+  },
+  customization(e) {
+    let {
+      item
+    } = e.target.dataset;
+    item.pitchOn = false;
+    if (item) this.selectComponent("#Custom").onClick(item)
+  },
+  customizedProduct(item) {
+    return new Promise((resolve) => {
+      let index = this.data.list.findIndex(v => v[this.data.idname] == item[this.data.idname]);
+      if (index != -1) this.data.list[index] = item;
+      if (item.pitchOn) this.data.result.push(item[this.data.idname])
+      this.setData({
+        list: this.data.list,
+        result: this.data.result
+      })
+      resolve(true)
+    })
   },
   getList(init = false) {
     //init 用于初始化分页
@@ -73,15 +93,34 @@ Page({
   },
   /* 选中 */
   changeResult(e) {
-    if (e.target.dataset.iscatch) return;
     let {
-      id
+      id,
+      item
     } = e.currentTarget.dataset, result = this.data.result;
-    result.some(v => v == id) ? result = result.filter(v => v != id) : result.push(id)
+    if (this.data.radio) {
+      result = [id];
+    } else {
+      let isAdd = result.some(v => v == id);
+      if (!isAdd) {
+        if (item.iscustomsize == 1) {
+          if ((item.widthschemeid && !item.width) || (item.lengthschemeid && !item.length)) {
+            item.pitchOn = true;
+            if (item) this.selectComponent("#Custom").onClick(item)
+          } else {
+            result.push(id)
+          }
+        } else {
+          result.push(id)
+        }
+      } else {
+        result = result.filter(v => v != id)
+      }
+    }
     this.setData({
       result
     });
   },
+
   /* 提交 */
   submit() {
     let result = this.data.result,

+ 2 - 1
packageA/activity/selectProduct/index.json

@@ -2,6 +2,7 @@
   "usingComponents": {
     "van-checkbox": "@vant/weapp/checkbox/index",
     "van-stepper": "@vant/weapp/stepper/index",
-    "list":"../modules/list/index"
+    "list": "../modules/list/index",
+    "custom": "../../../pages/index/collect/modules/custom"
   }
 }

+ 9 - 2
packageA/activity/selectProduct/index.wxml

@@ -1,6 +1,7 @@
 <van-search class="search" value="{{ params.content.where.condition }}" shape="round" placeholder="请输入搜索关键词" bind:search='startSearch' bind:clear='onClear' />
+<custom id="Custom" />
 <Yl_ListBox id='ListBox' bind:getlist='getList'>
-	<navigator url="#" wx:for="{{list}}" wx:key="itemid" class="item-box" data-id="{{item[idname]}}" bindtap="{{item.groupqty!=0 && item.maxQty<=0?'':'changeResult'}}">
+	<navigator url="#" wx:for="{{list}}" wx:key="itemid" class="item-box" data-id="{{item[idname]}}" data-item="{{item}}" bindtap="{{item.groupqty!=0 && item.maxQty<=0?'':'changeResult'}}">
 		<view class="top" bindtap="changeResults" data-item="{{item}}">
 			<view class="image">
 				<van-image width="100%" height="100%" fit="cover" src="{{item.attinfos[0].subfiles[0].url||item.attinfos[0].url||item.cover}}" use-loading-slot use-error-slot lazy-load>
@@ -17,7 +18,13 @@
 				<view class="exp">规格:{{item.spec ||" --"}}</view>
 				<view class="exp">型号:{{item.model ||" --"}}</view>
 				<view class="exp"><text style="font-size: 24rpx;font-weight: 600;color: #FF3B30;">{{item.newPrice}}</text><text style="font-size: 20rpx; text-decoration:line-through; margin-left: 6rpx;">¥{{item.oldprice}}</text></view>
-				<view class="exp">可购数量:{{item.groupqty==0?'不限购':(item.groupqty-item.saledqty)<=0?'已售罄':item.maxQty}}</view>
+
+				<view wx:if="{{item.iscustomsize}}" class="subfield line-1" data-item="{{item}}" catch:tap="customization" style="color:#085CDF;">
+					长:{{item.length||0}} / 宽:{{item.width||0}}
+					<van-icon name="arrow-down" />
+				</view>
+
+				<view class="exp">可购数量:{{item.groupqty==0?'不限购':(item.groupqty-item.saledqty)<=0?'已售罄':item.maxQty}} </view>
 				</view>
 			</view>
 			<view class="bottom">