navbars.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  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. console.log(this.navList)
  46. },
  47. ReturnNewNavList(listA,listB){
  48. let NewArray = []
  49. listA.map((item,index)=>{
  50. for (let i = 0; i < listB.length; i++) {
  51. if(index == i){
  52. NewArray.push(Object.assign(item,listB[i]))
  53. }
  54. }
  55. });
  56. return NewArray
  57. },
  58. NavToDetailPage(item,index) {//跳转
  59. console.log(index)
  60. /**
  61. * 页面跳转类型
  62. * 0、1、2、二级页面,
  63. * 3、5、6、7、嵌h5页面
  64. * 4、二手商品列表
  65. **/
  66. const typeMap = {
  67. 0:`/pages/goods/goods-secondary?linkId=${item.id}`,
  68. 1:`/pages/goods/goods-secondary?linkId=${item.id}`,
  69. 2:`/pages/goods/goods-secondary?linkId=${item.id}`,
  70. 3:`/h5/pages/article/page?linkType=${index}`,
  71. 4:`/second/pages/product/product-list`,
  72. 5:`/h5/pages/article/page?linkType=${index}`,
  73. 6:`/h5/pages/article/page?linkType=${index}`,
  74. 7:`/h5/pages/article/page?linkType=${index}`,
  75. }
  76. const url = typeMap[index];
  77. console.log(url)
  78. this.$api.navigateTo(url)
  79. }
  80. }
  81. }
  82. </script>
  83. <style lang="scss">
  84. .navbars-content{
  85. width: 100%;
  86. height: auto;
  87. box-sizing: border-box;
  88. padding: 0 24rpx;
  89. margin-top: 30rpx;
  90. .nav-item{
  91. width: 164rpx;
  92. height: auto;
  93. float: left;
  94. margin-bottom: 30rpx;
  95. margin-right: 15.3rpx;
  96. &:nth-child(4){
  97. margin-right: 0;
  98. }
  99. &:nth-child(8){
  100. margin-right: 0;
  101. }
  102. .icon{
  103. width: 130rpx;
  104. height: 130rpx;
  105. margin: 0 auto;
  106. position: relative;
  107. .icon-image{
  108. width: 130rpx;
  109. height: 130rpx;
  110. display: block;
  111. }
  112. .icon-new{
  113. width: 44rpx;
  114. height: 22rpx;
  115. display: block;
  116. position: absolute;
  117. right: 0;
  118. top: 20rpx;
  119. }
  120. }
  121. .name{
  122. width: 100%;
  123. height: 40rpx;
  124. line-height: 40rpx;
  125. text-align: center;
  126. font-size: $font-size-28;
  127. color: #666666;
  128. }
  129. .nav-cell-main{
  130. width: 100%;
  131. height: auto;
  132. position: absolute;
  133. right: 0;
  134. .nav-cell{
  135. width: 164rpx;
  136. height: auto;
  137. float: left;
  138. margin-bottom: 30rpx;
  139. margin-right: 15.3rpx;
  140. &:nth-child(4){
  141. margin-right: 0;
  142. }
  143. &:nth-child(8){
  144. margin-right: 0;
  145. }
  146. .icon{
  147. width: 130rpx;
  148. height: 130rpx;
  149. margin: 0 auto;
  150. position: relative;
  151. .icon-image{
  152. width: 130rpx;
  153. height: 130rpx;
  154. display: block;
  155. }
  156. .icon-new{
  157. width: 44rpx;
  158. height: 22rpx;
  159. display: block;
  160. position: absolute;
  161. right: 0;
  162. top: 20rpx;
  163. }
  164. }
  165. .name{
  166. width: 100%;
  167. height: 40rpx;
  168. line-height: 40rpx;
  169. text-align: center;
  170. font-size: $font-size-28;
  171. color: #666666;
  172. }
  173. }
  174. }
  175. }
  176. }
  177. </style>