index.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <template>
  2. <!-- 顶部下拉导航 -->
  3. <view class="animated dialog_nav dialogIndex"
  4. :style="{ top: navH + 'px' }" v-show="currentPage">
  5. <view class="dialog_nav_item" :class="item.after"
  6. v-for="(item,index) in headerNav" :key="index"
  7. @tap="linkPage(item.url)">
  8. <text class="iconfont" :class="item.icon"></text>
  9. <text class="pl-20">{{item.name}}</text>
  10. </view>
  11. </view>
  12. </template>
  13. <script>
  14. export default {
  15. name: "homeIdex",
  16. props: {
  17. navH: {
  18. type: String|Number,
  19. default: ""
  20. },
  21. currentPage: {
  22. type: Boolean,
  23. default: false
  24. },
  25. openNavList:{
  26. type: Array,
  27. default: ()=>[]
  28. }
  29. },
  30. data() {
  31. return {
  32. selectNavList:[
  33. {name:'首页',icon:'icon-ic_mall',url:'/pages/index/index',after:'dialog_after'},
  34. {name:'搜索',icon:'icon-ic_search',url:'/pages/goods/goods_search/index',after:'dialog_after'},
  35. {name:'购物车',icon:'icon-ic_ShoppingCart1',url:'/pages/order_addcart/order_addcart',after:'dialog_after'},
  36. {name:'我的收藏',icon:'icon-ic_star',url:'/pages/users/user_goods_collection/index',after:'dialog_after'},
  37. {name:'个人中心',icon:'icon-a-ic_user1',url:'/pages/user/index'},
  38. ]
  39. };
  40. },
  41. computed:{
  42. headerNav(){
  43. let arr = [];
  44. this.selectNavList.forEach((item,index)=>{
  45. if(this.openNavList.includes(index)){
  46. arr.push(item);
  47. }
  48. })
  49. return arr
  50. }
  51. },
  52. methods: {
  53. linkPage(url){
  54. if (['/pages/goods_cate/goods_cate', '/pages/order_addcart/order_addcart', '/pages/user/index', '/pages/index/index']
  55. .indexOf(url) == -1) {
  56. uni.navigateTo({
  57. url: url
  58. })
  59. } else {
  60. uni.switchTab({
  61. url: url
  62. })
  63. }
  64. }
  65. },
  66. };
  67. </script>
  68. <style scoped lang="scss">
  69. .dialog_nav{
  70. position: fixed;
  71. left: 14rpx;
  72. width: 240rpx;
  73. background: #FFFFFF;
  74. box-shadow: 0px 0px 16rpx rgba(0, 0, 0, 0.08);
  75. z-index: 310;
  76. border-radius: 14rpx;
  77. &::before{
  78. content: '';
  79. width: 0;
  80. height: 0;
  81. position: absolute;
  82. left: -26rpx;
  83. right: 0;
  84. margin:auto;
  85. top:-9px;
  86. border-bottom: 10px solid #FFFFFF;
  87. border-left: 10px solid transparent; /*transparent 表示透明*/
  88. border-right: 10px solid transparent;
  89. }
  90. &.dialogIndex{
  91. left: 14rpx;
  92. &::before{
  93. left: 0rpx;
  94. }
  95. }
  96. }
  97. .dialog_nav_item{
  98. width: 100%;
  99. height: 84rpx;
  100. line-height: 84rpx;
  101. padding: 0 20rpx 0;
  102. box-sizing: border-box;
  103. border-bottom: #eee;
  104. font-size: 28rpx;
  105. color: #333;
  106. position: relative;
  107. display: flex;
  108. .iconfont{
  109. font-size: 32rpx;
  110. margin-right: 26rpx;
  111. }
  112. }
  113. .dialog_after{
  114. ::after{
  115. content: '';
  116. position: absolute;
  117. width:90px;
  118. height: 1px;
  119. background-color: #EEEEEE;
  120. bottom: 0;
  121. right: 0;
  122. }
  123. }
  124. </style>