growth.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. const app = getApp()
  2. const WXAPI = require('apifm-wxapi')
  3. const AUTH = require('../../utils/auth')
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. growth: 0.00,
  10. cashlogs: undefined
  11. },
  12. /**
  13. * 生命周期函数--监听页面加载
  14. */
  15. onLoad: function (options) {
  16. },
  17. /**
  18. * 生命周期函数--监听页面初次渲染完成
  19. */
  20. onReady: function () {
  21. },
  22. /**
  23. * 生命周期函数--监听页面显示
  24. */
  25. onShow: function () {
  26. AUTH.checkHasLogined().then(isLogined => {
  27. if (isLogined) {
  28. this.doneShow();
  29. } else {
  30. wx.showModal({
  31. title: '提示',
  32. content: '本次操作需要您的登录授权',
  33. cancelText: '暂不登录',
  34. confirmText: '前往登录',
  35. success(res) {
  36. if (res.confirm) {
  37. wx.switchTab({
  38. url: "/pages/my/index"
  39. })
  40. } else {
  41. wx.navigateBack()
  42. }
  43. }
  44. })
  45. }
  46. })
  47. },
  48. doneShow: function () {
  49. const _this = this
  50. const token = wx.getStorageSync('token')
  51. WXAPI.userAmount(token).then(function (res) {
  52. if (res.code == 0) {
  53. _this.setData({
  54. growth: res.data.growth
  55. });
  56. } else {
  57. wx.showToast({
  58. title: res.msg,
  59. icon: 'none'
  60. })
  61. }
  62. })
  63. // 读取积分明细
  64. WXAPI.growthLogs({
  65. token: token,
  66. page: 1,
  67. pageSize: 50
  68. }).then(res => {
  69. if (res.code == 0) {
  70. _this.setData({
  71. cashlogs: res.data.result
  72. })
  73. }
  74. })
  75. },
  76. recharge: function (e) {
  77. wx.navigateTo({
  78. url: "/pages/recharge/index"
  79. })
  80. },
  81. withdraw: function (e) {
  82. wx.navigateTo({
  83. url: "/pages/withdraw/index"
  84. })
  85. }
  86. })