瀏覽代碼

banner广告功能

zhengkaixin 4 年之前
父節點
當前提交
a9b24496c3
共有 5 個文件被更改,包括 35 次插入21 次删除
  1. 1 1
      .env.js
  2. 11 0
      apis/index.js
  3. 2 2
      manifest.json
  4. 20 17
      pages/index/index.js
  5. 1 1
      pages/index/index.vue

+ 1 - 1
.env.js

@@ -1,5 +1,5 @@
 (function() {  
-    const NODE_ENV = 'test'; // dev:开发环境 | test:测试环境  
+    const NODE_ENV = 'dev'; // dev:开发环境 | test:测试环境  
     let ENV_VAR = null;  
 	 
     if (process.env.NODE_ENV === "development") {  

+ 11 - 0
apis/index.js

@@ -16,3 +16,14 @@ export function passengerNearbyStation(data) {
 		url: '/mobile/passengerApi/passengerNearbyStation'
 	})
 }
+export function getBannerInfo(data) {
+	return request({
+		method: 'post',
+		data: {
+			type:data
+		},
+		
+		url: '/mobile/bannerInfo/getBannerInfo'
+		
+	})
+}

+ 2 - 2
manifest.json

@@ -70,8 +70,8 @@
     },
     "h5" : {
         "devServer" : {
-            "port" : 80,
-            "https" : true,
+            "port" : 8080,
+            "https" : false,
             "disableHostCheck" : true
         },
         "optimization" : {

+ 20 - 17
pages/index/index.js

@@ -22,22 +22,7 @@ export default {
 											value: '沙市',
 					},
 				],
-				list: [{
-						image: 'https://cdn.uviewui.com/uview/swiper/1.jpg',
-						title: '昨夜星辰昨夜风,画楼西畔桂堂东',
-						url:"/pages/buytickets/index?id=0cb4dd6c-ca33-4837-bd4a-7f01afb4d1a3"
-					},
-					{
-						image: 'https://cdn.uviewui.com/uview/swiper/2.jpg',
-						title: '身无彩凤双飞翼,心有灵犀一点通',
-						url:"/pages/buytickets/index?id=0cb4dd6c-ca33-4837-bd4a-7f01afb4d1a3"
-					},
-					{
-						image: 'https://cdn.uviewui.com/uview/swiper/3.jpg',
-						title: '谁念西风独自凉,萧萧黄叶闭疏窗,沉思往事立残阳',
-						url:"/pages/buytickets/index?id=0cb4dd6c-ca33-4837-bd4a-7f01afb4d1a3"
-					}
-				],
+				list: [ ],
 				siteList:[
 				]
 			}
@@ -46,6 +31,20 @@ export default {
 			
 		},
 		methods: {
+			getBanner() {
+			      API.getBannerInfo("1").then((res) => {
+			      	this.list=res.data;
+					for(var i in this.list){
+						var obj=this.list[i]
+						obj.url=obj.linkUrl
+						obj.image=obj.picUrl
+						obj.title=obj.name
+					}
+					this.carhelp.set("bannerList",this.list);
+			      }).catch(error => {
+			      	this.$refs.common.alert( error);
+			      })     
+			},
 			 bindPickerChange: function(e) {
 			           // console.log('picker发送选择改变,携带值为', e.target.value)
 			            this.index = e.target.value
@@ -127,8 +126,12 @@ export default {
 			}
 		},onReady(){
 			WxJsApi.getWxConfig(['scanQRCode','getLocation']);	
-					
+			var list=this.carhelp.get("bannerList");
+			if(list){
+				this.list=list;
+			}
 			this.getPoint();
+			this.getBanner();
 			//清空缓存
 			this.carhelp.set("form",{});
 		}

+ 1 - 1
pages/index/index.vue

@@ -22,7 +22,7 @@
 			</view>
 			
 		</u-navbar>	
-		<view class="banner">
+		<view class="banner" v-show="list.length">
 			<u-swiper :list="list" @click="clickSwiper"></u-swiper>
 		</view>