index.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. //index.js
  2. //获取应用实例
  3. const app = getApp()
  4. var abouturl = '';
  5. Page({
  6. data: {
  7. realName: '',
  8. count: '',
  9. program: '',
  10. code: '',
  11. userInfo:{},
  12. appVersion: app.globalData.appVersion
  13. },
  14. onLoad: function () {
  15. this.getCode();
  16. this.getStaticurl();
  17. this.getUserInfo();
  18. },
  19. getCode(){
  20. let that = this;
  21. wx.login({
  22. success: function (ret) {
  23. that.code = ret.code;
  24. }
  25. });
  26. },
  27. getStatic: function(){
  28. },
  29. onShow:function(){
  30. var that = this;
  31. app.ajaxReadyCallback = res => {
  32. var apiname = res.data.apiname;
  33. if (apiname == 'logout'){
  34. app.globalData.isTourist = false;
  35. app.globalData.userinfo = {};
  36. wx.clearStorageSync();
  37. wx.reLaunch({ //关闭所有页面,打开到应用内的某个页面
  38. url: '/pages/splash/splash'
  39. })
  40. } else if (apiname == 'staticurl'){
  41. abouturl = res.data.data.aboutUrl;
  42. }else if (apiname == 'userInfo'){
  43. that.setData({
  44. userInfo:res.data.data
  45. })
  46. }else{
  47. that.setData({
  48. count: res.data.data
  49. });
  50. }
  51. }
  52. // this.getUnreadCount();
  53. },
  54. logout:function(e){
  55. app.globalData.userinfo = {};
  56. app.logout();
  57. setTimeout(function(){
  58. wx.reLaunch({ //关闭所有页面,打开到应用内的某个页面
  59. url: '/pages/splash/splash'
  60. })
  61. },2000);
  62. },
  63. getUserInfo(){
  64. app.ajax({
  65. url: app.globalData.serverUrl + '/User/info',
  66. type: 'POST',
  67. apiname:'userInfo',
  68. data: {
  69. }
  70. });
  71. },
  72. getStaticurl:function(){
  73. var org = app.globalData.userinfo.org;
  74. app.ajax({
  75. url: app.globalData.serverUrl + '/Login/staticUrl',
  76. type: 'POST',
  77. apiname:'staticurl',
  78. data: {
  79. }
  80. });
  81. },
  82. getUnreadCount:function(){
  83. var org = app.globalData.userinfo.org;
  84. app.ajax({
  85. url: app.globalData.serverUrl + 'server/notice/queryNoticeCount',
  86. type: 'POST',
  87. data: {
  88. orgId: org.orgId
  89. }
  90. });
  91. },
  92. about: function(e){
  93. console.log(abouturl)
  94. if (!abouturl){
  95. return false;
  96. }
  97. app.gotopage('/pages/webview/index', { url: abouturl });
  98. return false;
  99. }
  100. })