bt-lcyd/pages/activity/activity.js

172 lines
3.6 KiB
JavaScript
Raw Permalink Normal View History

2022-06-14 10:56:41 +08:00
// pages/activity/activity.js
const app = getApp()
Page({
/**
* 页面的初始数据
*/
data: {
indicatorDots: true,
autoplay: true,
requestIp: '',
token: '',
matchList: [],
activityList: [],
swiperList: []
},
getSwiper: function () {
var self = this
wx.request({
url: self.data.requestIp + 'wxminiapp/article/listpagearticlebycategoryrelease',
data: {
articleCategoryId: 'c3eeeaeb-d60b-4154-871b-67cdf027a558'
},
header: {
"token": self.data.token
},
success: function (res) {
var images = ''
for (var i = 0; i < res.data.rows.length; i++) {
if (i == 0) {
images = images + res.data.rows[i].images
} else {
images = images + ',' + res.data.rows[i].images
}
}
var result = images.split(',')
console.log(result)
self.setData({
swiperList: result
})
}
})
},
goDetail: function (e) {
wx.navigateTo({
url: '../newsDetail/newsDetail?articleContentId=' + e.currentTarget.dataset.id,
})
},
goMatch: function (e) {
wx.navigateTo({
url: '../matchList/matchList?type=' + e.currentTarget.dataset.type,
})
},
getMatchList: function () {
var self = this
wx.request({
url: self.data.requestIp + 'wxminiapp/article/listpagearticlebycategoryrelease',
header: {
'token': self.data.token
},
data: {
articleCategoryId: '674b6d2a-637b-4f65-950e-1343b602574a',
page: 1,
rows: 4
},
success: function (res) {
if(res.statusCode == 200){
for (var i = 0; i < res.data.rows.length; i++) {
res.data.rows[i].images = res.data.rows[i].images.split(',')[0]
}
self.setData({
matchList: res.data.rows
})
}
}
})
},
getAcitivityList: function () {
var self = this
wx.request({
url: self.data.requestIp + 'wxminiapp/article/listpagearticlebycategoryrelease',
header: {
'token': self.data.token
},
data: {
articleCategoryId: '48f0147d-5e12-493a-9d24-eb2d4f74064c',
page: 1,
rows: 4
},
success: function (res) {
for (var i = 0; i < res.data.rows.length; i++) {
res.data.rows[i].images = res.data.rows[i].images.split(',')[0]
}
self.setData({
activityList: res.data.rows
})
}
})
},
getToken: function () {
var self = this
wx.getStorage({
key: 'token',
success: function (res) {
self.setData({
token: res.data
})
self.getMatchList()
self.getAcitivityList()
self.getSwiper()
},
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.setData({
requestIp: app.globalData.requestIp
})
this.getToken()
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})