zs 2 лет назад
Родитель
Сommit
09b7e499db
3 измененных файлов с 134 добавлено и 22 удалено
  1. 0 1
      pages/home/index.vue
  2. 19 8
      pagesHome/order/detail.vue
  3. 115 13
      pagesHome/order/order.vue

+ 0 - 1
pages/home/index.vue

@@ -197,7 +197,6 @@
 						icon: 'none'
 					})
 				} else {
-					console.log(data.to);
 					uni.navigateTo({
 						url: `/${data.to}`
 					})

+ 19 - 8
pagesHome/order/detail.vue

@@ -22,8 +22,9 @@
 							</view>
 						</view>
 						<view class="one_2">
-							<text v-if="info.specs[0].price_name" class="money"><text>特价商品</text></text>
-							<text
+							<text v-if="info.specs[0].price"
+								class="money"><text>特价¥</text>{{info.specs&&info.specs.length>0?info.specs[0].price:0}}</text>
+							<text v-else
 								class="money"><text>¥</text>{{info.specs&&info.specs.length>0?info.specs[0].sell_money:0}}</text>
 							<text
 								class="money"><text>¥</text>{{info.specs&&info.specs.length>0?info.specs[0].flow_money:0}}</text>
@@ -408,19 +409,29 @@
 						let data = res.data;
 						if (data.goods.brief) data.goods.brief = data.goods.brief.replace(/\<img/gi,
 							'<img class="rich-img"');
-						let specs = data.specs.sort((a, b) => {
-							return a.sell_money - b.sell_money
-						})
 						let act = data.act.find(i => i.type == '3')
 						if (act) {
 							for (let val of act.list) {
-								for (let [index, arr] of specs.entries()) {
-									if (index == 0) arr.price_name = val.price
+								for (let [index, arr] of data.specs.entries()) {
 									if (val.spec == arr._id) arr.price = val.price
 								}
 							}
 						}
-						data.specs = specs;
+						var temp;
+						for (var i = 0; i < data.specs.length - 1; i++) { //确定轮数
+							for (var j = 0; j < data.specs.length - i - 1; j++) { //确定每次比较的次数
+								let a, b
+								if (data.specs[j].price) a = 'price'
+								else a = 'sell_money'
+								if (data.specs[j + 1].price) b = 'price'
+								else b = 'sell_money'
+								if (data.specs[j][a] > data.specs[j + 1][b]) {
+									temp = data.specs[j];
+									data.specs[j] = data.specs[j + 1];
+									data.specs[j + 1] = temp;
+								}
+							}
+						}
 						that.$set(that, `info`, data);
 						// 查询规格
 						that.searchSpecs(data.specs);

+ 115 - 13
pagesHome/order/order.vue

@@ -70,27 +70,31 @@
 									</view>
 								</view>
 							</view>
-							<view class="act">
+							<view class="act" v-if="total>0">
 								<view class="act_1">
-									订单已满<text>{{act.money||0}}元,为你推荐优惠商品搭配</text>
+									订单已满<text>{{act.money||0}}</text>元,为你推荐优惠商品搭配
 								</view>
 								<view class="act_2">
 									<checkbox-group @change="checkboxChange">
-										<label class="list" v-for="(item,index) in actList" :key="index">
+										<label class="actList" v-for="(item,index) in actList" :key="index">
 											<image class="image"
 												:src="item.file.length>0?item.file[0].url:item.file[0].url"
 												mode="aspectFill"></image>
 											<view class="name">{{item.goods_name}}</view>
 											<view class="money">
-												<text>¥{{item.sell_money}}</text>
-												<text>¥{{item.flow_money}}</text>
+												<text class="text_1">¥{{item.flow_money}}</text>
+												<text class="text_2">¥{{item.sell_money}}</text>
 											</view>
 											<view class="checkbox">
-												<checkbox :value="item.value" :checked="item.checked" />
+												<checkbox color="#FB1438" style="transform:scale(0.7)" :value="item._id"
+													:checked="item.checked" />
 											</view>
 										</label>
 									</checkbox-group>
-									<view class="bottom"><text class="iconfont icon-xiajiantou-copy"></text></view>
+									<view class="bottom" @tap="toOpen">
+										<text
+											:class="[change==false?'iconfont icon-xiajiantou-copy':'iconfont icon-shangjiantou-copy']"></text>
+									</view>
 								</view>
 							</view>
 							<view class="other" v-if="type=='0'">
@@ -163,6 +167,11 @@
 				inviter: '',
 				// 活动商品
 				actList: [],
+				total: 0,
+				page: 0,
+				skip: 0,
+				limit: 5,
+				change: false,
 			};
 		},
 		onLoad: function(e) {
@@ -212,6 +221,8 @@
 					key: that.key
 				})
 				if (arr.errcode == '0') {
+					// 查询活动商品列表
+					that.searchAct();
 					// 分享人id
 					that.$set(that, `inviter`, arr.data.inviter);
 					// 地址
@@ -226,6 +237,24 @@
 					that.$set(that, `couponList`, arr.data.couponList);
 				}
 			},
+			// 查询活动商品列表
+			async searchAct() {
+				const that = this;
+				let info = {
+					skip: that.skip,
+					limit: that.limit,
+					platform_act: '6371dad40aa8e005d5a47832',
+					goods_type: 'plus'
+				}
+				let res = await that.$api(`/goodsJoinAct`, 'GET', {
+					...info,
+				})
+				if (res.errcode == '0') {
+					let list = [...that.actList, ...res.data];
+					that.$set(that, `actList`, list)
+					that.$set(that, `total`, res.total)
+				}
+			},
 			// 使用优惠劵
 			toDiscount(e) {
 				const that = this;
@@ -254,17 +283,39 @@
 				that.$set(that, 'coupon', [])
 				that.$refs.popup.open();
 			},
+			// 选择活动商品
 			checkboxChange(e) {
 				const that = this;
 				var actList = that.actList,
-					id = e.detail._id;
+					values = e.detail.value;
 				for (var i = 0, lenI = actList.length; i < lenI; ++i) {
 					const item = actList[i]
-					if (id.includes(item._id)) {
-						this.$set(item, 'checked', true)
-					} else {
-						this.$set(item, 'checked', false)
-					}
+					if (values.includes(item._id)) that.$set(item, 'checked', true)
+					else that.$set(item, 'checked', false)
+				}
+			},
+			// 展开更多
+			toOpen() {
+				const that = this;
+				let list = that.actList;
+				let limit = that.limit;
+				if (that.total > list.length) {
+					uni.showLoading({
+						title: '加载中',
+						mask: true
+					})
+					let page = that.page + 1;
+					that.$set(that, `page`, page)
+					let skip = page * limit;
+					that.$set(that, `skip`, skip)
+					that.searchAct();
+					uni.hideLoading();
+				} else {
+					that.$set(that, 'change', true);
+					uni.showToast({
+						title: '没有更多优惠商品了',
+						icon: 'none'
+					})
 				}
 			},
 			// 提交订单
@@ -548,6 +599,57 @@
 					margin: 0 0 2vw 0;
 					width: 96vw;
 					padding: 2vw;
+
+					.act_1 {
+						font-size: var(--font14Size);
+						font-weight: bold;
+
+						text {
+							color: #FFA500;
+						}
+					}
+
+					.act_2 {
+						.actList {
+							display: flex;
+							margin: 2vw 0;
+
+							.image {
+								width: 12vw;
+								height: 10vw;
+								border: 1px solid #ffffff;
+							}
+
+							.name {
+								width: 52vw;
+								font-size: 12px;
+								margin: 0 0 0 1vw;
+							}
+
+							.money {
+								width: 25vw;
+
+								.text_1 {
+									font-size: 12px;
+									color: #858585;
+									text-decoration: line-through;
+								}
+
+								.text_2 {
+									font-size: 14px;
+									color: #ff0000;
+								}
+							}
+
+							.checkbox {
+								width: 7vw;
+							}
+						}
+					}
+
+					.bottom {
+						text-align: center;
+					}
 				}
 
 				.other {