市北人才赋能平台 --小程序端
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.

74 lines
1.6 KiB

6 years ago
// pages/billboards/park/park-category/index.js
import { BillboardModel } from '../../../../models/billboard.js'
let billboard = new BillboardModel()
Page({
/**
* 页面的初始数据
*/
data: {
list: []
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
},
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()
})
},
})