navbars.vue 4.0 KB

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