Переглянути джерело

收藏夹购物车生成订单根据领域选择对应账户

xiaohaizhao 1 рік тому
батько
коміт
aade1b7845
2 змінених файлів з 160 додано та 66 видалено
  1. 80 33
      packageA/favorites/index.js
  2. 80 33
      pages/index/collect/index.js

+ 80 - 33
packageA/favorites/index.js

@@ -18,6 +18,33 @@ Page({
   },
   onLoad() {
     this.getList()
+
+    let domainrelatedaccounts = wx.getStorageSync('domainrelatedaccounts');
+    if (domainrelatedaccounts.length) {
+      this.setData({
+        domainrelatedaccounts
+      })
+    } else {
+      _Http.basic({
+        "classname": "sysmanage.develop.optiontype.optiontype",
+        "method": "optiontypeselect",
+        "content": {
+          "pageNumber": 1,
+          "pageSize": 9999,
+          "typename": "domainrelatedaccounts"
+        }
+      }).then(res => {
+        console.log("查询领域对应列表", res)
+        if (res.msg == '成功' && res.data.length) {
+          domainrelatedaccounts = res.data;
+          wx.setStorageSync('domainrelatedaccounts', domainrelatedaccounts)
+          this.setData({
+            domainrelatedaccounts
+          })
+        }
+      })
+    }
+    console.log("domainrelatedaccounts", domainrelatedaccounts)
   },
   /* 打开设置定制项 */
   customization(e) {
@@ -159,44 +186,64 @@ Page({
     wx.showLoading({
       title: '生成中...',
     })
+
+    let tradefield = this.data.domainrelatedaccounts.find(v => v.value == data.type);
     _Http.basic({
-      "id": 20221128183202,
+      "id": 20221008134803,
+      "version": 1,
       "content": {
-        istool: 0,
-        type: "标准订单",
-        "tradefield": data.type, //必选
-        sa_brandid: this.data.sa_brandid,
-        "items": data.list.map(v => {
-          return {
-            "sa_orderitemsid": 0,
-            "itemid": v.itemid,
-            "qty": v.favoritesqty,
-            "sa_brandid": v.brand.length ? v.brand[0].sa_brandid : this.data.sa_brandid || 0,
-            width: v.favoriteswidth || 0,
-            length: v.favoriteslength || 0,
-          }
-        })
+        "pageNumber": 1,
+        "pageTotal": 1,
+        "pageSize": 9999,
+        "where": {
+          "condition": "",
+          "isused": 1,
+          "isnotspecialfund": 0, //是否专用
+        },
       }
-    }).then(res => {
-      wx.hideLoading()
-      console.log("转化订单", res)
-      if (res.msg != '成功') return wx.showToast({
-        title: res.msg,
-        icon: "none"
-      });
-      this.setData({
-        results: [],
-        isAll: false
-      })
-      wx.showModal({
-        title: '提示',
-        content: '生成成功!是否立即前往',
-        complete: (s) => {
-          if (s.confirm) wx.navigateTo({
-            url: '/packageA/orderForm/detail?id=' + res.data.sa_orderid,
+    }).then(acc => {
+      console.log("账户列表", acc)
+      let list = acc.data.filter(v => tradefield.subvalues.some(s => s == v.sa_accountclassid))
+      _Http.basic({
+        "id": 20221128183202,
+        "content": {
+          istool: 0,
+          type: "标准订单",
+          "tradefield": data.type, //必选
+          sa_brandid: this.data.sa_brandid,
+          sa_accountclassid: list.length ? list[0].sa_accountclassid : 0,
+          "items": data.list.map(v => {
+            return {
+              "sa_orderitemsid": 0,
+              "itemid": v.itemid,
+              "qty": v.favoritesqty,
+              "sa_brandid": v.brand.length ? v.brand[0].sa_brandid : this.data.sa_brandid || 0,
+              width: v.favoriteswidth || 0,
+              length: v.favoriteslength || 0,
+            }
           })
         }
-      });
+      }).then(res => {
+        wx.hideLoading()
+        console.log("转化订单", res)
+        if (res.msg != '成功') return wx.showToast({
+          title: res.msg,
+          icon: "none"
+        });
+        this.setData({
+          results: [],
+          isAll: false
+        })
+        wx.showModal({
+          title: '提示',
+          content: '生成成功!是否立即前往',
+          complete: (s) => {
+            if (s.confirm) wx.navigateTo({
+              url: '/packageA/orderForm/detail?id=' + res.data.sa_orderid,
+            })
+          }
+        });
+      })
     })
   },
   addToShoppingCart(index) {

+ 80 - 33
pages/index/collect/index.js

@@ -48,6 +48,34 @@ Component({
 					})
 				})
 			}
+
+
+			let domainrelatedaccounts = wx.getStorageSync('domainrelatedaccounts');
+			if (domainrelatedaccounts.length) {
+				this.setData({
+					domainrelatedaccounts
+				})
+			} else {
+				_Http.basic({
+					"classname": "sysmanage.develop.optiontype.optiontype",
+					"method": "optiontypeselect",
+					"content": {
+						"pageNumber": 1,
+						"pageSize": 9999,
+						"typename": "domainrelatedaccounts"
+					}
+				}).then(res => {
+					console.log("查询领域对应列表", res)
+					if (res.msg == '成功' && res.data.length) {
+						domainrelatedaccounts = res.data;
+						wx.setStorageSync('domainrelatedaccounts', domainrelatedaccounts)
+						this.setData({
+							domainrelatedaccounts
+						})
+					}
+				})
+			}
+			console.log("domainrelatedaccounts", domainrelatedaccounts)
 			return true;
 		},
 		/* 获取列表 */
@@ -114,43 +142,62 @@ Component({
 		},
 		handleSubmit(index) {
 			let data = this.data.classList[index];
+			let tradefield = this.data.domainrelatedaccounts.find(v => v.value == data.type);
 			_Http.basic({
-				"id": 20221128183202,
+				"id": 20221008134803,
+				"version": 1,
 				"content": {
-					istool: 0,
-					type: "标准订单",
-					"tradefield": data.type, //必选
-					"items": data.list.map(v => {
-						return {
-							"sa_orderitemsid": 0,
-							"itemid": v.itemid,
-							"sa_brandid": v.sa_brandid,
-							"qty": v.qty,
-							width: v.width || 0,
-							length: v.length || 0,
-							sa_shoppingcartid: v.sa_shoppingcartid || 0
-						}
-					})
+					"pageNumber": 1,
+					"pageTotal": 1,
+					"pageSize": 9999,
+					"where": {
+						"condition": "",
+						"isused": 1,
+						"isnotspecialfund": 0, //是否专用
+					},
 				}
-			}).then(res => {
-				console.log("转化订单", res)
-				if (res.msg != '成功') return wx.showToast({
-					title: res.msg,
-					icon: "none"
-				});
-				getApp().globalData.getCollectCount()
-				wx.showModal({
-					title: '提示',
-					content: '生成成功!是否立即前往',
-					complete: (s) => {
-						if (s.confirm) {
-							wx.navigateTo({
-								url: '/packageA/orderForm/detail?id=' + res.data.sa_orderid,
-							})
-						}
+			}).then(acc => {
+				console.log("账户列表", acc)
+				let list = acc.data.filter(v => tradefield.subvalues.some(s => s == v.sa_accountclassid))
+				_Http.basic({
+					"id": 20221128183202,
+					"content": {
+						istool: 0,
+						type: "标准订单",
+						"tradefield": data.type, //必选
+						sa_accountclassid: list.length ? list[0].sa_accountclassid : 0,
+						"items": data.list.map(v => {
+							return {
+								"sa_orderitemsid": 0,
+								"itemid": v.itemid,
+								"sa_brandid": v.sa_brandid,
+								"qty": v.qty,
+								width: v.width || 0,
+								length: v.length || 0,
+								sa_shoppingcartid: v.sa_shoppingcartid || 0
+							}
+						})
 					}
-				});
-				this.getList();
+				}).then(res => {
+					console.log("转化订单", res)
+					if (res.msg != '成功') return wx.showToast({
+						title: res.msg,
+						icon: "none"
+					});
+					getApp().globalData.getCollectCount()
+					wx.showModal({
+						title: '提示',
+						content: '生成成功!是否立即前往',
+						complete: (s) => {
+							if (s.confirm) {
+								wx.navigateTo({
+									url: '/packageA/orderForm/detail?id=' + res.data.sa_orderid,
+								})
+							}
+						}
+					});
+					this.getList();
+				})
 			})
 		},
 		/* 是否选择全部 */