z-tabbar.vue 5.0 KB

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