z-tabbar.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. <template>
  2. <view>
  3. <view class="seat"></view>
  4. <view class="tabbar flex-n fac fja">
  5. <view class="item" :class="$store.state.tabbarRouter==item.router?'choose':''" :key="index"
  6. v-for="(item,index) in menuList" @click="gotoPage(item.router)" v-if="!item.hide">
  7. <image class="icon" :src="$store.state.tabbarRouter==item.router?item.selecetedIcon:item.icon"></image>
  8. <view class="text">{{item.name}}</view>
  9. <view class="num" v-if="item.router=='remind/index/index'&&askOrderCount>0">{{askOrderCount}}</view>
  10. <view class="num" v-if="item.router=='book/index/index'&&orderCount>0">{{orderCount}}</view>
  11. <view class="num" v-if="item.router=='settlement/index/index'&&orderUnfinishedCount>0">{{orderUnfinishedCount}}</view>
  12. </view>
  13. </view>
  14. </view>
  15. </template>
  16. <script>
  17. const app = getApp({
  18. allowDefault: true
  19. });
  20. export default {
  21. name: 'z-tabbar',
  22. data() {
  23. return {
  24. askOrderCount: 0,
  25. orderCount: 0,
  26. orderUnfinishedCount: 0,
  27. choose: 1,
  28. menuList: [{
  29. icon: require('../../static/tabbar-1-0.png'),
  30. selecetedIcon: require('../../static/tabbar-1-1.png'),
  31. name: '提醒',
  32. hide:true,
  33. router: 'remind/index/index'
  34. },
  35. {
  36. icon: require('../../static/tabbar-2-0.png'),
  37. selecetedIcon: require('../../static/tabbar-2-1.png'),
  38. name: '预订',
  39. hide:true,
  40. router: 'book/index/index'
  41. },
  42. {
  43. icon: require('../../static/tabbar-3-0.png'),
  44. selecetedIcon: require('../../static/tabbar-3-1.png'),
  45. name: '结算',
  46. hide:true,
  47. router: 'settlement/index/index'
  48. },
  49. {
  50. icon: require('../../static/tabbar-4-0.png'),
  51. selecetedIcon: require('../../static/tabbar-4-1.png'),
  52. name: '我的',
  53. hide:false,
  54. router: 'center/index/index'
  55. },
  56. ],
  57. }
  58. },
  59. mounted() {
  60. var that = this;
  61. uni.getStorage({
  62. key: 'tabbarRouter',
  63. success: (res) => {
  64. console.log(res.data)
  65. this.$store.state.tabbarRouter = res.data;
  66. this.gotoPage(res.data);
  67. },
  68. fail: () => {
  69. this.$store.state.tabbarRouter = 'book/index/index';
  70. this.gotoPage('book/index/index');
  71. }
  72. })
  73. this.getMenu();
  74. },
  75. methods: {
  76. getMenu() {
  77. this.$axios.get('storeAuth/findAppIdByRoleId/' + uni.getStorageSync('roleId')).then(res => {
  78. console.log('菜单', res.data)
  79. var menu = [];
  80. for (var i = 0, len = res.data.list.length; i < len; i++) {
  81. menu.push(res.data.list[i].app_menu_id);
  82. }
  83. console.log(menu)
  84. if (menu.indexOf('101') != -1 || menu.indexOf('102') != -1) {
  85. this.$set(this.menuList[0],'hide',false);
  86. // for (var i = 0, len = this.menuList.length; i < len; i++) {
  87. // if (this.menuList[i].name == '提醒') {
  88. // this.menuList.splice(i, 1);
  89. // break;
  90. // }
  91. // }
  92. }
  93. console.log('42343')
  94. if (menu.indexOf('103') != -1) {
  95. this.$set(this.menuList[1],'hide',false);
  96. // for (var i = 0, len = this.menuList.length; i < len; i++) {
  97. // if (this.menuList[i].name == '预订') {
  98. // this.menuList.splice(i, 1);
  99. // break;
  100. // }
  101. // }
  102. }
  103. if (menu.indexOf('104') != -1|| menu.indexOf('105') != -1) {
  104. this.$set(this.menuList[2],'hide',false);
  105. // for (var i = 0, len = this.menuList.length; i < len; i++) {
  106. // if (this.menuList[i].name == '结算') {
  107. // this.menuList.splice(i, 1);
  108. // break;
  109. // }
  110. // }
  111. }
  112. // menuList
  113. console.warn('431344')
  114. uni.setStorage({
  115. key: 'menu',
  116. data: menu
  117. })
  118. }).catch(err => {
  119. // this.$refs.uToast.error(err.msg);
  120. })
  121. },
  122. gotoPage(router) {
  123. console.log('当前tabbar', router)
  124. uni.setStorage({
  125. key: 'tabbarRouter',
  126. data: router
  127. })
  128. this.$store.state.tabbarRouter = router;
  129. var that = this;
  130. uni.switchTab({
  131. url: '/pages/' + router,
  132. success: res => {
  133. console.log(this.$route)
  134. uni.$emit('switchTab',router);
  135. that.getTotal();
  136. },
  137. fail: () => {},
  138. complete: () => {}
  139. });
  140. },
  141. getTotal() {
  142. this.$axios.post('app/common/getCalcCount/', {
  143. "storeId": uni.getStorageSync('storeId'),
  144. "startTime": this.$Date.getDayDate().date,
  145. "endTime": this.$Date.getDayDate().date
  146. }).then(res => {
  147. console.log(res)
  148. this.askOrderCount = res.data.askOrderCount;
  149. this.orderCount = res.data.orderCount;
  150. this.orderUnfinishedCount = res.data.orderUnfinishedCount;
  151. }).catch(err => {
  152. // this.$refs.uToast.error(err.msg);
  153. })
  154. }
  155. }
  156. }
  157. </script>
  158. <style scoped lang="scss">
  159. .seat {
  160. height: 98rpx;
  161. }
  162. .tabbar {
  163. position: fixed;
  164. bottom: 0;
  165. left: 0;
  166. z-index: 500;
  167. width: 100%;
  168. height: 98rpx;
  169. background: white;
  170. box-shadow: 0px 1rpx 30rpx 0rpx rgba(53, 64, 84, 0.1);
  171. .choose {
  172. color: #2481EE !important;
  173. }
  174. .item {
  175. color: #333333;
  176. text-align: center;
  177. position: relative;
  178. .icon {
  179. width: 40rpx;
  180. height: 40rpx;
  181. // background: #F1F1F1;
  182. margin: 0 auto;
  183. }
  184. .text {
  185. font-size: 24rpx;
  186. margin-top: -4rpx;
  187. }
  188. .num {
  189. font-size: 24rpx;
  190. min-width: 36rpx;
  191. height: 36rpx;
  192. border-radius: 50%;
  193. line-height: 36rpx;
  194. text-align: center;
  195. background: #DD524D;
  196. color: white;
  197. position: absolute;
  198. top: -10rpx;
  199. right: -14rpx;
  200. }
  201. }
  202. }
  203. </style>