zs 2 tahun lalu
induk
melakukan
dec91026d3
1 mengubah file dengan 25 tambahan dan 43 penghapusan
  1. 25 43
      pagesHome/order/detail.vue

+ 25 - 43
pagesHome/order/detail.vue

@@ -97,10 +97,10 @@
 					<view class="other">
 						<view class="money">
 							<text>¥</text>
-							<text>{{money}}</text>
+							<text>{{specsInfo.sell_money}}</text>
 						</view>
 						<view class="other_1">
-							已选: <text>{{Selected}}</text>
+							已选: <text>{{specsInfo.name}}</text>
 						</view>
 					</view>
 					<view class="btn">
@@ -113,20 +113,22 @@
 						<text v-for="(item,index) in specs" :key="index" @click="toStyle(item,index)"
 							:class="{ 'style': isActive==index}">{{item.name}}
 						</text>
-						<!-- 	<text class="group" v-if="item.can_group=='0'" @click="toGroup(item)">参团</text> -->
 					</view>
 				</view>
 				<view class="thr">
 					<text>数量</text>
 					<view class="count">
-						<uni-number-box :min="1" :max="max" :disabled="disabled" v-model="num" @change="toCount">
+						<uni-number-box :min="1" :max="specsInfo.num" :disabled="disabled" v-model="num"
+							@change="toCount">
 						</uni-number-box>
 					</view>
-					<text>库存{{max}}</text>
+					<text>库存{{specsInfo.num||0}}</text>
 				</view>
 				<view class="btn">
-					<view @click="toBuy(type)" class="button1">{{type=='0'?'加入购物车':'立即购买'}}</view>
-					<view @click="toGroup" class="button2">参团</view>
+					<text @click="toBuy(type)" :class="{ 'button': specsInfo._id&&specsInfo.can_group=='0'}">
+						{{type=='0'?'加入购物车':'立即购买'}}
+					</text>
+					<text v-if="specsInfo._id&&specsInfo.can_group=='0'" @click="toGroup" class="button2">参团</text>
 				</view>
 			</view>
 		</uni-popup>
@@ -198,7 +200,7 @@
 				// 规格情况
 				specs: [],
 				// 已选
-				Selected: '',
+				specsInfo: {},
 				// 是否显示返回顶部
 				isShow: false,
 				topItem: '',
@@ -213,10 +215,8 @@
 				type: '0',
 				// 选择规格
 				isActive: -1,
-				money: 0,
 				// 计数器
 				num: 1,
-				max: 0,
 				// 分享
 				share: {},
 			};
@@ -306,29 +306,10 @@
 			// 参团
 			toGroup() {
 				const that = this;
-				if (that.Selected) {
-					let specs_id;
-					let specs = that.specs.find(i => i.name == that.Selected)
-					if (specs.can_group == '0') {
-						specs_id = specs._id
-						uni.navigateTo({
-							url: `/pagesHome/group/index?specs_id=${specs_id}&goods_id=${that.id}`
-						})
-					} else {
-						uni.showToast({
-							title: `该规格暂无团购`,
-							icon: 'error'
-						})
-					}
-				} else {
-					uni.showModal({
-						title: '提示',
-						content: '请选择规格',
-						confirmColor: '#ff0000',
-						showCancel: false,
-						success: function(res) {}
-					});
-				}
+				let specs_id = that.specsInfo._id
+				uni.navigateTo({
+					url: `/pagesHome/group/index?specs_id=${specs_id}&goods_id=${that.id}`
+				})
 			},
 			//主菜单跳转
 			toPath(e) {
@@ -369,9 +350,7 @@
 			toStyle(e, index) {
 				const that = this;
 				that.$set(that, `isActive`, index)
-				that.$set(that, `Selected`, e.name)
-				that.$set(that, `max`, e.num)
-				that.$set(that, `money`, e.sell_money)
+				that.$set(that, `specsInfo`, e)
 				that.disabled = false;
 			},
 			// 计数器
@@ -387,10 +366,8 @@
 					success: async function(res) {
 						let user = that.$jwt(res.data);
 						that.$set(that, `user`, user)
-						if (that.Selected) {
-							let specs_id;
-							let specs = that.specs.find(i => i.name == that.Selected)
-							if (specs) specs_id = specs._id
+						if (that.specsInfo._id) {
+							let specs_id = that.specsInfo._id
 							let data = {
 								customer: user._id,
 								shop: that.shop._id,
@@ -478,7 +455,8 @@
 					that.$set(that, `info`, res.data.goods)
 					that.$set(that, `specs`, res.data.specs)
 					that.$set(that, `shop`, res.data.shop)
-					if (res.data.specs.length > 0) that.$set(that, `money`, res.data.specs[0].sell_money)
+					if (res.data.specs.length > 0) that.$set(that.specsInfo, `sell_money`, res.data.specs[0]
+						.sell_money)
 					that.$set(that, `bannerList`, res.data.goods.file)
 				}
 			},
@@ -870,8 +848,8 @@
 			position: fixed;
 			bottom: 0;
 
-			.button1 {
-				width: 50vw;
+			text {
+				width: 100vw;
 				padding: 4vw 0;
 				background-color: var(--fFB1Color);
 				text-align: center;
@@ -879,6 +857,10 @@
 				color: var(--mainColor);
 			}
 
+			.button {
+				width: 50vw;
+			}
+
 			.button2 {
 				width: 50vw;
 				padding: 4vw 0;