Ver código fonte

Merge branch '新功能开发/定制项' into 德莱宝测试除了手机登录不合并

# Conflicts:
#	packageA/market/detail.js
#	packageA/market/detail.wxml
#	utils/Http.js
xiaohaizhao 1 ano atrás
pai
commit
c00f9d6b62

+ 25 - 22
packageA/activity/selectProduct/cart/index.js

@@ -6,6 +6,11 @@ const _Http = getApp().globalData.http,
 	}).format();
 let downCount = {};
 let ids = {};
+
+import {
+	getCustomText
+} from "../../../../utils/customItemType";
+
 Page({
 	data: {
 		list: [],
@@ -22,29 +27,26 @@ Page({
 		this.setData({
 			hidePrice: wx.getStorageSync('hidePrice'),
 		})
-		getApp().globalData.customizedProduct = this.customizedProduct.bind(this);
-	},
-	//修改定制
-	customizedProduct(item) {
-		return new Promise((resolve) => {
-			_Http.basic({
-				"id": 20220924104302,
-				"content": {
-					"sa_shoppingcartid": item.sa_shoppingcartid,
-					"qty": item.qty,
-					"width": item.width || 0,
-					"length": item.length || 0
-				},
-			}).then(res => {
-				console.log("修改定制", res)
-				wx.showToast({
-					title: res.msg != '成功' ? res.msg : '修改成功',
-					icon: "none"
-				});
-				this.getList()
-				resolve(true)
+		getApp().globalData.customizedProduct = (item, custom) => {
+			return new Promise((resolve) => {
+				_Http.basic({
+					"id": 20220924104302,
+					"content": {
+						"sa_shoppingcartid": item.sa_shoppingcartid,
+						"qty": item.qty,
+						...custom
+					},
+				}).then(res => {
+					console.log("修改定制", res)
+					wx.showToast({
+						title: res.msg != '成功' ? res.msg : '修改成功',
+						icon: "none"
+					});
+					this.getList()
+					resolve(true)
+				})
 			})
-		})
+		}
 	},
 	/* 获取列表 */
 	getList() {
@@ -82,6 +84,7 @@ Page({
 						results: [v.sa_shoppingcartid],
 					})
 				}
+				if (v.iscustomsize) v.customText = getCustomText(v);
 				return v
 			});
 			this.setData({

+ 1 - 2
packageA/activity/selectProduct/cart/index.wxml

@@ -21,8 +21,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.length}} / 宽:{{item.width}}
-						<van-icon name="arrow-down" />
+						{{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>
 				</view>

+ 39 - 29
packageA/activity/selectProduct/index.js

@@ -3,7 +3,11 @@ const _Http = getApp().globalData.http,
   file = require("../../../utils/FormatTheAttachment"),
   {
     getItem
-  } = require("./calculatePrice")
+  } = require("./calculatePrice");
+import {
+  getCustomText
+} from "../../../utils/customItemType";
+
 Page({
   data: {
     loading: true,
@@ -32,7 +36,34 @@ Page({
       idname: options.idname || this.data.idname
     });
     this.getList()
-    getApp().globalData.customizedProduct = this.customizedProduct.bind(this);
+    getApp().globalData.customizedProduct = (item, custom) => {
+      item = getItem(getItem(Object.assign(item, custom)), 'newOldPrice', 'oldprice');
+      item.customText = getCustomText(item);
+
+      return new Promise((resolve) => {
+        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;
+        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,
+          resultList
+        })
+        resolve(true)
+      })
+    }
   },
   onShow() {
     this.getCollectCount()
@@ -106,33 +137,6 @@ Page({
     item.pitchOn = false;
     if (item) this.selectComponent("#Custom").onClick(item)
   },
-  customizedProduct(item) {
-    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]),
-        resultList = this.data.resultList,
-        result = this.data.result;
-      if (index != -1) this.data.list[index] = item;
-      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,
-        resultList
-      })
-      resolve(true)
-    })
-  },
   getList(init = false) {
     //init 用于初始化分页
     if (init.detail != undefined) init = init.detail;
@@ -171,6 +175,12 @@ Page({
         if (!value.saledqty) value.saledqty = 0;
         value.maxQty = value.groupqty == 0 ? "" : value.groupqty - value.saledqty; //有限购 设置最高可订购数量
         value.qty = value.orderminqty;
+
+        if (value.iscustomsize) {
+          value.customText = getCustomText(value);
+          value.pitchOn = false;
+        }
+
         return value;
       })
       this.setData({

+ 1 - 1
packageA/activity/selectProduct/index.scss

@@ -107,7 +107,7 @@ page {
 	min-height: 130rpx;
 	position: fixed;
 	bottom: 0;
-	z-index: 999;
+	z-index: 9 !important;
 	display: flex;
 	justify-content: space-between;
 	padding: 0 30rpx;

+ 4 - 3
packageA/activity/selectProduct/index.wxml

@@ -18,9 +18,8 @@
 				<view class="exp">规格:{{item.standards ||" --"}}</view>
 				<view class="exp">型号:{{item.model ||" --"}}</view>
 				<view class="exp"><text style="font-size: 24rpx;font-weight: 600;color: #FF3B30;">{{item.showPrice||item.newPrice}}</text><text style="font-size: 20rpx; text-decoration:line-through; margin-left: 6rpx;">{{item.newOldPrice||item.oldPrice}}</text></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}}
+				<view wx:if="{{item.iscustomsize}}" class="exp" data-item="{{item}}" catch:tap="customization" style="color:#085CDF;">
+					{{item.customText}}
 					<van-icon name="arrow-down" />
 				</view>
 				<view class="exp">特征码:{{item.signaturecode ||" --"}}</view>
@@ -40,6 +39,8 @@
 	<Yl_Empty wx:if="{{list.length==0}}" />
 </Yl_ListBox>
 <footer wx:if="{{butText=='生成订单'}}" id='Footer' disabled='{{!result.length}}' bind:onClick='updateCart' />
+
+
 <!-- 底部 -->
 <block wx:else>
 	<view style="height: 130rpx;" />

+ 32 - 96
packageA/market/detail.js

@@ -1,6 +1,11 @@
 const _Http = getApp().globalData.http;
 let sa_brandid = null,
 	sys_enterpriseid = null;
+
+import {
+	getLabelList
+} from "../../utils/customItemType";
+
 import {
 	fileList
 } from "../../utils/FormatTheAttachment";
@@ -8,6 +13,7 @@ import currency from "../../utils/currency";
 
 Page({
 	data: {
+		labelList: getLabelList(),
 		hidePrice: wx.getStorageSync('hidePrice'),
 		badge: getApp().globalData.collectCount,
 		favoriteCount: getApp().globalData.favoriteCount,
@@ -17,15 +23,11 @@ Page({
 			spec: "", //规格
 			color: "", //颜色
 			material: "", //材质
-			cheek: "", //边框
-			dwidth: 0,
-			dlength: 0,
+			cheek: "" //边框
 		},
 		detail: {
 			spec: ""
 		},
-		cWidth: null, //宽定制方案
-		cLength: null, //长定制方案
 	},
 	onLoad(options) {
 		let data = JSON.parse(options.params);
@@ -74,47 +76,7 @@ Page({
 				loading: false
 			});
 			//是否定制
-			if (init) {
-				if (item.iscustomsize == 1) {
-					let cWidth = null,
-						cLength = null;
-					Promise.all([{
-						"id": "20230707091603",
-						"version": 1,
-						"content": {
-							"sa_sizecustomizedschemeid": item.lengthschemeid,
-							date: Date.now() + 1
-						}
-					}, {
-						"id": "20230707091603",
-						"version": 1,
-						"content": {
-							"sa_sizecustomizedschemeid": item.widthschemeid,
-							date: Date.now() + 2
-						}
-					}].map(v => _Http.basic(v))).then(s => {
-						if (s.some(c => c.msg != '成功')) return wx.showToast({
-							title: '定制方案获取失败',
-							icon: "none"
-						})
-						if (item.lengthschemeid) cLength = s[0].data;
-						if (item.widthschemeid) cWidth = s[1].data;
-						this.setData({
-							cWidth,
-							cLength,
-							"content.dwidth": cWidth.min || 0,
-							"content.dlength": cLength.min || 0,
-						});
-					})
-				} else {
-					this.setData({
-						cWidth: null,
-						cLength: null,
-						"content.dwidth": 0,
-						"content.dlength": 0,
-					});
-				}
-			}
+			if (init && item.iscustomsize == 1) this.selectComponent("#customMade").init(item);
 		})
 	},
 	/* 预览媒体 */
@@ -179,36 +141,13 @@ Page({
 		content[valuename] = (content[valuename] == value.parm) ? "" : value.parm;
 		this.getDetail(valuename == "spec")
 	},
-	/* 定制选项 */
-	customParameter(e) {
-		let {
-			value,
-			valuename
-		} = e.currentTarget.dataset;
-		this.data.content[valuename] = value;
-		this.setData({
-			content: this.data.content
-		})
-	},
-	/* 定制步进器 */
-	cahngeStepper(e) {
-		const name = e.currentTarget.dataset.name,
-			name2 = name == 'cWidth' ? "dwidth" : "dlength",
-			content = this.data.content;
-		if (e.type == 'plus') {
-			content[name2] += 1
-		} else if (e.type == 'minus') {
-			content[name2] -= 1
-		} else {
-			const data = this.data[name];
-			content[name2] = (e.detail.value - 0).toFixed(data.decimalplaces);
-		}
-		let item = this.data[name];
-		if (content[name2] > item.max) content[name2] = item.max;
-		if (content[name2] < item.min) content[name2] = item.min;
-		this.setData({
-			content
-		})
+
+	clickBut() {
+		this.data.detail.tradefield.length >= 2 ? wx.showToast({
+			title: '请选择加入产品领域',
+			icon: "none",
+			duration: 3000
+		}) : this.handleStorage(0);
 	},
 	/* 打开文档 */
 	openDocument(e) {
@@ -266,28 +205,25 @@ Page({
 	/* 加入购物车 */
 	addToShoppingCart(index) {
 		let detail = this.data.detail,
-			content = this.data.content;
-		if (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"
-			})
-		}
+			custom = {
+				length: 0,
+				width: 0
+			};
+		//是否为定制项
+		if (detail.iscustomsize == 1) custom = this.selectComponent("#customMade").getResult(true);
+		if (typeof custom == "boolean") return;
+
+		let content = Object.assign(this.data.content, {
+			sa_brandid,
+			itemid: detail.itemid, //货品id
+			qty: detail.orderminqty, //数量
+			itemno: detail.itemno, //货品编号
+			tradefield: detail.tradefield[index].tradefield,
+		}, custom);
+
 		_Http.basic({
 			"id": 20220924095102,
-			"content": {
-				sa_brandid,
-				"itemid": detail.itemid, //货品id
-				"qty": detail.orderminqty, //数量
-				itemno: detail.itemno, //货品编号
-				tradefield: detail.tradefield[index].tradefield,
-				width: content.dwidth,
-				length: content.dlength
-			},
+			content,
 		}).then(res => {
 			console.log("加入购物车", res)
 			wx.showToast({

+ 1 - 1
packageA/market/detail.json

@@ -1,6 +1,6 @@
 {
   "usingComponents": {
     "van-tag": "@vant/weapp/tag/index",
-    "van-stepper": "@vant/weapp/stepper/index"
+    "customMade": "/pages/index/collect/modules/customMade/index"
   }
 }

+ 1 - 0
packageA/market/detail.scss

@@ -97,6 +97,7 @@ swiper {
   padding-left: 30rpx;
   box-sizing: border-box;
   margin-top: 20rpx;
+  padding-bottom: 20rpx;
 
   .label {
     padding: 20rpx 0;

+ 8 - 42
packageA/market/detail.wxml

@@ -36,7 +36,7 @@
 <view class="model">
     <block wx:if="{{materialRows.length}}">
         <view class="label">
-            基材
+            {{labelList.material}}
         </view>
         <view class="product-box">
             <navigator url="#" class="product {{content.material===item.parm?'active':''}} {{item.flag?'':'disabled'}}" wx:for="{{materialRows}}" wx:key="index" bindtap="changeItemno" data-valuename="material" data-value="{{item}}">{{item.parm}}</navigator>
@@ -45,7 +45,7 @@
 
     <block wx:if="{{colorRows.length}}">
         <view class="label">
-            颜色
+            {{labelList.color}}
         </view>
         <view class="product-box">
             <navigator url="#" class="product {{content.color===item.parm?'active':''}} {{item.flag?'':'disabled'}}" wx:for="{{colorRows}}" wx:key="index" bindtap="changeItemno" data-valuename="color" data-value="{{item}}">{{item.parm}}</navigator>
@@ -54,7 +54,7 @@
 
     <block wx:if="{{cheekRows.length}}">
         <view class="label">
-            边框
+            {{labelList.cheek}}
         </view>
         <view class="product-box">
             <navigator url="#" class="product {{content.cheek===item.parm?'active':''}}  {{item.flag?'':'disabled'}}" wx:for="{{cheekRows}}" wx:key="index" bindtap="changeItemno" data-valuename="cheek" data-value="{{item}}">{{item.parm}}</navigator>
@@ -63,7 +63,7 @@
 
     <block wx:if="{{specRows.length}}">
         <view class="label">
-            尺寸
+            {{labelList.spec}}
         </view>
         <view class="product-box">
             <navigator url="#" class="product {{content.spec===item.parm?'active':''}} {{item.flag?'':'disabled'}}" wx:for="{{specRows}}" wx:key="index" bindtap="changeItemno" data-valuename="spec" data-value="{{item}}">{{item.parm=='custom'?'自定义':item.parm}}</navigator>
@@ -81,45 +81,11 @@
     </block>
 
     <!-- 定制项 -->
-    <view wx:if="{{detail.iscustomsize==1}}" style="padding-bottom: 20rpx;">
-        <view class="label">
-            定制
+    <customMade id="customMade">
+        <view slot='head' class="label">
+            {{labelList.custom}}
         </view>
-        <block wx:if="{{cWidth}}">
-            <view class="label custom" wx:if="{{cWidth.type == '自定义'}}">
-                <view style="display: flex; align-items: center;">
-                    <view style="margin-right: 10rpx;">宽:</view>
-                    <van-stepper plus-class='plus-class' value="{{ content.dwidth }}" input-width="60px" min="{{cWidth.min}}" max="{{cWidth.max}}" decimal-length="{{ cWidth.decimalplaces }}" data-name="cWidth" bind:plus='cahngeStepper' bind:blur='cahngeStepper' bind:minus='cahngeStepper' />
-                    <view class="explain">{{cWidth.min+'mm ~ '+ cWidth.max}}mm,<text wx:if="{{cWidth.decimalplaces}}">保留{{cWidth.decimalplaces}}位小数</text><text wx:else>不保留小数</text></view>
-                </view>
-            </view>
-            <view class="label custom" wx:else>
-                <view style="display: flex;">
-                    <view style="margin-right: 20rpx;margin-top: 30rpx;">宽:</view>
-                    <view class="product-box">
-                        <navigator url="#" class="product {{content.dwidth===item.num?'active':''}}" wx:for="{{cWidth.rowsdetail}}" wx:key="rowindex" bindtap="customParameter" data-valuename="dwidth" data-value="{{item.num}}">{{item.num}}</navigator>
-                    </view>
-                </view>
-            </view>
-        </block>
-        <block wx:if="{{cLength}}">
-            <view class="label custom" wx:if="{{cLength.type == '自定义'}}">
-                <view style="display: flex; align-items: center;">
-                    <view style="margin-right: 10rpx;">长:</view>
-                    <van-stepper plus-class='plus-class' value="{{ content.dlength  }}" input-width="60px" min="{{cLength.min}}" max="{{cLength.max}}" decimal-length="{{ cLength.decimalplaces }}" data-name="cLength" bind:plus='cahngeStepper' bind:blur='cahngeStepper' bind:minus='cahngeStepper' />
-                    <view class="explain">{{cLength.min+'mm ~ '+ cLength.max}}mm,<text wx:if="{{cLength.decimalplaces}}">保留{{cLength.decimalplaces}}位小数</text><text wx:else>不保留小数</text></view>
-                </view>
-            </view>
-            <view class="label custom" wx:else>
-                <view style="display: flex;">
-                    <view style="margin-right: 20rpx;margin-top: 30rpx;">长:</view>
-                    <view class="product-box">
-                        <navigator url="#" class="product {{content.dlength===item.num?'active':''}}" wx:for="{{cLength.rowsdetail}}" wx:key="rowindex" bindtap="customParameter" data-valuename="dlength" data-value="{{item.num}}">{{item.num}}</navigator>
-                    </view>
-                </view>
-            </view>
-        </block>
-    </view>
+    </customMade>
 </view>
 <van-tabs custom-class='tabs' title-active-color='var(--assist)' color='var(--assist)'>
     <van-tab title="商品简介">

+ 29 - 26
pages/index/collect/index.js

@@ -5,6 +5,9 @@ const _Http = getApp().globalData.http,
 		precision: 2
 	}).format();
 let downCount = {};
+import {
+	getCustomText
+} from "../../../utils/customItemType";
 Component({
 	options: {
 		addGlobalClass: true,
@@ -16,37 +19,36 @@ Component({
 		sa_brandid: null, //当前选中品牌id
 		classList: [], //生成订单时所选
 		sum: 0, //价格合
-		allBrandList: []
+		allBrandList: [],
+		hidePrice: wx.getStorageSync('hidePrice'),
 	},
 	methods: {
 		init() {
 			this.getList()
-			this.setData({
-				hidePrice: wx.getStorageSync('hidePrice'),
-			})
-			getApp().globalData.customizedProduct = this.customizedProduct.bind(this);
-			return true;
-		},
-		customizedProduct(item) {
-			return new Promise((resolve) => {
-				_Http.basic({
-					"id": 20220924104302,
-					"content": {
-						"sa_shoppingcartid": item.sa_shoppingcartid,
-						"qty": item.qty,
-						"width": item.width || 0,
-						"length": item.length || 0
-					},
-				}).then(res => {
-					console.log("修改定制", res)
-					wx.showToast({
-						title: res.msg != '成功' ? res.msg : '修改成功',
-						icon: "none"
-					});
-					this.getList()
-					resolve(true)
+			getApp().globalData.customizedProduct = (item, custom) => {
+				return new Promise((resolve) => {
+					wx.showLoading({
+						title: '修改中...',
+					})
+					_Http.basic({
+						"id": 20220924104302,
+						"content": {
+							"sa_shoppingcartid": item.sa_shoppingcartid,
+							"qty": item.qty,
+							...custom
+						},
+					}).then(res => {
+						console.log("修改定制", res)
+						wx.showToast({
+							title: res.msg != '成功' ? res.msg : '修改成功',
+							icon: "none"
+						});
+						this.getList()
+						resolve(true)
+					})
 				})
-			})
+			}
+			return true;
 		},
 		/* 获取列表 */
 		getList() {
@@ -83,6 +85,7 @@ Component({
 							results: [v.sa_shoppingcartid],
 						})
 					}
+					if (v.iscustomsize) v.customText = getCustomText(v);
 					return v
 				});
 				this.setData({

+ 3 - 3
pages/index/collect/index.wxml

@@ -16,12 +16,12 @@
 						<van-checkbox shape='square' disabled="{{sa_brandid && sa_brandid!=item.sa_brandid}}" icon-size='24rpx' value="{{ decide.checked(item.sa_shoppingcartid,results) }}" />
 					</view>
 					<view class="exp">编号:{{item.itemno}}</view>
-					<!-- <view class="exp">规格:{{item.spec ||" --"}}</view> -->
 					<view class="exp">型号:{{item.model ||" --"}}</view>
 					<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.length}} / 宽:{{item.width}} <van-icon name="arrow-down" />
+						{{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>
 				</view>
@@ -36,7 +36,7 @@
 		<view slot="right" class="cell-right">删 除</view>
 	</van-swipe-cell>
 	<Yl_Empty wx:if="{{list.length === 0}}" />
-	<view style="height: 200px;" />
+	<view style="height: 120px;" />
 </Yl_ListBox>
 <view class="footer-box">
 	<view class="footer">

+ 21 - 68
pages/index/collect/modules/custom.js

@@ -1,4 +1,5 @@
 const _Http = getApp().globalData.http;
+
 Component({
   properties: {
     isOldPrice: {
@@ -11,53 +12,35 @@ Component({
   },
   methods: {
     onClick(item) {
-      console.log(item)
       if (this.data.product != null && item.itemid == this.data.product.itemid) return this.setData({
         show: true
       })
       wx.showLoading({
         title: '获取定制方案中..',
       })
-      Promise.all([{
-        "id": "20230707091603",
-        "version": 1,
-        "content": {
-          "sa_sizecustomizedschemeid": item.lengthschemeid,
-          date: Date.now()
-        }
-      }, {
-        "id": "20230707091603",
-        "version": 1,
-        "content": {
-          "sa_sizecustomizedschemeid": item.widthschemeid,
-          date: Date.now() + 2
-        }
-      }].map(v => _Http.basic(v))).then(s => {
-        console.log("获取定制方案", s)
+      this.selectComponent("#customMade").init(item).then(res => {
         wx.hideLoading();
-        if (s.some(c => c.msg != '成功')) return wx.showToast({
-          title: '定制方案获取失败',
-          icon: "none"
-        })
-        s[0].data.name = '长度'
-        if (!item.length) item.length = s[0].data.type == '可选' ? s[0].data.rowsdetail[0].num : s[0].data.min - 0;
-        console.log("长度id", item.lengthschemeid, '长:' + item.length, '结果:', s[0].data.sa_sizecustomizedschemeid)
-        s[1].data.name = '宽度'
-        if (!item.width) item.width = s[1].data.type == '可选' ? s[1].data.rowsdetail[0].num : s[1].data.min - 0;
-        console.log("宽度id", item.widthschemeid, '宽:' + item.width, '结果:', s[1].data.sa_sizecustomizedschemeid)
-        this.setData({
-          show: true,
-          arr: [s[0].data, s[1].data],
-          product: item
-        });
-      });
-
+        if (res) {
+          this.setData({
+            show: true
+          })
+        } else {
+          wx.showToast({
+            title: '未获取到定制方案',
+            icon: "none"
+          })
+        }
+      })
       this.selectComponent("#Dialog").data.beforeClose = (action) => new Promise((resolve) => {
         if (action === 'confirm') {
-          //getItem(this.data.product, this.data.isOldPrice ? "oldprice" : "")
-          getApp().globalData.customizedProduct(this.data.product).then(res => {
-            resolve(true);
-          })
+          let custom = {
+            length: 0,
+            width: 0
+          };
+          //是否为定制项
+          custom = this.selectComponent("#customMade").getResult(true);
+          if (typeof custom == "boolean") return resolve(false);
+          getApp().globalData.customizedProduct(item, custom).then(res => resolve(true))
         } else {
           resolve(false);
           this.setData({
@@ -65,36 +48,6 @@ Component({
           })
         }
       });
-    },
-    selected(e) {
-      const {
-        name,
-        num
-      } = e.currentTarget.dataset;
-      this.data.product[name] = num;
-      this.setData({
-        product: this.data.product
-      })
-    },
-    /* 定制步进器 */
-    cahngeStepper(e) {
-      const {
-        name,
-        item
-      } = e.currentTarget.dataset,
-        product = this.data.product;
-      if (e.type == 'plus') {
-        product[name] += 1
-      } else if (e.type == 'minus') {
-        product[name] -= 1
-      } else {
-        product[name] = (e.detail.value - 0).toFixed(product.decimalplaces);
-      }
-      if (product[name] > item.max) product[name] = item.max;
-      if (product[name] < item.min) product[name] = item.min;
-      this.setData({
-        product
-      })
     }
   }
 })

+ 2 - 1
pages/index/collect/modules/custom.json

@@ -2,6 +2,7 @@
   "component": true,
   "usingComponents": {
     "van-dialog": "@vant/weapp/dialog/index",
-    "van-stepper": "@vant/weapp/stepper/index"
+    "van-stepper": "@vant/weapp/stepper/index",
+    "customMade": "./customMade/index"
   }
 }

+ 11 - 39
pages/index/collect/modules/custom.scss

@@ -1,44 +1,16 @@
-.box {
-	width: 100%;
-	padding: 0 30rpx 20rpx;
-	box-sizing: border-box;
+.external-custom-stepper-box {
+	display: block !important;
+}
 
-	.item {
-		display: flex;
-		margin-top: 20rpx;
+.external-explain {
+	margin: 10rpx 0 !important;
+}
 
-		.label {
-			font-weight: 700;
-		}
+.external-custom-option {
+	font-size: 24rpx;
+}
 
-		.selectable {
-			display: flex;
-			flex-wrap: wrap;
 
-			.num {
-				border: 1px solid #ddd;
-				margin-right: 8rpx;
-				padding: 4rpx 15rpx;
-				border-radius: 8rpx;
-				font-size: 26rpx;
-				margin-bottom: 10rpx;
-			}
-
-			.active {
-				border: 1px solid #085CDF;
-				color: #085CDF;
-				font-weight: 700;
-			}
-		}
-
-		.stepper {
-
-			.explain {
-				font-size: 24rpx;
-				color: #999;
-				margin-top: 6rpx;
-			}
-		}
-
-	}
+.external-active {
+	color: #085CDF;
 }

+ 2 - 15
pages/index/collect/modules/custom.wxml

@@ -1,18 +1,5 @@
 <van-dialog id="Dialog" use-slot title="定制" show="{{ show }}" asyncClose confirm-button-color='#085CDF' show-cancel-button>
-	<view class="box">
-		<view class="item" wx:for="{{arr}}" wx:key="name">
-			<view class="label">
-				{{item.name}}:
-			</view>
-			<view class="selectable" wx:if="{{item.type=='可选'}}">
-				<view class="num {{product[item.name=='宽度'?'width':'length']==it.num?'active':''}}" wx:for="{{item.rowsdetail}}" wx:for-item='it' wx:for-index='i' wx:key="rowno" data-name="{{item.name=='宽度'?'width':'length'}}" data-num="{{it.num}}" catch:tap='selected'>
-					{{it.num}}
-				</view>
-			</view>
-			<view class="stepper" wx:else>
-				<van-stepper value="{{ product[ item.name=='宽度'?'width':'length'] }}" input-width="60px" min="{{item.min}}" max="{{item.max}}" decimal-length="{{ item.decimalplaces }}" data-item="{{item}}" data-name="{{ item.name=='宽度'?'width':'length' }}" bind:plus='cahngeStepper' bind:blur='cahngeStepper' bind:minus='cahngeStepper' />
-				<view class="explain">{{item.min+'mm ~ '+ item.max}}mm,<text wx:if="{{item.decimalplaces}}">保留{{item.decimalplaces}}位小数</text><text wx:else>不保留小数</text></view>
-			</view>
-		</view>
+	<view style="padding: 20rpx;box-sizing: border-box;">
+		<customMade id="customMade" external-custom-stepper-box='external-custom-stepper-box' external-explain='external-explain' external-active='external-active' external-custom-option='external-custom-option' />
 	</view>
 </van-dialog>

+ 89 - 0
pages/index/collect/modules/customMade/index.js

@@ -0,0 +1,89 @@
+import {
+  getCustomItems
+} from "../../../../../utils/customItemType";
+
+Component({
+  properties: {
+    topHei: {
+      type: String,
+      value: "20rpx"
+    },
+    onChange: {
+      type: Function
+    }
+  },
+  options: {
+    multipleSlots: true
+  },
+  externalClasses: ["external-custom-box", "external-custom-label", "external-custom-stepper-box", "external-explain", "external-active", "external-custom-option"],
+  data: {
+    list: []
+  },
+  methods: {
+    init(data) {
+      return new Promise((resolve) => {
+        getCustomItems(data).then(list => {
+          this.setData({
+            list
+          });
+          this.getResult();
+          resolve(list.length);
+        });
+      });
+    },
+    onOption(e) {
+      const {
+        index,
+        value
+      } = e.currentTarget.dataset;
+      if (this.data.list[index].value == value) return;
+      this.setData({
+        [`list[${index}].value`]: value
+      });
+      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
+    },
+    /* 定制步进器 */
+    changeStepper(e) {
+      const {
+        index,
+        item
+      } = e.currentTarget.dataset;
+      if (!item.value) item.value = 0;
+      if (e.type == 'plus') {
+        item.value += 1
+      } else if (e.type == 'minus') {
+        item.value -= 1
+      } else {
+        item.value = (e.detail.value - 0).toFixed(item.decimalplaces);
+      }
+      item.value = item.value - 0;
+      if (item.value > item.max) item.value = item.max;
+      if (item.value < item.min) item.value = item.min;
+      this.setData({
+        [`list[${index}]`]: item
+      })
+      this.getResult();
+    },
+  }
+})

+ 6 - 0
pages/index/collect/modules/customMade/index.json

@@ -0,0 +1,6 @@
+{
+  "component": true,
+  "usingComponents": {
+    "van-stepper": "@vant/weapp/stepper/index"
+  }
+}

+ 39 - 0
pages/index/collect/modules/customMade/index.scss

@@ -0,0 +1,39 @@
+.custom {
+	display: flex;
+	flex-wrap: wrap;
+	margin-bottom: 6rpx;
+
+	&-label {
+		font-size: 28rpx;
+		font-weight: bold;
+		color: #333333;
+		margin-top: 4rpx;
+	}
+
+	&-option {
+		background-color: #F4F5F7;
+		padding: 8rpx 20rpx;
+		border-radius: 8rpx;
+		overflow: hidden;
+		margin-right: 12rpx;
+		margin-bottom: 14rpx;
+	}
+
+	&-option:last-child {
+		margin-right: 0;
+	}
+
+	.active {
+		background: #E7EEFF !important;
+	}
+
+	.stepper-box {
+		display: flex;
+		align-items: center;
+	}
+
+	.explain {
+		font-size: 22rpx;
+		color: #333;
+	}
+}

+ 19 - 0
pages/index/collect/modules/customMade/index.wxml

@@ -0,0 +1,19 @@
+<view hidden="{{!list.length}}">
+	<slot name='head' />
+	<view style="height: {{topHei}};" />
+</view>
+<view class="custom external-custom-box" wx:for="{{list}}" wx:key="sa_sizecustomizedschemeid">
+	<view class="custom-label external-custom-label">
+		{{item.label}}:
+	</view>
+	<!-- 可选项 -->
+	<block wx:if="{{item.type=='可选'}}">
+		<navigator url="#" class="custom-option {{it.num == item.value?'active external-active':''}} external-custom-option" data-value="{{it.num}}" data-index="{{index}}" wx:for="{{item.rowsdetail}}" wx:for-item="it" wx:for-index="i" wx:key="sa_sizeschemedetailid" bindtap="onOption">
+			{{it.num}}
+		</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' />
+		<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>

+ 7 - 0
project.private.config.json

@@ -78,6 +78,13 @@
           "query": "",
           "launchMode": "default",
           "scene": null
+        },
+        {
+          "name": "商品详情",
+          "pathName": "packageA/market/detail",
+          "query": "params=%7B%22sa_itemgroupid%22%3A6009%2C%22sa_brandid%22%3A47%7D",
+          "launchMode": "default",
+          "scene": null
         }
       ]
     }

+ 20 - 12
select/product/index.js

@@ -1,6 +1,12 @@
 const _Http = getApp().globalData.http,
 	file = require("../../utils/FormatTheAttachment");
 import currency from "../../utils/currency";
+
+import {
+	getCustomText
+} from "../../utils/customItemType";
+
+
 Page({
 	data: {
 		hidePrice: wx.getStorageSync('hidePrice'),
@@ -29,19 +35,20 @@ Page({
 			newPrice: options.newprice || "price", //红色价格
 		});
 		this.getList();
-		getApp().globalData.customizedProduct = this.customizedProduct.bind(this);
-	},
-	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
+		getApp().globalData.customizedProduct = (item, custom) => {
+			return new Promise((resolve) => {
+				item = Object.assign(item, custom)
+				item.customText = getCustomText(item);
+				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)
 			})
-			resolve(true)
-		})
+		}
 	},
 	getList(init = false) {
 		//init 用于初始化分页
@@ -74,6 +81,7 @@ Page({
 				value.qty = value.orderminqty;
 				value.width = 0;
 				value.length = 0;
+				if (value.iscustomsize) value.customText = getCustomText(value);
 				return value;
 			})
 			this.setData({

+ 1 - 1
select/product/index.wxml

@@ -34,7 +34,7 @@
                     规格:{{item.standards||' --'}}
                 </view>
                 <view wx:if="{{item.iscustomsize}}" class="subfield line-1" data-item="{{item}}" catch:tap="customization" style="color:#085CDF;">
-                    长:{{item.length}} / 宽:{{item.width}}
+                    {{item.customText}}
                     <van-icon name="arrow-down" />
                 </view>
                 <view class="price line-1">

+ 6 - 0
utils/Http.js

@@ -4,9 +4,15 @@ class HTTP {
 		if (ENV === 'release') { // 正式版
 			this.baseUrl = "https://lsa.cnyunl.com";
 		} else {
+<<<<<<< HEAD
 					// this.baseUrl = "https://lsa.cnyunl.com";
 					this.baseUrl = "http://61.164.207.46:8200";
 					// this.baseUrl = "https://cucu.cnyunl.com:8079";
+=======
+			// this.baseUrl = "https://lsa.cnyunl.com";
+			this.baseUrl = "http://61.164.207.46:8300";
+			// this.baseUrl = "http://61.164.207.46:8200";
+>>>>>>> 新功能开发/定制项
 		}
 		console.log("接口地址:", this.baseUrl)
 	}

+ 68 - 0
utils/customItemType.js

@@ -0,0 +1,68 @@
+function getLabelList() {
+	let siteCustomLabel = {
+		"default": {
+			width: "宽",
+			length: "长",
+			cheek: "边框",
+			color: "颜色",
+			material: "基材",
+			spec: "尺寸",
+			custom: "定制"
+		},
+		"DLB": {
+			width: "宽",
+			length: "长",
+			cheek: "工艺",
+			color: "颜色",
+			material: "选项",
+			spec: "尺寸",
+			custom: "定制"
+		}
+	};
+	return siteCustomLabel[wx.getStorageSync('siteP').siteid] || siteCustomLabel.default
+}
+
+function getCustomItems(data) {
+	const _Http = getApp().globalData.http;
+	let labelList = getLabelList(),
+		httpList = [];
+	for (const key in labelList) {
+		const name = key + 'schemeid';
+		if (data[name]) httpList.push({
+			sa_sizecustomizedschemeid: data[name],
+			date: Date.now() + 1,
+			label: labelList[key],
+			value: data[key] || "",
+			key: key,
+			name
+		})
+	};
+
+	return new Promise((resolve, reject) => {
+		if (!httpList.length) return resolve([]);
+		Promise.all(httpList.map(v => _Http.basic({
+			"id": "20230707091603",
+			"version": 1,
+			content: v
+		}))).then(res => resolve(res.map((v, i) => {
+			v.data = Object.assign(v.data, httpList[i])
+			return v
+		}).filter(v => v.msg == '成功').map(v => v.data)))
+	})
+}
+
+function getCustomText(data) {
+	let labelList = getLabelList(),
+		customText = [];
+	for (const key in labelList) {
+		const name = key + 'schemeid';
+		if (data[name]) customText.push(`${labelList[key]}:${data[key]||'定制'}`)
+	};
+	return customText
+}
+
+module.exports = {
+	getLabelList,
+	getCustomItems,
+	getCustomText
+}