Ver Fonte

二级市场订单可以多选购买

李书文 há 1 ano atrás
pai
commit
882a683cf8
3 ficheiros alterados com 47 adições e 4 exclusões
  1. 7 0
      common/style.scss
  2. 39 3
      pages/market/two/list.vue
  3. 1 1
      pages/market/two/purchaser/buy/buy.vue

+ 7 - 0
common/style.scss

@@ -645,6 +645,13 @@
 		box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.08);
 		margin-bottom: 10px;
 		overflow: hidden;
+		position: relative;
+		.check {
+			position: absolute;
+			right: 5px;
+			top: 4px;
+			font-size: 24px;
+		}
 		.title {
 			margin-bottom: 9px;
 			float: left;

+ 39 - 3
pages/market/two/list.vue

@@ -18,6 +18,10 @@
 			</view>
 			<view class="item" v-for="(item, index) in list" :key="index" @click="detail(item)">
 				<view class="title">{{ item.createName }}</view>
+				<view class="check" @click.stop="selected(item)">
+					<text class="check icon" v-if="item.check" style="color: #4581fb">&#xe631;</text>
+					<text class="check icon" v-else>&#xe60c;</text>
+				</view>
 				<image src="../../../static/news.jpg" mode="aspectFill" class="pic"></image>
 				<view class="con">
 					<view class="productName omit">{{ item.goodsName }}</view>
@@ -35,6 +39,13 @@
 			<text class="icon">&#xe600;</text>
 			<view class="bag animated" :class="{ bounce: add }" v-if="cars > 0">{{ cars }}</view>
 		</button>
+		<view class="mfooter" v-if="selects.length > 0">
+			<view class="flex">
+				<view class="f">
+					<button class="btn" @click="buy({})">立即购买({{ selects.length }})</button>
+				</view>
+			</view>
+		</view>
 	</view>
 </template>
 
@@ -54,11 +65,14 @@ export default {
 			],
 			list: [],
 			param: { pageNo: 1, pageSize: 10 },
-			loadMore: true
+			loadMore: true,
+			selects: []
 		};
 	},
+	onShow(){
+		this.refresh();
+	},
 	onLoad(e) {
-		this.getData();
 		//选择商品分类
 		uni.$on('productType', res => {
 			this.param.goodsType = res.name;
@@ -89,6 +103,12 @@ export default {
 				}
 			});
 		},
+		//多选购买
+		selected(item) {
+			item.check = !item.check;
+			this.$forceUpdate();
+			this.selects = this.list.filter(item => item.check);
+		},
 		//选择分类
 		go() {
 			uni.navigateTo({ url: '/pages/market/productType?current=' + this.param.current + '&now=' + this.param.now });
@@ -115,13 +135,22 @@ export default {
 			uni.navigateTo({ url: '/pages/market/two/purchaser/order/cart' });
 		},
 		buy(item) {
-			uni.navigateTo({ url: '/pages/market/two/purchaser/buy/buy?orderId=' + item.id });
+			if (item.id) {
+				uni.navigateTo({
+					url: '/pages/market/two/purchaser/buy/buy?orderId=' + item.id
+				});
+			} else {
+				uni.navigateTo({
+					url: '/pages/market/two/purchaser/buy/buy?orderId=' + this.selects.map(item => item.id)
+				});
+			}
 		},
 		//刷新数据
 		refresh() {
 			this.loadMore = true;
 			this.param.pageNum = 1;
 			this.list = [];
+			this.selects=[];
 			this.getData();
 		}
 	},
@@ -162,4 +191,11 @@ page {
 		line-height: 20px;
 	}
 }
+.mfooter {
+	background-color: #ffffff00;
+	border: 0px;
+	.btn{
+		background-color: #F44336;
+	}
+}
 </style>

+ 1 - 1
pages/market/two/purchaser/buy/buy.vue

@@ -73,7 +73,7 @@ export default {
 							method: 'POST',
 							data: { ids: this.orderIds},
 							success: res => {
-								uni.navigateTo({ url: '/pages/market/two/leader/success' });
+								uni.redirectTo({url:'/pages/market/two/leader/success'});
 							}
 						});
 					}