app.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. //app.js
  2. var app = getApp();
  3. // var wxh = require('../../utils/wxh.js');
  4. App({
  5. onLaunch: function () {
  6. // 展示本地存储能力
  7. var that = this;
  8. var logs = wx.getStorageSync('logs') || []
  9. logs.unshift(Date.now())
  10. wx.setStorageSync('logs', logs)
  11. that.getRoutineStyle();
  12. },
  13. globalData: {
  14. routineStyle:'#ffffff',
  15. uid: null,
  16. openPages:'',
  17. spid:0,
  18. urlImages: '',
  19. url: 'https://shop.crmeb.net/'
  20. },
  21. getRoutineStyle:function(){
  22. var that = this;
  23. wx.request({
  24. url: that.globalData.url + '/routine/login/get_routine_style',
  25. method: 'post',
  26. dataType  : 'json',
  27. success: function (res) {
  28. that.globalData.routineStyle = res.data.data.routine_style;
  29. that.setBarColor();
  30. }
  31. })
  32. },
  33. setBarColor:function(){
  34. var that = this;
  35. wx.setNavigationBarColor({
  36. frontColor: '#000000',
  37. backgroundColor: that.globalData.routineStyle,
  38. })
  39. },
  40. setUserInfo : function(){
  41. var that = this;
  42. if (that.globalData.uid == null) {//是否存在用户信息,如果不存在跳转到首页
  43. wx.showToast({
  44. title: '用户信息获取失败',
  45. icon: 'none',
  46. duration: 1500,
  47. })
  48. setTimeout(function () {
  49. wx.navigateTo({
  50. url: '/pages/load/load',
  51. })
  52. }, 1500)
  53. }
  54. },
  55. })