App.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  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://dm.static.elab-plus.com/miniProgram/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 landDataId = this.$route.query.landDataId ? this.$route.query.landDataId : '';//土地id
  49. let houseName = this.$route.query.houseName ? this.$route.query.houseName : '';//项目名称
  50. let cityCode = this.$route.query.cityCode ? this.$route.query.cityCode : '';//土地id
  51. let customizedRecordId = this.$route.query.customizedRecordId ? this.$route.query.customizedRecordId : '';//作品id-说明已经存储了
  52. let ueId = this.$route.query.ueId ? this.$route.query.ueId : '';//ueId-说明选择了具体的户型
  53. let query = this.$route.query;
  54. let brandId = this.$route.query.brandId || this.$route.query.special_ID;
  55. if (brandId) { //如果存在集团id
  56. $config.brandId = brandId;
  57. }
  58. if (landDataId) { //如果存在土地id
  59. this.$store.state.landDataId = landDataId;
  60. }
  61. if (houseName) { //如果存在项目名称
  62. this.$store.state.houseName = houseName;
  63. }
  64. if (cityCode) { //如果存在cityCode
  65. this.$store.state.cityCode = cityCode;
  66. }
  67. if (customizedRecordId) { //如果存在customizedRecordId
  68. this.$store.state.customizedRecordId = customizedRecordId;
  69. }
  70. if (ueId) { //如果存在ueId
  71. this.$store.state.ueId = ueId;
  72. }
  73. if (xcxHouseId) { //如果存在houseid
  74. this.$store.dispatch('setHouseId', xcxHouseId);
  75. }
  76. if (query) { //如果存在入参
  77. setStorage('queryObj', query);
  78. }
  79. if (userId) { //如果存在用户id
  80. this.$store.dispatch('setUserId', userId);
  81. // 开启websocket连接
  82. util.initWebsocket();
  83. }else{
  84. this.webLogin()
  85. }
  86. let isIOS = !!navigator.userAgent.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);
  87. this.isIOS = isIOS;
  88. window.addEventListener('error', (error) => {
  89. console.warn("***error***",error)
  90. // 区分是否是js错误
  91. if (error.message) {
  92. console.warn("error" + error.message)
  93. }
  94. }, true)
  95. // window.onerror = function(message,source,line,column,error) {
  96. // };
  97. },
  98. watch: {
  99. loading: {
  100. handler(newVal) {
  101. if (!newVal) {
  102. this.$store.state.loadingMsg = ''
  103. }
  104. }
  105. },
  106. },
  107. computed: {
  108. loading() {
  109. return this.$store.state.loading;
  110. },
  111. loadingMsg() {
  112. if (this.$store.state.loadingMsg) {
  113. return this.$store.state.loadingMsg;
  114. } else {
  115. return "正在查询,请耐心等待";
  116. }
  117. }
  118. },
  119. mounted() {
  120. // 禁止图片单机事件,防止出现图片点击浏览器自动预览功能
  121. document.body.addEventListener("click", function(e) {
  122. if (e.target.nodeName.toLowerCase() == "img") {
  123. e.preventDefault();
  124. }
  125. });
  126. },
  127. methods: {
  128. async webLogin(){
  129. let xcxHouseId = this.$route.query.xcxHouseId ? this.$route.query.xcxHouseId : (this.$route.query.houseId || '');
  130. let param = {
  131. "terminal": 7,
  132. "brandId": $config.brandId,
  133. "houseId": xcxHouseId,
  134. "shareToken": '',
  135. };
  136. let res = await requestConfig('webXcxLogin', param, true);
  137. if (res && res.single && res.single.id) { //如果存在用户id
  138. let userId = res.single.id;
  139. let userInfo = {
  140. userId:userId,
  141. openId:res.single.openId,
  142. token:res.single.token,
  143. }
  144. this.$store.dispatch('setUserId', userId);
  145. setStorage('userInfo', userInfo);
  146. // 开启websocket连接
  147. util.initWebsocket();
  148. }
  149. }
  150. },
  151. };
  152. </script>
  153. <style>
  154. #app {
  155. font-family: Avenir, Helvetica, Arial, sans-serif;
  156. -webkit-font-smoothing: antialiased;
  157. -moz-osx-font-smoothing: grayscale;
  158. /* text-align: center;
  159. color: #2c3e50;
  160. margin-top: 60px; */
  161. }
  162. body {
  163. background: #181C28;
  164. }
  165. .el-tooltip__popper .popper__arrow,
  166. .el-tooltip__popper .popper__arrow::after {
  167. border-style: none !important;
  168. }
  169. .el-picker-panel__body .el-date-picker__header .el-picker-panel__icon-btn {
  170. color: #FFFFFF;
  171. }
  172. .el-picker-panel__body .el-date-picker__header .el-date-picker__header-label {
  173. color: #FFFFFF;
  174. }
  175. .el-picker-panel__body .el-picker-panel__content .el-date-table th {
  176. color: #FFFFFF;
  177. }
  178. </style>
  179. <style lang="scss" scoped>
  180. @import "./assets/common.scss";
  181. </style>