guhongwei 2 gadi atpakaļ
vecāks
revīzija
990ee0dd5f
3 mainītis faili ar 447 papildinājumiem un 126 dzēšanām
  1. 224 62
      pages/week/index.vue
  2. 2 2
      pagesHome/market/search.vue
  3. 221 62
      pagesHome/market/type.vue

+ 224 - 62
pages/week/index.vue

@@ -15,29 +15,37 @@
 					</scroll-view>
 				</view>
 				<view class="two_2">
-					<scroll-view scroll-y="true" class="scroll-view">
+					<scroll-view scroll-y="true" class="scroll-view" @scrolltolower="toPage" @scroll="toScroll">
 						<view class="list-scroll-view">
-							<view class="list" v-for="(item,index) in list" :key="index" @tap="toCommon('pagesHome/market/search',item,'2')">
-								<view class="title">
-									{{item.label}}
-								</view>
-								<view class="market" v-if="item.children&&item.children.length>0">
-									<view class="marketList" v-for="(tag,indexs) in item.children" :key="indexs" @tap.stop="toCommon('pagesHome/market/search',tag,'3')">
+							<view class="two_2_1">
+								<scroll-view scroll-x="true" class="typeScrollview">
+									<view class="list" v-for="(item,index) in list" :key="index" @tap="twoChange(item,index)">
+										<image class="image" :src="item.file&&item.file.length>0?item.file[0].url:logoUrl" mode=""></image>
+										<view class="label textOver"><text :style="{color:twoActive==index?'#ff0000':'#000000'}">{{item.label}}</text></view>
+									</view>
+								</scroll-view>
+							</view>
+							<view class=" two_2_2">
+								<view class="list" v-for="(tag,index) in marketList" :key="index" @tap="toBuy(tag)">
+									<view class="img">
 										<image class="image" :src="tag.file&&tag.file.length>0?tag.file[0].url:''" mode=""></image>
-										<view class="name">
-											{{tag.label}}
-										</view>
 									</view>
-								</view>
-								<view class="market" v-else>
-									<view class="marketList" @tap.stop="toCommon('pagesHome/market/search',item,'3')">
-										<image class="image" :src="item.file&&item.file.length>0?item.file[0].url:''" mode=""></image>
-										<view class="name">
-											{{item.label}}
+									<view class="info">
+										<view class="name textOver">
+											<text>{{tag.name}}</text>
+										</view>
+										<view class="num">
+											<text>库存{{tag.num}}</text>
+										</view>
+										<view class="money">
+											<text>¥{{tag.sell_money}}</text>
 										</view>
 									</view>
 								</view>
 							</view>
+							<view class="is_bottom" v-if="is_bottom">
+								<text>{{config.bottom_title}}</text>
+							</view>
 						</view>
 					</scroll-view>
 				</view>
@@ -56,16 +64,48 @@
 				active: '0',
 				typeList: [],
 				list: [],
-				// 一级
-				classa: {},
+				// 平台信息
+				config: {},
+				logoUrl: '',
+				// 商品分类tags
+				tags: '',
+				twoActive: null,
+				// 商品列表
+				marketList: [],
+				total: 0,
+				page: 0,
+				skip: 0,
+				limit: 6,
+				// 数据是否触底
+				is_bottom: false,
+				scrollTop: 0,
 			};
 		},
-		onLoad: function() {
+		onShow: function() {
 			const that = this;
-			that.searchOther();
+			that.searchConfig();
+			that.search();
 		},
 		methods: {
-			async searchOther() {
+			// 查询基本设置
+			searchConfig() {
+				const that = this;
+				uni.getStorage({
+					key: 'config',
+					success: function(res) {
+						let data = res.data;
+						that.$set(that, `config`, data)
+						if (data) {
+							that.$set(that, `logoUrl`, data.config.logo[0].url)
+						}
+					},
+					fail: function(err) {
+						console.log(err);
+					}
+				})
+			},
+			// 查询左侧一级列表
+			async search() {
 				const that = this;
 				let res;
 				res = await that.$api(`/goodsTags`, 'GET', {
@@ -75,18 +115,13 @@
 					that.$set(that, `typeList`, res.data);
 					if (res.total > 0) {
 						that.searchRight(res.data[0]);
-						that.$set(that, `classa`, res.data[0]);
+						// 查询产品
+						that.$set(that, `tags`, res.data[0].code)
+						that.searchMarket()
 					}
 				}
 			},
-			toChange(index, e) {
-				const that = this;
-				that.$set(that, `list`, []);
-				that.$set(that, `active`, index);
-				that.searchRight(e);
-				that.$set(that, `classa`, e);
-			},
-			// 查询左侧信息
+			// 查询左侧二级信息
 			async searchRight(e) {
 				const that = this;
 				let info = {};
@@ -95,26 +130,100 @@
 					...info
 				})
 				if (res.errcode == '0' && res.data.length > 0) {
-					that.$set(that, `list`, res.data[0].children)
+					that.$set(that, `list`, res.data[0].children);
 				}
 			},
-			// 公共跳转
-			toCommon(e, code, num) {
+			// 查询产品
+			async searchMarket() {
 				const that = this;
-				if (num == '2') {
-					uni.navigateTo({
-						url: `/${e}?tags=${code.code}&pid=${that.classa._id}`
-					})
-				} else if (num == '3') {
-					uni.navigateTo({
-						url: `/${e}?tags=${code.code}`
-					})
+				let info = {
+					skip: that.skip,
+					limit: that.limit,
+					tags: that.tags
+				}
+				const res = await that.$api(`/viewGoods/indexGoodsList`, `GET`, {
+					...info,
+				})
+				if (res.errcode == '0') {
+					let list = [...that.marketList, ...res.data];
+					that.$set(that, `marketList`, list);
+					that.$set(that, `total`, res.total)
 				} else {
-					uni.navigateTo({
-						url: `/${e}`
+					uni.showToast({
+						title: res.errmsg || '错误信息',
+						icon: 'none'
 					})
 				}
 			},
+			// 分页
+			toPage() {
+				const that = this;
+				let list = that.marketList;
+				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.searchMarket();
+					uni.hideLoading();
+				} else that.$set(that, `is_bottom`, true)
+			},
+			// 触底
+			toScroll(e) {
+				const that = this;
+				let up = that.scrollTop;
+				that.$set(that, `scrollTop`, e.detail.scrollTop);
+				let num = Math.sign(up - e.detail.scrollTop);
+				if (num == 1) that.$set(that, `is_bottom`, false);
+			},
+			// 左侧一级选择
+			toChange(index, e) {
+				const that = this;
+				that.$set(that, `list`, []);
+				that.$set(that, `active`, index);
+				that.$set(that, `tags`, e.code);
+				that.$set(that, `twoActive`, null);
+				that.clearPage();
+				that.searchRight(e);
+				that.searchMarket();
+			},
+			// 右侧二级选择
+			twoChange(e, index) {
+				const that = this;
+				that.$set(that, `tags`, e.code);
+				that.$set(that, `twoActive`, index);
+				that.clearPage();
+				that.searchMarket();
+			},
+			// 清空列表
+			clearPage() {
+				const that = this;
+				that.$set(that, `marketList`, []);
+				that.$set(that, `skip`, 0)
+				that.$set(that, `limit`, 6)
+				that.$set(that, `page`, 0)
+			},
+			// 搜索商品
+			toCommon(e) {
+				const that = this;
+				that.clearPage();
+				uni.navigateTo({
+					url: `/${e}`
+				})
+			},
+			// 购买
+			toBuy(e) {
+				const that = this;
+				that.clearPage();
+				uni.navigateTo({
+					url: `/pagesHome/order/detail?id=${e.id||e._id}`
+				})
+			},
 			// 菜单跳转
 			toPath(e) {
 				if (e && e.route && e.type == '0') {
@@ -126,7 +235,7 @@
 						url: `/${e.route}`
 					})
 				}
-			}
+			},
 		}
 	}
 </script>
@@ -183,43 +292,85 @@
 			}
 
 			.two_2 {
-				padding: 2vw;
 				flex-grow: 1;
 				position: relative;
 				display: flex;
 				flex-direction: column;
 
-				.list {
+				.two_2_1 {
+					padding: 0 2vw;
 					margin: 0 0 2vw 0;
-					padding: 2vw;
-
-					.title {
-						font-size: var(--font16Size);
-						margin: 0 0 2vw 0;
-					}
 
-					.market {
+					.typeScrollview {
 						display: flex;
-						flex-direction: row;
-						flex-wrap: wrap;
+						white-space: nowrap;
 
-						.marketList {
+						.list {
+							display: inline-block;
+							width: 14vw;
+							padding: 1vw;
 							text-align: center;
-							margin: 0 2vw 2vw 0;
-							width: 22vw;
+							border-radius: 5px;
+							margin: 0 2vw 0 0;
 
 							.image {
 								width: 100%;
-								height: 15vw;
+								height: 7vh;
+								border-radius: 5px;
+								border: 1px solid var(--f1Color);
+								;
+							}
+
+							.label {
+								font-size: var(--font12Size);
+							}
+						}
+					}
+				}
+
+				.two_2_2 {
+					padding: 0 2vw;
+					width: 70vw;
+
+					.list {
+						display: flex;
+						width: 66vw;
+						margin: 0 0 2vw 0;
+						padding: 2vw;
+						box-shadow: 0 0 5px var(--f1Color);
+						;
+						border-radius: 5px;
+
+						.img {
+							width: 19vw;
+
+							.image {
+								width: 19vw;
+								height: 12vh;
+								border-radius: 5px;
 							}
+						}
+
+						.info {
+							width: 45vw;
+							padding: 0 0 0 2vw;
 
 							.name {
+								font-size: var(--font15Size);
+								margin: 0 0 1vw 0;
+							}
+
+							.num {
 								font-size: var(--font14Size);
+								color: #858585;
+								margin: 0 0 1vw 0;
 							}
-						}
 
-						.marketList:nth-child(3n) {
-							margin: 0 0 2vw 0;
+							.money {
+								font-size: var(--font14Size);
+								color: #ff0000;
+								margin: 0 0 1vw 0;
+							}
 						}
 					}
 				}
@@ -239,4 +390,15 @@
 			flex-direction: column;
 		}
 	}
+
+	.is_bottom {
+		text-align: center;
+
+		text {
+			padding: 2vw 0;
+			display: inline-block;
+			color: #858585;
+			font-size: 14px;
+		}
+	}
 </style>

+ 2 - 2
pagesHome/market/search.vue

@@ -79,7 +79,7 @@
 				total: 0,
 				page: 0,
 				skip: 0,
-				limit: 5,
+				limit: 6,
 				condActive: 0,
 				shang: '',
 				xia: '',
@@ -268,7 +268,7 @@
 				const that = this;
 				that.$set(that, `list`, [])
 				that.$set(that, `skip`, 0)
-				that.$set(that, `limit`, 5)
+				that.$set(that, `limit`, 6)
 				that.$set(that, `page`, 0)
 			}
 		}

+ 221 - 62
pagesHome/market/type.vue

@@ -15,29 +15,37 @@
 					</scroll-view>
 				</view>
 				<view class="two_2">
-					<scroll-view scroll-y="true" class="scroll-view">
+					<scroll-view scroll-y="true" class="scroll-view" @scrolltolower="toPage" @scroll="toScroll">
 						<view class="list-scroll-view">
-							<view class="list" v-for="(item,index) in list" :key="index" @tap="toCommon('pagesHome/market/search',item,'2')">
-								<view class="title">
-									{{item.label}}
-								</view>
-								<view class="market" v-if="item.children&&item.children.length>0">
-									<view class="marketList" v-for="(tag,indexs) in item.children" :key="indexs" @tap.stop="toCommon('pagesHome/market/search',tag,'3')">
+							<view class="two_2_1">
+								<scroll-view scroll-x="true" class="typeScrollview">
+									<view class="list" v-for="(item,index) in list" :key="index" @tap="twoChange(item,index)">
+										<image class="image" :src="item.file&&item.file.length>0?item.file[0].url:logoUrl" mode=""></image>
+										<view class="label textOver"><text :style="{color:twoActive==index?'#ff0000':'#000000'}">{{item.label}}</text></view>
+									</view>
+								</scroll-view>
+							</view>
+							<view class=" two_2_2">
+								<view class="list" v-for="(tag,index) in marketList" :key="index" @tap="toBuy(tag)">
+									<view class="img">
 										<image class="image" :src="tag.file&&tag.file.length>0?tag.file[0].url:''" mode=""></image>
-										<view class="name">
-											{{tag.label}}
-										</view>
 									</view>
-								</view>
-								<view class="market" v-else>
-									<view class="marketList" @tap.stop="toCommon('pagesHome/market/search',item,'3')">
-										<image class="image" :src="item.file&&item.file.length>0?item.file[0].url:''" mode=""></image>
-										<view class="name">
-											{{item.label}}
+									<view class="info">
+										<view class="name textOver">
+											<text>{{tag.name}}</text>
+										</view>
+										<view class="num">
+											<text>库存{{tag.num}}</text>
+										</view>
+										<view class="money">
+											<text>¥{{tag.sell_money}}</text>
 										</view>
 									</view>
 								</view>
 							</view>
+							<view class="is_bottom" v-if="is_bottom">
+								<text>{{config.bottom_title}}</text>
+							</view>
 						</view>
 					</scroll-view>
 				</view>
@@ -53,17 +61,48 @@
 				active: '0',
 				typeList: [],
 				list: [],
-				// 一级
-				classa: {},
+				// 平台信息
+				config: {},
+				logoUrl: '',
+				// 商品分类tags
+				tags: '',
+				twoActive: null,
+				// 商品列表
+				marketList: [],
+				total: 0,
+				page: 0,
+				skip: 0,
+				limit: 6,
+				// 数据是否触底
+				is_bottom: false,
+				scrollTop: 0,
 			};
 		},
-		onLoad: function() {
+		onShow: function() {
 			const that = this;
-			that.searchOther();
-
+			that.searchConfig();
+			that.search();
 		},
 		methods: {
-			async searchOther() {
+			// 查询基本设置
+			searchConfig() {
+				const that = this;
+				uni.getStorage({
+					key: 'config',
+					success: function(res) {
+						let data = res.data;
+						that.$set(that, `config`, data)
+						if (data) {
+							that.$set(that, `logoUrl`, data.config.logo[0].url)
+						}
+					},
+					fail: function(err) {
+						console.log(err);
+					}
+				})
+			},
+			// 查询左侧一级列表
+			async search() {
 				const that = this;
 				let res;
 				res = await that.$api(`/goodsTags`, 'GET', {
@@ -73,18 +112,13 @@
 					that.$set(that, `typeList`, res.data);
 					if (res.total > 0) {
 						that.searchRight(res.data[0]);
-						that.$set(that, `classa`, res.data[0]);
+						// 查询产品
+						that.$set(that, `tags`, res.data[0].code)
+						that.searchMarket()
 					}
 				}
 			},
-			toChange(index, e) {
-				const that = this;
-				that.$set(that, `list`, []);
-				that.$set(that, `active`, index);
-				that.searchRight(e);
-				that.$set(that, `classa`, e);
-			},
-			// 查询左侧信息
+			// 查询左侧二级信息
 			async searchRight(e) {
 				const that = this;
 				let info = {};
@@ -93,26 +127,100 @@
 					...info
 				})
 				if (res.errcode == '0' && res.data.length > 0) {
-					that.$set(that, `list`, res.data[0].children)
+					that.$set(that, `list`, res.data[0].children);
 				}
 			},
-			// 公共跳转
-			toCommon(e, code, num) {
+			// 查询产品
+			async searchMarket() {
 				const that = this;
-				if (num == '2') {
-					uni.navigateTo({
-						url: `/${e}?tags=${code.code}&pid=${that.classa._id}`
-					})
-				} else if (num == '3') {
-					uni.navigateTo({
-						url: `/${e}?tags=${code.code}`
-					})
+				let info = {
+					skip: that.skip,
+					limit: that.limit,
+					tags: that.tags
+				}
+				const res = await that.$api(`/viewGoods/indexGoodsList`, `GET`, {
+					...info,
+				})
+				if (res.errcode == '0') {
+					let list = [...that.marketList, ...res.data];
+					that.$set(that, `marketList`, list);
+					that.$set(that, `total`, res.total)
 				} else {
-					uni.navigateTo({
-						url: `/${e}`
+					uni.showToast({
+						title: res.errmsg || '错误信息',
+						icon: 'none'
 					})
 				}
 			},
+			// 分页
+			toPage() {
+				const that = this;
+				let list = that.marketList;
+				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.searchMarket();
+					uni.hideLoading();
+				} else that.$set(that, `is_bottom`, true)
+			},
+			// 触底
+			toScroll(e) {
+				const that = this;
+				let up = that.scrollTop;
+				that.$set(that, `scrollTop`, e.detail.scrollTop);
+				let num = Math.sign(up - e.detail.scrollTop);
+				if (num == 1) that.$set(that, `is_bottom`, false);
+			},
+			// 左侧一级选择
+			toChange(index, e) {
+				const that = this;
+				that.$set(that, `list`, []);
+				that.$set(that, `active`, index);
+				that.$set(that, `tags`, e.code);
+				that.$set(that, `twoActive`, null);
+				that.clearPage();
+				that.searchRight(e);
+				that.searchMarket();
+			},
+			// 右侧二级选择
+			twoChange(e, index) {
+				const that = this;
+				that.$set(that, `tags`, e.code);
+				that.$set(that, `twoActive`, index);
+				that.clearPage();
+				that.searchMarket();
+			},
+			// 清空列表
+			clearPage() {
+				const that = this;
+				that.$set(that, `marketList`, []);
+				that.$set(that, `skip`, 0)
+				that.$set(that, `limit`, 6)
+				that.$set(that, `page`, 0)
+			},
+			// 搜索商品
+			toCommon(e) {
+				const that = this;
+				that.clearPage();
+				uni.navigateTo({
+					url: `/${e}`
+				})
+			},
+			// 购买
+			toBuy(e) {
+				const that = this;
+				that.clearPage();
+				uni.navigateTo({
+					url: `/pagesHome/order/detail?id=${e.id||e._id}`
+				})
+			},
 		},
 
 	}
@@ -165,43 +273,83 @@
 			}
 
 			.two_2 {
-				padding: 2vw;
 				flex-grow: 1;
 				position: relative;
 				display: flex;
 				flex-direction: column;
 
-				.list {
+				.two_2_1 {
+					padding: 0 2vw;
 					margin: 0 0 2vw 0;
-					padding: 2vw;
 
-					.title {
-						font-size: var(--font16Size);
-						margin: 0 0 2vw 0;
-					}
-
-					.market {
+					.typeScrollview {
 						display: flex;
-						flex-direction: row;
-						flex-wrap: wrap;
+						white-space: nowrap;
 
-						.marketList {
+						.list {
+							display: inline-block;
+							width: 14vw;
+							padding: 1vw;
 							text-align: center;
-							margin: 0 2vw 2vw 0;
-							width: 22vw;
+							border-radius: 5px;
+							margin: 0 2vw 0 0;
 
 							.image {
 								width: 100%;
-								height: 15vw;
+								height: 7vh;
+								border-radius: 5px;
+								border: 1px solid var(--f1Color);
+							}
+
+							.label {
+								font-size: var(--font12Size);
+							}
+						}
+					}
+				}
+
+				.two_2_2 {
+					padding: 0 2vw;
+					width: 70vw;
+
+					.list {
+						display: flex;
+						width: 66vw;
+						margin: 0 0 2vw 0;
+						padding: 2vw;
+						box-shadow: 0 0 5px var(--f1Color);
+						border-radius: 5px;
+
+						.img {
+							width: 19vw;
+
+							.image {
+								width: 19vw;
+								height: 12vh;
+								border-radius: 5px;
 							}
+						}
+
+						.info {
+							width: 45vw;
+							padding: 0 0 0 2vw;
 
 							.name {
+								font-size: var(--font15Size);
+								margin: 0 0 1vw 0;
+							}
+
+							.num {
 								font-size: var(--font14Size);
+								color: var(--f85Color);
+								margin: 0 0 1vw 0;
 							}
-						}
 
-						.marketList:nth-child(3n) {
-							margin: 0 0 2vw 0;
+							.money {
+								font-size: var(--font14Size);
+								color: var(--fFB1Color);
+								margin: 0 0 1vw 0;
+							}
 						}
 					}
 				}
@@ -209,6 +357,17 @@
 		}
 	}
 
+	.is_bottom {
+		text-align: center;
+
+		text {
+			padding: 2vw 0;
+			display: inline-block;
+			color: #858585;
+			font-size: 14px;
+		}
+	}
+
 	.scroll-view {
 		position: absolute;
 		top: 0;