Quellcode durchsuchen

修复排序不生效问题

李书文 vor 1 Jahr
Ursprung
Commit
d84797c80e
2 geänderte Dateien mit 20 neuen und 16 gelöschten Zeilen
  1. 10 10
      pages/market/one/list.vue
  2. 10 6
      pages/market/two/list.vue

+ 10 - 10
pages/market/one/list.vue

@@ -8,8 +8,8 @@
 			<view class="sort-list">
 				<view class="sort-item" :class="{ active: item.check }" v-for="(item, index) in sort" :key="index" @click="select(item, index)">
 					<text>{{ item.name }}</text>
-					<text v-if="index > 0 && item.orderBy == 'desc'" class="icon">&#xeb0a;</text>
-					<text v-if="index > 0 && item.orderBy == 'asc'" class="icon">&#xeb0b;</text>
+					<text v-if="index > 0 && item.isAsc == 'desc'" class="icon">&#xeb0a;</text>
+					<text v-if="index > 0 && item.isAsc == 'asc'" class="icon">&#xeb0b;</text>
 				</view>
 				<view class="type" @click="go()">
 					<text>{{ param.goodsType || '分类' }}</text>
@@ -43,10 +43,11 @@ export default {
 		return {
 			show: false,
 			user: this.getUser(),
+			isAsc: 'desc',
 			sort: [
-				{ name: '综合', sortType: 1, orderBy: 'desc', check: false },
-				{ name: '日期', sortType: 15, orderBy: 'desc', check: false },
-				{ name: '价格', sortType: 7, orderBy: 'desc', check: false }
+				{ name: '综合', sortName: 'id', isAsc: 'desc', check: false },
+				{ name: '日期', sortName: 'create_time', isAsc: 'desc', check: false },
+				{ name: '价格', sortName: 'price', isAsc: 'desc', check: false }
 			],
 			list: [],
 			param: { pageNo: 1, pageSize: 10 },
@@ -68,11 +69,10 @@ export default {
 			this.sort.forEach(it => (it.check = false));
 			item.check = true;
 			if (index > 0) {
-				this.orderBy = this.orderBy == 'desc' ? 'asc' : 'desc';
-				item.orderBy = this.orderBy;
+				this.isAsc = this.isAsc == 'desc' ? 'asc' : 'desc';
+				item.isAsc = this.isAsc;
 			}
-			this.param.orderBy = item.orderBy;
-			this.param.sortType = item.sortType;
+			this.param.orderBy = item.sortName + ' ' + this.isAsc;
 			this.refresh();
 		},
 		getData() {
@@ -147,4 +147,4 @@ page {
 .search {
 	padding: 12px 12px 0px 12px;
 }
-</style>
+</style>

+ 10 - 6
pages/market/two/list.vue

@@ -21,7 +21,7 @@
 				<image @click="detail(item)" src="../../../static/news.jpg" mode="aspectFill" class="pic"></image>
 				<view class="con">
 					<view class="productName omit" @click="detail(item)">{{ item.goodsName }}</view>
-					<view class="desc" @click="detail(item)">{{ item.goodsQuantity }}</view>
+					<view class="desc" @click="detail(item)">数量:{{ item.goodsQuantity }}</view>
 					<view class="btn" v-if="user.userType == 2" @click="confirm(item)">立即接单</view>
 				</view>
 			</view>
@@ -38,7 +38,12 @@ export default {
 		return {
 			user: this.getUser(),
 			show: false,
-			sort: [{ name: '综合' }, { name: '日期' }, { name: '价格' }],
+			isAsc: 'desc',
+			sort: [
+				{ name: '综合', sortName: 'id', isAsc: 'desc', check: false },
+				{ name: '日期', sortName: 'create_time', isAsc: 'desc', check: false },
+				{ name: '数量', sortName: 'goods_quantity', isAsc: 'desc', check: false }
+			],
 			list: [],
 			param: { pageNo: 1, pageSize: 10 },
 			loadMore: true
@@ -59,11 +64,10 @@ export default {
 			this.sort.forEach(it => (it.check = false));
 			item.check = true;
 			if (index > 0) {
-				this.orderBy = this.orderBy == 'desc' ? 'asc' : 'desc';
-				item.orderBy = this.orderBy;
+				this.isAsc = this.isAsc == 'desc' ? 'asc' : 'desc';
+				item.isAsc = this.isAsc;
 			}
-			this.param.orderBy = item.orderBy;
-			this.param.sortType = item.sortType;
+			this.param.orderBy = item.sortName + ' ' + this.isAsc;
 			this.refresh();
 		},
 		getData() {