xiaohaizhao 1 rok temu
rodzic
commit
5c33597668
1 zmienionych plików z 15 dodań i 5 usunięć
  1. 15 5
      packageA/market/detail.js

+ 15 - 5
packageA/market/detail.js

@@ -86,16 +86,26 @@ Page({
 				materialRows: res.data.materialRows,
 				colorRows: res.data.colorRows,
 			};
-			['spec', 'cheek', 'material', 'color'].forEach(key => {
-				let list = ros[key + 'Rows'].filter(v => v.flag);
-				if (list.length == 1) content[key] = list[0].parm
-			})
+
+			let obj = {},
+				auto = true;
+			['spec', 'cheek', 'material', 'color'].forEach(key => obj[key] = ros[key + 'Rows'].filter(v => v.flag))
+
+			for (const key in obj) {
+				if (obj[key].length > 1) auto = false;
+			}
+			if (auto) {
+				for (const key in obj) {
+					if (obj[key].length) content[key] = obj[key][0].parm;
+				}
+			}
 			this.setData({
 				content,
 				detail: item,
 				...ros,
 				loading: false,
-				itemCount: ['specRows', 'cheekRows', 'materialRows', 'colorRows'].filter(v => res.data[v].length).length
+				itemCount: ['specRows', 'cheekRows', 'materialRows', 'colorRows'].filter(v => res.data[v].length).length,
+				selectCount: ['cheek', 'color', 'material', 'spec'].filter(v => content[v].length).length
 			});
 			//是否定制
 			if (getCustom && item.iscustomsize == 1) this.selectComponent("#customMade").init(item);