App.vue 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <script>
  2. import ProductInfo from '@/components/ProductInfo';
  3. export default {
  4. onLaunch(options) {
  5. wx.login({
  6. success: res => {
  7. console.log(res);
  8. this.$http
  9. .post('/auth/maLogin', { code: res.code })
  10. .then(res => {
  11. this.$http.setToken(res.token);
  12. this.$store.commit('setSessionKey', res.sessionKey);
  13. this.$store
  14. .dispatch('getUserInfo')
  15. .then(() => {
  16. this.globalData.initialize = true;
  17. console.log(this.globalData);
  18. if (this.globalData.initializeCallback) {
  19. this.globalData.initializeCallback();
  20. }
  21. })
  22. .catch(() => {
  23. this.globalData.initialize = true;
  24. });
  25. })
  26. .catch(e => {
  27. console.log(e);
  28. });
  29. }
  30. });
  31. wx.getSystemInfo({
  32. success: res => {
  33. console.log(res);
  34. this.$store.commit('setSystemInfo', res);
  35. }
  36. });
  37. // Do something initial when launch.
  38. },
  39. onShow(options) {
  40. // Do something when show.
  41. console.log('App onShow');
  42. },
  43. onHide() {
  44. // Do something when hide.
  45. console.log('App onHide');
  46. },
  47. onError(msg) {
  48. console.log('App onError');
  49. console.log(msg);
  50. },
  51. globalData() {
  52. return {
  53. a: 'I am global data'
  54. };
  55. }
  56. };
  57. </script>
  58. <style lang="less" scoped>
  59. /deep/.van-image {
  60. display: block;
  61. }
  62. </style>