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

77 lines
1.5 KiB

6 years ago
// pages/billboards/park/park-category/index.js
import { BillboardModel } from '../../../../models/billboard.js'
let billboard = new BillboardModel()
Page({
/**
* 页面的初始数据
*/
data: {
list: [],
curCode: '' //
6 years ago
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
const { code,title } = options
wx.setNavigationBarTitle({
title: title,
})
console.log(code)
this.setData({
curCode: code,
})
this.fetchTags()
},
onTapMoreItem (e) {
const {code} = e.currentTarget.dataset
console.log(code)
},
clickCardItem(e) {
console.log(e.detail)
const { id } = e.detail
wx.navigateTo({
url: `/pages/article/index?id=${id}`,
})
6 years ago
},
fetchList(code, index) {
billboard.fetchBailList(code, 1, res => {
6 years ago
console.log(res)
const datas = res.list
let tempDatas = []
datas.forEach(item => {
tempDatas.push({
id: item.id,
title: item.title,
image: item.titlePic
})
})
this.setData({
[`list[${index}].datas`]: tempDatas
})
6 years ago
})
},
// 获取分类Tags
fetchTags() {
wx.showLoading({
title: '加载中...',
})
billboard.fetchTagsByCode(this.data.curCode, res => {
6 years ago
console.log(res)
const categorys = res.result.records
6 years ago
this.setData({
list: categorys,
})
categorys.forEach((item, index) => {
this.fetchList(item.code, index)
6 years ago
})
wx.hideLoading()
6 years ago
})
},
})