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

202 lines
4.7 KiB

5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
  1. <template>
  2. <view class="page__view">
  3. <!-- 导航栏 -->
  4. <navbar 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. ></productCard>
  30. </view>
  31. </view>
  32. <template v-else>
  33. <uv-empty mode="list"></uv-empty>
  34. </template>
  35. </view>
  36. </view>
  37. </template>
  38. <script>
  39. import mixinsList from '@/mixins/list.js'
  40. import sortBar from '@/components/product/sortBar.vue'
  41. import productCard from '@/components/product/productCard.vue'
  42. export default {
  43. mixins: [mixinsList],
  44. components: {
  45. sortBar,
  46. productCard,
  47. },
  48. data() {
  49. return {
  50. keyword: '',
  51. isFocusSearch: false,
  52. queryParams: {
  53. pageNo: 1,
  54. pageSize: 10,
  55. title: '',
  56. sort: 'comprehensive',
  57. },
  58. // todo
  59. mixinsListApi: '',
  60. }
  61. },
  62. onLoad({ search }) {
  63. if (search) {
  64. this.keyword = search
  65. this.queryParams.title = search
  66. }
  67. this.getData()
  68. },
  69. methods: {
  70. // todo: delete
  71. getData() {
  72. this.list = [
  73. {
  74. id: '001',
  75. image: '/static/image/temp-20.png',
  76. name: '新疆天山行7/9日丨醉美伊犁&吐鲁番双套餐',
  77. desc: '国内游·7-9天·12岁+',
  78. currentPrice: 688.99,
  79. originalPrice: 1200,
  80. registered: 4168,
  81. },
  82. {
  83. id: '002',
  84. image: '/static/image/temp-24.png',
  85. name: '坝上双草原6日|乌兰布统+锡林郭勒+长城',
  86. desc: '国内游·7-9天·12岁+',
  87. currentPrice: 688.99,
  88. originalPrice: 1200,
  89. registered: 4168,
  90. },
  91. {
  92. id: '003',
  93. image: '/static/image/temp-25.png',
  94. name: '牛湖线探秘 | 清远牛湖线徒步,探秘天坑与大草原',
  95. desc: '国内游·7-9天·12岁+',
  96. currentPrice: 688.99,
  97. originalPrice: 1200,
  98. registered: 4168,
  99. },
  100. {
  101. id: '004',
  102. image: '/static/image/temp-26.png',
  103. name: '低海拔藏区草原,汉藏文化大穿越',
  104. desc: '国内游·7-9天·12岁+',
  105. currentPrice: 688.99,
  106. originalPrice: 1200,
  107. registered: 4168,
  108. },
  109. {
  110. id: '005',
  111. image: '/static/image/temp-27.png',
  112. name: '新丝路到敦煌7日 | 甘青轻松穿越,沙漠+草原',
  113. desc: '国内游·7-9天·12岁+',
  114. currentPrice: 688.99,
  115. originalPrice: 1200,
  116. registered: 4168,
  117. },
  118. {
  119. id: '006',
  120. image: '/static/image/temp-28.png',
  121. name: '呼伦贝尔6/8日|经典or环线双套餐可选',
  122. desc: '国内游·7-9天·12岁+',
  123. currentPrice: 688.99,
  124. originalPrice: 1200,
  125. registered: 4168,
  126. },
  127. ]
  128. this.total = this.list.length
  129. },
  130. search() {
  131. this.queryParams.pageNo = 1
  132. this.queryParams.pageSize = 10
  133. this.queryParams.title = this.keyword
  134. this.getData()
  135. },
  136. onSortChange(sort) {
  137. console.log('onSortChange', sort)
  138. },
  139. },
  140. }
  141. </script>
  142. <style scoped lang="scss">
  143. .search {
  144. $h: 64rpx;
  145. $radius: 32rpx;
  146. $borderWidth: 4rpx;
  147. margin: 24rpx 32rpx 0 32rpx;
  148. width: calc(100% - 32rpx * 2);
  149. height: $h;
  150. position: relative;
  151. border-radius: $radius;
  152. &-icon {
  153. margin: 0 13rpx 0 26rpx;
  154. width: 30rpx;
  155. height: auto;
  156. }
  157. /deep/ .uv-search__content {
  158. padding: 12rpx 0;
  159. background: #FFFFFF !important;
  160. border-color: #CFEFFF !important;
  161. border: 4rpx solid transparent;
  162. }
  163. &.is-focus {
  164. /deep/ .uv-search__action {
  165. padding: 19rpx 24rpx;
  166. font-size: 26rpx;
  167. font-weight: 500;
  168. line-height: 1;
  169. color: #FFFFFF;
  170. background: #00A9FF;
  171. border-radius: 32rpx;
  172. }
  173. }
  174. }
  175. .main {
  176. margin-top: 24rpx;
  177. padding: 0 32rpx 100rpx 32rpx;
  178. }
  179. .content {
  180. margin-top: 24rpx;
  181. display: grid;
  182. grid-template-columns: repeat(2, 1fr);
  183. gap: 16rpx;
  184. }
  185. </style>