user.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. // pages/user/user.js
  2. const app = getApp()
  3. var host = app.globalData.host;
  4. const $api = require('../../utils/api.js').API;
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. userinfo:{},
  11. todayinfo:{},
  12. },
  13. /**
  14. * 生命周期函数--监听页面加载
  15. */
  16. onLoad: function (options) {
  17. this.getUserData()
  18. },
  19. zx(){
  20. wx.navigateTo({
  21. url: '../message/message',
  22. })
  23. },
  24. getUserData() {
  25. $api.getAuthinfo().then(res=>{
  26. this.setData({
  27. userinfo: res.data.data,
  28. })
  29. })
  30. .catch(err=>{
  31. this.setData({
  32. userinfo: {}
  33. })
  34. })
  35. },
  36. getTodayData() {
  37. $api.getMineLatest().then(res=>{
  38. this.setData({
  39. todayinfo: res.data.data,
  40. todayMoney:((res.data.data.today_fund - res.data.data.yesterday_fund)*10000).toFixed(2)
  41. })
  42. })
  43. .catch(err=>{
  44. this.setData({
  45. todayinfo: {},
  46. status:0
  47. })
  48. })
  49. },
  50. logout() {
  51. wx.removeStorage({
  52. key: 'userInfo'
  53. })
  54. this.setData({
  55. userinfo: {},
  56. usercode: ''
  57. })
  58. wx.navigateTo({
  59. url: '../login/user',
  60. })
  61. },
  62. onCustomerService(){
  63. wx.openCustomerServiceChat({
  64. extInfo: {url: 'https://work.weixin.qq.com/kfid/kfcc1bd2a8bddad1dfb'},
  65. corpId: 'wwc4de479c81db4706',
  66. success(res) {}
  67. })
  68. },
  69. /**
  70. * 生命周期函数--监听页面初次渲染完成
  71. */
  72. onReady: function () {
  73. },
  74. /**
  75. * 生命周期函数--监听页面显示
  76. */
  77. onShow: function () {
  78. this.getUserData()
  79. this.getTodayData()
  80. },
  81. /**
  82. * 生命周期函数--监听页面隐藏
  83. */
  84. onHide: function () {
  85. },
  86. /**
  87. * 生命周期函数--监听页面卸载
  88. */
  89. onUnload: function () {
  90. },
  91. /**
  92. * 页面相关事件处理函数--监听用户下拉动作
  93. */
  94. onPullDownRefresh: function () {
  95. },
  96. /**
  97. * 页面上拉触底事件的处理函数
  98. */
  99. onReachBottom: function () {
  100. },
  101. /**
  102. * 用户点击右上角分享
  103. */
  104. onShareAppMessage: function () {
  105. }
  106. })