暂存首页改造,banner
This commit is contained in:
		
							
								
								
									
										68
									
								
								pages/home/components/home-swiper/index.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										68
									
								
								pages/home/components/home-swiper/index.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,68 @@ | ||||
| import { getBannerList } from "../../../../service/system" | ||||
| import { alertInfo } from "../../../../utils/index"; | ||||
| import request from '../../../../utils/request' | ||||
|  | ||||
| const { OK } = request; | ||||
|  | ||||
| // pages/home/components/home-swiper/index.js | ||||
| Component({ | ||||
|  | ||||
|   /** | ||||
|    * 组件的属性列表 | ||||
|    */ | ||||
|   properties: { | ||||
|     park: String, | ||||
|   }, | ||||
|   observers: { | ||||
|     'park': function(newValue) { | ||||
|       this.init(newValue) | ||||
|     } | ||||
|   }, | ||||
|   /** | ||||
|    * 组件的初始数据 | ||||
|    */ | ||||
|   data: { | ||||
|     indicatorDots: true, | ||||
|     vertical: false, | ||||
|     autoplay: false, | ||||
|     interval: 2000, | ||||
|     duration: 500, | ||||
|     list: [], | ||||
|   }, | ||||
|   /** | ||||
|    * 组件的方法列表 | ||||
|    */ | ||||
|   methods: { | ||||
|     async init(park) { | ||||
|       const { code, message, data = [] } = await getBannerList(park, 1); | ||||
|       if (code !== OK) { | ||||
|         alertInfo(message); | ||||
|         this.setData({ list: [] }) | ||||
|         return  | ||||
|       } | ||||
|       this.setData({ list: data }) | ||||
|     }, | ||||
|     handleJump(e) { | ||||
|       const { data = {} } = e.currentTarget.dataset; | ||||
|       switch(data.jumpType) { | ||||
|         case 1: | ||||
|           wx.navigateToMiniProgram({ | ||||
|             appId: data.appId, | ||||
|             path: data.wxPath, | ||||
|             envVersion: "trial" | ||||
|           }) | ||||
|           break; | ||||
|         case 2: | ||||
|           wx.navigateTo({ | ||||
|             url: data.value, | ||||
|           }) | ||||
|           break; | ||||
|         case 3: | ||||
|           wx.navigateTo({ | ||||
|             url: '/pages/webPage/index?path=' + data.value, | ||||
|           }) | ||||
|           break; | ||||
|       } | ||||
|     } | ||||
|   } | ||||
| }) | ||||
							
								
								
									
										6
									
								
								pages/home/components/home-swiper/index.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								pages/home/components/home-swiper/index.json
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,6 @@ | ||||
| { | ||||
|   "component": true, | ||||
|   "usingComponents": { | ||||
|     "van-image": "@vant/weapp/image/index" | ||||
|   } | ||||
| } | ||||
							
								
								
									
										21
									
								
								pages/home/components/home-swiper/index.wxml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								pages/home/components/home-swiper/index.wxml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,21 @@ | ||||
| <!--pages/home/components/home-swiper/index.wxml--> | ||||
| <swiper  | ||||
|     indicator-dots="{{indicatorDots}}" | ||||
|     autoplay="{{autoplay}}"  | ||||
|     interval="{{interval}}"  | ||||
|     duration="{{duration}}" | ||||
|     wx:if="{{list.length}}" | ||||
| > | ||||
|   <block wx:for="{{list}}" wx:key="{{item.id}}" wx:item="item"> | ||||
|     <swiper-item> | ||||
|         <van-image | ||||
|             width="100%" | ||||
|             height="100%" | ||||
|             lazy-load | ||||
|             src="{{item.url}}" | ||||
|             data-data="{{item}}" | ||||
|             bind:click="handleJump" | ||||
|         /> | ||||
|     </swiper-item> | ||||
|   </block> | ||||
| </swiper> | ||||
							
								
								
									
										1
									
								
								pages/home/components/home-swiper/index.wxss
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								pages/home/components/home-swiper/index.wxss
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1 @@ | ||||
| /* pages/home/components/home-swiper/index.wxss */ | ||||
		Reference in New Issue
	
	Block a user