123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- const api = require('../../utils/api')
- const util = require('../../utils/util')
- const app = getApp()
- Page({
- // 页面的初始数据
- data: {
- auth: {},
- params: {
- type_id: 0,
- page: 1,
- offset: 10
- },
- result: {
- list: []
- },
- mpType: app.globalData.mpType
- },
- // 生命周期函数--监听页面加载
- onLoad: function (opt) {
- let timer = setInterval(() => {
- if (app.globalData.PageCallback) {
- clearInterval(timer)
- this.setData({
- auth: app.globalData.auth
- })
- }
- }, 60)
-
- let { params } = this.data
- params.type_id = opt.type
- this.setData({
- params
- })
- wx.setNavigationBarTitle({
- title: opt.title || '更多'
- })
- this.getList()
- },
- routeDetail: function (e) {
- // util.routeTo(`/pages/detail/detail?id=${e.currentTarget.dataset.id}`)
- },
- // 页面相关事件处理函数--监听用户下拉动作
- onPullDownRefresh: function () {
- let { result, params } = this.data
- // 重置数据和参数
- result = {
- list: []
- }
- params.page = 1
- this.setData({
- result,
- params
- })
- // 请求新数据
- this.getList(true)
- wx.stopPullDownRefresh()
- },
- // 页面上拉触底事件的处理函数
- onReachBottom: function () {
- this.getList()
- },
-
- openGame: function (e) {
- let id = e.currentTarget.dataset.id
- api.openGame({
- game_id: id
- }).then(res => {
- console.log(res)
- }, err => {
- console.log(err)
- })
- },
- getList: function (hdld) {
- let { params, result } = this.data
- if (result.count <= (params.page - 1) * params.offset) {
- return false
- }
- api.getTagGameList(hdld ? { ...params, HideLoading: true} : params).then(res => {
- params.page++
- res.data.list = [
- ...result.list,
- ...res.data.list
- ]
- result = res.data
- this.setData({
- params,
- result
- })
- }, err => {
- console.log(err)
- })
- }
- })
|