chargemoneyresult.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. // pages/chargemoneyresult/chargemoneyresult.js
  2. let Util = require("../../utils/util");
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. timeStamp:null,
  9. money:null
  10. },
  11. /**
  12. * 生命周期函数--监听页面加载
  13. */
  14. onLoad: function (options) {
  15. var{
  16. timeStamp,
  17. money
  18. }=options;
  19. var startDate = new Date();
  20. startDate.setTime(timeStamp*1000);
  21. //console.log(startDate);
  22. var timeStamp = startDate.getFullYear()+ '年' +Util.formatNumber(startDate.getMonth() + 1) + '月' + Util.formatNumber(startDate.getDate()) + '日 ' + Util.formatNumber(startDate.getHours()) + ':' + Util.formatNumber(startDate.getMinutes()) + ':' + Util.formatNumber(startDate.getSeconds());
  23. this.setData({
  24. timeStamp,
  25. money
  26. });
  27. },
  28. /**
  29. * 生命周期函数--监听页面初次渲染完成
  30. */
  31. onReady: function () {
  32. },
  33. /**
  34. * 生命周期函数--监听页面显示
  35. */
  36. onShow: function () {
  37. let userInfo = wx.getStorageSync('userInfo');
  38. let isLogin = wx.getStorageSync('isLogin');
  39. let that = this;
  40. wx.request({
  41. url: getApp().globalData.postHeadAgreement + '/restapi/wechat/syncUser',
  42. data: {
  43. loginName: userInfo.loginName
  44. },
  45. method: 'POST',
  46. success: function (res) {
  47. let {
  48. data
  49. } = res;
  50. if (data.code && data.code != 200) {
  51. wx.removeStorageSync('userInfo');
  52. wx.removeStorageSync('isLogin');
  53. let url = '/pages/login/phone_login/phone_login';
  54. wx.redirectTo({
  55. url,
  56. });
  57. } else {
  58. that.setData({
  59. userInfo: data,
  60. isLogin: true
  61. });
  62. wx.setStorageSync('userInfo', data);
  63. wx.setStorageSync('isLogin', true);
  64. }
  65. },
  66. fail(e) {
  67. console.log("用户数据同步失败");
  68. }
  69. });
  70. },
  71. /**
  72. * 生命周期函数--监听页面隐藏
  73. */
  74. onHide: function () {
  75. },
  76. /**
  77. * 生命周期函数--监听页面卸载
  78. */
  79. onUnload: function () {
  80. },
  81. /**
  82. * 页面相关事件处理函数--监听用户下拉动作
  83. */
  84. onPullDownRefresh: function () {
  85. },
  86. /**
  87. * 页面上拉触底事件的处理函数
  88. */
  89. onReachBottom: function () {
  90. },
  91. /**
  92. * 用户点击右上角分享
  93. */
  94. onShareAppMessage: function () {
  95. }
  96. })