user.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. // pages/user/user.js
  2. const app = getApp()
  3. var host = app.globalData.host;
  4. const $api = require('../../utils/api.js').API;
  5. const $push = require('../../utils/api.js').PUSH;
  6. Page({
  7. /**
  8. * 页面的初始数据
  9. */
  10. data: {
  11. userinfo:{},
  12. todayinfo:{},
  13. },
  14. /**
  15. * 生命周期函数--监听页面加载
  16. */
  17. onLoad: function (options) {
  18. this.getUserData()
  19. },
  20. zx(){
  21. wx.navigateTo({
  22. url: '../message/message',
  23. })
  24. },
  25. getUserData() {
  26. $api.getAuthinfo().then(res=>{
  27. if(res.data.code == 0){
  28. this.setData({
  29. userinfo: res.data.data,
  30. })
  31. wx.setStorage({
  32. key: 'user',
  33. data: res.data.data,
  34. })
  35. }
  36. })
  37. .catch(err=>{
  38. this.setData({
  39. userinfo: {}
  40. })
  41. })
  42. },
  43. getTodayData() {
  44. $api.getMineLatest().then(res=>{
  45. this.setData({
  46. todayinfo: res.data.data,
  47. todayMoney:((res.data.data.today_fund - res.data.data.yesterday_fund)*10000).toFixed(2)
  48. })
  49. })
  50. .catch(err=>{
  51. this.setData({
  52. todayinfo: {},
  53. status:0
  54. })
  55. })
  56. },
  57. deleteShow(){
  58. wx.showModal({
  59. title: '删除作业',
  60. content: '如有出入金请先申报除权再重新提交作业',
  61. complete: (res) => {
  62. if (res.cancel) {
  63. }
  64. if (res.confirm) {
  65. this.deleteData()
  66. }
  67. }
  68. })
  69. },
  70. deleteData(){
  71. var data={
  72. user_id:this.data.todayinfo.user_id,
  73. match_id:this.data.todayinfo.match_id,
  74. stock_date:this.data.todayinfo.stock_date
  75. }
  76. $api.deleteTodayData(data).then(res=>{
  77. this.setData({
  78. todayinfo:{}
  79. })
  80. })
  81. },
  82. logout() {
  83. wx.removeStorage({
  84. key: 'userInfo'
  85. })
  86. wx.removeStorage({
  87. key: 'user'
  88. })
  89. this.setData({
  90. userinfo: {},
  91. usercode: ''
  92. })
  93. // wx.navigateTo({
  94. // url: '../login/user',
  95. // })
  96. },
  97. onCustomerService(){
  98. wx.openCustomerServiceChat({
  99. extInfo: {url: 'https://work.weixin.qq.com/kfid/kfcc1bd2a8bddad1dfb'},
  100. corpId: 'wwc4de479c81db4706',
  101. success(res) {}
  102. })
  103. },
  104. pushToday(e){
  105. $push.pushToday(e.currentTarget.dataset)
  106. },
  107. pushMessage(e){
  108. if($api.checkUser()){
  109. wx.navigateTo({
  110. url: '../message/message',
  111. })
  112. }
  113. },
  114. /**
  115. * 生命周期函数--监听页面初次渲染完成
  116. */
  117. onReady: function () {
  118. },
  119. /**
  120. * 生命周期函数--监听页面显示
  121. */
  122. onShow: function () {
  123. this.getUserData()
  124. this.getTodayData()
  125. $api.initUser()
  126. },
  127. /**
  128. * 生命周期函数--监听页面隐藏
  129. */
  130. onHide: function () {
  131. },
  132. /**
  133. * 生命周期函数--监听页面卸载
  134. */
  135. onUnload: function () {
  136. },
  137. /**
  138. * 页面相关事件处理函数--监听用户下拉动作
  139. */
  140. onPullDownRefresh: function () {
  141. },
  142. /**
  143. * 页面上拉触底事件的处理函数
  144. */
  145. onReachBottom: function () {
  146. },
  147. /**
  148. * 用户点击右上角分享
  149. */
  150. onShareAppMessage: function () {
  151. }
  152. })