purse.js 2.3 KB

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