Browse Source

Merge refs/heads/测试 into refs/heads/莱斯奥/2.6.0

xiaohaizhao 9 months ago
parent
commit
219acfb130
2 changed files with 39 additions and 28 deletions
  1. 33 26
      packageA/market/detail.js
  2. 6 2
      pages/index/collect/modules/customMade/index.js

+ 33 - 26
packageA/market/detail.js

@@ -27,8 +27,7 @@ Page({
 			spec: ""
 		},
 		privacyFieldC: [],
-		isShowFavorites: false,
-		UniqueLine: false
+		isShowFavorites: false
 	},
 	onLoad(options) {
 		let data = JSON.parse(options.params);
@@ -50,10 +49,9 @@ Page({
 		}
 	},
 	/* 获取详情 */
-	getDetail(init = false, getCustom = true) {
+	getDetail(reset = false) {
 		let content = this.data.content;
 		if (sys_enterpriseid) content.sys_enterpriseid = sys_enterpriseid;
-		if (this.data.UniqueLine)['spec', 'cheek', 'material', 'color'].forEach(key => content[key] = '')
 		_Http.basic({
 			"id": "20221223165503",
 			content
@@ -84,36 +82,41 @@ Page({
 				materialRows: res.data.materialRows,
 				colorRows: res.data.colorRows,
 			};
-
 			let obj = {},
-				auto = true,
-				UniqueLine = true;
+				isRecursion = false;
 			res.data.customschemeItems.map(v => v.value).forEach(key => obj[key] = row[key + 'Rows'].filter(v => v.flag))
 			for (const key in obj) {
-				if (obj[key].length > 1) {
-					auto = false
-					UniqueLine = false;
-				}
-			}
-			if (auto) {
-				for (const key in obj) {
-					if (obj[key].length) content[key] = obj[key][0].parm;
+				if (obj[key].length == 1) {
+					content[key] = obj[key][0].parm;
+					isRecursion = true;
 				}
 			}
-
+			let itemCount = res.data.customschemeItems.length,
+				selectCount = ['cheek', 'color', 'material', 'spec'].filter(v => content[v].length).length;
 			this.setData({
 				content,
 				detail: item,
 				row,
 				customschemeItems: res.data.customschemeItems,
 				loading: false,
-				itemCount: ['specRows', 'cheekRows', 'materialRows', 'colorRows'].filter(v => res.data[v].length).length,
-				selectCount: ['cheek', 'color', 'material', 'spec'].filter(v => content[v].length).length,
-				UniqueLine
+				itemCount,
+				selectCount
 			});
-			console.log("itmes", this.data.itmes)
+			if (!reset && isRecursion) {
+				wx.showLoading({
+					title: '加载中...',
+					mask: true
+				})
+				this.getDetail(true)
+			}
 			//是否定制
-			if (getCustom && item.iscustomsize == 1) this.selectComponent("#customMade").init(item);
+			if (itemCount == selectCount && item.iscustomsize == 1) {
+				this.selectComponent("#customMade").init(item);
+			} else {
+				this.selectComponent("#customMade").setData({
+					list: []
+				});
+			}
 		})
 	},
 	/* 预览媒体 */
@@ -175,12 +178,16 @@ Page({
 			title: '加载中...',
 			mask: true
 		})
-		// UniqueLine
-		content[valuename] = (content[valuename] == value.parm) ? "" : value.parm;
+		if (content[valuename] == value.parm && this.data.row[valuename + 'Rows'].filter(v => v.flag).length == 1) {
+			['spec', 'cheek', 'material', 'color'].forEach(key => content[key] = '')
+		} else {
+			content[valuename] = (content[valuename] == value.parm) ? "" : value.parm;
+		}
 		this.setData({
-			selectCount: ['cheek', 'color', 'material', 'spec'].filter(v => content[v].length).length
+			selectCount: ['cheek', 'color', 'material', 'spec'].filter(v => content[v].length).length,
+			content
 		})
-		this.getDetail(valuename == "spec")
+		this.getDetail()
 	},
 	/* 打开文档 */
 	openDocument(e) {
@@ -369,7 +376,7 @@ Page({
 			favoriteCount: getApp().globalData.favoriteCount,
 			badge: getApp().globalData.collectCount,
 		})
-		this.getDetail(true, this.data.loading);
+		this.getDetail(true);
 	},
 	/* 步进器输入框失去焦点 */
 	inputBlur(e) {

+ 6 - 2
pages/index/collect/modules/customMade/index.js

@@ -23,9 +23,13 @@ Component({
     init(data, prefix = '') {
       return new Promise((resolve) => {
         getCustomItems(data, prefix).then(list => {
-          console.log("list", list)
           this.setData({
-            list
+            list: list.map(v => {
+              if (v.type == '可选' && v.rowsdetail.length == 1) {
+                v.value = v.rowsdetail[0].num
+              }
+              return v
+            })
           });
           this.getResult();
           resolve(list.length);