const { index, util } = getApp().globalData Page({ /** * 页面的初始数据 */ data: { active: 0, hall: [ { title: '失物招领', index: 0, children: [ { title: '全部', type: -1, page: 1, content: [] }, { title: '证件', type: 1, page: 1, content: [] }, { title: '服装', type: 2, page: 1, content: [] }, { title: '数码', type: 3, page: 1, content: [] }, { title: '日用品', type: 4, page: 1, content: [] }, { title: '其他', type: 5, page: 1, content: [] }, ] }, { title: '寻物启事', index: 0, children: [ { title: '全部', type: -1, page: 1, content: [] }, { title: '证件', type: 1, page: 1, content: [] }, { title: '服装', type: 2, page: 1, content: [] }, { title: '数码', type: 3, page: 1, content: [] }, { title: '日用品', type: 4, page: 1, content: [] }, { title: '其他', type: 5, page: 1, content: [] }, ] } ] }, onLoad: function (options) { this.getList() }, onReady: function () {}, onShow: function () {}, async getList() { let { hall, active } = this.data; let res = await index.tab({ thing_type: active + 1, thing_category: hall[active].children[hall[active].index].type, page: 1 }); var temp = `hall[${active}].children` var oth = `${temp}[${hall[active].index}].content` this.setData({ [oth]: res }) }, // 改变子项激活的下标 changeChildren(e) { var temp = `hall[${this.data.active}].index` this.setData({ [temp]: e.target.dataset.cid}, () => this.getList()) }, onChange(event) { this.setData({ active: event.detail.name },() => this.getList()) }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { } })