鸿宇研学生前端代码
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.

158 lines
3.4 KiB

  1. <template>
  2. <view class="page__view">
  3. <!-- 导航栏 -->
  4. <navbar :title="title" leftClick @leftClick="$utils.navigateBack" bgColor="transparent" color="#191919" />
  5. <!-- 搜索栏 -->
  6. <view :class="['flex', 'search', isFocusSearch ? 'is-focus' : '']" >
  7. <uv-search
  8. v-model="keyword"
  9. placeholder="输入关键词搜索"
  10. color="#181818"
  11. bgColor="transparent"
  12. :showAction="isFocusSearch"
  13. @custom="search"
  14. @search="search"
  15. @focus="isFocusSearch = true"
  16. @blur="isFocusSearch = false"
  17. >
  18. <template #prefix>
  19. <image class="search-icon" src="/static/image/icon-search-dark.png" mode="widthFix"></image>
  20. </template>
  21. </uv-search>
  22. </view>
  23. <view class="main">
  24. <sortBar v-model="queryParams.sort" @change="onSortChange"></sortBar>
  25. <view v-if="list.length" class="content">
  26. <view v-for="item in list" :key="item.id">
  27. <productCard
  28. :data="item"
  29. size="small"
  30. ></productCard>
  31. </view>
  32. </view>
  33. <template v-else>
  34. <uv-empty mode="list"></uv-empty>
  35. </template>
  36. </view>
  37. </view>
  38. </template>
  39. <script>
  40. import mixinsList from '@/mixins/list.js'
  41. import sortBar from '@/components/product/sortBar.vue'
  42. import productCard from '@/components/product/productCard.vue'
  43. export default {
  44. mixins: [mixinsList],
  45. components: {
  46. sortBar,
  47. productCard,
  48. },
  49. data() {
  50. return {
  51. title: '搜索结果',
  52. keyword: '',
  53. isFocusSearch: false,
  54. queryParams: {
  55. pageNo: 1,
  56. pageSize: 10,
  57. title: '',
  58. // todo
  59. sort: 'comprehensive',
  60. },
  61. mixinsListApi: 'queryActivityList',
  62. }
  63. },
  64. onLoad({ search, title, isDiscount, isHot, isNew }) {
  65. if (search) {
  66. this.keyword = search
  67. this.queryParams.title = search
  68. }
  69. if (title) {
  70. this.title = title
  71. }
  72. if (isDiscount) {
  73. this.queryParams.isDiscount = isDiscount
  74. }
  75. if (isHot) {
  76. this.queryParams.isHot = isHot
  77. }
  78. if (isNew) {
  79. this.queryParams.isNew = isNew
  80. }
  81. this.getData()
  82. },
  83. methods: {
  84. search() {
  85. this.queryParams.pageNo = 1
  86. this.queryParams.pageSize = 10
  87. this.queryParams.title = this.keyword
  88. this.getData()
  89. },
  90. onSortChange(sort) {
  91. console.log('onSortChange', sort)
  92. // todo set sort
  93. this.getData()
  94. },
  95. },
  96. }
  97. </script>
  98. <style scoped lang="scss">
  99. .search {
  100. $h: 64rpx;
  101. $radius: 32rpx;
  102. $borderWidth: 4rpx;
  103. margin: 24rpx 32rpx 0 32rpx;
  104. width: calc(100% - 32rpx * 2);
  105. height: $h;
  106. position: relative;
  107. border-radius: $radius;
  108. &-icon {
  109. margin: 0 13rpx 0 26rpx;
  110. width: 30rpx;
  111. height: auto;
  112. }
  113. /deep/ .uv-search__content {
  114. padding: 12rpx 0;
  115. background: #FFFFFF !important;
  116. border-color: #CFEFFF !important;
  117. border: 4rpx solid transparent;
  118. }
  119. &.is-focus {
  120. /deep/ .uv-search__action {
  121. padding: 19rpx 24rpx;
  122. font-size: 26rpx;
  123. font-weight: 500;
  124. line-height: 1;
  125. color: #FFFFFF;
  126. background: #00A9FF;
  127. border-radius: 32rpx;
  128. }
  129. }
  130. }
  131. .main {
  132. margin-top: 24rpx;
  133. padding: 0 32rpx 100rpx 32rpx;
  134. }
  135. .content {
  136. margin-top: 24rpx;
  137. display: grid;
  138. grid-template-columns: repeat(2, 1fr);
  139. gap: 16rpx;
  140. }
  141. </style>