footer.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. <template>
  2. <view class="footer-h" v-if="isShowFooter">
  3. <view class="footer-box footer-h">
  4. <view class="footer-main flex space">
  5. <view v-for="(item,index) in getFooter" :key="index" :data-model="item.model" @click="linkTo" class="footer-item" :style="{width:getWidth,color:model== item.model ? tempColor : '#AEB2C1'}">
  6. <text class="ft22 iconfont" :class="item.icon"></text>
  7. <view class="ft12 mt4 ftw600">{{item.name}}</view>
  8. </view>
  9. </view>
  10. </view>
  11. </view>
  12. </template>
  13. <script>
  14. export default{
  15. props:{
  16. model:{
  17. type:String,
  18. default:'',
  19. },
  20. },
  21. data(){
  22. return {
  23. footerList:[
  24. {name:'首页',icon:'icontabbar03',model:'index',show:1},
  25. {name:'全部列表',icon:'icontabbar01',model:'tuan',show:1},
  26. {name:'次卡',icon:'icontabbar03',model:'card',show:0},
  27. {name:'优惠券',icon:'icontabbar06',model:'coupon',show:0}, //预留其他组件
  28. {name:'积分商城',icon:'icontabbar05',model:'integral',show:0},
  29. {name:'个人中心',icon:'icontabbar04',model:'member',show:1},
  30. ]
  31. // footerList:[
  32. // {name:'VIP',icon:'icontabbar01',model:'index',show:1},
  33. // {name:'特惠',icon:'icontabbar02',model:'tuan',show:1},
  34. // {name:'次卡',icon:'icontabbar03',model:'card',show:1},
  35. // {name:'优惠券',icon:'icontabbar06',model:'coupon',show:0}, //预留其他组件
  36. // {name:'积分商城',icon:'icontabbar05',model:'integral',show:1},
  37. // {name:'我的',icon:'icontabbar04',model:'member',show:1},
  38. // ]
  39. }
  40. },
  41. computed:{
  42. isShowFooter(){
  43. let show = false;
  44. for(var a in this.footerList){
  45. if(this.footerList[a].model == this.model && this.footerList[a].show == 1){
  46. show = true;
  47. }
  48. }
  49. return show;
  50. },
  51. getFooter(){
  52. let arr = new Array;
  53. for(var a in this.footerList){
  54. if(this.footerList[a].show == 1){
  55. arr.push(this.footerList[a]);
  56. }
  57. }
  58. return arr;
  59. },
  60. getWidth(){
  61. let len = this.getFooter.length;
  62. if(len > 0){
  63. return (100/len) + '%';
  64. }
  65. return '100%';
  66. }
  67. },methods:{
  68. linkTo(e){ //链接相关的操作 这个操作一般在首页 和底部菜单出现,其他地方的请另外操作
  69. let model = e.currentTarget.dataset.model;
  70. if(this.model == model) return;
  71. if(model == 'index'){
  72. let page = getCurrentPages();
  73. if(page.length > 1){
  74. uni.navigateBack({
  75. delta:page.length
  76. });
  77. }else{
  78. uni.reLaunch({
  79. url:'/pages/client/index'
  80. })
  81. }
  82. return;
  83. }
  84. let url = '';
  85. switch(model){
  86. case 'tuan':
  87. url = '/pages/client/tuan/index';
  88. break;
  89. case 'coupon':
  90. url = '/pages/client/coupon/index';
  91. break;
  92. case 'card':
  93. url = '/pages/client/card/index';
  94. break;
  95. case 'member':
  96. url = '/pages/client/member/index';
  97. break;
  98. case 'integral':
  99. url = '/pages/client/integral/index'
  100. break;
  101. }
  102. if(url == '') return;
  103. if(this.model == 'index'){
  104. uni.navigateTo({
  105. url:url
  106. })
  107. }else{
  108. uni.redirectTo({
  109. url:url
  110. })
  111. }
  112. }
  113. }
  114. }
  115. </script>
  116. <style>
  117. .footer-h {
  118. height: 100rpx;
  119. height: calc(100rpx + constant(safe-area-inset-bottom));
  120. height: calc(100rpx + env(safe-area-inset-bottom));
  121. }
  122. .footer-box {
  123. width: 100%;
  124. position: fixed;
  125. z-index: 100;
  126. left: 0;
  127. bottom: 0;
  128. background: #FFFFFF;
  129. box-shadow: 0rpx -4rpx 16rpx 0rpx rgba(0, 0, 0, 0.04);
  130. }
  131. .footer-main {
  132. height: 100rpx;
  133. }
  134. .footer-item {
  135. height: 100rpx;
  136. width: 20%;
  137. padding-top: 10rpx;
  138. text-align: center;
  139. }
  140. </style>