// pages/user/help.js import api from '../../utils/api' Page({ /** * 页面的初始数据 */ data: { tabIndex: 1, result: { list: [] }, params: { page: 1, offset: 10 }, showList: [], rotateList: [], qrCode: '' }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { this.getList() // this.getContactInfo() }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { let { tabIndex, result, params } = this.data // 重置数据和参数 result[tabIndex] = { list: [] } params[tabIndex].page = 1 this.setData({ result, params }) // 请求新数据 this.getList() wx.stopPullDownRefresh() }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { this.getList() }, slideHelp: function (e) { let { showList, rotateList } = this.data let index = +e.currentTarget.dataset.index showList[index] = !showList[index] rotateList[index] = showList[index] this.setData({ showList, rotateList }) setTimeout(() => { rotateList[index] = false this.setData({ rotateList }) }, 500) }, getList: function () { let { params, result } = this.data if (result.count <= (params.page - 1) * params.offset) { return false } api.getHelpList(params).then(res => { params.page++ res.data.list = [ ...result.list, ...res.data.list ] result = res.data this.setData({ params, result }) }) }, tabChange: function (e) { let index = +e.currentTarget.dataset.index this.setData({ tabIndex: index }) if (!index && !this.data.result.list.length) { this.getList() } }, getContactInfo: function (e) { if (!this.data.qrCode) { api.getWithdrawTips().then(res => { if (res.code === 200) { this.setData({ qrCode: res.data.image }) } }) } }, copyQQ: function (e) { wx.setClipboardData({ data: e.currentTarget.dataset.qq, success: function () { wx.showToast({ title: 'QQ已复制' }) } }) }, onShareAppMessage: function () { let { shareinfo, state, mem_id } = app.globalData.userInfo return { path: `/pages/share/share?state=${state}&mem_id=${mem_id}` } } })