App.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. <template>
  2. <div id="app">
  3. <!-- IOS机器会跳转两次到其他路由,当from路由被缓存时,原因未知 -->
  4. <keep-alive >
  5. <!-- <transition name="fade"> -->
  6. <router-view v-if="$route.meta.keepAlive"></router-view>
  7. <!-- </transition> -->
  8. </keep-alive>
  9. <router-view v-if="!$route.meta.keepAlive"></router-view>
  10. <div class="loadingShadow" v-show="loading">
  11. <div class="loadData">
  12. <img src="https://skyforest.static.elaber.cn/detail/loading.gif" alt="" />
  13. <div class="loadingMsg">{{loadingMsg}}</div>
  14. </div>
  15. </div>
  16. </div>
  17. </template>
  18. <script>
  19. import {
  20. setStorage,
  21. getStorage,
  22. pxoveItem
  23. } from '@/utils/localStorage';
  24. const util = require('@/utils/util.js').default;
  25. export default {
  26. name: "App",
  27. // provide() {
  28. // return {
  29. // reload: this.reload,
  30. // };
  31. // },
  32. data() {
  33. return {
  34. themeColor: "rgba(0,97,232,1)",
  35. themeColor2: "rgba(0,97,232,0.2)",
  36. isRouterAlive: true,
  37. showAccountView: false, //是否显示用户账号列表
  38. acountList: [], //弹出层账号列表数据
  39. selectAccount: null, //选中的账号
  40. isIOS: false,
  41. include: []
  42. };
  43. },
  44. created() {
  45. let userInfo = getStorage('userInfo') ? JSON.parse(getStorage('userInfo')) : null;
  46. let userId = this.$route.query.leavePhoneCustomerId ? this.$route.query.leavePhoneCustomerId : (userInfo?userInfo.userId:'');
  47. let xcxHouseId = this.$route.query.xcxHouseId ? this.$route.query.xcxHouseId : (this.$route.query.houseId || '');
  48. let query = this.$route.query;
  49. let brandId = this.$route.query.brandId || this.$route.query.special_ID;
  50. if (brandId) { //如果存在集团id
  51. $config.brandId = brandId;
  52. }
  53. if (xcxHouseId) { //如果存在houseid
  54. this.$store.dispatch('setHouseId', xcxHouseId);
  55. }
  56. if (query) { //如果存在入参
  57. setStorage('queryObj', query);
  58. }
  59. if (userId) { //如果存在用户id
  60. this.$store.dispatch('setUserId', userId);
  61. // 开启websocket连接
  62. util.initWebsocket();
  63. }else{
  64. this.webLogin()
  65. }
  66. let isIOS = !!navigator.userAgent.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);
  67. this.isIOS = isIOS;
  68. window.addEventListener('error', (error) => {
  69. console.warn("***error***",error)
  70. // 区分是否是js错误
  71. if (error.message) {
  72. console.warn("error" + error.message)
  73. }
  74. }, true)
  75. // window.onerror = function(message,source,line,column,error) {
  76. // };
  77. },
  78. watch: {
  79. loading: {
  80. handler(newVal) {
  81. if (!newVal) {
  82. this.$store.state.loadingMsg = ''
  83. }
  84. }
  85. },
  86. },
  87. computed: {
  88. loading() {
  89. return this.$store.state.loading;
  90. },
  91. loadingMsg() {
  92. if (this.$store.state.loadingMsg) {
  93. return this.$store.state.loadingMsg;
  94. } else {
  95. return "正在查询,请耐心等待";
  96. }
  97. }
  98. },
  99. mounted() {
  100. // 禁止图片单机事件,防止出现图片点击浏览器自动预览功能
  101. document.body.addEventListener("click", function(e) {
  102. if (e.target.nodeName.toLowerCase() == "img") {
  103. e.preventDefault();
  104. }
  105. });
  106. },
  107. methods: {
  108. async webLogin(){
  109. let xcxHouseId = this.$route.query.xcxHouseId ? this.$route.query.xcxHouseId : (this.$route.query.houseId || '');
  110. let param = {
  111. "terminal": 7,
  112. "brandId": $config.brandId,
  113. "houseId": xcxHouseId,
  114. "shareToken": '',
  115. };
  116. let res = await requestConfig('webXcxLogin', param, true);
  117. if (res && res.single && res.single.id) { //如果存在用户id
  118. let userId = res.single.id;
  119. let userInfo = {
  120. userId:userId,
  121. openId:res.single.openId,
  122. token:res.single.token,
  123. }
  124. this.$store.dispatch('setUserId', userId);
  125. setStorage('userInfo', userInfo);
  126. // 开启websocket连接
  127. util.initWebsocket();
  128. }
  129. }
  130. },
  131. };
  132. </script>
  133. <style>
  134. #app {
  135. font-family: Avenir, Helvetica, Arial, sans-serif;
  136. -webkit-font-smoothing: antialiased;
  137. -moz-osx-font-smoothing: grayscale;
  138. /* text-align: center;
  139. color: #2c3e50;
  140. margin-top: 60px; */
  141. }
  142. body {
  143. background: #181C28;
  144. }
  145. .el-tooltip__popper .popper__arrow,
  146. .el-tooltip__popper .popper__arrow::after {
  147. border-style: none !important;
  148. }
  149. .el-picker-panel__body .el-date-picker__header .el-picker-panel__icon-btn {
  150. color: #FFFFFF;
  151. }
  152. .el-picker-panel__body .el-date-picker__header .el-date-picker__header-label {
  153. color: #FFFFFF;
  154. }
  155. .el-picker-panel__body .el-picker-panel__content .el-date-table th {
  156. color: #FFFFFF;
  157. }
  158. </style>
  159. <style lang="scss" scoped>
  160. @import "./assets/common.scss";
  161. </style>