123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- // components/gamelist/gamelist.js
- const api = require('../../utils/api.js')
- const util = require('../../utils/util.js')
- const app = getApp()
- Component({
- /**
- * 组件的属性列表
- */
- properties: {
- btnType: { // 按钮类型 1: 打开 2:推广
- type: String
- },
- params: {
- type: Object,
- value: {},
- observer: function (newVal, oldVal) {
- if (newVal.listype == 1) {
- // 1: 游戏列表 2: 推广游戏列表
- if (this.data.gameCount <= this.data.gameData.length) {
- return false
- }
- api.getGameList({ page: newVal.page, offset: newVal.offset, rank_type: newVal.rank_type }).then(res => {
- this.setData({
- gameData: newVal.page > 1 ? this.data.gameData.concat(res.data.list) : res.data.list,
- gameCount: res.data.count,
- floats: this.data.floats.concat(res.data.list.map((item) => {
- return this.data.mpType === 'gd' ? item.mem_agent_integral : (item.mem_agent_reward || 0).toFixed(2)
- }))
- })
- })
- } else if (newVal.listype == 2) {
- api.getMemGameList({page: newVal.page, offset: newVal.offset}).then(res => {
- this.setData({
- gameData: newVal.page > 1 ? this.data.gameData.concat(res.data.list) : res.data.list,
- gameCount: res.data.count,
- floats: this.data.floats.concat(res.data.list.map((item) => {
- return this.data.mpType === 'gd' ? item.mem_agent_integral : (item.mem_agent_reward || 0).toFixed(2)
- }))
- })
- })
- }
- }
- }
- },
- /**
- * 组件的初始数据
- */
- data: {
- floats: [],
- gameCount: 10,
- gameData: [],
- mpType: app.globalData.mpType
- },
- /**
- * 组件的方法列表
- */
- methods: {
- routeDetail: function (e) {
- util.routeTo(`/pages/detail/detail?id=${e.currentTarget.dataset.id}`)
- },
- openGame: function (e) {
- let id = e.currentTarget.dataset.id
- api.openGame({
- game_id: id
- }).then(res => {
- console.log(res)
- }, err => {
- console.log(err)
- })
- }
- }
- })
|