12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- const { apiRequest } = require('../../../utils/API.js')
- let currentPage = 1
- Page({
- data: {
- isShowLoadTip: false,
- pageLength: 15,
- prizeList: [],
- dataList: []
- },
- onLoad: function (options) {
- this.getList()
- },
- toDetail: function (e) {
- wx.navigateTo({
- url: '/pages/award-detail/award-detail?id=' + e.currentTarget.id
- })
- },
- getList: function (callback) {
- let that = this
- wx.showLoading({
- title: '加载中',
- mask: true
- })
- apiRequest('/user/lotteries/win').then(data => {
- that.setData({
- prizeList: data.data.length > that.data.pageLength ? data.data.slice(0, that.data.pageLength) : data.data,
- dataList: data.data
- })
- wx.hideLoading()
- callback && callback()
- })
- },
- onPullDownRefresh: function () {
- let that = this
- wx.showNavigationBarLoading()
- this.getList(function () {
- wx.hideNavigationBarLoading()
- wx.stopPullDownRefresh()
- wx.showToast({
- title: '刷新成功',
- icon: 'none'
- })
- that.setData({
- isShowLoadTip: false
- })
- currentPage = 1
- })
- },
- onReachBottom: function () {
- let that = this
- wx.showLoading({
- title: '加载中',
- mask: true
- })
- setTimeout(function () {
- wx.hideLoading()
- if (that.data.dataList.length != that.data.prizeList.length) {
- currentPage++
- }
- let currentLength = that.data.pageLength * currentPage
- let data = that.data.dataList.length > currentLength ? that.data.dataList.slice(0, currentLength) : that.data.dataList
- that.setData({
- prizeList: data
- })
- if (that.data.dataList.length == that.data.prizeList.length) {
- that.setData({
- isShowLoadTip: true
- })
- }
- }, 500)
- }
- })
|