// pages/user/service/index.js import commonApi from "../../../utils/https/common" import util from '../../../utils/util' Page({ /** * 页面的初始数据 */ data: { tags:[], types:[], typeId:null, list:[], total:1, page_no:1, typename:"" }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { // 获取问题标签 commonApi._post("ics/getTags").then(res=>{ console.log(res) this.setData({ tags:res.data }) }) // 获取问题分类 commonApi._post("ics/getType").then(res=>{ this.setData({ types:res.data, typeId:res.data[0].id, typename:res.data[0].type_name }) this.getList(); }) }, changeType:function(e){ this.setData({ typeId:e.currentTarget.dataset.type, typename:e.currentTarget.dataset.typename, list:[], total:1, page_no:1 }) this.getList(); }, getList:function(){ let list = this.data.list; if(list.length>=this.data.total) return; commonApi._post("ics/getQuestionByTypeId",{ type_id:this.data.typeId, page_no:1, page_num:10 }).then(res=>{ this.setData({ list:res.data.rows, total:res.data.total, page_no:this.data.page_no+1 }) }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { // this.getList() } })