123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- 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"
- })
- }
- })
|