guhongwei 2 years ago
parent
commit
30344d655a
1 changed files with 20 additions and 22 deletions
  1. 20 22
      pages/home/index.vue

+ 20 - 22
pages/home/index.vue

@@ -1,17 +1,14 @@
 <template>
 	<mobile-frame :frameStyle="frameStyle" @toPath="toPath">
-		<scroll-view class="scrollView" scroll-with-animation :scroll-into-view="topItem" scroll-y="true"
-			@scroll="handleScroll">
+		<scroll-view class="scrollView" scroll-with-animation :scroll-into-view="topItem" scroll-y="true" @scroll="handleScroll">
 			<view class="main" id="top">
 				<view class="zero one">
-					<input type="text" placeholder="搜索商品" @tap="toCommon('pagesHome/market/search')"
-						placeholder-class="placss">
+					<input type="text" placeholder="搜索商品" @tap="toCommon('pagesHome/market/search')" placeholder-class="placss">
 				</view>
 				<view class="zero two">
-					<swiper class="swiper" circular :indicator-dots="true" indicator-color="#ffffff"
-						indicator-active-color="#FB1438" :autoplay="true" :interval="3000" :duration="1000">
+					<swiper class="swiper" circular :indicator-dots="true" indicator-color="#ffffff" indicator-active-color="#FB1438" :autoplay="true" :interval="3000" :duration="1000">
 						<swiper-item class="list" v-for="(item,index) in bannerList" :key="index">
-							<image class="image" :src="item.url" mode=""></image>
+							<image class="image" :src="item.url&&item.url.length>0?item.url[0].url:''" mode=""></image>
 						</swiper-item>
 					</swiper>
 				</view>
@@ -37,8 +34,7 @@
 					</view>
 				</view>
 				<view class="zero five">
-					<view class="list" v-for="(item,index) in marketList" :key="index"
-						@tap="toCommon('pagesHome/market/detail')">
+					<view class="list" v-for="(item,index) in marketList" :key="index" @tap="toCommon('pagesHome/market/detail')">
 						<image class="image" :src="item.url" mode=""></image>
 						<view class="name">
 							{{item.name}}
@@ -70,18 +66,6 @@
 					useBar: true
 				},
 				bannerList: [ // 轮播图
-					{
-						url: require('@/static/test.png')
-					},
-					{
-						url: require('@/static/test.png')
-					},
-					{
-						url: require('@/static/test.png')
-					},
-					{
-						url: require('@/static/test.png')
-					},
 				],
 				btnList: [ //功能按钮
 					{
@@ -226,8 +210,22 @@
 				topItem: ''
 			};
 		},
-		onShow: function() {},
+		onShow: function() {
+			const that = this;
+			that.search();
+		},
 		methods: {
+			async search() {
+				const that = this;
+				let res;
+				// 轮播图
+				res = await that.$api(`/banner`, 'GET', {
+					is_use: '0'
+				});
+				if (res.errcode == '0') {
+					that.$set(that, `bannerList`, res.data);
+				}
+			},
 			// 公共跳转
 			toCommon(e) {
 				uni.navigateTo({