Browse Source

Signed-off-by: liuboyan <632697560@qq.com>
图标

liuboyan 4 years ago
parent
commit
7dc7dd7d31
6 changed files with 113 additions and 58 deletions
  1. 35 30
      pages.json
  2. 50 16
      pages/index/index.vue
  3. 8 0
      pagesGood/goodList.vue
  4. 8 0
      pagesGood/shopDetails.vue
  5. 10 7
      static/iconfont.css
  6. 2 5
      utils/request.js

+ 35 - 30
pages.json

@@ -1,6 +1,5 @@
 {
-	"pages": [
-		{
+	"pages": [{
 			"path": "pages/index/index",
 			"style": {
 				"navigationBarTitleText": "首页"
@@ -19,18 +18,25 @@
 			}
 		}
 	],
-	"subPackages": [
-		{
-			"root": "pagesGood",
-			"pages": [{
-					"path": "goodDetails",
-					"style": {
-						"navigationBarTitleText": "商品详情"
-					}
-				}
-			]
-		}
-	],
+	"subPackages": [{
+		"root": "pagesGood",
+		"pages": [{
+			"path": "goodDetails",
+			"style": {
+				"navigationBarTitleText": "商品详情"
+			}
+		}, {
+			"path": "goodList",
+			"style": {
+				"navigationBarTitleText": "商品列表"
+			}
+		}, {
+			"path": "shopDetails",
+			"style": {
+				"navigationBarTitleText": "商铺详情"
+			}
+		}]
+	}],
 	"globalStyle": {
 		"navigationStyle": "default",
 		"navigationBarTextStyle": "black",
@@ -44,21 +50,20 @@
 		"color": "#9A9A9A",
 		"selectedColor": "#52A63A",
 		"list": [{
-				"pagePath": "pages/index/index",
-				"iconPath": "static/images/caizhai.png",
-				"selectedIconPath": "static/images/caizhai.png",
-				"text": "首页"
-			},{
-				"pagePath": "pages/shop/index",
-				"iconPath": "static/images/caizhai.png",
-				"selectedIconPath": "static/images/caizhai.png",
-				"text": "商城"
-			},{
-				"pagePath": "pages/cart/cart",
-				"iconPath": "static/images/caizhai.png",
-				"selectedIconPath": "static/images/caizhai.png",
-				"text": "购物车"
-			}
-		]
+			"pagePath": "pages/index/index",
+			"iconPath": "static/images/caizhai.png",
+			"selectedIconPath": "static/images/caizhai.png",
+			"text": "首页"
+		}, {
+			"pagePath": "pages/shop/index",
+			"iconPath": "static/images/caizhai.png",
+			"selectedIconPath": "static/images/caizhai.png",
+			"text": "商城"
+		}, {
+			"pagePath": "pages/cart/cart",
+			"iconPath": "static/images/caizhai.png",
+			"selectedIconPath": "static/images/caizhai.png",
+			"text": "购物车"
+		}]
 	}
 }

+ 50 - 16
pages/index/index.vue

@@ -1,17 +1,17 @@
 <template>
 	<view class="container">
 		<view class="search">
-			<uni-search-bar radius="100" placeholder="搜索" clearButton="auto" cancelButton="none" bgColor="#ffffff" @confirm="search" />
+			<uni-search-bar radius="100" placeholder="搜索" clearButton="auto" cancelButton="none" bgColor="#ffffff" @confirm="goToGoodList" />
 		</view>
 		<view>
 			<swiper class="swiper" :indicator-dots="false" :autoplay="true" :interval="3000" :duration="500">
 				<swiper-item>
-					<view>A</view>
+					<cover-image class="" v-for="(item,index) in advertList" :key="index" :src="item.imgPath"></cover-image>
 				</swiper-item>
 			</swiper>
 		</view>
 		<view class="entrance">
-			<view class="entrance-col">
+			<view class="entrance-col" @click="goToGoodList">
 				<view class="entrance-button caizhai">自助采摘</view>
 			</view>
 			<view class="entrance-col">
@@ -63,7 +63,8 @@
 		<view class="index-title">
 			<view class="title-text">猜你喜欢</view>
 		</view>
-		<view class="content-box">
+		<scroll-view class="content-box" scroll-y="true" refresher-enabled="true" :refresher-triggered="triggered"
+		 @refresherrefresh="onRefresh" @refresherrestore="onRestore">
 			<view class="goods-row" v-for="(item,index) in goodsList" :key="index" @click="goToGoodDetails(item)">
 				<cover-image class="goods-img" :src="item.imgPath"></cover-image>
 				<view class="goods-info">
@@ -76,7 +77,7 @@
 					</text>
 				</view>
 			</view>
-		</view>
+		</scroll-view>
 	</view>
 </template>
 
@@ -88,7 +89,9 @@
 			return {
 				liveTelecast: null,
 				shortVideo: null,
+				advertList: [],
 				discountList: [],
+				triggered: false,
 				goodsList: [],
 			}
 		},
@@ -96,7 +99,7 @@
 			// this.appLoginWx()
 			NET.request(API.getAdvert, {}, 'GET').then(res => {
 				if (res.code == 0) {
-
+					this.advertList = res.data
 				} else {
 					uni.showToast({
 						title: "获取广告列表失败",
@@ -134,18 +137,12 @@
 					});
 				}
 			})
-			NET.request(API.getPreferGoods, {}, 'GET').then(res => {
-				if (res.code == 0) {
-					this.goodsList = res.data
-				} else {
-					uni.showToast({
-						title: "获取猜你喜欢商品列表失败",
-						icon: "none"
-					});
-				}
-			})
+			setTimeout(() => {
+				this.triggered = true;
+			}, 1000)
 		},
 		methods: {
+			//  获取登录权限
 			appLoginWx() {
 				uni.getProvider({
 					service: 'oauth',
@@ -202,6 +199,43 @@
 					}
 				});
 			},
+			//  下拉刷新
+			onRefresh() {
+				this.getPreferGoodsList()
+			},
+			//  刷新终止
+			onRestore() {
+				this.triggered = 'restore'
+			},
+			//  获取猜你喜欢商品列表
+			getPreferGoodsList() {
+				NET.request(API.getPreferGoods, {}, 'GET').then(res => {
+					if (res.code == 0) {
+						this.triggered = false;
+						this.goodsList = res.data
+					} else {
+						uni.showToast({
+							title: "获取猜你喜欢商品列表失败",
+							icon: "none"
+						})
+					}
+				})
+			},
+			//  跳转商品列表
+			goToGoodList(data) {
+				switch (data) {
+					case 0:
+						uni.navigateTo({
+							url: '/pagesGood/goodList?search=' + data
+						});
+						break;
+					default:
+						uni.navigateTo({
+							url: '/pagesGood/goodList?search=' + data.value
+						});
+				}
+			},
+			//  跳转商品详情
 			goToGoodDetails(item) {
 				uni.navigateTo({
 					url: '/pagesGood/goodDetails?goodId=' + item.productId

+ 8 - 0
pagesGood/goodList.vue

@@ -0,0 +1,8 @@
+<template>
+</template>
+
+<script>
+</script>
+
+<style lang="less" scoped>
+</style>

+ 8 - 0
pagesGood/shopDetails.vue

@@ -0,0 +1,8 @@
+<template>
+</template>
+
+<script>
+</script>
+
+<style>
+</style>

+ 10 - 7
static/iconfont.css

@@ -1,13 +1,12 @@
 @font-face {
   font-family: 'iconfont';  /* project id 2119167 */
-  src: url('https://at.alicdn.com/t/font_2119167_niiwf8dzp8q.eot');
-  src: url('https://at.alicdn.com/t/font_2119167_niiwf8dzp8q.eot?#iefix') format('embedded-opentype'),
-  url('https://at.alicdn.com/t/font_2119167_niiwf8dzp8q.woff2') format('woff2'),
-  url('https://at.alicdn.com/t/font_2119167_niiwf8dzp8q.woff') format('woff'),
-  url('https://at.alicdn.com/t/font_2119167_niiwf8dzp8q.ttf') format('truetype'),
-  url('https://at.alicdn.com/t/font_2119167_niiwf8dzp8q.svg#iconfont') format('svg');
+  src: url('https://at.alicdn.com/t/font_2119167_yyvtw5fd2t.eot');
+  src: url('https://at.alicdn.com/t/font_2119167_yyvtw5fd2t.eot?#iefix') format('embedded-opentype'),
+  url('https://at.alicdn.com/t/font_2119167_yyvtw5fd2t.woff2') format('woff2'),
+  url('https://at.alicdn.com/t/font_2119167_yyvtw5fd2t.woff') format('woff'),
+  url('https://at.alicdn.com/t/font_2119167_yyvtw5fd2t.ttf') format('truetype'),
+  url('https://at.alicdn.com/t/font_2119167_yyvtw5fd2t.svg#iconfont') format('svg');
 }
-
 .iconfont {
   font-family: "iconfont" !important;
   font-size: 16px;
@@ -16,6 +15,10 @@
   -moz-osx-font-smoothing: grayscale;
 }
 
+.iconfeigouxuan:before {
+  content: "\e646";
+}
+
 .iconfangxiang:before {
   content: "\e622";
 }

+ 2 - 5
utils/request.js

@@ -3,11 +3,8 @@ const request = (url, data, method = 'GET') => {
 		let header = {
 			'Content-Type': 'application/json',
 		}
-		const res = uni.getStorageSync('storage_key');
-		// const token = res.token
-		// const token = 'eyJ0eXAiOiJKc29uV2ViVG9rZW4iLCJhbGciOiJIUzI1NiJ9.eyJuYW1lIjoiTEJZIiwidG9rZW5fdHlwZSI6InRva2VuIiwidXNlcmlkIjoiMTMxNDc2OTM4MjQ5NjI3MjM4NCIsImFjY291bnQiOiJvQm56ODRoR3g3QTh2VVBqakNLWEJnQUhLb29nIiwiZXhwIjoxNjAyMzM5NDc3LCJuYmYiOjE2MDIzMTA2Nzd9.TyrNEt6F_tY36xtiLULCiExV2LaS7n_TUO-fb578Ae4'
-		// if (token) {
-		// 	header['token'] = 'Bearer ' + token
+		// if (uni.getStorageSync('token')) {
+		// 	header['token'] = 'Bearer ' + uni.getStorageSync('token')
 		// }
 		uni.request({
 			url: url,