App.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. <script>
  2. export default {
  3. globalData() {
  4. return {
  5. stystem: {},
  6. text: ''
  7. }
  8. },
  9. onLaunch: function (options) {
  10. console.log(options)
  11. console.log('app onLaunch--->'); // 公众号文章进小程序无底部导航调试,请勿删除
  12. console.log(options); // 公众号文章进小程序无底部导航调试,请勿删除
  13. console.log('<---app onLaunch'); // 公众号文章进小程序无底部导航调试,请勿删除
  14. // #ifdef H5
  15. if (!this.$jwx.isWechat()) {
  16. uni.getLocation({
  17. success() {
  18. },
  19. fail() {
  20. }
  21. });
  22. }
  23. // #endif
  24. if (options && options.scene) {
  25. this.$appScene = options.scene;
  26. }
  27. this.$store.dispatch('mallConfig/actionGetConfig');
  28. let _this = this;
  29. wx.getSystemInfo({
  30. success: function (response) {
  31. _this.$store.dispatch('gConfig/setSystemInfo', response);
  32. _this.$store.dispatch('iPhoneX/setIphone', response);
  33. }
  34. });
  35. // #ifdef MP-WEIXIN
  36. if (options.scene == '1011' || options.scene == '1012' || options.scene == '1013'
  37. || options.scene == '1047' || options.scene == '1048' || options.scene == '1049') {
  38. this.$store.dispatch('page/actionSetIsScanQrCode', true);
  39. }
  40. // #endif
  41. // #ifdef MP-ALIPAY
  42. if (typeof options.query != 'undefined') {
  43. this.$store.dispatch('page/actionSetQeury', options.query)
  44. }
  45. // #endif
  46. if (options.query && typeof options.query.user_id !== 'undefined') {
  47. this.$store.dispatch('user/setTempParentId', options.query.user_id)
  48. }
  49. // #ifdef H5
  50. this.$storage.setStorageSync('platform', 'wechat');
  51. if (this.$jwx.isWechat()) {
  52. if (!this.$storage.getStorageSync('_USER_SIGN')) {
  53. this.$storage.setStorageSync('isSign', false);
  54. this.$storage.removeStorageSync('_USER_ACCESS_TOKEN');
  55. this.$user.silentLogin();
  56. } else {
  57. this.$storage.setStorageSync('_USER_SIGN', false);
  58. let params = this.$utils.getUrlParam('code');
  59. if (params) {
  60. this.$request({
  61. url: this.$api.registered.login,
  62. data: {
  63. code: params,
  64. type: 'wechat'
  65. },
  66. method: 'post'
  67. }).then(response => {
  68. if (response.code === 0) {
  69. this.$storage.setStorageSync('_USER_ACCESS_TOKEN', response.data.access_token);
  70. }
  71. let url = window.location.href;
  72. let res = url.replace(url.slice(url.indexOf('?'), url.indexOf('#')), '');
  73. let index = res.indexOf('#');
  74. let newRes = res.slice(0, index) + '?' + res.slice(index);
  75. this.$storage.setStorageSync('_USER_SIGN', true);
  76. window.location.replace(newRes);
  77. this.$storage.setStorageSync('isSign', true);
  78. });
  79. }
  80. return true;
  81. }
  82. } else {
  83. this.$storage.setStorageSync('isSign', true);
  84. if (window.location.href.indexOf('?#') === -1) {
  85. let { hash, origin, pathname } = window.location;
  86. this.$storage.setStorageSync('_USER_SIGN', true);
  87. window.location.replace(`${origin}${pathname}?${hash}`);
  88. return true;
  89. }
  90. }
  91. if (this.$jwx.isWechat()) {
  92. let hash= window.location.hash;
  93. if (hash.indexOf('isWechat=true') > -1 && hash.indexOf('isPay=ture') > -1 && hash.indexOf('payType=alipay_h5') > -1) {
  94. uni.reLaunch({
  95. url: '/pages/registered/placard'
  96. });
  97. }
  98. this.$storage.setStorageSync('isSign', true);
  99. }
  100. // #endif
  101. // #ifdef MP-WEIXIN
  102. this.$user.silentLogin();
  103. // #endif
  104. },
  105. onShow(options) {
  106. console.log('app onShow--->'); // 公众号文章进小程序无底部导航调试,请勿删除
  107. console.log(options); // 公众号文章进小程序无底部导航调试,请勿删除
  108. console.log('<---app onShow'); // 公众号文章进小程序无底部导航调试,请勿删除
  109. if (options && options.scene) {
  110. this.$appScene = options.scene;
  111. }
  112. }
  113. };
  114. </script>
  115. <style lang="scss">
  116. /*每个页面公共css */
  117. @import "./static/css/flex.scss";
  118. @import "./static/css/themeColor.scss";
  119. @import "./static/css/text.scss";
  120. @import "./static/css/image.scss";
  121. @import "./static/css/parse.scss";
  122. @import "./static/css/gift.scss";
  123. @import "./static/css/u-index.scss";
  124. @import "./static/css/border-box.scss";
  125. @import './static/css/iconfont.css';
  126. .u-goods-detail {
  127. background-image: url("./static/image/goods.png");
  128. background-repeat: no-repeat;
  129. background-size: 100% 100%;
  130. min-height: 100vh;
  131. }
  132. .u-border-box {
  133. box-sizing: border-box;
  134. }
  135. /* #ifdef H5 */
  136. body.pages-index-index uni-page-body { background: transparent!important;}
  137. /* #endif */
  138. /* #ifdef H5 */
  139. //uni-page-head { display: none}
  140. /* #endif */
  141. </style>