推广小程序前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

108 lines
2.1 KiB

2 months ago
  1. <template>
  2. <view class="page">
  3. <navbar title="商品列表" leftClick @leftClick="$utils.navigateBack" />
  4. <view class="search">
  5. <uv-search
  6. placeholder="搜你喜欢的产品"
  7. bgColor="#fff"
  8. @search="getData"
  9. @custom="getData"
  10. v-model="queryParams.title"></uv-search>
  11. </view>
  12. <view class="category">
  13. <uv-vtabs
  14. :list="category"
  15. keyName="title"
  16. :barItemBadgeStyle="{right:'20px',top:'12px'}"
  17. @change="change">
  18. <uv-vtabs-item>
  19. <view class="list">
  20. <productItem
  21. v-for="(item, index) in list"
  22. :key="index"
  23. :item="item"
  24. @click="$utils.navigateTo('/pages_order/product/productDetail?id=' + item.id)"
  25. />
  26. </view>
  27. </uv-vtabs-item>
  28. </uv-vtabs>
  29. </view>
  30. </view>
  31. </template>
  32. <script>
  33. import productItem from '@/components/product/productItem.vue';
  34. import mixinsList from '@/mixins/list.js'
  35. import { mapState } from 'vuex'
  36. export default {
  37. mixins : [mixinsList],
  38. components: {
  39. productItem,
  40. },
  41. data() {
  42. return {
  43. mixinsListApi : 'getClassShopPageList',
  44. }
  45. },
  46. computed: {
  47. ...mapState(['category'])
  48. },
  49. onLoad({search}) {
  50. if(search){
  51. this.queryParams.title = search
  52. }
  53. this.$store.commit('getCategoryList')
  54. if(this.category.length > 0){
  55. this.queryParams.classId = this.category[0].id
  56. }
  57. },
  58. methods: {
  59. change(e) {
  60. this.queryParams.classId = this.category[e].id
  61. this.getData()
  62. },
  63. }
  64. }
  65. </script>
  66. <style scoped lang="scss">
  67. .page{
  68. /deep/ .uv-vtabs{
  69. height: calc(100vh - 220rpx) !important;
  70. }
  71. /deep/ .uv-vtabs__bar{
  72. height: calc(100vh - 220rpx) !important;
  73. }
  74. /deep/ .uv-vtabs__content{
  75. height: calc(100vh - 220rpx) !important;
  76. }
  77. .search {
  78. position: relative;
  79. background: #FFFFFF;
  80. margin: 20rpx;
  81. border-radius: 41rpx;
  82. padding: 10rpx 20rpx;
  83. display: flex;
  84. align-items: center;
  85. /deep/ .uv-search__action {
  86. background-color: $uni-color;
  87. color: #FFFFFF;
  88. padding: 10rpx 20rpx;
  89. border-radius: 30rpx;
  90. }
  91. }
  92. }
  93. .category {
  94. font-size: 30rpx;
  95. color: #333;
  96. .list{
  97. margin: 0 auto;
  98. width: 100%;
  99. }
  100. }
  101. </style>