67 lines
1.9 KiB
JavaScript
Raw Permalink Normal View History

2024-02-21 17:43:11 +08:00
var app = getApp()
Page({
2024-02-23 09:56:56 +08:00
data: {
type: 1,
currentTab: 0,
labelList: [
'休闲',
'免费'
],
homelist: [],
IMG_NAME: app.IMG_NAME
},
onLoad(options) {
// 页面初始化 options为页面跳转所带来的参数
wx.setNavigationBarTitle({
title: options.name
})
},
onShow(e) {
let that = this
// wx.setStorageSync('token', '535e73059d2f4301b78d05326e1a55d8')
app.AjaxRequest('get', {
'content-type': 'application/json',
'Authorization': 'Bearer ' + app.Getopenid()
}, '/activity/list', {},
function (res) {
if (res.code == 0) {
for (var i in res.rows) {
let day = res.rows[i].actBegin.slice(5, 7) + '月' + res.rows[i].actBegin.slice(8, 10) + '日'
res.rows[i].day = day
}
that.setData({
homelist: res.rows
})
}
})
},
//滑动切换
swiperTab: function (e) {
var that = this
that.setData({
currentTab: e.detail.current
})
},
//点击切换
clickTab: function (e) {
var that = this
if (this.data.currentTab === e.target.dataset.current) {
return false
} else {
that.setData({
currentTab: e.target.dataset.current
})
}
},
navDetail(e) {
let that = this
let index = e.currentTarget.dataset.index
if (wx.getStorageSync('token')) {
wx.navigateTo({
url: '/pages/community/eventDetails/eventDetails?id=' + that.data.homelist[index].id
})
} else {
app.getlogin()
2024-02-21 17:43:11 +08:00
}
}
})