const app = getApp() const WXAPI = require('apifm-wxapi') const AUTH = require('../../utils/auth') Page({ /** * 页面的初始数据 */ data: { growth: 0.00, cashlogs: undefined }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { AUTH.checkHasLogined().then(isLogined => { if (isLogined) { this.doneShow(); } else { wx.showModal({ title: '提示', content: '本次操作需要您的登录授权', cancelText: '暂不登录', confirmText: '前往登录', success(res) { if (res.confirm) { wx.switchTab({ url: "/pages/my/index" }) } else { wx.navigateBack() } } }) } }) }, doneShow: function () { const _this = this const token = wx.getStorageSync('token') WXAPI.userAmount(token).then(function (res) { if (res.code == 0) { _this.setData({ growth: res.data.growth }); } else { wx.showToast({ title: res.msg, icon: 'none' }) } }) // 读取积分明细 WXAPI.growthLogs({ token: token, page: 1, pageSize: 50 }).then(res => { if (res.code == 0) { _this.setData({ cashlogs: res.data.result }) } }) }, recharge: function (e) { wx.navigateTo({ url: "/pages/recharge/index" }) }, withdraw: function (e) { wx.navigateTo({ url: "/pages/withdraw/index" }) } })