123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164 |
- // 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}`
- }
- }
- })
|