暂存首页改造,banner

This commit is contained in:
2024-11-26 17:00:51 +08:00
parent cfad35ec52
commit 6af35a4632
16 changed files with 209 additions and 18 deletions

View 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;
}
}
}
})

View File

@@ -0,0 +1,6 @@
{
"component": true,
"usingComponents": {
"van-image": "@vant/weapp/image/index"
}
}

View 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>

View File

@@ -0,0 +1 @@
/* pages/home/components/home-swiper/index.wxss */