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

263 lines
6.9 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. <view class="flex sort">
  25. <view :class="['flex', 'sort-item', queryParams.sort == 'comprehensive' ? 'is-active' : '']" @click="onClickSort('comprehensive')">综合</view>
  26. <view :class="['flex', 'sort-item', ['sale-asc', 'sale-desc'].includes(queryParams.sort) ? 'is-active' : '']" @click="onClickSort('sale')">
  27. <view>销量</view>
  28. <view class="sort-item-icon">
  29. <uv-icon v-if="queryParams.sort == 'sale-asc'" name="arrow-up-fill" color="#00A9FF" size="16rpx" :bold="true"></uv-icon>
  30. <uv-icon v-else-if="queryParams.sort == 'sale-desc'" name="arrow-down-fill" color="#00A9FF" size="16rpx" :bold="true"></uv-icon>
  31. <image v-else style="width: 8rpx; height: auto;" src="/static/image/icon-sort.png" mode="widthFix"></image>
  32. </view>
  33. </view>
  34. <view :class="['flex', 'sort-item', ['price-asc', 'price-desc'].includes(queryParams.sort) ? 'is-active' : '']" @click="onClickSort('price')">
  35. <view>价格</view>
  36. <view class="sort-item-icon">
  37. <uv-icon v-if="queryParams.sort == 'price-asc'" name="arrow-up-fill" color="#00A9FF" size="16rpx" :bold="true"></uv-icon>
  38. <uv-icon v-else-if="queryParams.sort == 'price-desc'" name="arrow-down-fill" color="#00A9FF" size="16rpx" :bold="true"></uv-icon>
  39. <image v-else style="width: 8rpx; height: auto;" src="/static/image/icon-sort.png" mode="widthFix"></image>
  40. </view>
  41. </view>
  42. </view>
  43. <view v-if="list.length" class="content">
  44. <view v-for="item in list" :key="item.id">
  45. <productCard
  46. :data="item"
  47. ></productCard>
  48. </view>
  49. </view>
  50. <template v-else>
  51. <uv-empty mode="list"></uv-empty>
  52. </template>
  53. </view>
  54. </view>
  55. </template>
  56. <script>
  57. import mixinsList from '@/mixins/list.js'
  58. import productCard from '@/components/home/productCard.vue'
  59. export default {
  60. mixins: [mixinsList],
  61. components: {
  62. productCard,
  63. },
  64. data() {
  65. return {
  66. keyword: '',
  67. queryParams: {
  68. pageNo: 1,
  69. pageSize: 10,
  70. title: '',
  71. sort: 'comprehensive',
  72. },
  73. // todo
  74. mixinsListApi: '',
  75. }
  76. },
  77. onLoad({ search }) {
  78. if (search) {
  79. this.keyword = search
  80. this.queryParams.title = search
  81. }
  82. this.getData()
  83. },
  84. methods: {
  85. // todo: delete
  86. getData() {
  87. this.list = [
  88. {
  89. id: '001',
  90. image: '/static/image/temp-20.png',
  91. name: '新疆天山行7/9日丨醉美伊犁&吐鲁番双套餐',
  92. desc: '国内游·7-9天·12岁+',
  93. currentPrice: 688.99,
  94. originalPrice: 1200,
  95. registered: 4168,
  96. },
  97. {
  98. id: '002',
  99. image: '/static/image/temp-24.png',
  100. name: '坝上双草原6日|乌兰布统+锡林郭勒+长城',
  101. desc: '国内游·7-9天·12岁+',
  102. currentPrice: 688.99,
  103. originalPrice: 1200,
  104. registered: 4168,
  105. },
  106. {
  107. id: '003',
  108. image: '/static/image/temp-25.png',
  109. name: '牛湖线探秘 | 清远牛湖线徒步,探秘天坑与大草原',
  110. desc: '国内游·7-9天·12岁+',
  111. currentPrice: 688.99,
  112. originalPrice: 1200,
  113. registered: 4168,
  114. },
  115. {
  116. id: '004',
  117. image: '/static/image/temp-26.png',
  118. name: '低海拔藏区草原,汉藏文化大穿越',
  119. desc: '国内游·7-9天·12岁+',
  120. currentPrice: 688.99,
  121. originalPrice: 1200,
  122. registered: 4168,
  123. },
  124. {
  125. id: '005',
  126. image: '/static/image/temp-27.png',
  127. name: '新丝路到敦煌7日 | 甘青轻松穿越,沙漠+草原',
  128. desc: '国内游·7-9天·12岁+',
  129. currentPrice: 688.99,
  130. originalPrice: 1200,
  131. registered: 4168,
  132. },
  133. {
  134. id: '006',
  135. image: '/static/image/temp-28.png',
  136. name: '呼伦贝尔6/8日|经典or环线双套餐可选',
  137. desc: '国内游·7-9天·12岁+',
  138. currentPrice: 688.99,
  139. originalPrice: 1200,
  140. registered: 4168,
  141. },
  142. ]
  143. this.total = this.list.length
  144. },
  145. search() {
  146. this.queryParams.pageNo = 1
  147. this.queryParams.pageSize = 10
  148. this.queryParams.title = this.keyword
  149. this.getData()
  150. },
  151. onClickSort(key) {
  152. switch(key) {
  153. case 'comprehensive':
  154. this.queryParams.sort = 'comprehensive'
  155. break;
  156. case 'sale':
  157. if (this.queryParams.sort == 'sale-desc') {
  158. this.queryParams.sort = 'sale-asc'
  159. } else {
  160. this.queryParams.sort = 'sale-desc'
  161. }
  162. break;
  163. case 'price':
  164. if (this.queryParams.sort == 'price-desc') {
  165. this.queryParams.sort = 'price-asc'
  166. } else {
  167. this.queryParams.sort = 'price-desc'
  168. }
  169. break;
  170. default:
  171. break;
  172. }
  173. },
  174. },
  175. }
  176. </script>
  177. <style scoped lang="scss">
  178. .page__view {
  179. background: linear-gradient(#DAF3FF, #F4F4F4 200rpx, #F4F4F4);
  180. }
  181. .search {
  182. $h: 64rpx;
  183. $radius: 32rpx;
  184. $borderWidth: 4rpx;
  185. margin: 24rpx 32rpx 0 32rpx;
  186. width: calc(100% - 32rpx * 2);
  187. height: $h;
  188. position: relative;
  189. border-radius: $radius;
  190. &-icon {
  191. margin: 0 13rpx 0 26rpx;
  192. width: 30rpx;
  193. height: auto;
  194. }
  195. /deep/ .uv-search__content {
  196. padding: 12rpx 0;
  197. background: #FFFFFF !important;
  198. border-color: #CFEFFF !important;
  199. border: 4rpx solid transparent;
  200. }
  201. /deep/ .uv-search__action {
  202. padding: 19rpx 24rpx;
  203. font-size: 26rpx;
  204. font-weight: 500;
  205. line-height: 1;
  206. color: #FFFFFF;
  207. background: #00A9FF;
  208. border-radius: 32rpx;
  209. }
  210. }
  211. .main {
  212. margin-top: 24rpx;
  213. padding: 0 32rpx 100rpx 32rpx;
  214. }
  215. .sort {
  216. justify-content: space-between;
  217. &-item {
  218. padding: 12rpx 32rpx;
  219. font-size: 28rpx;
  220. line-height: 1.5;
  221. color: #191919;
  222. column-gap: 4rpx;
  223. &.is-active {
  224. font-weight: 600;
  225. color: #00A9FF;
  226. }
  227. &-icon {
  228. width: 32rpx;
  229. display: inline-flex;
  230. align-items: center;
  231. justify-content: center;
  232. }
  233. }
  234. }
  235. .content {
  236. margin-top: 24rpx;
  237. display: grid;
  238. grid-template-columns: repeat(2, 1fr);
  239. gap: 16rpx;
  240. }
  241. </style>