caseList.js 3.0 KB
// pages/caseList/caseList.js
const app = getApp();
Page({

    /**
     * 页面的初始数据
     */
    data: {
        connectButton: [
            { className: "", text: "在线客服", bindtap: "" }
        ],
        caseList: [],
        baseImgUrl: app.globalData.baseImgUrl,
        page: 1,
        typeId: null,
        minscreenHeight: 0,
        scrollTop: 0,
        jzSuccess: false,
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        let that = this;
        wx.setNavigationBarTitle({
            title: options.html,
        });
        that.setData({
            typeId: options.id
        })
        that.getData();
    },
    onPageScroll: function (e) { // 获取滚动条当前位置
        // console.log(e)
        this.setData({
            scrollTop: e.scrollTop
        })
    },
    goTop: function () {
        app.goTop()
    },
    getData() {
        let that = this;
        let url = '/portal/Api/listCategory';
        // console.log(that.data.page);
        // console.log(that.data.typeId);
        let data = {
            typeId: that.data.typeId,
            page: that.data.page,
        };
        app.post(url, data).then((res) => {
            console.log('res', res);
            let data = [];
            if (res.page == 1 && res.list.length == 0) {
                that.setData({
                    jzSuccess: true,
                    jzSuccessContent: "暂无相关数据",
                })
            } else if (res.list.length < 10) {
                that.setData({
                    caseList: that.data.caseList.concat(res.list),
                    jzSuccess: true,
                    jzSuccessContent: "已加载全部内容",
                })
            } else {
                that.setData({
                    caseList: that.data.caseList.concat(res.list),
                    jzSuccess: false,
                })
            }
            // data.



        }).catch((err) => {
            console.log(err);
        })
    },
    jumpFun(e) {
        // console.log(e.currentTarget.dataset.id);
        wx.navigateTo({
            url: '../caseDetail/caseDetail?id=' + e.currentTarget.dataset.id
        })
    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {
        var that = this;
        that.setData({
            page: that.data.page + 1
        })
        that.getData();
    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {

    }
})