Page({ data: { active: 0, page: 1, pageTotal: 0, show: false, // 表格数据 tabData: [], // 表格标题列 columns: [ { label: '公告标题', prop: 'noticeTitle', fontSize: '', fontWeight: 600, color: '#000' }, // { label: '公告类型', prop: 'noticeType' }, { label: '创建时间', prop: 'createTime' }, { label: '操作', prop: 'action', fontSize: '', fontWeight: 400, textDecoration: '', color: '#1890FF', onclick: true, }, // { label: '上架时间', prop: 'shelveTime', type: 'time', param: 'YY-MM-DD'} ], // 自定义样式配置项 setting: { tableRadius: 0, // 表格圆角 tableOutBorder: '', // 表格外边框 tableInBorder: '', // 表格内边框 tableInBorderLevel: 'true', // 表格内只显示水平边框 theadHeight: 70, // 表头的高度 theadAlign: '', // 表头的字体对齐方式 theadColor: '', // 表头的字体颜色 theadBgColor: '', // 表头的背景色 theadFontSize: '', // 表头的字体大小 theadFontWeight: '', // 表头的字体粗细 tbodyHeight: '600', // 表格 tbody 的高度, 用于垂直滚动 tbodyAlign: '', // 表格行的的字体对齐方式 tbodyColor: '', // 表格行的字体颜色 tbodyBgColor: '', // 表格行的背景色 tbodyFontSize: '', // 表格行的字体大小 tbodyFontWeight: '', // 表格行的字体粗细 trHeight: 70, // 表格行 tr 的高度 stripe: '#fdf5e6' // #fafafa #f5f5f5 #fdf5e6 #fff8dc #f0f9eb } }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { this.getList() }, /** * 生命周期函数--监听页面显示 */ onShow: function () { this.getList() }, onChangeactive(e) { this.setData({ active: e.detail.index, page: 1, }) this.getList() }, onChange() { }, getList() { let that = this let data = { pageNum: this.data.page, pageSize: 10, noticeType: this.data.active + 1 } wx.request({ url: 'https://puyue.yhupai.com/prod-api/system/notice/list', method: 'GET', header: { "Access-Control-Allow-Headers": 'token', Authorization: `Bearer ${wx.getStorageSync('token')}` }, data: data, success(res) { if (res.data.code != 200) { wx.showToast({ title: res.data.msg, icon: 'none' }); } else { let arr = res.data.rows for (let i = 0; i < arr.length; i++) { let a = arr[i].createTime.split(' ') arr[i].id = i + 1 arr[i].createTime = a[0] arr[i].action = '查看' if (arr[i].noticeType == 1) { arr[i].noticeType = '通知' } if (arr[i].noticeType == 2) { arr[i].noticeType = '公告' } } let total = Math.ceil(res.data.total / 10) that.setData({ tabData: arr, pageTotal: total, }) console.log(that.data.pageTotal, that.data.show); } } }) }, pagChange(e) { console.log(e); this.setData({ page: e.detail.currentIndex }) this.getList() }, // 表格的自定义点击事件 getCurrentValue(e) { console.log(e, e.detail.id); wx.setStorageSync('noticeId', e.detail.noticeId) wx.navigateTo({ url: '/pages/noticeDetail/noticeDetail', }) } })