Browse Source

收藏夹定制品加前缀

xiaohaizhao 1 year ago
parent
commit
e7eaa99d21

+ 13 - 4
packageA/favorites/index.js

@@ -28,7 +28,15 @@ Page({
   },
   onShow() {
     //修改定制项产品
-    getApp().globalData.customizedProduct = item => {
+    getApp().globalData.customizedProduct = (item, custom) => {
+      let obj = {
+        "width": 0,
+        "length": 0,
+      }
+      for (const key in custom) {
+        let name = key.replace("favorites", '')
+        obj[name] = custom[key]
+      }
       return new Promise((resolve) => {
         _Http.basic({
           "id": 20231121143403,
@@ -37,8 +45,8 @@ Page({
             "sa_favoritesid": item.sa_favoritesid,
             "favoritesqty": item.favoritesqty,
             "qty": item.favoritesqty,
-            "width": item.width || 0,
-            "length": item.length || 0,
+            ...obj,
+            ...custom,
             "iscollection": true
           },
         }).then(res => {
@@ -77,7 +85,7 @@ Page({
       this.setData({
         list: res.data.map(v => {
           v.showPrice = CNY(v.gradeprice)
-          if (v.iscustomsize) v.customText = getCustomText(v);
+          if (v.iscustomsize) v.customText = getCustomText(v, 'favorites');
           return v
         })
       });
@@ -162,6 +170,7 @@ Page({
             "sa_orderitemsid": 0,
             "itemid": v.itemid,
             "qty": v.favoritesqty,
+            sa_brandid: this.data.sa_brandid,
             width: v.favoriteswidth || 0,
             length: v.favoriteslength || 0,
           }

+ 1 - 1
packageA/favorites/index.wxml

@@ -1,5 +1,5 @@
 <view class="head" />
-<custom id="Custom" />
+<custom id="Custom" prefix='favorites' />
 <Yl_ListBox id='ListBox' bind:getlist='getList'>
 	<van-swipe-cell wx:for="{{list}}" wx:key="itemid" id="swipe-cell" right-width="{{ 65 }}" async-close data-item="{{item}}" bind:close="deteleItem">
 		<view url="#" class="item-box">

+ 9 - 6
packageA/market/detail.js

@@ -79,7 +79,7 @@ Page({
 				itemCount: ['specRows', 'cheekRows', 'materialRows', 'colorRows'].filter(v => res.data[v].length).length
 			});
 			//是否定制
-			if (init && item.iscustomsize == 1) this.selectComponent("#customMade").init(item);
+			if (item.iscustomsize == 1) this.selectComponent("#customMade").init(item);
 		})
 	},
 	/* 预览媒体 */
@@ -142,7 +142,6 @@ Page({
 			mask: true
 		})
 		content[valuename] = (content[valuename] == value.parm) ? "" : value.parm;
-		console.log(content)
 		this.setData({
 			selectCount: ['cheek', 'color', 'material', 'spec'].filter(v => content[v].length).length
 		})
@@ -219,7 +218,6 @@ Page({
 		//是否为定制项
 		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
@@ -247,11 +245,15 @@ Page({
 		let detail = this.data.detail,
 			iscollection = detail.iscollection == 1 ? false : true,
 			custom = {
+				width: 0,
 				length: 0,
-				width: 0
-			};
+			},
+			favorites = {};
 		//是否为定制项
 		if (detail.iscustomsize == 1) custom = this.selectComponent("#customMade").getResult(true);
+		for (const key in custom) {
+			favorites['favorites' + key] = custom[key]
+		}
 		if (typeof custom == "boolean") return;
 		_Http.basic({
 			"id": 20231121143403,
@@ -259,7 +261,8 @@ Page({
 				"itemid": this.data.detail.itemid, //货品id
 				"qty": detail.orderminqty, //数量
 				...custom,
-				iscollection
+				iscollection,
+				...favorites
 			},
 		}).then(res => {
 			console.log(iscollection + "收藏夹", res)

+ 5 - 1
pages/index/collect/modules/custom.js

@@ -4,6 +4,10 @@ Component({
   properties: {
     isOldPrice: {
       type: Boolean
+    },
+    prefix: {
+      type: String,
+      value: ""
     }
   },
   data: {
@@ -18,7 +22,7 @@ Component({
       wx.showLoading({
         title: '获取定制方案中..',
       })
-      this.selectComponent("#customMade").init(item).then(res => {
+      this.selectComponent("#customMade").init(item, this.data.prefix).then(res => {
         wx.hideLoading();
         if (res) {
           this.setData({

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

@@ -20,9 +20,9 @@ Component({
     list: []
   },
   methods: {
-    init(data) {
+    init(data, prefix = '') {
       return new Promise((resolve) => {
-        getCustomItems(data).then(list => {
+        getCustomItems(data, prefix).then(list => {
           this.setData({
             list
           });

+ 5 - 5
utils/customItemType.js

@@ -22,7 +22,7 @@ function getLabelList() {
 	return siteCustomLabel[wx.getStorageSync('siteP').siteid] || siteCustomLabel.default
 }
 
-function getCustomItems(data) {
+function getCustomItems(data, prefix = '') {
 	const _Http = getApp().globalData.http;
 	let labelList = getLabelList(),
 		httpList = [];
@@ -32,8 +32,8 @@ function getCustomItems(data) {
 			sa_sizecustomizedschemeid: data[name],
 			date: Date.now() + 1,
 			label: labelList[key],
-			value: data[key] || "",
-			key: key,
+			value: data[prefix + key] || "",
+			key: prefix + key,
 			name
 		})
 	};
@@ -51,12 +51,12 @@ function getCustomItems(data) {
 	})
 }
 
-function getCustomText(data) {
+function getCustomText(data, prefix = '') {
 	let labelList = getLabelList(),
 		customText = [];
 	for (const key in labelList) {
 		const name = key + 'schemeid';
-		if (data[name]) customText.push(`${labelList[key]}:${data[key]||'定制'}`)
+		if (data[name]) customText.push(`${labelList[key]}:${data[prefix+key]||'定制'}`)
 	};
 	return customText
 }