guhongwei 2 년 전
부모
커밋
609028a0da
4개의 변경된 파일285개의 추가작업 그리고 29개의 파일을 삭제
  1. 9 3
      pages.json
  2. 87 24
      pages/home/index.vue
  3. 3 2
      pages/index/index.vue
  4. 186 0
      pagesRest/recom/index.vue

+ 9 - 3
pages.json

@@ -149,7 +149,7 @@
 						"navigationBarTitleText": "新增收货地址"
 					}
 				},
-         {
+				{
 					"path": "account/index",
 					"style": {
 						"navigationBarTitleText": "账号管理"
@@ -276,13 +276,19 @@
 		},
 		{
 			"root": "pagesRest",
-			"pages": [
-				{
+			"pages": [{
 					"path": "article/index",
 					"style": {
 						"navigationBarTitleText": "详细信息"
 					}
+				},
+				{
+					"path": "recom/index",
+					"style": {
+						"navigationBarTitleText": "商品类别"
+					}
 				}
+
 			]
 		}
 	],

+ 87 - 24
pages/home/index.vue

@@ -23,13 +23,20 @@
 						</view>
 					</view>
 					<view class="zero four" v-if="recomList&&recomList.length>0">
-						<view class="recomList" v-for="(item,index) in recomList" :key="index">
+						<view class="recomList" v-for="(item,index) in recomList" :key="index" v-if="item.list&&item.list.length>0">
 							<view class="list" v-for="(tag,indexs) in item.list" :key="indexs" @tap="toBuy(tag)">
-								<view class="title">
-									<text>{{tag.title||'&nbsp;'}}</text>
+								<view class="list_1">
+									<view class="txt">
+										<text>{{tag.title}}</text>
+									</view>
+									<view class="more" v-if="indexs==1" @tap.stop="toMore(tag)">
+										<text>更多</text>
+									</view>
 								</view>
-								<image class="image" :src="tag.url&&tag.url.length>0?tag.url[0].url:''" mode=""></image>
-								<view class="textOver name">
+								<view class="list_2">
+									<image class="image" :src="tag.url&&tag.url.length>0?tag.url[0].url:''" mode=""></image>
+								</view>
+								<view class="list_3 textOver">
 									{{tag.name}}
 								</view>
 							</view>
@@ -56,9 +63,9 @@
 							</view>
 						</view>
 					</view>
-					<view class="is_bottom" v-if="is_bottom">
+					<!-- 			<view class="is_bottom" v-if="is_bottom">
 						<text>数据到底了!!</text>
-					</view>
+					</view> -->
 				</view>
 			</view>
 		</scroll-view>
@@ -95,8 +102,8 @@
 				old: {
 					scrollTop: 0
 				},
-				// 数据是否触底
-				is_bottom: false,
+				// // 数据是否触底
+				// is_bottom: false,
 			};
 		},
 		onLoad: function() {},
@@ -165,6 +172,14 @@
 					})
 				}
 			},
+			// 推荐好物更多
+			toMore(e) {
+				const that = this;
+				that.clearPage();
+				uni.navigateTo({
+					url: `/pagesRest/recom/index?act_tags=${e.value}&type=2`
+				})
+			},
 			// 购买
 			toBuy(e) {
 				const that = this;
@@ -201,7 +216,7 @@
 					that.search();
 					uni.hideLoading();
 				} else {
-					that.$set(that, `is_bottom`, true)
+					// that.$set(that, `is_bottom`, true)
 				}
 			},
 			// 计算高度
@@ -307,44 +322,92 @@
 			padding: 2vw 0 0 0;
 
 			.recomList {
+				width: 41vw;
 				display: flex;
-				flex-direction: row;
 				justify-content: space-around;
-				width: 41vw;
+				background-image: linear-gradient(to bottom, rgba(250, 216, 213, 1) 5%, rgba(255, 255, 255, 1) 22%);
 				margin: 0 0 2vw 0;
+				border-radius: 5px;
 				padding: 2vw;
-				border-radius: 10px;
-				background-image: linear-gradient(to bottom, rgba(250, 216, 213, 1) 5%, rgba(255, 255, 255, 1) 22%);
 
 				.list {
 					width: 20vw;
 					text-align: center;
 
-					.title {
-						text-align: center;
-						font-weight: bold;
-						font-size: var(--font15Size);
-						;
+					.list_1 {
+						display: flex;
+						justify-content: space-between;
 						margin: 0 0 1vw 0;
+
+						.txt {
+							font-size: 15px;
+						}
+
+						.more {
+							font-size: 12px;
+						}
 					}
 
-					.image {
-						width: 18vw;
-						height: 20vw;
+					.list_2 {
 						margin: 0 0 1vw 0;
+
+						.image {
+							width: 96%;
+							height: 18vw;
+						}
 					}
 
-					.name {
+					.list_3 {
 						width: 17vw;
 						font-size: var(--font12Size);
-						;
 						border: 1px solid var(--fFB1Color);
 						border-radius: 25px;
 						padding: 0 1vw;
 						text-align: center;
 					}
 				}
+
 			}
+
+			// .recomList {
+			// 	display: flex;
+			// 	flex-direction: row;
+			// 	justify-content: space-around;
+			// 	width: 41vw;
+			// 	margin: 0 0 2vw 0;
+			// 	padding: 2vw;
+			// 	border-radius: 10px;
+			// 	background-image: linear-gradient(to bottom, rgba(250, 216, 213, 1) 5%, rgba(255, 255, 255, 1) 22%);
+
+			// 	.list {
+			// 		width: 20vw;
+			// 		text-align: center;
+
+			// 		.title {
+			// 			text-align: center;
+			// 			font-weight: bold;
+			// 			font-size: var(--font15Size);
+			// 			;
+			// 			margin: 0 0 1vw 0;
+			// 		}
+
+			// 		.image {
+			// 			width: 18vw;
+			// 			height: 20vw;
+			// 			margin: 0 0 1vw 0;
+			// 		}
+
+			// 		.name {
+			// 			width: 17vw;
+			// 			font-size: var(--font12Size);
+			// 			;
+			// 			border: 1px solid var(--fFB1Color);
+			// 			border-radius: 25px;
+			// 			padding: 0 1vw;
+			// 			text-align: center;
+			// 		}
+			// 	}
+			// }
 		}
 
 		.five {

+ 3 - 2
pages/index/index.vue

@@ -27,8 +27,8 @@
 			async searchConfig() {
 				const that = this;
 				let res = await that.$api(`/config`, 'GET', {});
-				if (res.errcode == '0' && res.total > 0) {
-					let config = res.data[0];
+				if (res.errcode == '0') {
+					let config = res.data;
 					that.$set(that, `logoUrl`, config.config.share[0].url)
 					uni.setStorage({
 						key: 'config',
@@ -53,6 +53,7 @@
 							data: res,
 							success: function() {
 								uni.redirectTo({
+									// url: `/pagesRest/recom/index?act_tags=xpsj`
 									url: `/pages/home/index`
 								})
 							}

+ 186 - 0
pagesRest/recom/index.vue

@@ -0,0 +1,186 @@
+<template>
+	<mobile-frame>
+		<view class="main">
+			<view class="one">
+				<image class="image" :src="topUrl" mode=""></image>
+			</view>
+			<view class="two">
+				<view class="pubu">
+					<view class="list" v-for="(item,index) in list" :key="index" @tap="toBuy(item)">
+						<view class="list_1">
+							<image class="image" :src="item.file&&item.file.length>0?item.file[0].url:''" mode=""></image>
+						</view>
+						<view class="name">
+							{{item.name}}
+						</view>
+					</view>
+				</view>
+			</view>
+			<view class="is_bottom" v-if="is_bottom">
+				<text>数据到底了!!</text>
+			</view>
+		</view>
+	</mobile-frame>
+</template>
+
+<script>
+	export default {
+		data() {
+			return {
+				// 系统设置
+				config: {},
+				// 路由参数
+				type: '1',
+				tags: '',
+				act_tags: '',
+				topUrl: '',
+				// 数据列表
+				list: [],
+				is_bottom: true
+			};
+		},
+		onLoad(e) {
+			const that = this;
+			if (e && e.tags) {
+				that.$set(that, `type`, '1')
+				that.$set(that, `tags`, e.tags || '');
+			} else {
+				that.$set(that, `type`, '2')
+				that.$set(that, `act_tags`, e.act_tags || '');
+			}
+		},
+		onShow: function() {
+			const that = this;
+			that.searchConfig();
+			that.searchOther();
+			that.search();
+		},
+		methods: {
+			// 查询基本设置
+			searchConfig() {
+				const that = this;
+				uni.getStorage({
+					key: 'config',
+					success: function(res) {
+						if (res.data) that.$set(that, `config`, res.data)
+					},
+					fail: function(err) {
+						console.log(err);
+					}
+				})
+			},
+			async search() {
+				const that = this;
+				let info = {};
+				if (that.type == '1') info.tags = that.tags;
+				else if (that.type == '2') info.act_tags = that.act_tags;
+				let res = await that.$api(`/goods`, 'GET', {
+					...info
+				});
+				if (res.errcode == '0') {
+					that.$set(that, `list`, res.data)
+				}
+			},
+			// 查询其他信息
+			async searchOther() {
+				const that = this;
+				let type = that.type;
+				let act_tags = that.act_tags;
+				let tags = that.tags;
+				let topUrl = [];
+				let res;
+				if (type == '1') {
+					res = await that.$api(`/goodsTags`, 'GET', {
+						code: tags
+					})
+				} else if (type == '2') {
+					res = await that.$api(`/actTags`, 'GET', {
+						value: act_tags
+					})
+				}
+				if (res.errcode == '0' && res.total > 0) {
+					let data = res.data[0];
+					uni.setNavigationBarTitle({
+						title: data.label
+					});
+					if (data.file.length > 0) topUrl = data;
+				}
+				if (topUrl.length > 0) {
+					that.$set(that, `topUrl`, topUrl[0].url)
+				} else {
+					that.$set(that, `topUrl`, that.config.config.logo[0].url)
+				}
+			},
+			// 购买
+			toBuy(e) {
+				const that = this;
+				uni.navigateTo({
+					url: `/pagesHome/order/detail?id=${e._id}`
+				})
+			},
+		}
+	}
+</script>
+
+<style lang="scss">
+	.main {
+		display: flex;
+		flex-direction: column;
+		width: 100vw;
+		height: 100vh;
+
+		.one {
+			padding: 2vw;
+
+			.image {
+				width: 100%;
+				height: 200px;
+				box-shadow: 0 0 5px #858585;
+				border-radius: 10px;
+			}
+		}
+
+		.two {
+			padding: 0 2vw;
+			margin: 0 0 2vw 0;
+
+			.pubu {
+				column-count: 2;
+				column-gap: 3vw;
+
+				.list {
+					margin: 0 0 2vw 0;
+					-webkit-column-break-inside: avoid;
+					break-inside: avoid;
+					box-shadow: 0 0 5px #858585;
+					padding: 2vw;
+					border-radius: 5px;
+
+					.list_1 {
+						margin: 0 0 1vw 0;
+
+						.image {
+							width: 100%;
+							height: 30vh;
+							border-radius: 10px;
+							box-shadow: 0 0 5px #f1f1f1;
+						}
+					}
+
+					.name {
+						font-size: 16px;
+					}
+				}
+			}
+		}
+	}
+
+	.is_bottom {
+		text-align: center;
+
+		text {
+			padding: 2vw 0;
+			display: inline-block;
+		}
+	}
+</style>