|
|
- <template>
- <view class="page__view">
-
- <!-- 导航栏 -->
- <navbar title="搜索结果" leftClick @leftClick="$utils.navigateBack" bgColor="transparent" color="#191919" />
-
- <!-- 搜索栏 -->
- <view class="flex search">
- <uv-search
- v-model="keyword"
- placeholder="输入关键词搜索"
- color="#181818"
- bgColor="transparent"
- :showAction="true"
- @custom="search"
- @search="search"
- @focus="isFocusSearch = true"
- @blur="isFocusSearch = false"
- >
- <template #prefix>
- <image class="search-icon" src="/static/image/icon-search-dark.png" mode="widthFix"></image>
- </template>
- </uv-search>
- </view>
-
- <view class="main">
- <view class="flex sort">
- <view :class="['flex', 'sort-item', queryParams.sort == 'comprehensive' ? 'is-active' : '']" @click="onClickSort('comprehensive')">综合</view>
- <view :class="['flex', 'sort-item', ['sale-asc', 'sale-desc'].includes(queryParams.sort) ? 'is-active' : '']" @click="onClickSort('sale')">
- <view>销量</view>
- <view class="sort-item-icon">
- <uv-icon v-if="queryParams.sort == 'sale-asc'" name="arrow-up-fill" color="#00A9FF" size="16rpx" :bold="true"></uv-icon>
- <uv-icon v-else-if="queryParams.sort == 'sale-desc'" name="arrow-down-fill" color="#00A9FF" size="16rpx" :bold="true"></uv-icon>
- <image v-else style="width: 8rpx; height: auto;" src="/static/image/icon-sort.png" mode="widthFix"></image>
- </view>
- </view>
- <view :class="['flex', 'sort-item', ['price-asc', 'price-desc'].includes(queryParams.sort) ? 'is-active' : '']" @click="onClickSort('price')">
- <view>价格</view>
- <view class="sort-item-icon">
- <uv-icon v-if="queryParams.sort == 'price-asc'" name="arrow-up-fill" color="#00A9FF" size="16rpx" :bold="true"></uv-icon>
- <uv-icon v-else-if="queryParams.sort == 'price-desc'" name="arrow-down-fill" color="#00A9FF" size="16rpx" :bold="true"></uv-icon>
- <image v-else style="width: 8rpx; height: auto;" src="/static/image/icon-sort.png" mode="widthFix"></image>
- </view>
- </view>
- </view>
-
- <view v-if="list.length" class="content">
- <view v-for="item in list" :key="item.id">
- <productCard
- :data="item"
- ></productCard>
- </view>
- </view>
- <template v-else>
- <uv-empty mode="list"></uv-empty>
- </template>
- </view>
-
- </view>
- </template>
-
- <script>
- import mixinsList from '@/mixins/list.js'
-
- import productCard from '@/components/home/productCard.vue'
-
- export default {
- mixins: [mixinsList],
- components: {
- productCard,
- },
- data() {
- return {
- keyword: '',
- queryParams: {
- pageNo: 1,
- pageSize: 10,
- title: '',
- sort: 'comprehensive',
- },
- // todo
- mixinsListApi: '',
- }
- },
- onLoad({ search }) {
- if (search) {
- this.keyword = search
- this.queryParams.title = search
- }
-
- this.getData()
- },
- methods: {
- // todo: delete
- getData() {
- this.list = [
- {
- id: '001',
- image: '/static/image/temp-20.png',
- name: '新疆天山行7/9日丨醉美伊犁&吐鲁番双套餐',
- desc: '国内游·7-9天·12岁+',
- currentPrice: 688.99,
- originalPrice: 1200,
- registered: 4168,
- },
- {
- id: '002',
- image: '/static/image/temp-24.png',
- name: '坝上双草原6日|乌兰布统+锡林郭勒+长城',
- desc: '国内游·7-9天·12岁+',
- currentPrice: 688.99,
- originalPrice: 1200,
- registered: 4168,
- },
- {
- id: '003',
- image: '/static/image/temp-25.png',
- name: '牛湖线探秘 | 清远牛湖线徒步,探秘天坑与大草原',
- desc: '国内游·7-9天·12岁+',
- currentPrice: 688.99,
- originalPrice: 1200,
- registered: 4168,
- },
- {
- id: '004',
- image: '/static/image/temp-26.png',
- name: '低海拔藏区草原,汉藏文化大穿越',
- desc: '国内游·7-9天·12岁+',
- currentPrice: 688.99,
- originalPrice: 1200,
- registered: 4168,
- },
- {
- id: '005',
- image: '/static/image/temp-27.png',
- name: '新丝路到敦煌7日 | 甘青轻松穿越,沙漠+草原',
- desc: '国内游·7-9天·12岁+',
- currentPrice: 688.99,
- originalPrice: 1200,
- registered: 4168,
- },
- {
- id: '006',
- image: '/static/image/temp-28.png',
- name: '呼伦贝尔6/8日|经典or环线双套餐可选',
- desc: '国内游·7-9天·12岁+',
- currentPrice: 688.99,
- originalPrice: 1200,
- registered: 4168,
- },
- ]
- this.total = this.list.length
- },
- search() {
- this.queryParams.pageNo = 1
- this.queryParams.pageSize = 10
- this.queryParams.title = this.keyword
- this.getData()
- },
- onClickSort(key) {
- switch(key) {
- case 'comprehensive':
- this.queryParams.sort = 'comprehensive'
- break;
- case 'sale':
- if (this.queryParams.sort == 'sale-desc') {
- this.queryParams.sort = 'sale-asc'
- } else {
- this.queryParams.sort = 'sale-desc'
- }
- break;
- case 'price':
- if (this.queryParams.sort == 'price-desc') {
- this.queryParams.sort = 'price-asc'
- } else {
- this.queryParams.sort = 'price-desc'
- }
- break;
- default:
- break;
- }
- },
- },
- }
- </script>
-
- <style scoped lang="scss">
-
- .page__view {
- background: linear-gradient(#DAF3FF, #F4F4F4 200rpx, #F4F4F4);
- }
-
- .search {
- $h: 64rpx;
- $radius: 32rpx;
- $borderWidth: 4rpx;
-
- margin: 24rpx 32rpx 0 32rpx;
- width: calc(100% - 32rpx * 2);
- height: $h;
- position: relative;
- border-radius: $radius;
-
- &-icon {
- margin: 0 13rpx 0 26rpx;
- width: 30rpx;
- height: auto;
- }
-
- /deep/ .uv-search__content {
- padding: 12rpx 0;
- background: #FFFFFF !important;
- border-color: #CFEFFF !important;
- border: 4rpx solid transparent;
- }
-
- /deep/ .uv-search__action {
- padding: 19rpx 24rpx;
- font-size: 26rpx;
- font-weight: 500;
- line-height: 1;
- color: #FFFFFF;
- background: #00A9FF;
- border-radius: 32rpx;
- }
- }
-
- .main {
- margin-top: 24rpx;
- padding: 0 32rpx 100rpx 32rpx;
- }
-
- .sort {
- justify-content: space-between;
-
- &-item {
- padding: 12rpx 32rpx;
- font-size: 28rpx;
- line-height: 1.5;
- color: #191919;
- column-gap: 4rpx;
-
- &.is-active {
- font-weight: 600;
- color: #00A9FF;
- }
-
- &-icon {
- width: 32rpx;
- display: inline-flex;
- align-items: center;
- justify-content: center;
- }
- }
- }
-
- .content {
- margin-top: 24rpx;
- display: grid;
- grid-template-columns: repeat(2, 1fr);
- gap: 16rpx;
- }
-
- </style>
|