App.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. <script>
  2. import md5Libs from "uview-ui/libs/function/md5";
  3. export default {
  4. onLaunch: async function() {
  5. console.log('uview 版本', this.$u.config.v);
  6. // #ifdef H5
  7. if(window.location.hash != ''){
  8. let search = window.location.search.substring(1);
  9. try{
  10. if(search.indexOf('hashpath') != -1){
  11. let sea = JSON.parse('{"' + decodeURIComponent(search).replace(/"/g, '\\"').replace(/&/g, '","').replace(/=/g,'":"') + '"}');
  12. if(sea.hashpath && sea.code && sea.state){
  13. window.location.href = window.location.origin + window.location.pathname+'#'+sea.hashpath+'?code='+sea.code+'&state='+sea.state
  14. }
  15. }
  16. }catch(e){
  17. //TODO handle the exception
  18. }
  19. }
  20. // #endif
  21. //加载配置
  22. let res = await this.$api.getConfig();
  23. if (!res.code) {
  24. return;
  25. }
  26. //主题做缓存
  27. let theme_key = md5Libs.md5(JSON.stringify(res.data.theme));
  28. if(!this.vuex_theme.key || this.vuex_theme.key != theme_key){
  29. this.$u.vuex('vuex_theme', {key:theme_key,value:res.data.theme});
  30. }
  31. this.$u.vuex('vuex_config', res.data);
  32. // #ifdef APP-PLUS
  33. let tabbar = this.$u.deepClone(this.vuex_config.tabbar);
  34. if (!tabbar) {
  35. this.$util.setTabbar(this.vuex_tabbar);
  36. return;
  37. }
  38. let num = 0;
  39. for (let i in tabbar.list) {
  40. try {
  41. let imagepath = await this.$util.getCachedImage(tabbar.list[i].image);
  42. let selectedImage = await this.$util.getCachedImage(tabbar.list[i].selectedImage);
  43. tabbar.list[i].image = imagepath;
  44. tabbar.list[i].selectedImage = selectedImage;
  45. num = i;
  46. } catch (e) {
  47. console.log(e);
  48. }
  49. }
  50. //更新tabbar配置
  51. this.$u.vuex('vuex_config.tabbar.list', tabbar.list);
  52. return ;
  53. //全部下载成功使用服务器的导航,否则启用本地备用导航
  54. if (parseInt(num) + 1 == tabbar.list.length) {
  55. this.$util.setTabbar(tabbar);
  56. } else {
  57. this.$util.setTabbar(this.vuex_tabbar);
  58. }
  59. // #endif
  60. },
  61. onShow: function() {
  62. console.log('App Show');
  63. },
  64. onHide: function() {
  65. console.log('App Hide');
  66. }
  67. };
  68. </script>
  69. <style lang="scss">
  70. @import 'uview-ui/index.scss';
  71. /*每个页面公共css */
  72. .u-bg-white {
  73. background-color: #ffffff;
  74. }
  75. .u-text-weight {
  76. font-weight: bold;
  77. }
  78. .u-line-height {
  79. line-height: 50rpx;
  80. }
  81. .bg-white {
  82. background-color: #ffffff;
  83. }
  84. .price {
  85. color: $u-type-error;
  86. }
  87. .text-weight {
  88. font-weight: bold;
  89. }
  90. .text-normal {
  91. font-weight: normal;
  92. }
  93. .fa-empty {
  94. width: 100%;
  95. flex-direction: column;
  96. image {
  97. width: 400rpx;
  98. height: 400rpx;
  99. }
  100. &.top-15 {
  101. padding-top: 15vh;
  102. }
  103. }
  104. .footer-bar {
  105. position: fixed;
  106. left: 0;
  107. bottom: 0;
  108. width: 100%;
  109. height: 120rpx;
  110. background-color: #ffffff;
  111. padding: 0 30rpx;
  112. z-index: 9999;
  113. }
  114. .share-btn {
  115. padding: 0;
  116. margin: 0;
  117. border: 0;
  118. background-color: transparent;
  119. line-height: inherit;
  120. border-radius: 0;
  121. font-size: inherit;
  122. color: #999;
  123. }
  124. .share-btn::after {
  125. border: none;
  126. }
  127. // #ifdef MP-BAIDU
  128. .u-radio__icon-wrap,.u-checkbox__icon-wrap{
  129. line-height: 0;
  130. }
  131. // #endif
  132. </style>