App.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. <template>
  2. <div id="app">
  3. <!-- <header class="bar bar-nav d-flex justify-content-between align-items-center p-2">-->
  4. <!-- <el-button type="text" icon="el-icon-arrow-left" v-on:click="goBack"-->
  5. <!-- v-if="$route.meta.showBackLeftBtn"></el-button>-->
  6. <!--&lt;!&ndash; <h4 class="title">{{title}}</h4>&ndash;&gt;-->
  7. <!-- <el-button type="text"><span v-if="$route.meta.showBarRightBtn">编辑</span></el-button>-->
  8. <!-- </header>-->
  9. <keep-alive>
  10. <router-view class="app-body" v-if="$route.meta.keepAlive"/>
  11. </keep-alive>
  12. <router-view class="app-body" v-if="!$route.meta.keepAlive"/>
  13. <div class="tab-nav nav-bar" v-if="$route.meta.showTab">
  14. <a href="javascript:;" v-for="(i,index) in data.tabs" :key="index" :class="{active:index == data.thatnum}" @click="addClassName(index)">
  15. <router-link :to="i.url">
  16. <img v-if="data.thatnum!=index" :src="i.img" class="first weui-tabbar__icon">
  17. <img v-if="data.thatnum==index" :src="i.active" class="last first weui-tabbar__icon">
  18. </router-link>
  19. </a>
  20. <!-- <el-row>
  21. <el-col :span="8" v-for="(i,index) in data.tabs" :key="index">
  22. <a href="javascript:;" :class="{active:index == data.thatnum}" @click="addClassName(index)">
  23. <router-link :to="i.url">
  24. <img v-if="data.thatnum!=index" :src="i.img" class="first weui-tabbar__icon">
  25. <img v-if="data.thatnum==index" :src="i.active" class="last first weui-tabbar__icon">
  26. </router-link>
  27. </a>
  28. </el-col>
  29. </el-row> -->
  30. </div>
  31. </div>
  32. </template>
  33. <script lang="ts" >
  34. import {Component,Vue} from "vue-property-decorator";
  35. import router from "@/router";
  36. import Utils from './extend/Utils';
  37. import login from "./store/module/login";
  38. var configJson = require('./static/common.json')
  39. @Component({})
  40. export default class App extends Vue {
  41. public data:any= {
  42. thatnum: -1,
  43. tabs:[
  44. {url:'/index',img:require('./assets/image/label_01@2x.png'),active:require('./assets/image/label-2_01@2x.png')},
  45. {url:'/other',img:require('./assets/image/label_02@2x.png'),active:require('./assets/image/label-2_02@2x.png')},
  46. {url:'/user',img:require('./assets/image/label_03@2x.png'),active:require('./assets/image/label-2_03@2x.png')}
  47. ]
  48. }
  49. addClassName(index) {
  50. this.data.thatnum = index;
  51. }
  52. public get title() {
  53. return this.$route.meta.title;
  54. }
  55. public goBack() {
  56. router.back();
  57. }
  58. created() {
  59. const version = configJson.version; //版本号(每次上线前需要更新下版本号)
  60. console.log('最新版本号common.js:',version)
  61. const clientVersion =localStorage.getItem('_version_')
  62. console.log('当前版本号app.vue:',clientVersion)
  63. if(clientVersion !== version){
  64. let storage = window.localStorage;
  65. storage.clear()
  66. this.$router.replace('/login')
  67. localStorage.setItem('_version_', JSON.stringify(version))
  68. }
  69. }
  70. beforeUpdate() {
  71. const version = configJson.version; //版本号(每次上线前需要更新下版本号)
  72. // console.log('修改版本号common.js:',version)
  73. const clientVersion =localStorage.getItem('_version_')
  74. // console.log('修改版本号app.vue:',clientVersion)
  75. if(clientVersion !== version){
  76. let storage = window.localStorage;
  77. storage.clear()
  78. this.$router.replace('/login')
  79. localStorage.setItem('_version_', JSON.stringify(version))
  80. }
  81. }
  82. }
  83. </script>
  84. <style lang="scss">
  85. @import '../node_modules/bootstrap/dist/css/bootstrap.min.css';
  86. @import '@/assets/scss/common.scss';
  87. #app {
  88. position: relative;
  89. min-height: 100%;
  90. background: white;
  91. }
  92. #app > div:first-child {
  93. font-size: 1.2rem;
  94. }
  95. .nav-ul{
  96. display: flex;
  97. width: 100%;
  98. }
  99. .tab-nav {
  100. position: fixed;
  101. display: flex;
  102. justify-content: space-between;
  103. bottom: 0;
  104. left: 0;
  105. right: 0;
  106. border-bottom: 0;
  107. border-top: 1px solid #f0f0f0;
  108. background: #fff;
  109. z-index: 999;
  110. // height: 50px;
  111. img{
  112. width: 100%;
  113. // height: 100%;
  114. }
  115. }
  116. .app-body {
  117. /*margin-top: 45px;*/
  118. /*margin-bottom: 5rem;*/
  119. overflow: hidden;
  120. }
  121. .bar-nav .title {
  122. position: absolute;
  123. left: 0;
  124. right: 0;
  125. text-align: center;
  126. }
  127. body .el-message-box {
  128. width: 300px;
  129. }
  130. body .el-message {
  131. min-width: 90%;
  132. }
  133. </style>