index.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <template>
  2. <view class="main-content">
  3. <view>
  4. <indexBox v-if=" pageAction == 'index' " />
  5. <meBox v-if=" pageAction == 'me' " />
  6. </view>
  7. <view class="main-tabar">
  8. <view class="main-tabar-info">
  9. <view class="main-tabar-item" @click="clickTabbar('index')">
  10. <view>
  11. <image :src="pageAction=='index'?(staticUrl+'tabar/index_1.png'):(staticUrl+'tabar/index_0.png')"></image>
  12. </view>
  13. <text :style="{ color: pageAction=='index'? '#ED0000':'#595D60' }">{{ '首页' }}</text>
  14. </view>
  15. <view class="main-tabar-item">
  16. <view>
  17. <image :src="pageAction=='me'?(staticUrl+'tabar/me_1.png'):(staticUrl+'tabar/me_0.png')" @click="clickTabbar('me')"></image>
  18. </view>
  19. <text :style="{ color: pageAction=='me'? '#ED0000':'#595D60' }">{{ '我的' }}</text>
  20. </view>
  21. </view>
  22. </view>
  23. </view>
  24. </template>
  25. <script>
  26. import indexBox from "../index/index.vue"
  27. import meBox from "../me/index.vue"
  28. export default {
  29. components: {
  30. indexBox,
  31. meBox
  32. },
  33. data() {
  34. return {
  35. title: '主页',
  36. pageAction: 'index',
  37. staticUrl:this.$commonConfig.staticUrl,
  38. }
  39. },
  40. onLoad(e) {
  41. this.pageAction = e.router || 'index'
  42. // window.history.pushState(null, null, document.URL + '#1') //往浏览器历史中添加一次记录
  43. // window.onhashchange = (e) => {
  44. // console.log(e);
  45. // uni.showModal({
  46. // title: '提示',
  47. // content: '返回后此页面的操作将不作保留!',
  48. // cancelText: '确定返回',
  49. // confirmText: '留在此页',
  50. // success: (res) => {
  51. // if (res.confirm) {
  52. // window.history.pushState(null, null, document.URL + '#1')
  53. // } else if (res.cancel) {
  54. // window.history.back();
  55. // window.onhashchange = null //这里不取消监听那么上面的history.back()也会触发一次uni.showModal,就会有两个弹窗
  56. // }
  57. // }
  58. // });
  59. // }
  60. },
  61. onUnload() {
  62. console.log("dsfasfasdf======")
  63. //window.removeEventListener("popstate", this.browserBack);
  64. },
  65. onShow() {
  66. },
  67. methods: {
  68. /**
  69. * @author ygh
  70. * @data 2023-12-19
  71. * @param {Object} type
  72. */
  73. clickTabbar(type){
  74. if( this.pageAction == type ) return
  75. this.pageAction = type
  76. //this.$u.route('/pages/main/index',{router:this.pageAction});
  77. uni.reLaunch({
  78. url: "/pages/main/index?router="+type
  79. })
  80. },
  81. }
  82. }
  83. </script>
  84. <style lang="scss" scoped>
  85. .main-content {
  86. width: 100%;
  87. height: 100%;
  88. position: relative;
  89. }
  90. /** tabar */
  91. .main-tabar {
  92. width: 80vw;
  93. height: 100rpx;
  94. position: fixed;
  95. bottom: 20rpx;
  96. left: 50%;
  97. transform: translateX(-50%);
  98. box-sizing: border-box;
  99. .main-tabar-info {
  100. width: 100%;
  101. height: 100%;
  102. display: flex;
  103. justify-content: space-between;
  104. background: #FFFFFF;
  105. box-shadow: 0rpx 2rpx 20rpx 0rpx rgba(181,179,179,0.5);
  106. border-radius: 40rpx;
  107. .main-tabar-item {
  108. flex: 1;
  109. display: flex;
  110. align-items: center;
  111. flex-direction: column;
  112. justify-content: center;
  113. image {
  114. width: 50rpx;
  115. height: 50rpx;
  116. }
  117. text {
  118. font-size: 24rpx;
  119. }
  120. }
  121. }
  122. }
  123. </style>