App.vue 6.1 KB

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