暂存我的页面修改
This commit is contained in:
72
components/banner/index.js
Normal file
72
components/banner/index.js
Normal file
@@ -0,0 +1,72 @@
|
||||
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,
|
||||
type: Number,
|
||||
},
|
||||
observers: {
|
||||
'park,type': function(newPark, newType) {
|
||||
if ((!newPark && newType === 0) || (!newType && newType !== 0)) {
|
||||
return
|
||||
}
|
||||
this.init(newPark, newType)
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 组件的初始数据
|
||||
*/
|
||||
data: {
|
||||
indicatorDots: true,
|
||||
vertical: false,
|
||||
autoplay: false,
|
||||
interval: 2000,
|
||||
duration: 500,
|
||||
list: [],
|
||||
},
|
||||
/**
|
||||
* 组件的方法列表
|
||||
*/
|
||||
methods: {
|
||||
async init(park, type) {
|
||||
const { code, message, data = [] } = await getBannerList(park, type);
|
||||
if (code !== OK) {
|
||||
alertInfo(message);
|
||||
this.setData({ list: [], park, type })
|
||||
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
components/banner/index.json
Normal file
6
components/banner/index.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {
|
||||
"van-image": "@vant/weapp/image/index"
|
||||
}
|
||||
}
|
22
components/banner/index.wxml
Normal file
22
components/banner/index.wxml
Normal file
@@ -0,0 +1,22 @@
|
||||
<!--pages/home/components/home-swiper/index.wxml-->
|
||||
<swiper
|
||||
indicator-dots="{{indicatorDots}}"
|
||||
autoplay="{{autoplay}}"
|
||||
interval="{{interval}}"
|
||||
duration="{{duration}}"
|
||||
wx:if="{{list.length}}"
|
||||
style="height: 288rpx"
|
||||
>
|
||||
<block wx:for="{{list}}" wx:key="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
components/banner/index.wxss
Normal file
1
components/banner/index.wxss
Normal file
@@ -0,0 +1 @@
|
||||
/* pages/home/components/home-swiper/index.wxss */
|
Reference in New Issue
Block a user