county_seat/xz_mini/pages/activity/activity.js
2024-02-22 11:01:15 +08:00

174 lines
4.5 KiB
JavaScript

// pages/activity/activity.js
var app = getApp();
Page({
/**
* 页面的初始数据
*/
data: {
dataList: [],
areaList: [],
typeList: [],
pages: {
page: 1,
rows: 5,
activityType: ''
}
},
//获取活动分类
getActivityTypeList() {
var _self = this;
app.restAjax.get(app.restAjax.path(app.usercenterUrl + '/app/dictionaryself/listdictionarybyparentidrelease/e36ad682-c6b4-44fe-a05c-889a5ff7c284', []),
null, null,
function (code, data) {
_self.setData({
typeList: data,
'pages.activityType': data[0].dataId
})
_self.getActivityList()
},
function (err) {
}
);
},
getAreaList: function () {
var self = this;
app.restAjax.get(app.restAjax.path(app.usercenterUrl + '/app/dictionaryself/listdictionarybyparentidrelease/e36ad682-c6b4-44fe-a05c-889a5ff7c284', []),
self.data.pages, null,
function (code, data) {
if (code == '200') {
self.setData({
areaList: data,
})
}
}
)
},
changeArea: function (e) {
app.dialog.loading('正在加载');
console.log(e)
this.setData({
'pages.activityType': e.currentTarget.dataset.dataid
})
this.getActivityList()
},
loadAll: function () {
this.setData({
'pages.county': ''
})
this.getActivityList()
},
goDetail: function (e) {
var id = e.currentTarget.dataset.id;
wx.navigateTo({
url: '../activityDetail/activityDetail?id=' + id
})
},
getActivityList: function () {
var self = this;
app.restAjax.get(app.restAjax.path(app.activityUrl + '/app/activitylibrary/listpageactivitylibraryfornetrelease/{areaCode}', [app.areaCode]),
self.data.pages, null,
function (code, data) {
console.log(code + "===" + data)
if ('200' == code) {
for (var item of data.rows) {
if ('' != item.activityImage) {
item.activityImage = app.activityUrl + '/route/file/download/true/' + item.activityImage;
}
}
if (1 === self.data.pages.page) {
self.setData({
dataList: data.rows,
})
} else {
if (data.rows.length == 0) {
self.setData({
[`pages.page`]: self.data.pages.page - 1
})
app.dialog.msg('暂无更多')
return false;
}
self.setData({
dataList: data.rows.concat(self.data.dataList),
})
}
}
},
function () {
},
function () {
wx.hideNavigationBarLoading(); //完成停止加载图标
wx.stopPullDownRefresh();
wx.hideLoading();
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.getActivityTypeList()
// this.getActivityList();
// this.getAreaList()
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
// 在标题栏中显示加载图标
wx.showNavigationBarLoading();
var self = this;
self.setData({
[`pages.page`]: 1,
dataList: []
})
this.getActivityList();
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})