123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- // pages/tips/tips.js
- const api = require('../../utils/api.js')
- const util = require('../../utils/util.js')
- const app = getApp()
- Page({
- data: {
- TabIndex: 0,
- dayIncomeList: [],
- dayIncomeCount: 99,
- sum: 0,
- userInfo: {},
- tipsText: [],
- sharePath: 'pages/share/share',
- shareInfo: {},
- mpType: app.globalData.mpType
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- let timer = setInterval(() => {
- if (app.globalData.PageCallback) {
- this.getIncomeList()
- this.gethelptipsTextFun()
- this.getShareInfo()
- clearInterval(timer)
- }
- }, 200)
-
- },
- getShareInfo: function () {
- api.getShareInfo({
- data: {
- path: this.data.sharePath
- }
- }).then(res => {
- this.setData({
- shareInfo: res.data
- })
- }).catch(err => {
- console.log('getShare', err)
- })
- },
- // 获取今日收益列表
- getIncomeList: function () {
- const d = new Date()
- let today = d.getFullYear() + "-"
- today += ((d.getMonth() + 1) < 10 ? '0' : '') + (d.getMonth() + 1) + '-'
- today += ((d.getDate() + 1) < 10 ? '0' : '') + d.getDate()
- api.getIncomeList({ page: 1, offset: 1000 }).then(res => {
- res.data.list.forEach((item, ids) => {
- if (this.data.mpType === 'rp') {
- item.amount = item.amount
- }
- item.create_time = util.formatTime(item.create_time, 'yyyy/MM/dd')
- })
- this.setData({
- dayIncomeList: res.data.list,
- dayIncomeCount: res.data.count,
- userInfo: app.globalData.userInfo,
- sum: this.data.mpType === 'gd' ? (res.data.sum ? res.data.sum.my_integral : 0) : (res.data.sum ? res.data.sum.sum_agent_gain : 0).toFixed(2)
- })
- })
- },
- // 赚钱小技巧文字
- gethelptipsTextFun: function () {
- api.gethelpTipsText().then(res => {
- if (res.code === 200) {
- this.setData({
- tipsText: res.data.text.split('\n')
- })
- }
- })
- },
- routeTo: function (e) {
- util.routeTo(e.currentTarget.dataset.to)
- },
- toRank: function (e) {
- util.routeTo('/pages/user/rank')
- },
- routeUser: function (e) {
- if (this.data.mpType === 'rp') {
- app.globalData.openGZH = true
- wx.switchTab({
- url: '/pages/user/index?open=1',
- })
- } else if (this.data.mpType === 'gd') {
- // app.globalData.openGZH = true
- wx.navigateBack({
- delta: 1
- })
- }
- },
- routeBox: function (e) {
- wx.switchTab({
- url: '/pages/box/box',
- })
- },
- routeTask: function (e) {
- util.routeTo('/pages/user/task')
- },
- ChangeTab: function (e) {
- this.setData({
- TabIndex: e.target.dataset.index
- })
- },
- onShow: function () {
- wx.showShareMenu({ // 允许转发时携带 shareTicket。
- withShareTicket: true
- })
- }
- })
|