scroll_menu.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <template>
  2. <view class="scroll_memu">
  3. <!-- <scroll-view scroll-x="true" class="scroll">
  4. <view class="memu_list">
  5. <view v-if="tabList.length>0" class="item" v-for="(item,idx) in tabList" :key="idx" hover-class="item-hover" @tap="jumpGoodsDes(item)">{{item.keyword}}</view>
  6. </view>
  7. </scroll-view> -->
  8. </view>
  9. </template>
  10. <script>
  11. export default {
  12. data() {
  13. return {
  14. tabList:[]
  15. };
  16. },
  17. created() {
  18. // this.getProductCategorys();
  19. this.getExporeHotWord()
  20. },
  21. methods:{
  22. async getExporeHotWord(){
  23. let resp = await this.$api.getExporeHotWord({
  24. type:2, // type:0:默认, 1:商品搜索, 2:商品详情
  25. num: '10'
  26. })
  27. this.tabList = resp;
  28. },
  29. async getProductCategorys() {
  30. let resp = await this.$api.getProductCategorys();
  31. if (resp) {
  32. let plen = resp.length
  33. if (plen <= 2 && plen > 0) {
  34. if (resp[0] && resp[0].childrens && resp[0].childrens.children) {
  35. let list = resp[0].childrens.children
  36. this.tabList = Array.isArray(list) ? list : []
  37. }
  38. } else if (plen > 2) {
  39. this.tabList = resp;
  40. } else {
  41. this.tabList = [];
  42. }
  43. } else {
  44. this.tabList = [];
  45. }
  46. return resp
  47. },
  48. jumpGoodsDes(item) {
  49. uni.navigateTo({
  50. url: "/pagesM/pages/goods_des?id=" + item.extendData
  51. })
  52. },
  53. // 跳转搜索
  54. jumpSearch(item) {
  55. if (!item) {
  56. uni.navigateTo({
  57. url: "/pagesM/pages/search"
  58. })
  59. } else {
  60. let params = {
  61. keyword: item.name,
  62. productCategoryId: item.id
  63. }
  64. uni.navigateTo({
  65. url: "/pagesM/pages/search?" + this.$util.serialize(params)
  66. })
  67. }
  68. },
  69. }
  70. }
  71. </script>
  72. <style lang="scss">
  73. .scroll_memu {
  74. // height: 90upx;
  75. margin: 20upx 0 20upx 0;
  76. width: 100%;
  77. .scroll {
  78. white-space: nowrap;
  79. width: 100%;
  80. height: 100%;
  81. .memu_list {
  82. height: 100%;
  83. display: flex;
  84. flex-direction: row;
  85. align-items: center;
  86. font-size: 20upx;
  87. color: #fff;
  88. .item {
  89. // background-image: url(http://139.9.103.171:1888/img/image/home_yezi.png);
  90. // background-size: auto 100% ;
  91. // background-position-x: center;
  92. // background-repeat: no-repeat;
  93. background: rgba($color: #FFFFFF, $alpha: 0.3);
  94. border-radius: 25px;
  95. height: 40upx;
  96. line-height: 40upx;
  97. padding: 0 20upx;
  98. margin-right: 20upx;
  99. text-align: center;
  100. }
  101. .item-hover {
  102. opacity: 0.5;
  103. }
  104. .space {
  105. padding-right: 30rpx;
  106. }
  107. }
  108. }
  109. }
  110. </style>