You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
133 lines
3.0 KiB
133 lines
3.0 KiB
// pages/billboards/firm/index.js
|
|
import { BillboardModel } from '../../../models/billboard.js'
|
|
let billboard = new BillboardModel()
|
|
import { config } from '../../../config.js'
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
list: [],
|
|
navs: [],
|
|
curCode: '',
|
|
currPage: 1,
|
|
tags: [],
|
|
img1:config.api_url + '/image/5.png',
|
|
img2:config.api_url + '/image/6.png',
|
|
img3:config.api_url + '/image/7.png',
|
|
img4:config.api_url + '/image/8.png',
|
|
img5:config.api_url + '/image/9.png',
|
|
img6:config.api_url + '/image/10.png',
|
|
img7:config.api_url + '/image/11.png',
|
|
img8:config.api_url + '/image/12.png',
|
|
img9:config.api_url + '/image/13.png',
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad: function (options) {
|
|
this.fetchTags() // 获取Tags
|
|
wx.showShareMenu({
|
|
withShareTicket: true,
|
|
menus: ['shareAppMessage']
|
|
});
|
|
},
|
|
tapSegemnt (e) {
|
|
console.log(e.detail)
|
|
const { index } = e.detail
|
|
this.setData({
|
|
curCode: this.data.tags[index].code,
|
|
currPage: 1,
|
|
})
|
|
this.fetchList()
|
|
},
|
|
clickCardItem (e) {
|
|
console.log(e.detail)
|
|
const { id } = e.detail
|
|
wx.navigateTo({
|
|
url: `/pages/article/index?id=${id}`,
|
|
})
|
|
},
|
|
fetchList () {
|
|
const { curCode } = this.data
|
|
const page = this.data.currPage
|
|
billboard.fetchBailList(curCode, page, res => {
|
|
console.log(res)
|
|
const datas = res.list
|
|
let tempDatas = []
|
|
datas.forEach(item => {
|
|
tempDatas.push({
|
|
id: item.id,
|
|
title: item.title,
|
|
image: item.titlePic
|
|
})
|
|
})
|
|
if (page == 1) {
|
|
this.setData({
|
|
list: tempDatas
|
|
})
|
|
} else {
|
|
if (tempDatas.length > 0) {
|
|
const list = [...this.data.list, ...tempDatas]
|
|
this.setData({
|
|
list: list
|
|
})
|
|
} else {
|
|
const page = this.data.currPage - 1
|
|
this.setData({
|
|
currPage: page
|
|
})
|
|
wx.showToast({
|
|
title: '已加载全部',
|
|
icon: 'none'
|
|
})
|
|
}
|
|
}
|
|
wx.stopPullDownRefresh()
|
|
})
|
|
},
|
|
// 获取分类Tags
|
|
fetchTags () {
|
|
billboard.fetchTagsByCode('sc-zdqy', res => {
|
|
console.log(res)
|
|
const tags = res.result.records
|
|
const navs = tags.map(item => item.name)
|
|
this.setData({
|
|
navs: navs,
|
|
tags: tags,
|
|
curCode: tags.length > 0 ? tags[0].code : ''
|
|
})
|
|
this.fetchList()
|
|
})
|
|
},
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh: function () {
|
|
this.setData({
|
|
currPage: 1
|
|
})
|
|
this.fetchList()
|
|
},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom: function () {
|
|
const page = this.data.currPage + 1
|
|
this.setData({
|
|
currPage: page
|
|
})
|
|
this.fetchList()
|
|
},
|
|
detail:function(e){
|
|
var id = e.currentTarget.dataset.code
|
|
wx.navigateTo({
|
|
url: '/pages/article/index?id=' + id,
|
|
})
|
|
}
|
|
|
|
|
|
})
|