Parcourir la source

Merge branch '新功能开发/商城优化' into 楚楚/楚楚master

xiaohaizhao il y a 1 an
Parent
commit
aa313c4eab

+ 86 - 10
packageA/market/detail.js

@@ -42,7 +42,6 @@ Page({
 			userrole: wx.getStorageSync('userrole'),
 			isShowFavorites: wx.getStorageSync('auth').wfavorites ? true : false
 		})
-
 		try {
 			let privacyFieldC = wx.getStorageSync('auth').wmarket.forms.wmarket.formcols.map(v => v.title);
 			this.setData({
@@ -80,6 +79,7 @@ Page({
 			}).format();
 			item.gradeprice = CNY(item.gradeprice);
 			item.marketprice = CNY(item.marketprice);
+			item.qty = item.orderaddqty;
 			this.setData({
 				content,
 				detail: item,
@@ -159,13 +159,6 @@ Page({
 		})
 		this.getDetail(valuename == "spec")
 	},
-	clickBut() {
-		this.data.detail.tradefield.length >= 2 ? wx.showToast({
-			title: '请选择加入产品领域',
-			icon: "none",
-			duration: 3000
-		}) : this.handleStorage(0);
-	},
 	/* 打开文档 */
 	openDocument(e) {
 		const {
@@ -209,6 +202,10 @@ Page({
 		})
 	},
 	clickBut(e) {
+		if (this.data.itemCount != this.data.selectCount) return wx.showToast({
+			title: '请完成产品选项在进行操作',
+			icon: "none"
+		})
 		this.data.detail.tradefield.length >= 2 ? wx.showToast({
 			title: '请选择加入产品领域',
 			icon: "none",
@@ -232,7 +229,7 @@ Page({
 		let content = Object.assign(this.data.content, {
 			sa_brandid,
 			itemid: detail.itemid, //货品id
-			qty: detail.orderminqty, //数量
+			qty: detail.qty, //数量
 			itemno: detail.itemno, //货品编号
 			tradefield: detail.tradefield[index].tradefield,
 		}, custom);
@@ -270,7 +267,7 @@ Page({
 			"id": 20231121143403,
 			"content": {
 				"itemid": this.data.detail.itemid, //货品id
-				"qty": detail.orderminqty, //数量
+				"qty": detail.qty, //数量
 				...custom,
 				iscollection,
 				...favorites
@@ -293,6 +290,48 @@ Page({
 			}
 		})
 	},
+	/* 立即下单 */
+	placeAnOrder(index) {
+		let detail = this.data.detail,
+			content = {
+				"type": "标准订单",
+				tradefield: detail.tradefield[index].tradefield
+			},
+			custom = {
+				length: 0,
+				width: 0
+			}
+		//是否为定制项
+		if (detail.iscustomsize == 1) custom = this.selectComponent("#customMade").getResult(true);
+		if (typeof custom == "boolean") return;
+		content.items = [Object.assign({
+			sa_orderitemsid: 0,
+			sa_brandid,
+			itemid: detail.itemid, //货品id
+			qty: detail.qty, //数量
+			itemno: detail.itemno, //货品编号
+		}, custom)];
+
+
+		_Http.basic({
+			"id": 20221128183202,
+			content,
+		}).then(res => {
+			console.log("创建订单", res)
+			wx.showModal({
+				title: '提示',
+				content: res.msg == '成功' ? '订单创建成功!是否立即查看' : res.msg,
+				complete: ({
+					confirm
+				}) => {
+					if (confirm) wx.navigateTo({
+						url: '/packageA/orderForm/detail?id=' + res.data.sa_orderid,
+					})
+				}
+			})
+		})
+
+	},
 	/* 前往购物车 */
 	toCollect(e) {
 		getApp().globalData.changeBar({
@@ -307,4 +346,41 @@ Page({
 		})
 		this.getDetail(true, this.data.loading);
 	},
+	/* 步进器输入框失去焦点 */
+	inputBlur(e) {
+		let item = this.data.detail;
+		let qty = 0;
+		if (item.orderminqty > e.detail.value) {
+			wx.showToast({
+				title: '输入数量低于最低起订量!',
+				icon: "none"
+			})
+			qty = item.orderminqty;
+		} else if (item.orderminqty < e.detail.value) {
+			var currencyRounding = value => currency(value, {
+				increment: item.orderaddqty
+			});
+			qty = currency(currencyRounding(currency(e.detail.value).subtract(item.orderminqty)).format()).add(item.orderminqty).value;
+
+		} else {
+			qty = e.detail.value;
+		}
+		this.setData({
+			"detail.qty": 0
+		});
+		this.setData({
+			"detail.qty": qty
+		});
+	},
+	stepperChange(e) {
+		let item = this.data.detail;
+		if (e.type == 'plus') {
+			item.qty += (item.orderaddqty) - 0 || 1
+		} else {
+			item.qty -= item.orderaddqty || 1
+		}
+		this.setData({
+			detail: item
+		})
+	},
 })

+ 1 - 0
packageA/market/detail.json

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

+ 8 - 1
packageA/market/detail.scss

@@ -141,6 +141,10 @@ swiper {
     display: flex;
     flex-wrap: wrap;
 
+    .input-class {
+      width: 120rpx;
+    }
+
     .product {
       height: 60rpx;
       line-height: 60rpx;
@@ -228,8 +232,11 @@ swiper {
     color: #3874F6;
     margin-bottom: 20rpx;
   }
+
 }
 
+
+
 .submit {
   height: 104rpx !important;
   border: none !important;
@@ -242,7 +249,7 @@ swiper {
 }
 
 .w610 {
-  width: 610rpx !important;
+  width: 306rpx !important;
 }
 
 .bg-blue {

+ 23 - 14
packageA/market/detail.wxml

@@ -13,7 +13,9 @@
 <!-- 产品介绍 -->
 <view class="intr">
     <view class="title">
-        {{detail.itemname}} <van-tag type="warning">{{detail.delistingstatus}}</van-tag>
+        {{detail.itemname}}
+        <text wx:if="{{isShowFavorites}}" class="{{detail.iscollection?'cuIcon-favorfill':'cuIcon-favor'}}" style="color:{{detail.iscollection?'#FADB14':''}};padding: 6rpx;" id='addToFavorites' bind:tap="{{'clickBut'}}" />
+        <van-tag type="warning">{{detail.delistingstatus}}</van-tag>
     </view>
     <view class="tags">
         <text wx:if="{{detail.iscustomsize==1}}" style="background-color: #EE0A24;color: #fff;">定制</text>
@@ -77,6 +79,12 @@
             </view>
         </customMade>
     </view>
+    <view class="label">
+        数量 <text style="font-size: 24rpx;font-weight: 400;">(起订量:{{detail.orderminqty}},增减量:{{detail.orderaddqty}},包装量:{{detail.packageqty}})</text>
+    </view>
+    <view class="product-box" style="margin-top: 20rpx;">
+        <van-stepper value="{{ detail.qty }}" min="{{detail.orderminqty}}" step="{{detail.orderaddqty||1}}" input-class='input-class' data-iscatch="catch" catch:minus='stepperChange' catch:plus='stepperChange' catch:blur='inputBlur' />
+    </view>
 
     <block wx:if="{{detail.canuseactivity.length}}">
         <view class="label" style="border: none;">
@@ -107,7 +115,7 @@
                 规格:{{detail.standards || ' --'}}
             </view>
             <view class="row">
-                特殊说明:{{detail.specalnote || ' --'}}
+                特殊说明:<text wx:if="{{detail.specalnote}}" style="color: red;">{{detail.specalnote}}</text><text wx:else> --</text>
             </view>
         </view>
     </van-tab>
@@ -120,26 +128,27 @@
 </van-tabs>
 <view style="height: 200rpx;" />
 <view class="cu-bar bg-white tabbar border shop footer" style="display: flex;">
-    <navigator url="#" class="action" style="height: 100%;display: flex; flex-direction: column; align-items: center;" bindtap="toCollect">
-        <view class="cuIcon-cart">
+    <navigator url="#" class="action " style="height: 100%;display: flex; flex-direction: column; align-items: center;" bindtap="toCollect">
+        <view class="cuIcon-cart" style="color: #F37B1D;">
             <view class="cu-tag badge">{{badge}}</view>
         </view>
         购物车
     </navigator>
-    <block wx:if="{{isShowFavorites}}">
-        <navigator url="/packageA/favorites/index" class="action" style="height: 100%;display: flex; flex-direction: column; align-items: center;">
-            <view class="{{detail.iscollection?'cuIcon-favorfill':'cuIcon-favor'}}" style="color:{{detail.iscollection?'#FADB14':''}}">
-                <view class="cu-tag badge">{{favoriteCount}}</view>
-            </view>
-            收藏夹
-        </navigator>
-        <van-button custom-class="bg-blue submit" id='addToFavorites' disabled='{{itemCount!=selectCount}}' bind:click="clickBut">{{detail.iscollection?'取消收藏商品':'加入收藏夹'}}</van-button>
-    </block>
-
+    <navigator wx:if="{{isShowFavorites}}" url="/packageA/favorites/index" class="action" style="height: 100%;display: flex; flex-direction: column; align-items: center;">
+        <view class="{{detail.iscollection?'cuIcon-favorfill':'cuIcon-favor'}}" style="color:{{detail.iscollection?'#FADB14':''}}">
+            <view class="cu-tag badge">{{favoriteCount}}</view>
+        </view>
+        收藏夹
+    </navigator>
 
     <picker wx:if="{{detail.tradefield.length>=2}}" range='{{detail.tradefield}}' disabled='{{itemCount!=selectCount}}' range-key='tradefield' bindchange='storage'>
         <van-button custom-class="bg-orange submit {{isShowFavorites?'w240':'w610'}}" id='addToShoppingCart' disabled='{{itemCount!=selectCount}}' bind:click="clickBut">加入购物车</van-button>
     </picker>
     <van-button wx:else custom-class="bg-orange submit {{isShowFavorites?'w240':'w610'}}" id='addToShoppingCart' disabled='{{itemCount!=selectCount}}' bind:click="clickBut">加入购物车</van-button>
+
+    <picker wx:if="{{detail.tradefield.length>=2}}" range='{{detail.tradefield}}' disabled='{{itemCount!=selectCount}}' range-key='tradefield' bindchange='storage'>
+        <van-button custom-class="bg-blue submit {{isShowFavorites?'w240':'w610'}}" id='addToShoppingCart' disabled='{{itemCount!=selectCount}}' bind:click="clickBut">立即下单</van-button>
+    </picker>
+    <van-button wx:else custom-class="bg-blue submit {{isShowFavorites?'w240':'w610'}}" id='placeAnOrder' disabled='{{itemCount!=selectCount}}' bind:click="clickBut">立即下单</van-button>
 </view>
 <wxs src="/utils/hidePrice.wxs" module="handleHide" />

+ 65 - 30
pages/index/market/modules/list/index.js

@@ -28,7 +28,8 @@ Component({
           } = this.data.authName;
           let privacyFieldC = wx.getStorageSync('auth')[appName].forms[formName].formcols.map(v => v.title);
           this.setData({
-            privacyFieldC
+            privacyFieldC,
+            isShowFavorites: wx.getStorageSync('auth').wfavorites ? true : false
           })
           console.log("privacyFieldC", privacyFieldC)
         } catch (error) {
@@ -53,35 +54,69 @@ Component({
       })
     },
     buyMore(e) {
-      const item = e.currentTarget.dataset.item.item[0];
-      const item1 = e.currentTarget.dataset.item;
-      wx.showModal({
-        title: '提示',
-        content: `是否确定将“${item.itemname}”加入到购物车`,
-        complete: (res) => {
-          if (res.confirm) _Http.basic({
-            "id": 20220924095102,
-            "content": {
-              sa_brandid: item1.sa_brandid,
-              "itemid": item.itemid, //货品id
-              "qty": item.orderminqty, //数量
-              itemno: item.itemno, //货品编号
-              tradefield: item1.tradefield,
-              width: item.width,
-              length: item.length
-            },
-          }).then(res => {
-            console.log("加入购物车", res)
-            wx.showToast({
-              title: res.msg == '成功' ? '加入成功' : res.msg,
-              icon: "none"
-            });
-            if (res.msg == '成功') getApp().globalData.getCollectCount().then(badge => this.setData({
-              badge
-            }))
-          })
-        }
-      })
+      const {
+        name
+      } = e.target.dataset;
+      if (!name) return;
+      const item1 = e.currentTarget.dataset.item,
+        index = e.currentTarget.dataset.index,
+        item = item1.item[0];
+
+      if (name == '购物车') {
+        wx.showModal({
+          title: '提示',
+          content: `是否确定将“${item.itemname}”加入到购物车`,
+          complete: (res) => {
+            if (res.confirm) _Http.basic({
+              "id": 20220924095102,
+              "content": {
+                sa_brandid: item1.sa_brandid,
+                "itemid": item.itemid, //货品id
+                "qty": item.orderminqty, //数量
+                itemno: item.itemno, //货品编号
+                tradefield: item1.tradefield,
+                width: item.width,
+                length: item.length
+              },
+            }).then(res => {
+              console.log("加入购物车", res)
+              wx.showToast({
+                title: res.msg == '成功' ? '加入成功' : res.msg,
+                icon: "none"
+              });
+              if (res.msg == '成功') getApp().globalData.getCollectCount().then(badge => this.setData({
+                badge
+              }))
+            })
+          }
+        })
+      } else {
+        let iscollection = item.iscollection == 1 ? false : true
+        _Http.basic({
+          "id": 20231121143403,
+          "content": {
+            "itemid": item.itemid, //货品id
+            "qty": item.orderminqty, //数量
+            iscollection,
+            width: item.width,
+            length: item.length
+          }
+        }).then(res => {
+          console.log(iscollection + "收藏夹", res)
+          wx.showToast({
+            title: res.msg == '成功' ? iscollection ? '收藏成功' : "已取消收藏" : res.msg,
+            icon: "none"
+          });
+          if (res.msg == '成功') {
+            this.setData({
+              [`list[${index}].item[0].iscollection`]: iscollection ? 1 : 0
+            })
+            getCurrentPages()[getCurrentPages().length - 1].setData({
+              [`list[${index}].item[0].iscollection`]: iscollection ? 1 : 0
+            })
+          }
+        })
+      }
     },
   }
 })

+ 7 - 0
pages/index/market/modules/list/index.scss

@@ -88,11 +88,18 @@
 			}
 
 			.shopping {
+				display: flex;
 				font-size: 24rpx;
+				align-items: center;
 
 				.iconfont {
 					color: #F29C37;
 				}
+
+				.cuIcon {
+					font-size: 36rpx;
+					margin-right: 20rpx;
+				}
 			}
 
 		}

+ 4 - 3
pages/index/market/modules/list/index.wxml

@@ -35,9 +35,10 @@
 				</view>
 				<view class="punit">× {{item.unitname}}</view>
 			</view>
-			<navigator wx:if="{{!item.isscheme}}" url="#" class="shopping" data-item="{{item}}" catchtap="buyMore">
-				<text class="iconfont icon-gouwuche" />
-			</navigator>
+			<view wx:if="{{!item.isscheme}}" class="shopping" data-item="{{item}}" data-index="{{index}}" catchtap="buyMore">
+				<view hover-class="navigator-hover" wx:if="{{isShowFavorites}}" url="#" data-name="收藏" class="{{item.item[0].iscollection?'cuIcon-favorfill':'cuIcon-favor'}} cuIcon" style="color:{{item.item[0].iscollection?'#FADB14':''}}" />
+				<view hover-class="navigator-hover" url="#" data-name="购物车" class="iconfont icon-gouwuche" />
+			</view>
 		</view>
 	</view>
 </navigator>

+ 7 - 0
project.private.config.json

@@ -10,6 +10,13 @@
   "condition": {
     "miniprogram": {
       "list": [
+        {
+          "name": "商城详情",
+          "pathName": "packageA/market/detail",
+          "query": "params=%7B%22sa_itemgroupid%22%3A4536%2C%22sa_brandid%22%3A32%7D",
+          "launchMode": "default",
+          "scene": null
+        },
         {
           "name": "",
           "pathName": "pages/index/index",

+ 7 - 0
select/product/index.scss

@@ -21,12 +21,19 @@ page {
 	margin-bottom: 20rpx;
 
 	.mian {
+		position: relative;
 		display: flex;
 		align-items: center;
 		width: 100%;
 		padding: 20rpx 30rpx;
 		box-sizing: border-box;
 
+		.checkbox {
+			position: absolute;
+			top: 20rpx;
+			right: 10rpx;
+		}
+
 		.img {
 			flex-shrink: 0;
 			width: 128rpx;

+ 3 - 1
select/product/index.wxml

@@ -8,7 +8,9 @@
 <Yl_ListBox id='ListBox' bind:getlist='getList'>
     <view class="setclient-list-item" wx:for="{{list}}" wx:key="itemno">
         <navigator url="#" class="mian" data-id="{{item[idname]}}" data-item="{{item}}" bindtap="changeResult">
-            <van-checkbox wx:if="{{!radio}}" value="{{ handle.isCheck(item[idname],result) }}" shape="square" icon-size='28rpx' />
+            <view class="checkbox">
+                <van-checkbox wx:if="{{!radio}}" value="{{ handle.isCheck(item[idname],result) }}" shape="square" icon-size='28rpx' />
+            </view>
             <view class="img" data-file="{{item.attinfos}}" catchtap="viewImage">
                 <van-image width="100%" height="100%" wx:if="{{item.cover}}" src="{{item.cover}}" use-loading-slot use-error-slot lazy-load>
                     <van-loading slot="loading" type="spinner" size="20" vertical />