purse.js 2.9 KB

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