app.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. //app.js
  2. const utils = require('utils/util.js');
  3. wx.cloud.init();
  4. wx.u = utils
  5. App({
  6. onLaunch: function () {
  7. const that = this;
  8. wx.showLoading();
  9. wx.cloud.callFunction({
  10. name: "quickstartFunctions",
  11. data: {
  12. type: "getUser"
  13. }
  14. }).then(res => {
  15. if(res.result.code !== 0) return wx.showToast({
  16. title: '网络繁忙',
  17. icon: "none"
  18. })
  19. that.globalData.userInfo = res.result.data;
  20. if(that.haveUserInfo) that.haveUserInfo();
  21. wx.hideLoading();
  22. }).catch(err => {
  23. console.log(err)
  24. wx.showToast({
  25. title: '服务走丢了~',
  26. icon: "none"
  27. })
  28. wx.hideLoading();
  29. })
  30. },
  31. globalData: {
  32. userInfo: null
  33. }
  34. })
  35. /**
  36. * tab
  37. * {
  38. "text": "答题",
  39. "iconPath": "images/answer.png",
  40. "selectedIconPath": "images/answer-select.png",
  41. "pagePath": "pages/problemPage/index"
  42. },
  43. {
  44. "text": "排名",
  45. "iconPath": "images/sort.png",
  46. "selectedIconPath": "images/sort-select.png",
  47. "pagePath": "pages/rank/index"
  48. },
  49. {
  50. "text": "我的",
  51. "iconPath": "images/my.png",
  52. "selectedIconPath": "images/my-select.png",
  53. "pagePath": "pages/my/index"
  54. }
  55. */