App.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <template>
  2. <div class="safari-fix" :class="{'hide-bar':!showTabbar}" id="app">
  3. <!-- <img src="./assets/logo.png"> -->
  4. <router-view/>
  5. <mt-tabbar v-model="selectedTab" v-if="showTabbar">
  6. <mt-tab-item id="index">
  7. <img slot="icon" :src="icon_now.index">
  8. 首页
  9. </mt-tab-item>
  10. <mt-tab-item id="contract">
  11. <img slot="icon" :src="icon_now.contract">
  12. 合同
  13. </mt-tab-item>
  14. <mt-tab-item id="contact">
  15. <img slot="icon" :src="icon_now.contact">
  16. 联系人
  17. </mt-tab-item>
  18. <mt-tab-item id="my">
  19. <img slot="icon" :src="icon_now.my">
  20. 我的
  21. </mt-tab-item>
  22. </mt-tabbar>
  23. </div>
  24. </template>
  25. <script>
  26. import icon_index from '../static/tabbar/index.png';
  27. import icon_contract from '../static/tabbar/contract.png';
  28. import icon_contact from '../static/tabbar/contact.png';
  29. import icon_my from '../static/tabbar/my.png';
  30. import icon_index_active from '../static/tabbar/index_active.png';
  31. import icon_contract_active from '../static/tabbar/contract_active.png';
  32. import icon_contact_active from '../static/tabbar/contact_active.png';
  33. import icon_my_active from '../static/tabbar/my_active.png';
  34. export default {
  35. name: 'App',
  36. data(){
  37. return{
  38. selectedTab:'index',
  39. icon_now:{
  40. index:icon_index_active,
  41. contract:icon_contract,
  42. contact:icon_contact,
  43. my:icon_my
  44. },
  45. icon:{
  46. index:icon_index,
  47. contract:icon_contract,
  48. contact:icon_contact,
  49. my:icon_my
  50. },
  51. icon_active:{
  52. index:icon_index_active,
  53. contract:icon_contract_active,
  54. contact:icon_contact_active,
  55. my:icon_my_active
  56. },
  57. showTabbar:true
  58. }
  59. },
  60. mounted(){
  61. console.log(this.$router.currentRoute.path)
  62. let showTab=['/index','/contract','/contact','/my'];
  63. if(!~showTab.indexOf(this.$router.currentRoute.path)){
  64. this.showTabbar=false
  65. }else{
  66. this.showTabbar=true;
  67. this.selectedTab=this.$router.currentRoute.path.substr(1);
  68. }
  69. },
  70. watch:{
  71. 'selectedTab':function(val){
  72. this.$router.push('/'+val);
  73. for(let i in this.icon_now){
  74. this.icon_now[i]=this.icon[i];
  75. }
  76. this.icon_now[val]=this.icon_active[val];
  77. },
  78. '$route' (to, from) {
  79. // console.log(this.$route.json.path)
  80. // console.log(to)
  81. let showTab=['/index','/contract','/contact','/my'];
  82. if(!~showTab.indexOf(to.path)){
  83. this.showTabbar=false
  84. }else{
  85. this.showTabbar=true
  86. this.selectedTab=to.path.substr(1);
  87. }
  88. }
  89. }
  90. }
  91. </script>
  92. <style>
  93. #app {
  94. font-family: 'Avenir', Helvetica, Arial, sans-serif;
  95. -webkit-font-smoothing: antialiased;
  96. -moz-osx-font-smoothing: grayscale;
  97. text-align: center;
  98. color: #2c3e50;
  99. }
  100. </style>