my.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. <template>
  2. <view class="container">
  3. <view class="placeholder"></view>
  4. <!-- 每一个选项 -->
  5. <view class="box" v-for="item in list" :key="item.id" @click="handleClick(item)">
  6. <view class="icon"><img :src="item.icon" /></view>
  7. <view class="title">{{ item.title }}</view>
  8. <view class="right"><img src="../../static/imgs/right.png" /></view>
  9. </view>
  10. <!-- 底部导航栏区域 -->
  11. <view class="tab_bar">
  12. <navigator open-type="redirect" url="/pages/home/home" class="tab_box">
  13. <img v-if="pageUrl == 'pages/home/home'" src="../../static/imgs/home_active.png" />
  14. <img v-else src="../../static/imgs/home.png" />
  15. <view v-if="pageUrl == 'pages/home/home'" class="tab_title_active">首页</view>
  16. <view v-else class="tab_title">首页</view>
  17. </navigator>
  18. <navigator open-type="redirect" url="/pages/stat/stat" class="tab_box">
  19. <img v-if="pageUrl == 'pages/stat/stat'" src="../../static/imgs/stat_active.png" />
  20. <img v-else src="../../static/imgs/stat.png" />
  21. <view v-if="pageUrl == 'pages/stat/stat'" class="tab_title_active">统计</view>
  22. <view v-else class="tab_title">统计</view>
  23. </navigator>
  24. <navigator open-type="redirect" v-if="flag" url="/pages/my/my" class="tab_box">
  25. <img v-if="pageUrl == 'pages/my/my'" src="../../static/imgs/my_active.png" />
  26. <img v-else src="../../static/imgs/my.png" />
  27. <view v-if="pageUrl == 'pages/my/my'" class="tab_title_active">我的</view>
  28. <view v-else class="tab_title">我的</view>
  29. </navigator>
  30. </view>
  31. </view>
  32. </template>
  33. <script>
  34. import my1 from '../../static/imgs/my1.png'
  35. import my2 from '../../static/imgs/my2.png'
  36. import my3 from '../../static/imgs/my3.png'
  37. import my4 from '../../static/imgs/my4.png'
  38. export default {
  39. data() {
  40. return {
  41. // 是否为管理员标识
  42. flag: false,
  43. // 页面选项数组
  44. list: [
  45. {
  46. id: 1,
  47. icon: my1,
  48. title: '规则设置',
  49. url: '/pages/ruleSet/ruleSet'
  50. },
  51. {
  52. id: 2,
  53. icon: my2,
  54. title: '权限设置',
  55. url: '/pages/powerSet/powerSet'
  56. },
  57. {
  58. id: 3,
  59. icon: my3,
  60. title: '打卡记录',
  61. url: '/pages/cardRecord/cardRecord'
  62. },
  63. {
  64. id: 4,
  65. icon: my4,
  66. title: '考勤组',
  67. url: '/pages/group/group?flag=1'
  68. }
  69. ],
  70. // 当前页面的路由地址
  71. pageUrl: ''
  72. }
  73. },
  74. onLoad() {},
  75. onShow() {
  76. this.getPageUrl()
  77. let flag = uni.getStorageSync('manager')
  78. let flag2 = uni.getStorageSync('sub-administrator')
  79. if (flag || flag2) {
  80. this.flag = true
  81. } else {
  82. this.flag = false
  83. uni.redirectTo({
  84. url: '/pages/404/404'
  85. })
  86. }
  87. },
  88. methods: {
  89. handleClick(item) {
  90. // console.log(item.url);
  91. uni.navigateTo({
  92. url: item.url
  93. })
  94. },
  95. getPageUrl() {
  96. // 获取当前打开过的页面路由数组
  97. let routes = getCurrentPages()
  98. // 获取当前页面路由,也就是最后一个打开的页面路由
  99. let curRoute = routes[routes.length - 1].route
  100. this.pageUrl = curRoute
  101. }
  102. }
  103. }
  104. </script>
  105. <style lang="scss" scoped>
  106. .container {
  107. min-width: 100vw;
  108. min-height: 100vh;
  109. background-color: #f2f2f2;
  110. .placeholder {
  111. height: 30rpx;
  112. }
  113. .box {
  114. display: flex;
  115. width: 750rpx;
  116. height: 110rpx;
  117. line-height: 110rpx;
  118. border-bottom: 1rpx solid #dddddd;
  119. background-color: #fff;
  120. .icon {
  121. flex: 1;
  122. text-align: center;
  123. img {
  124. margin-top: 36rpx;
  125. width: 42rpx;
  126. height: 38rpx;
  127. }
  128. }
  129. .title {
  130. flex: 5;
  131. font-size: 30rpx;
  132. font-weight: 400;
  133. }
  134. .right {
  135. flex: 1;
  136. text-align: center;
  137. img {
  138. width: 24rpx;
  139. height: 32rpx;
  140. }
  141. }
  142. }
  143. .tab_bar {
  144. position: fixed;
  145. left: 0;
  146. bottom: 0;
  147. display: flex;
  148. width: 750rpx;
  149. height: 128rpx;
  150. border-top: 1rpx solid #ccc;
  151. background-color: #fff;
  152. .tab_box {
  153. flex: 1;
  154. display: flex;
  155. flex-direction: column;
  156. justify-content: center;
  157. align-items: center;
  158. img {
  159. margin-bottom: 10rpx;
  160. width: 54rpx;
  161. height: 48rpx;
  162. }
  163. .tab_title {
  164. font-size: 20rpx;
  165. }
  166. .tab_title_active {
  167. font-size: 20rpx;
  168. color: #0082fc;
  169. }
  170. }
  171. }
  172. }
  173. </style>