purse.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. // pages/ucenter/purse/purse.js
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  6. data: {
  7. userInfo: {},
  8. isLogin: false
  9. },
  10. chargemony(e) {
  11. let isBindPhone = wx.getStorageSync('isBindPhone');
  12. if(isBindPhone==0){
  13. let url = `/pages/bindPhone/bindPhone`;
  14. wx.navigateTo({
  15. url
  16. });
  17. return;
  18. }else if(isBindPhone==1){
  19. let url = "/pages/chargemoney/chargemoney";
  20. wx.navigateTo({
  21. url
  22. });
  23. }
  24. },
  25. withdrawDeposit(e) {
  26. let url = "/pages/outmoney/outmoney";
  27. wx.navigateTo({
  28. url
  29. });
  30. },
  31. /**
  32. * 生命周期函数--监听页面加载
  33. */
  34. onLoad: function(options) {
  35. },
  36. /**
  37. * 生命周期函数--监听页面初次渲染完成
  38. */
  39. onReady: function() {
  40. },
  41. /**
  42. * 生命周期函数--监听页面显示
  43. */
  44. onShow: function() {
  45. let userInfo = wx.getStorageSync('userInfo');
  46. let isLogin = wx.getStorageSync('isLogin');
  47. let that = this;
  48. wx.request({
  49. url: getApp().globalData.postHeadAgreement +'/restapi/wechat/syncUser',
  50. data: {
  51. loginName: userInfo.loginName
  52. },
  53. method: 'POST',
  54. success: function(res) {
  55. let {
  56. data
  57. } = res;
  58. if (data.code && data.code != 200) {
  59. wx.removeStorageSync('userInfo');
  60. wx.removeStorageSync('isLogin');
  61. let url = '/pages/login/phone_login/phone_login';
  62. wx.redirectTo({
  63. url,
  64. });
  65. } else {
  66. that.setData({
  67. userInfo: data,
  68. isLogin: true
  69. });
  70. wx.setStorageSync('userInfo', data);
  71. wx.setStorageSync('isLogin', true);
  72. }
  73. },
  74. fail(e) {
  75. console.log("用户数据同步失败");
  76. }
  77. });
  78. },
  79. /**
  80. * 生命周期函数--监听页面隐藏
  81. */
  82. onHide: function() {
  83. },
  84. /**
  85. * 生命周期函数--监听页面卸载
  86. */
  87. onUnload: function() {
  88. },
  89. /**
  90. * 页面相关事件处理函数--监听用户下拉动作
  91. */
  92. onPullDownRefresh: function() {
  93. },
  94. /**
  95. * 页面上拉触底事件的处理函数
  96. */
  97. onReachBottom: function() {
  98. },
  99. /**
  100. * 用户点击右上角分享
  101. */
  102. onShareAppMessage: function() {
  103. },
  104. /*跳转到充值卡 */
  105. gotochargemoneycard() {
  106. let url = `/pages/ucenter/chargemoneycard/chargemoneycard`;
  107. wx.navigateTo({
  108. url
  109. });
  110. },
  111. /*跳转到代金券 */
  112. gotocashcoupon() {
  113. let url = `/pages/ucenter/cashcoupon/cashcoupon`;
  114. wx.navigateTo({
  115. url
  116. });
  117. }
  118. })