zs 2 years ago
parent
commit
d080eeb449
2 changed files with 43 additions and 55 deletions
  1. 33 51
      pagesHome/group/index.vue
  2. 10 4
      pagesHome/order/order.vue

+ 33 - 51
pagesHome/group/index.vue

@@ -48,7 +48,7 @@
 										<text>{{item.sell_money||0}}</text>
 									</view>
 									<view class="other_2">
-										<view class="btn" @click="toJoin(item)">
+										<view class="btn" @click="onSubmit(item)">
 											<text>{{item.status||'开团中'}}</text>立即参团
 										</view>
 									</view>
@@ -91,7 +91,7 @@
 				shopInfo: {},
 				// 参团列表
 				list: [],
-				num: 0,
+				num: 1,
 				total: 0,
 				skip: 0,
 				limit: 6,
@@ -115,64 +115,46 @@
 			async toGroup() {
 				const that = this;
 				that.$refs.popup.open();
-				// let user = that.user;
-				// if (user._id) {
-				// 	let data = {
-				// 		customer: user._id,
-				// 		shop: that.shopInfo._id,
-				// 		goods: that.goodsInfo._id,
-				// 		goodsSpec: that.specsInfo._id,
-				// 		num: that.num,
-				// 	}
-				// 	let arr = await that.$api(`/util/checkCanBuy`, 'POST', data)
-				// 	if (arr.errcode == '0') {
-				// 		if (arr.data.result == true) {
-				// 			uni.navigateTo({
-				// 				url: `/pagesHome/order/order?key=${arr.data.key}`
-				// 			})
-				// 		} else {
-				// 			uni.showToast({
-				// 				title: arr.data.msg,
-				// 				icon: 'none'
-				// 			})
-				// 		}
-				// 	} else {
-				// 		uni.showToast({
-				// 			title: arr.errmsg,
-				// 			icon: 'none'
-				// 		})
-				// 	}
-				// 	const arr = await that.$api(`/group`, 'POST', data)
-				// 	if (arr.errcode == '0') {
-				// 		uni.showToast({
-				// 			title: '开团成功',
-				// 			icon: 'none'
-				// 		})
-				// 		that.clearPage();
-				// 		that.search()
-				// 	} else {
-				// 		uni.showToast({
-				// 			title: arr.data.errmsg,
-				// 			icon: 'none'
-				// 		})
-				// 	}
-				// } else {
-				// 	uni.navigateTo({
-				// 		url: `/pages/login/index`
-				// 	})
-				// }
 			},
 			// 计数器
 			toCount(e) {
 				const that = this;
 				that.num = e;
 			},
-			// 立即参团
-			toJoin(e) {
+			// 确认开团 立即参团
+			async onSubmit(e) {
 				const that = this;
 				let user = that.user;
 				if (user._id) {
-					console.log(e);
+					let data = {
+						customer: user._id,
+						shop: that.shopInfo._id,
+						goods: that.goodsInfo._id,
+						goodsSpec: that.specsInfo._id,
+						num: that.num,
+						type: '1'
+					}
+					if (e._id) {
+						data.group_id = e._id
+					}
+					let arr = await that.$api(`/util/checkCanBuy`, 'POST', data)
+					if (arr.errcode == '0') {
+						if (arr.data.result == true) {
+							uni.navigateTo({
+								url: `/pagesHome/order/order?key=${arr.data.key}`
+							})
+						} else {
+							uni.showToast({
+								title: arr.data.msg,
+								icon: 'none'
+							})
+						}
+					} else {
+						uni.showToast({
+							title: arr.errmsg,
+							icon: 'none'
+						})
+					}
 				} else {
 					uni.navigateTo({
 						url: `/pages/login/index`

+ 10 - 4
pagesHome/order/order.vue

@@ -40,9 +40,12 @@
 										</view>
 									</view>
 									<view class="r">
-										<view class="price">
+										<view class="price" v-if="type=='0'">
 											¥{{tag.money}}
 										</view>
+										<view v-else class="price">
+											¥{{tag.group_sell_money}}
+										</view>
 										<view class="num">
 											×{{tag.num}}
 										</view>
@@ -67,7 +70,7 @@
 									</view>
 								</view>
 							</view>
-							<view class="other">
+							<view class="other" v-if="type=='0'">
 								<view class="other_1">优惠劵</view>
 								<view class="other_2" @click="toCoupon" v-if="couponList.length">
 									{{coupon_name||'请选择优惠劵'}}
@@ -156,6 +159,8 @@
 				coupon: [],
 				// 优惠劵名称
 				coupon_name: '',
+				// 是否开团
+				type: '0'
 			};
 		},
 		onLoad: async function(e) {
@@ -333,8 +338,7 @@
 					that.$set(that, `address`, arr.data.address);
 					that.$set(that, `orderList`, arr.data.goodsData);
 					that.$set(that, `total_detail`, arr.data.orderTotal);
-					// var total = arr.data.orderTotal.freight_total + arr.data.orderTotal.goods_total
-					// that.$set(that, `goods_total`, total);
+					that.$set(that, `type`, arr.data.type);
 					this.computedTotal();
 					that.$set(that, `couponList`, arr.data.couponList);
 				}
@@ -372,6 +376,8 @@
 				}
 				if (total >= 0) {
 					this.$set(this, `goods_total`, total);
+					console.log(total);
+					console.log(this.total_detail);
 				} else {
 					uni.showToast({
 						title: `实付金额不能为负数 不能使用该优惠劵`,