navigation1.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <template>
  2. <!-- <view :class="{'padding-lr':showStyle!=='0px'}">
  3. <view v-if="storage" class="bg-white">
  4. <view class="cate-section" :style="{backgroundColor:bgColor}">
  5. <view v-for="(item, index) in categoryButtomList" :key="index"
  6. @click="naviageToPage(item.url+('&id='+item.id),item.title)" class="cate-item" :style={color:fontColor}>
  7. <image :src="JSON.parse(item.imgUrl)[0].url" :style="{borderRadius: iconStyle}"></image>
  8. <text>{{item.title}}</text>
  9. </view>
  10. </view>
  11. </view>
  12. </view> -->
  13. <view class="navigation-view" :style="{padding:showStyle}">
  14. <view class="content" :style="`background-color:${bgColor}`">
  15. <view class="list" style="display: flex;flex-wrap: wrap;padding-top: 10px;padding-bottom: 5px;">
  16. <view v-for="(item, index) in items" :key="index" class="list-item"
  17. @click="naviageToPage(item.link,item.title)"
  18. :style="`width: ${itemWidth}%;display: flex;flex-direction: column;
  19. justify-content: center;align-items: center;padding-bottom: 5px;`">
  20. <image :src="JSON.parse(item.imgUrl)[0].url" style="width: 43px;height: 43px;margin-bottom: 3px;" :style="{borderRadius: iconStyle}"></image>
  21. <!-- <img :src="JSON.parse(item.imgUrl)[0].url" width="100%" height="100%" :style="{borderRadius:iconStyle}"> -->
  22. <text
  23. style="font-size: 13px;"
  24. :style="{color:item.fontColor}">{{item.title}}</text>
  25. <!-- <div class="text" style="font-size: 13px;" :style="{color:item.fontColor}">{{ item.title }}</div> -->
  26. </view>
  27. </view>
  28. </view>
  29. </view>
  30. </template>
  31. <script>
  32. export default {
  33. name: 'Navigation',
  34. props: ['storage', 'options'],
  35. computed: {
  36. showStyle() {
  37. return this.options.showStyle
  38. },
  39. fontColor() {
  40. return this.options.fontColor
  41. },
  42. bgColor() {
  43. return this.options.bgColor
  44. },
  45. iconStyle() {
  46. return this.options.iconStyle
  47. },
  48. colNum() {
  49. return this.options.colNum || 5 // 设置默认值为5列
  50. },
  51. itemWidth() {
  52. console.log('100 / this.colNum----',100 / this.colNum)
  53. return 100 / this.colNum; // 计算每个item的宽度
  54. },
  55. items(){
  56. return this.options.items
  57. }
  58. },
  59. methods: {
  60. naviageToPage(url, title) {
  61. this.$emit('naviage-to-page', url, title)
  62. },
  63. getImgUrl(item){
  64. console.log('item.imgUrl------',item.imgUrl)
  65. // let item1 = JSON.parse(item)
  66. let imgUrl = JSON.parse(item.imgUrl)
  67. console.log('item.imgUrl1------',imgUrl)
  68. return imgUrl[0].url;
  69. },
  70. itemImgs(index) {
  71. // console.log('index------',index)
  72. // console.log('this.options------',this.options)
  73. let imgUrl = JSON.parse(this.options.itemImgs[index])
  74. // console.log('imgUrl------',imgUrl)
  75. return imgUrl[0].url
  76. }
  77. }
  78. }
  79. </script>
  80. <style scoped lang="scss">
  81. // /* 分类 */
  82. // .cate-section {
  83. // display: flex;
  84. // //justify-content: space-around;
  85. // align-items: center;
  86. // flex-wrap: wrap;
  87. // padding-top: 34rpx;
  88. // // padding: 30upx 25upx;
  89. // background-color: #fff;
  90. // justify-content: space-evenly;
  91. // .cate-item {
  92. // display: flex;
  93. // flex-direction: column;
  94. // align-items: center;
  95. // width: 138rpx;
  96. // padding-bottom: 24rpx;
  97. // font-size: $kxmall-font-sm + 2upx;
  98. // color: $kxmall-font-color-dark;
  99. // }
  100. // /* 原图标颜色太深,不想改图了,所以加了透明度 */
  101. // image {
  102. // width: 86upx;
  103. // height: 86upx;
  104. // margin-bottom: 24upx;
  105. // border-radius: 8rpx;
  106. // opacity: .7;
  107. // // box-shadow: 4upx 4upx 20upx rgba(250, 67, 106, 0.3);
  108. // }
  109. // }
  110. </style>