templateNav.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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:'https://static.caimei365.com/app/img/icon/icon-nav1.png'},
  27. {icon:'https://static.caimei365.com/app/img/icon/icon-nav2.png'},
  28. {icon:'https://static.caimei365.com/app/img/icon/icon-nav3.png'},
  29. {icon:'https://static.caimei365.com/app/img/icon/icon-nav4.png'},
  30. {icon:'https://static.caimei365.com/app/img/icon/icon-nav5.png'},
  31. {icon:'https://static.caimei365.com/app/img/icon/icon-nav6.png'},
  32. {icon:'https://static.caimei365.com/app/img/icon/icon-nav7.png'},
  33. {icon:'https://static.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(pro){//分类导航跳转
  59. let self = this;
  60. uni.setStorage({
  61. key: 'commodity_id',
  62. data: pro.tinyTypeID,
  63. success: function () {
  64. self.$api.navigateTo(`/pages/goods/goods-classify?title=${pro.name}&id=${pro.bigTypeID}`)
  65. }
  66. })
  67. }
  68. }
  69. }
  70. </script>
  71. <style lang="scss">
  72. .navbars-content{
  73. width: 100%;
  74. height: auto;
  75. box-sizing: border-box;
  76. padding: 0 24rpx;
  77. margin-top: 30rpx;
  78. .nav-item{
  79. width: 164rpx;
  80. height: auto;
  81. float: left;
  82. margin-bottom: 30rpx;
  83. margin-right: 15.3rpx;
  84. &:nth-child(4){
  85. margin-right: 0;
  86. }
  87. &:nth-child(8){
  88. margin-right: 0;
  89. }
  90. .icon{
  91. width: 130rpx;
  92. height: 130rpx;
  93. margin: 0 auto;
  94. position: relative;
  95. .icon-image{
  96. width: 130rpx;
  97. height: 130rpx;
  98. display: block;
  99. }
  100. .icon-new{
  101. width: 44rpx;
  102. height: 22rpx;
  103. display: block;
  104. position: absolute;
  105. right: 0;
  106. top: 20rpx;
  107. }
  108. }
  109. .name{
  110. width: 100%;
  111. height: 40rpx;
  112. line-height: 40rpx;
  113. text-align: center;
  114. font-size: $font-size-26;
  115. color: #666666;
  116. }
  117. .nav-cell-main{
  118. width: 100%;
  119. height: auto;
  120. position: absolute;
  121. right: 0;
  122. .nav-cell{
  123. width: 164rpx;
  124. height: auto;
  125. float: left;
  126. margin-bottom: 30rpx;
  127. margin-right: 15.3rpx;
  128. &:nth-child(4){
  129. margin-right: 0;
  130. }
  131. &:nth-child(8){
  132. margin-right: 0;
  133. }
  134. .icon{
  135. width: 130rpx;
  136. height: 130rpx;
  137. margin: 0 auto;
  138. position: relative;
  139. .icon-image{
  140. width: 130rpx;
  141. height: 130rpx;
  142. display: block;
  143. }
  144. .icon-new{
  145. width: 44rpx;
  146. height: 22rpx;
  147. display: block;
  148. position: absolute;
  149. right: 0;
  150. top: 20rpx;
  151. }
  152. }
  153. .name{
  154. width: 100%;
  155. height: 40rpx;
  156. line-height: 40rpx;
  157. text-align: center;
  158. font-size: $font-size-28;
  159. color: #666666;
  160. }
  161. }
  162. }
  163. }
  164. }
  165. </style>