姨妈管家小程序代码

index.js 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import initCalendar from '../../template/calendar/index';
  2. let chooseYear = null;
  3. let chooseMonth = null;
  4. const app = getApp();
  5. const conf = {
  6. onLoad () {
  7. const that = this,
  8. userInfo = wx.getStorageSync('userInfo') || null,
  9. noticeLists = wx.getStorageSync('noticeLists'),
  10. token = wx.getStorageSync('token');
  11. let info = wx.getStorageSync('latest_info');
  12. if (info && userInfo && noticeLists) {
  13. app.globalData.userInfo = userInfo;
  14. app.globalData.noticeLists = noticeLists;
  15. app.globalData.token = token;
  16. info = JSON.parse(info);
  17. // console.log('test');
  18. that.setData({info: info, notice: app.globalData.noticeLists[1]});
  19. }else{
  20. wx.redirectTo({url: '/pages/firstSetting/firstSetting'})
  21. }
  22. },
  23. onHide () {
  24. this.setData({'calendar.hiddenLoading': false})
  25. },
  26. onShow: function() {
  27. initCalendar();
  28. let info = wx.getStorageSync('latest_info');
  29. if (!info) {
  30. wx.redirectTo({url: '/pages/firstSetting/firstSetting'})
  31. }
  32. },
  33. onShareAppMessage: function () {
  34. return {
  35. title: app.globalData.title,
  36. imageUrl: app.globalData.img,
  37. path: '/pages/index/index',
  38. success: function(res) {
  39. app.confirmModal('分享成功', false)
  40. },
  41. fail: function(res) {
  42. app.confirmModal('您取消了分享', false)
  43. }
  44. }
  45. }
  46. };
  47. Page(conf);