// subpages/understandJs/pages/sclerotia/sclerotia.js const api = require("../../../../utils/understandJs") Page({ /** * 页面的初始数据 */ data: { pageIndex: 1, pageSize: 10, deptinfolist: [], nodata: false, loadMoreType: "none", loadMoreVisible: false, }, /** * 生命周期函数--监听页面加载 */ onLoad: function () { this.deptinfolist() }, //了解锦水-硬核管理接口 deptinfolist () { let that = this; let params = { pageIndex: that.data.pageIndex, pageSize: that.data.pageSize, } api.deptinfolist(params).then(function (res) { //了解锦水-模块管理接口 that.setData({ deptinfolist: that.data.deptinfolist.concat(res.data), loadMoreType: res.data.length === that.data.pageSize ? "loading" : "none", loadMoreVisible: res.data.length === that.data.pageSize ? false : true }) if (that.data.deptinfolist.length == 0) {//没有值 that.setData({ nodata: true, loadMoreType: "none", loadMoreVisible: false, }) } }).catch(err => { that.setData({ deptinfolist: [], nodata: true, loadMoreType: "none", loadMoreVisible: false, }) console.log(err) }) }, mobile (e) { wx.showModal({ title: "拨打电话", content: `您确定拨打${e.currentTarget.dataset.mobile}`, cancelColor: "#29B9A5", confirmColor: "#29B9A5", success: (res) => { if (res.confirm) { console.log("用户点击确定") wx.makePhoneCall({ phoneNumber: e.currentTarget.dataset.mobile }) } else if (res.cancel) { console.log("用户点击取消") } } }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { this.setData({ loadMoreVisible: true }) if (this.data.loadMoreType === "loading") { this.setData({ pageIndex: this.data.pageIndex + 1, pageSize: this.data.pageSize, }) this.deptinfolist(); } }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { } })