Browse Source

bug修复

zhaoxw 4 years ago
parent
commit
64b0a7d614
3 changed files with 172 additions and 41 deletions
  1. 61 0
      pagesGood/CnumberBox.vue
  2. 104 40
      pagesGood/goodDetails.vue
  3. 7 1
      pagesMain/orderDetail.vue

+ 61 - 0
pagesGood/CnumberBox.vue

@@ -0,0 +1,61 @@
+<template>
+	<view class="main">
+		<uni-icons type="minus-filled" size="20" color="#A67A54" @click="numReduce"></uni-icons>
+		<!-- <text class="buy-select">{{number}}</text> -->
+		<u-input
+		  v-model="number"
+		  type="number"
+		  height="40"
+		  :placeholder="placeholder"
+		  :clearable="false"
+		  :disabled="isDisabled"
+		  input-align="center"
+		  :custom-style="{width:'45px'}"/>
+		<uni-icons type="plus-filled" size="20" color="#A67A54" @click="numPlus"></uni-icons>
+	</view>
+</template>
+
+<script>
+	export default {
+		props: {
+			isDisabled: {
+				default: false
+			},
+			placeholder: {
+				default: ''
+			},
+			step: {
+				default: 1
+			},
+			minNum: {
+				default: 0.01
+			}
+		},
+		data() {
+			return {
+			    number: 1,
+			}
+		},
+		methods: {
+			numPlus() {
+			    this.number = this.number + this.step
+				this.$emit('getNum',this.number);
+			},
+			numReduce() {
+			    if ((this.number - this.step) >= this.minNum) {
+				    this.number = this.number - this.step
+			    }
+				this.$emit('getNum',this.number);
+			}
+		}
+	}
+</script>
+
+<style>
+</style>
+<style lang="less" scoped>
+	.main {
+		display: flex;
+		align-items: center;
+	}
+</style>

+ 104 - 40
pagesGood/goodDetails.vue

@@ -35,11 +35,20 @@
 		</view>
 		<view class="buy-num" v-if="goodData.productType != 2">
 			<view class="buy-text">购买数量:</view>
-			<view>
+			<!-- <view style="display: flex;">
 				<uni-icons type="minus-filled" size="20" color="#A67A54" @click="number>1?number--:''"></uni-icons>
 				<text class="buy-select">{{number}}</text>
+				<u-input
+				  v-model="number"
+				  type="number"
+				  height="40"
+				  placeholder=" "
+				  :clearable="false"
+				  input-align="center"
+				  :custom-style="{width:'40px'}"/>
 				<uni-icons type="plus-filled" size="20" color="#A67A54" @click="number++"></uni-icons>
-			</view>
+			</view> -->
+			<CnumberBox @getNum="getNum" :isDisabled="true" minNum="1"></CnumberBox>
 		</view>
 		<view class="tab-box">
 			<view class="tab-col" :class="tabIndex == 1 ? 'tab-col-active' :''" @click="tabIndex = 1">产品介绍</view>
@@ -76,7 +85,7 @@
 		</view>
 		<uni-goods-nav :fill="true" :options="goodData.productType == 4 ? [] : options" @click="goToShop" @buttonClick="showPopup"
 		 style="width: 100%; position: fixed; bottom: 0px;" :buttonGroup="goodData.productType == 2 ? buttonGroup2 : (goodData.productType == 4 ? (minePlant ? buttonGroup4 : buttonGroup3) : buttonGroup1)" />
-		<uni-popup ref="popup" type="bottom">
+		<!-- <uni-popup ref="popup" type="bottom">
 			<view class="popup-box">
 				<view class="popup-good-info-box">
 					<image mode="aspectFill" class="popup-good-img" v-if="goodData.imgs.length" :src="goodData.imgs[0].imgPath"></image>
@@ -95,7 +104,7 @@
 				</view>
 				<uni-goods-nav :fill="true" :options="[]" :buttonGroup="buttonGroup1" @buttonClick="submitData" style="width: 100%; position: absolute; bottom: 0px;left:0px" />
 			</view>
-		</uni-popup>
+		</uni-popup> -->
 		<u-top-tips ref="uTips"></u-top-tips>
 	</view>
 </template>
@@ -103,7 +112,11 @@
 <script>
 	const NET = require('@/utils/request')
 	const API = require('@/config/api')
+	import CnumberBox from '@/pagesGood/CnumberBox.vue'
 	export default {
+		components: {
+			CnumberBox
+		},
 		data() {
 			return {
 				//  从我的种植进入minePlant为true
@@ -135,6 +148,12 @@
 				options: [{
 					icon: 'shop',
 					text: '店铺',
+				},{
+					icon: 'cart',
+					text: '购物车',
+					info: 0,
+					infoBackgroundColor: '#52A63A',
+					infoColor:""
 				}],
 				buttonGroup1: [{
 						text: '加入购物车',
@@ -213,6 +232,10 @@
 			}
 		},
 		methods: {
+			// 获取子组件的购买数量
+			getNum(num) {
+				this.number = num
+			},
 			//  获取拍卖详情
 			getAuctionData() {
 				NET.request(API.getAuctionDetail + this.goodId, {}, 'GET').then(res => {
@@ -225,10 +248,16 @@
 				})
 			},
 			//  跳转商铺页
-			goToShop() {
-				uni.navigateTo({
-					url: '/pagesGood/shopDetails?goodId=' + this.goodId
-				});
+			goToShop(e) {
+				if (e.index == 0) {
+					uni.navigateTo({
+						url: '/pagesGood/shopDetails?goodId=' + this.goodId
+					});
+				} else {
+					uni.navigateTo({
+						url: 'pages/cart/cart'
+					});
+				}
 			},
 			//  跳转评价页
 			goToEvaluate() {
@@ -253,21 +282,26 @@
 					url: '/pagesGood/goodDetails?goodId=' + item.productId + '&goodType=' + item.productType
 				});
 			},
-			//  弹出购物弹窗
+			//  弹出购物弹窗->需求变更,不需要购物车弹窗,直接加入购物车
 			showPopup(e) {
 				uni.removeStorageSync('defaultAddress');
 				this.setGoodStorage()
 				if (this.goodData.productType == 2) {
+					//拍卖商品
 					uni.navigateTo({
 						url: '/pagesGood/auctionDetail?goodId=' + this.goodId
 					});
 				} else if (this.goodData.productType == 4) {
+					//共享种植商品
 					if (this.minePlant) {
+						// 如果是已买到的共享种植
 						if (e.index == 0) {
+							// 去视察
 							uni.navigateTo({
 								url: '/pagesGood/plantVideo?productId=' + this.goodId
 							});
 						} else {
+							// 去委托种植
 							uni.navigateTo({
 								url: '/pagesMain/entrustList?productId=' + this.goodData.productId + '&tenantCode=' + this.goodData.tenantCode +
 									'&productName=' + this.goodData.productName + '&areaSize=' + this.orderId + '&orderId=' + this.orderId
@@ -283,7 +317,37 @@
 						// }
 					}
 				} else {
-					this.$refs.popup.open()
+					// 需求变更,不需要购物车弹窗,直接加入购物车
+					// this.$refs.popup.open()
+					if (e.index == 0) {
+						NET.request(API.addCart, {
+							productId: this.goodId,
+							productName: this.goodData.productName,
+							imgUrl: this.goodData.imgs.length ? this.goodData.imgs[0].imgPath : '',
+							bizPrice: this.goodData.bizPrice,
+							originalPrice: this.goodData.originalPrice,
+							productType: this.goodData.productType,
+							tenantCode: this.goodData.tenantCode,
+							buyNum: this.number
+						}, 'POST').then(res => {
+							this.$refs.uTips.show({
+								title: '加入购物车成功',
+								type: 'success',
+							})
+							this.$refs.popup.close()
+						}).catch(error => {
+							this.$refs.uTips.show({
+								title: '加入购物车失败',
+								type: 'warning',
+							})
+						})
+					} else {
+						//  立即购买
+						this.setGoodStorage()
+						uni.navigateTo({
+							url: '/pagesGood/orderPay?flag=2&orderType=1'
+						});
+					}
 				}
 			},
 			//  存入商品信息缓存
@@ -310,36 +374,36 @@
 			},
 			//  提交操作
 			submitData(e) {
-				if (e.index) {
-					//  立即购买
-					this.setGoodStorage()
-					uni.navigateTo({
-						url: '/pagesGood/orderPay?flag=2&orderType=1'
-					});
-				} else {
-					//  加入购物车
-					NET.request(API.addCart, {
-						productId: this.goodId,
-						productName: this.goodData.productName,
-						imgUrl: this.goodData.imgs.length ? this.goodData.imgs[0].imgPath : '',
-						bizPrice: this.goodData.bizPrice,
-						originalPrice: this.goodData.originalPrice,
-						productType: this.goodData.productType,
-						tenantCode: this.goodData.tenantCode,
-						buyNum: this.number
-					}, 'POST').then(res => {
-						this.$refs.uTips.show({
-							title: '加入购物车成功',
-							type: 'success',
-						})
-						this.$refs.popup.close()
-					}).catch(error => {
-						this.$refs.uTips.show({
-							title: '加入购物车失败',
-							type: 'warning',
-						})
-					})
-				}
+				// if (e.index) {
+				// 	//  立即购买
+				// 	this.setGoodStorage()
+				// 	uni.navigateTo({
+				// 		url: '/pagesGood/orderPay?flag=2&orderType=1'
+				// 	});
+				// } else {
+				// 	//  加入购物车
+				// 	NET.request(API.addCart, {
+				// 		productId: this.goodId,
+				// 		productName: this.goodData.productName,
+				// 		imgUrl: this.goodData.imgs.length ? this.goodData.imgs[0].imgPath : '',
+				// 		bizPrice: this.goodData.bizPrice,
+				// 		originalPrice: this.goodData.originalPrice,
+				// 		productType: this.goodData.productType,
+				// 		tenantCode: this.goodData.tenantCode,
+				// 		buyNum: this.number
+				// 	}, 'POST').then(res => {
+				// 		this.$refs.uTips.show({
+				// 			title: '加入购物车成功',
+				// 			type: 'success',
+				// 		})
+				// 		this.$refs.popup.close()
+				// 	}).catch(error => {
+				// 		this.$refs.uTips.show({
+				// 			title: '加入购物车失败',
+				// 			type: 'warning',
+				// 		})
+				// 	})
+				// }
 			},
 		},
 	}

+ 7 - 1
pagesMain/orderDetail.vue

@@ -453,7 +453,6 @@
 							  }
 							})
 							//  自助采摘
-							
 						} else if (this.orderData.orderStatus == 3) {
 							if (e.index == 1) {
 								//  确认收货
@@ -466,6 +465,13 @@
 									url: '/pagesMain/logisticsDeatil?logisticCode=' + this.orderData.logisticsNum
 								});
 							}
+						} else if (this.orderData.orderStatus == 4) {
+							if (e.index == 1) {
+								//  去我的种植
+								uni.navigateTo({
+									url: '/pagesGood/goodDetails?minePlant=true&goodId=' + this.orderData.merchantInfoResVO.products[0].productId + '&orderId=' + this.orderData.orderId
+								});
+							} 
 						} else {
 							//  评价
 							uni.navigateTo({