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

199 lines
4.5 KiB

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