146 lines
2.8 KiB
JavaScript
146 lines
2.8 KiB
JavaScript
|
//index.js
|
||
|
//获取应用实例
|
||
|
const app = getApp()
|
||
|
|
||
|
Page({
|
||
|
|
||
|
/**
|
||
|
* 页面的初始数据
|
||
|
*/
|
||
|
data: {
|
||
|
indicatorDots: false,
|
||
|
autoplay: false,
|
||
|
projectList: [],
|
||
|
venueList: [],
|
||
|
token: '',
|
||
|
requestIp: ''
|
||
|
},
|
||
|
goList: function (event) {
|
||
|
wx.navigateTo({
|
||
|
url: '../list/list?categoryId=' + event.currentTarget.dataset.id + '&categoryName=' + event.currentTarget.dataset.name,
|
||
|
})
|
||
|
},
|
||
|
goDetail: function (event) {
|
||
|
wx.navigateTo({
|
||
|
url: '../detail/detail?venuesInfoId=' + event.currentTarget.dataset.id,
|
||
|
})
|
||
|
},
|
||
|
getSwiper: function () {
|
||
|
var self = this
|
||
|
wx.request({
|
||
|
url: self.data.requestIp + 'app/wechatprogram/listvenuesproject',
|
||
|
header:{
|
||
|
"token": self.data.token
|
||
|
},
|
||
|
data: {
|
||
|
id: 'f59ebf77-c2b7-49bc-8f58-2928bd2b450d'
|
||
|
},
|
||
|
success: function (res) {
|
||
|
if (res.statusCode == 200){
|
||
|
var list = [];
|
||
|
if(res.data.list.length > 8){
|
||
|
self.setData({
|
||
|
indicatorDots: true
|
||
|
})
|
||
|
}
|
||
|
res.data.list.forEach((item, index) => {
|
||
|
const page = Math.floor(index / 8)
|
||
|
if (!list[page]) {
|
||
|
list[page] = []
|
||
|
}
|
||
|
list[page].push(item)
|
||
|
})
|
||
|
console.log(list)
|
||
|
self.setData({
|
||
|
projectList: list
|
||
|
})
|
||
|
}
|
||
|
}
|
||
|
})
|
||
|
},
|
||
|
getList: function () {
|
||
|
var self = this
|
||
|
wx.request({
|
||
|
url: self.data.requestIp + 'app/wechatprogram/listvenuesbykeywords',
|
||
|
header: {
|
||
|
"token": self.data.token
|
||
|
},
|
||
|
success: function (res) {
|
||
|
self.setData({
|
||
|
venueList: res.data.data
|
||
|
})
|
||
|
}
|
||
|
})
|
||
|
},
|
||
|
getToken: function () {
|
||
|
var self = this
|
||
|
wx.getStorage({
|
||
|
key: 'token',
|
||
|
success: function(res) {
|
||
|
self.setData({
|
||
|
token: res.data
|
||
|
})
|
||
|
self.getSwiper()
|
||
|
self.getList()
|
||
|
},
|
||
|
})
|
||
|
},
|
||
|
/**
|
||
|
* 生命周期函数--监听页面加载
|
||
|
*/
|
||
|
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 () {
|
||
|
|
||
|
}
|
||
|
})
|