chenxiong il y a 3 ans
Parent
commit
2d1058401b
2 fichiers modifiés avec 56 ajouts et 5 suppressions
  1. 18 1
      common/httpList/base.js
  2. 38 4
      pages/index/index.vue

+ 18 - 1
common/httpList/base.js

@@ -22,6 +22,23 @@ export default {
 			method: 'get',
 			data: data
 		})
-	}
+	},
+	
+	advertisingHomeLocation(data) {
+		return myRequest({
+			url: '/app/common/base/advertising/homeLocation',
+			method: 'get',
+			data: data,
+			noToken: true
+		})
+	},
+	advertisingList(data) {
+		return myRequest({
+			url: '/app/common/base/advertising/list',
+			method: 'get',
+			data: data,
+			noToken: true
+		})
+	},
 	
 }

+ 38 - 4
pages/index/index.vue

@@ -5,7 +5,11 @@
 				<image  src="/static/logo2.png"></image>
 			</view>
 		</u-navbar>
-		<u-swiper height="320" border-radius="0" :list="list" @change="e => current = e.current" :autoplay="false"></u-swiper>
+		<swiper :style="{'height':swiperHeight+'rpx'}" @change="e => current = e.current" :interval="interval" :duration="duration"  :autoplay="autoplay">
+			<swiper-item v-for="swiper in list">
+				<image style="width:100%"  @load="imageLoad" :src="$method.splitImgHost(swiper.adverUrl, true)" mode="widthFix"></image>
+			</swiper-item>
+		</swiper>
 		<view class="content">
 			<view class="notice" v-if="infoNums">
 				<image src="/static/icon/msg_icon1.png" class="icon"></image>
@@ -126,9 +130,7 @@ export default {
 	data() {
 		return {
 			infoNums:0,
-			list:[
-				'https://file.xyyxt.net/oss/images/file/20220111.jpg',
-			],
+			list:[],
 			tabCurrent:0,
 			date:['日','一','二','三','四','五','六'],
 			date_num: [],
@@ -137,6 +139,7 @@ export default {
 			autoplay: true,
 			interval: 2000,
 			duration: 500,
+			swiperHeight:0,
 			menu: [{
 					name: '推荐课程',
 				}, {
@@ -174,6 +177,7 @@ export default {
 		this.init()
 		this.courseList();
 		this.bankList();
+		this.getAdvertising()
 	},
 	onShow() {
 		if (uni.getStorageSync('updateHome')|| !this.isOld){
@@ -204,6 +208,36 @@ export default {
 		};
 	},
 	methods: {
+		/**
+		 * banner图片加载完成
+		 */
+		imageLoad(e) {
+			let winW = 750;
+			let imgW = e.detail.width;
+			let imgH = e.detail.height;
+			this.swiperHeight = 750 * imgH / imgW;
+		},
+		async getAdvertising() {
+			await this.advertisingHomeLocation();
+			await this.advertisingList();
+		},
+		
+		advertisingHomeLocation() {
+			return new Promise(resolve => {
+				this.$api.advertisingHomeLocation().then(res => {
+					this.interval = res.data.data.intervalTime * 1000
+					resolve()
+				})
+			})
+		},
+		advertisingList() {
+			return new Promise(resolve => {
+				this.$api.advertisingList().then(res => {
+					this.list = res.data.rows;
+					resolve()
+				})
+			})
+		},
 		jumpPage(){
 			this.$navTo.togo('/pages2/msg/index')
 		},