wallet.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. var app = getApp()
  2. const util = require('../../../utils/utils.js')
  3. Page({
  4. data: {
  5. balance:'0.00',//显示余额
  6. state:'',//认证状态
  7. phone: '',//手机认证状态
  8. imgUrl:'http://resource.weilaibike.com/xiaobanma/walletBg.png',
  9. stateStatus: '',
  10. is_bindPhone: '',
  11. student:'',
  12. is_student:'',
  13. setting:wx.getStorageSync('setting')
  14. },
  15. getBalance: util.throttle(function (e) {
  16. app.request("/me", '', "GET").then(res => {
  17. 200 == res.statusCode && wx.setStorageSync("userInfo", res.data), this.setData({
  18. balance: res.data.wallet_money
  19. })
  20. })
  21. //获取实名认证状态
  22. },1000),
  23. walletDetail: function () {
  24. wx.navigateTo({
  25. url: '/pages/wallet_details/wallet_details',
  26. })
  27. },
  28. goCertified:function(){
  29. wx.navigateTo({
  30. url: '/pages/real_name/real_name?state2=2&index=1&hidden=true',
  31. })
  32. },
  33. goStudent:function(){
  34. wx.navigateTo({
  35. url: '/pages/student_certification/student_certification',
  36. })
  37. },
  38. goBindphone: function () {
  39. wx.navigateTo({
  40. url: '/pages/real_name/real_name?state1=1&index=0&hidden=true',
  41. })
  42. },
  43. huanbang: function () {
  44. wx.navigateTo({
  45. url: '/pages/huan_bang/huan_bang',
  46. })
  47. },
  48. onLoad: function (options) {
  49. },
  50. onReady: function () {
  51. },
  52. onShow: function () {
  53. this.getBalance();
  54. app.request("/user/status", '', "GET").then(res => {
  55. console.log(res)
  56. if (res.statusCode == 200) {
  57. if (res.data.is_card_certified == 1){
  58. this.setData({
  59. state:'已认证'
  60. })
  61. }else{
  62. this.setData({
  63. state:'去认证'
  64. })
  65. }
  66. if (res.data.is_bind_mobile == 1) {
  67. this.setData({
  68. phone: '去换绑'
  69. })
  70. } else {
  71. this.setData({
  72. phone: '去认证'
  73. })
  74. }
  75. if (res.data.is_student == 1) {
  76. this.setData({
  77. student: '认证成功'
  78. })
  79. } else {
  80. this.setData({
  81. student: '去认证'
  82. })
  83. }
  84. this.setData({
  85. stateStatus: res.data.is_card_certified,
  86. is_bindPhone: res.data.is_bind_mobile,
  87. is_student:res.data.is_student,
  88. setting:wx.getStorageSync('setting')
  89. })
  90. wx.setStorageSync('userState', res.data)
  91. }
  92. })
  93. },
  94. onHide: function () {
  95. },
  96. onUnload: function () {
  97. },
  98. onPullDownRefresh: function () {
  99. },
  100. onReachBottom: function () {
  101. },
  102. onShareAppMessage: function () {
  103. }
  104. })