Kaynağa Gözat

解决冲突

1004749546@qq.com 4 yıl önce
ebeveyn
işleme
3a8347fbb7

+ 6 - 2
components/uni-coods/uni-coods.vue

@@ -18,7 +18,7 @@
 					<text>{{item.sellGold}}</text>
 					<u-image mode="scaleToFill" width="40rpx" height="40rpx" src="/static/ledou.png"></u-image>
 				</view>
-				<view @click.stop="addCart(item)" v-if="item.inventoryQty > 0">
+				<view @click="addCart(item)" v-if="item.inventoryQty > 0">
 					<u-image mode="scaleToFill" width="45rpx" height="45rpx" src="/static/addCart.png"></u-image>
 				</view>
 			</view>
@@ -33,6 +33,10 @@
 				type: Number,
 				default: 250
 			},
+			goldLimit: {
+				type: [Number,String],
+				default: 0
+			},
 			list:{
 				type: Array,
 				default: function(){
@@ -57,7 +61,7 @@
 			// 商品详情
 			toDetail(item){
 				uni.navigateTo({
-					url:"/pages/goods/goodsDetail?id="+item.id
+					url:"/pages/goods/goodsDetail?id="+item.id + "&goldLimit="+this.goldLimit
 				})
 			}
 		},

+ 5 - 2
pages/cart/cart.vue

@@ -23,7 +23,7 @@
 						</view>
 					</view>
 					<view class="des">
-						<view>商品乐豆合计满<text>{{item.goldLimit}}</text></view>
+						<view>商品满<text>{{item.goldLimit}}</text></view>
 						<u-image mode="scaleToFill" width="26rpx" height="26rpx" src="/static/ledou.png"></u-image>
 						<view>才可购买</view>
 					</view>
@@ -66,7 +66,7 @@
 					</view>
 				</view>
 			</view>
-			<view class="noData" v-if="cartList.length==0">
+			<view class="noData" v-if="!loading&&cartList.length==0">
 				<u-empty mode="car">
 					<view slot="bottom">
 						<u-button size="mini" @click="toBuy">去选商品</u-button>
@@ -111,6 +111,7 @@
 				checkAll: false,// 全选
 				isEdit: false, // 是否编辑模式
 				cartList: [], // 商品列表
+				loading: false
 			};
 		},
 		computed: {
@@ -146,10 +147,12 @@
 			},
 		},
 		onLoad() {
+			this.loading = true
 			uni.$emit('getCartList')
 			// 刷新列表成功
 			uni.$on('getCarListSuccess',item => {
 				this.cartList = JSON.parse(JSON.stringify(this.$store.state.vuex_cartList))
+				this.loading = false
 				// 默认全选
 				if(!this.isEdit){
 					this.checkAllChange()

+ 0 - 1
pages/checkOut/checkOut.vue

@@ -157,7 +157,6 @@
 						uni.navigateTo({
 							url: '/pages/checkOut/checkFinish?num='+this.number
 						})
-						
 					} else {
 						uni.showToast({
 							icon: 'none',

+ 27 - 6
pages/goods/goodsDetail.vue

@@ -22,6 +22,9 @@
 						<u-number-box :max="goodContent.inventoryQty" v-model="nums"></u-number-box>
 					</view>
 				</view>
+				<view class="goods-goldLimit">
+					此商品需要满<text>{{goldLimit}}</text>乐豆才可购买
+				</view>
 			</view>
 			<!-- 商品属性 -->
 			<view class="goods-attr">
@@ -74,12 +77,14 @@
 				imageList:[], // 商品图片
 				nums:1, // 商品数量
 				id: '',
-				goodContent: null
+				goodContent: null,
+				goldLimit: 0
 			};
 		},
 		onLoad(opts) {
 			console.log(opts)
 			this.id = opts.id
+			this.goldLimit = opts.goldLimit
 			this.getDetail()
 		},
 		methods: {
@@ -104,10 +109,17 @@
 			// 立即下单
 			toOrder(){
 				// console.log(this.goodContent,this.id,'pppppppp')
-				this.$u.vuex("vuex_toOrderList",[{id:this.id,buyQty:this.nums,goodsNo:this.goodContent.goodsNo,goods:this.goodContent}])
-				uni.redirectTo({
-					url:"/pages/toOrder/index"
-				})
+				if(this.goodContent.sellGold * this.nums >= this.goldLimit){
+					this.$u.vuex("vuex_toOrderList",[{id:this.id,buyQty:this.nums,goodsNo:this.goodContent.goodsNo,goods:this.goodContent}])
+					uni.redirectTo({
+						url:"/pages/toOrder/index"
+					})
+				}else{
+					uni.showToast({
+						icon:"none",
+						title:"此商品需要满" +this.goldLimit+ "乐豆才可购买"
+					})
+				}
 			}
 		},
 	}
@@ -174,7 +186,7 @@ page{
 			display: flex;
 			align-items: center;
 			justify-content: space-between;
-			padding:0 40upx 20upx;
+			padding:0 40upx;
 			>view{
 				&:first-child{
 					font-size: 22upx;
@@ -186,6 +198,15 @@ page{
 				}
 			}
 		}
+		.goods-goldLimit{
+			padding: 10upx 40upx;
+			color: #F0AD4E;
+			font-size: 24rpx;
+			text-align: right;
+			text{
+				color: red;
+			}
+		}
 	}
 	.goods-attr{
 		margin: 20upx 0;

+ 2 - 2
pages/goods/index.vue

@@ -9,7 +9,7 @@
 			<view v-for="(item,index) in goodsList" :key="index" v-if="goodsList.length&&item.list.length">
 				<u-section :title="item.type.name" font-size="35" line-color="#01c9b2" sub-title="更多" @click="toGoods(item.type)"></u-section>
 				<view class="goods-list">
-					<uni-coods :list="item.list"></uni-coods>
+					<uni-coods :goldLimit="item.type.goldLimit" :list="item.list"></uni-coods>
 				</view>
 			</view>
 			<view v-if="goodsList.length==0">
@@ -32,7 +32,7 @@
 		},
 		data() {
 			return {
-				noDataText: '正加载...',
+				noDataText: '正加载...',
 				imageTopList:[],
 				goodsList:[], // 商品
 				goodsType:[], // 商品分类

+ 2 - 0
pages/toOrder/index.vue

@@ -258,6 +258,8 @@
 							this.orderId = res.data.id
 							// 校验用户是否设置过支付密码
 							this.toCheckPwd()
+							// 刷新购物车
+							uni.$emit('getCartList')
 						} else {
 							uni.showToast({
 								title: res.message,