electricity_bill_calc_wx/pages/home/components/home-swiper/index.js

68 lines
1.4 KiB
JavaScript

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