Browse Source

定制项未选择不能加入收藏夹

xiaohaizhao 1 year ago
parent
commit
f62563a86e
3 changed files with 15 additions and 16 deletions
  1. 5 0
      packageA/favorites/index.js
  2. 1 1
      packageA/favorites/index.wxml
  3. 9 15
      packageA/market/detail.js

+ 5 - 0
packageA/favorites/index.js

@@ -5,6 +5,9 @@ const _Http = getApp().globalData.http,
     precision: 2
   }).format();
 let downCount = {};
+import {
+  getCustomText
+} from "../../utils/customItemType";
 Page({
   data: {
     list: [],
@@ -74,6 +77,7 @@ Page({
       this.setData({
         list: res.data.map(v => {
           v.showPrice = CNY(v.gradeprice)
+          if (v.iscustomsize) v.customText = getCustomText(v);
           return v
         })
       });
@@ -226,6 +230,7 @@ Page({
     } = my ? e : e.currentTarget.dataset;
     let results = this.data.results,
       sa_brandid = this.data.sa_brandid;
+    console.log(item)
     if (sa_brandid && sa_brandid != item.sa_brandid) return;
     if (results.length == 0) {
       results.push(item.sa_favoritesid);

+ 1 - 1
packageA/favorites/index.wxml

@@ -20,7 +20,7 @@
 					<view class="exp">品牌:{{item.brandname ||" --"}}</view>
 					<view class="exp">领域:{{item.tradefield_shoppingcart ||" --"}}</view>
 					<view class="exp" wx:if="{{item.iscustomsize}}" data-item="{{item}}" catch:tap="customization" style="color:#085CDF;">
-						长:{{item.favoriteslength}} / 宽:{{item.favoriteswidth}}
+						{{item.customText}}
 						<van-icon name="arrow-down" />
 					</view>
 					<view class="price" style="bottom: {{item.iscustomsize?'40rpx':'0rpx'}};">{{handleHide.query(item.showPrice,hidePrice)}}/{{item.unitname}}</view>

+ 9 - 15
packageA/market/detail.js

@@ -245,26 +245,20 @@ Page({
 	/* 加入收藏夹 */
 	addToFavorites() {
 		let detail = this.data.detail,
-			content = this.data.content,
-			iscollection = this.data.detail.iscollection == 1 ? false : true
-
-		if (iscollection && detail.iscustomsize == 1) {
-			if (detail.widthschemeid != 0 && content.dwidth == 0) return wx.showToast({
-				title: '请完成定制宽选项',
-				icon: "none"
-			})
-			if (detail.lengthschemeid != 0 && content.dlength == 0) return wx.showToast({
-				title: '请完成定制长选项',
-				icon: "none"
-			})
-		}
+			iscollection = detail.iscollection == 1 ? false : true,
+			custom = {
+				length: 0,
+				width: 0
+			};
+		//是否为定制项
+		if (detail.iscustomsize == 1) custom = this.selectComponent("#customMade").getResult(true);
+		if (typeof custom == "boolean") return;
 		_Http.basic({
 			"id": 20231121143403,
 			"content": {
 				"itemid": this.data.detail.itemid, //货品id
 				"qty": detail.orderminqty, //数量
-				width: content.dwidth || 0,
-				length: content.dlength || 0,
+				...custom,
 				iscollection
 			},
 		}).then(res => {