navbars.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. <template name="navbars">
  2. <view>
  3. <view class="navbars-content clearfix">
  4. <view class="nav-item" v-for="(item,index) in navList" :key="index" @click="NavToDetailPage(item,index)">
  5. <view class="icon">
  6. <image class="icon-image" :src="item.icon" mode="widthFix"></image>
  7. </view>
  8. <view class="name">{{ item.name }}</view>
  9. </view>
  10. </view>
  11. </view>
  12. </template>
  13. <script>
  14. export default{
  15. name:"navbars",
  16. props:{
  17. list:{
  18. type:Array
  19. }
  20. },
  21. data() {
  22. return{
  23. current:100,
  24. navList:[
  25. {icon:'https://static.caimei365.com/app/img/icon/icon-nav1.png'},
  26. {icon:'https://static.caimei365.com/app/img/icon/icon-nav2.png'},
  27. {icon:'https://static.caimei365.com/app/img/icon/icon-nav3.png'},
  28. {icon:'https://static.caimei365.com/app/img/icon/icon-nav4.png'},
  29. {icon:'https://static.caimei365.com/app/img/icon/icon-nav5.png'},
  30. {icon:'https://static.caimei365.com/app/img/icon/icon-nav6.png'},
  31. {icon:'https://static.caimei365.com/app/img/icon/icon-nav7.png'},
  32. {icon:'https://static.caimei365.com/app/img/icon/icon-nav8.png'},
  33. ]
  34. }
  35. },
  36. created(){
  37. this.initData(this.list)
  38. },
  39. computed: {
  40. },
  41. methods:{
  42. initData(list){
  43. this.navList = this.ReturnNewNavList(this.navList,list)
  44. },
  45. ReturnNewNavList(listA,listB){
  46. let NewArray = []
  47. listA.map((item,index)=>{
  48. for (let i = 0; i < listB.length; i++) {
  49. if(index == i){
  50. NewArray.push(Object.assign(item,listB[i]))
  51. }
  52. }
  53. });
  54. return NewArray
  55. },
  56. NavToDetailPage(item,index) {//跳转
  57. console.log(index)
  58. /**
  59. * 页面跳转类型
  60. * 0、1、2、二级页面,
  61. * 3、5、6、7、嵌h5页面
  62. * 4、二手商品列表
  63. **/
  64. const typeMap = {
  65. 0:`/pages/goods/goods-secondary?linkId=${item.id}`,
  66. 1:`/pages/goods/goods-secondary?linkId=${item.id}`,
  67. 2:`/pages/goods/goods-secondary?linkId=${item.id}`,
  68. 3:`/h5/pages/article/page?linkType=${index}`,
  69. 4:`/second/pages/product/product-list`,
  70. 5:`/h5/pages/article/page?linkType=${index}`,
  71. 6:`/h5/pages/article/page?linkType=${index}`,
  72. 7:`/h5/pages/article/page?linkType=${index}`,
  73. }
  74. const url = typeMap[index];
  75. console.log(url)
  76. this.$api.navigateTo(url)
  77. }
  78. }
  79. }
  80. </script>
  81. <style lang="scss">
  82. .navbars-content{
  83. width: 100%;
  84. height: auto;
  85. box-sizing: border-box;
  86. padding: 0 24rpx;
  87. margin-top: 30rpx;
  88. .nav-item{
  89. width: 164rpx;
  90. height: auto;
  91. float: left;
  92. margin-bottom: 30rpx;
  93. margin-right: 15.3rpx;
  94. &:nth-child(4){
  95. margin-right: 0;
  96. }
  97. &:nth-child(8){
  98. margin-right: 0;
  99. }
  100. .icon{
  101. width: 130rpx;
  102. height: 130rpx;
  103. margin: 0 auto;
  104. position: relative;
  105. .icon-image{
  106. width: 130rpx;
  107. height: 130rpx;
  108. display: block;
  109. }
  110. .icon-new{
  111. width: 44rpx;
  112. height: 22rpx;
  113. display: block;
  114. position: absolute;
  115. right: 0;
  116. top: 20rpx;
  117. }
  118. }
  119. .name{
  120. width: 100%;
  121. height: 40rpx;
  122. line-height: 40rpx;
  123. text-align: center;
  124. font-size: $font-size-26;
  125. color: #666666;
  126. }
  127. .nav-cell-main{
  128. width: 100%;
  129. height: auto;
  130. position: absolute;
  131. right: 0;
  132. .nav-cell{
  133. width: 164rpx;
  134. height: auto;
  135. float: left;
  136. margin-bottom: 30rpx;
  137. margin-right: 15.3rpx;
  138. &:nth-child(4){
  139. margin-right: 0;
  140. }
  141. &:nth-child(8){
  142. margin-right: 0;
  143. }
  144. .icon{
  145. width: 130rpx;
  146. height: 130rpx;
  147. margin: 0 auto;
  148. position: relative;
  149. .icon-image{
  150. width: 130rpx;
  151. height: 130rpx;
  152. display: block;
  153. }
  154. .icon-new{
  155. width: 44rpx;
  156. height: 22rpx;
  157. display: block;
  158. position: absolute;
  159. right: 0;
  160. top: 20rpx;
  161. }
  162. }
  163. .name{
  164. width: 100%;
  165. height: 40rpx;
  166. line-height: 40rpx;
  167. text-align: center;
  168. font-size: $font-size-28;
  169. color: #666666;
  170. }
  171. }
  172. }
  173. }
  174. }
  175. </style>