|
|
|
@ -22,7 +22,7 @@ |
|
|
|
<view class="flex range price"> |
|
|
|
<view class="range-item"> |
|
|
|
<uv-input |
|
|
|
v-model="startPrice" |
|
|
|
v-model="priceLow" |
|
|
|
type="number" |
|
|
|
inputAlign="center" |
|
|
|
placeholder="开始价格" |
|
|
|
@ -36,12 +36,14 @@ |
|
|
|
}" |
|
|
|
fontSize="28rpx" |
|
|
|
:clearable="true" |
|
|
|
@confirm="onStartPriceChange" |
|
|
|
@clear="onStartPriceChange(null)" |
|
|
|
></uv-input> |
|
|
|
</view> |
|
|
|
<view class="split">至</view> |
|
|
|
<view class="range-item"> |
|
|
|
<uv-input |
|
|
|
v-model="endPrice" |
|
|
|
v-model="priceHigh" |
|
|
|
type="number" |
|
|
|
inputAlign="center" |
|
|
|
placeholder="结束价格" |
|
|
|
@ -55,6 +57,8 @@ |
|
|
|
}" |
|
|
|
fontSize="28rpx" |
|
|
|
:clearable="true" |
|
|
|
@confirm="onEndPriceChange" |
|
|
|
@clear="onEndPriceChange(null)" |
|
|
|
></uv-input> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
@ -62,22 +66,22 @@ |
|
|
|
<template v-else-if="filter.key === 'time'"> |
|
|
|
<view class="flex range time"> |
|
|
|
<view class="range-item" @click="openStartDatePicker"> |
|
|
|
{{ startDate ? $dayjs(startDate).format('YYYY-MM-DD') : '开始日期' }} |
|
|
|
<button v-if="startDate" class="btn btn-clear" @click.stop="onClearStartDate"> |
|
|
|
{{ dateLow ? $dayjs(dateLow).format('YYYY-MM-DD') : '开始日期' }} |
|
|
|
<button v-if="dateLow" class="btn btn-clear" @click.stop="onClearStartDate"> |
|
|
|
<uv-icon name="close-circle" color="#B5B5B5" size="28rpx"></uv-icon> |
|
|
|
</button> |
|
|
|
</view> |
|
|
|
<view class="split">至</view> |
|
|
|
<view class="range-item" @click="openEndDatePicker"> |
|
|
|
{{ endDate ? $dayjs(endDate).format('YYYY-MM-DD') : '结束日期' }} |
|
|
|
<button v-if="endDate" class="btn btn-clear" @click.stop="onClearEndDate"> |
|
|
|
{{ dateHigh ? $dayjs(dateHigh).format('YYYY-MM-DD') : '结束日期' }} |
|
|
|
<button v-if="dateHigh" class="btn btn-clear" @click.stop="onClearEndDate"> |
|
|
|
<uv-icon name="close-circle" color="#B5B5B5" size="28rpx"></uv-icon> |
|
|
|
</button> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
<uv-datetime-picker |
|
|
|
ref="startDatePicker" |
|
|
|
v-model="startDate" |
|
|
|
v-model="dateLow" |
|
|
|
mode="date" |
|
|
|
title="开始日期" |
|
|
|
confirmColor="#00A9FF" |
|
|
|
@ -87,12 +91,12 @@ |
|
|
|
></uv-datetime-picker> |
|
|
|
<uv-datetime-picker |
|
|
|
ref="endDatePicker" |
|
|
|
v-model="endDate" |
|
|
|
v-model="dateHigh" |
|
|
|
mode="date" |
|
|
|
title="结束日期" |
|
|
|
confirmColor="#00A9FF" |
|
|
|
round="32rpx" |
|
|
|
:minDate="startDate || minTime" |
|
|
|
:minDate="dateLow || minTime" |
|
|
|
@confirm="onEndDateChange" |
|
|
|
></uv-datetime-picker> |
|
|
|
</template> |
|
|
|
@ -187,19 +191,19 @@ |
|
|
|
data() { |
|
|
|
return { |
|
|
|
current: 0, |
|
|
|
startPrice: null, |
|
|
|
endPrice: null, |
|
|
|
startDate: null, |
|
|
|
endDate: null, |
|
|
|
priceLow: null, |
|
|
|
priceHigh: null, |
|
|
|
dateLow: null, |
|
|
|
dateHigh: null, |
|
|
|
minTime: new Date().getTime(), |
|
|
|
queryParams: { |
|
|
|
pageNo: 1, |
|
|
|
pageSize: 1000, |
|
|
|
// todo |
|
|
|
sort: 'comprehensive', |
|
|
|
}, |
|
|
|
categoryList: [], |
|
|
|
filters: [], |
|
|
|
addressOptionsConfig: {}, |
|
|
|
isFold: true, |
|
|
|
} |
|
|
|
}, |
|
|
|
@ -230,167 +234,52 @@ |
|
|
|
} catch(err) { |
|
|
|
this.categoryList = [] |
|
|
|
} |
|
|
|
return |
|
|
|
|
|
|
|
this.categoryList = [ |
|
|
|
{ |
|
|
|
"key": "1962345168240185345", |
|
|
|
"title": "国际游", |
|
|
|
"icon": null, |
|
|
|
"parentId": "0", |
|
|
|
"value": null, |
|
|
|
"code": null, |
|
|
|
"children": null, |
|
|
|
"leaf": true |
|
|
|
}, |
|
|
|
{ |
|
|
|
"key": "1962345225345634305", |
|
|
|
"title": "夏令营", |
|
|
|
"icon": null, |
|
|
|
"parentId": "0", |
|
|
|
"value": null, |
|
|
|
"code": null, |
|
|
|
"children": null, |
|
|
|
"leaf": true |
|
|
|
}, |
|
|
|
{ |
|
|
|
"key": "1962345290571255810", |
|
|
|
"title": "周末营", |
|
|
|
"icon": null, |
|
|
|
"parentId": "0", |
|
|
|
"value": null, |
|
|
|
"code": null, |
|
|
|
"children": null, |
|
|
|
"leaf": true |
|
|
|
}, |
|
|
|
{ |
|
|
|
"key": "1962345372007862273", |
|
|
|
"title": "周边游", |
|
|
|
"icon": null, |
|
|
|
"parentId": "0", |
|
|
|
"value": null, |
|
|
|
"code": null, |
|
|
|
"children": null, |
|
|
|
"leaf": true |
|
|
|
}, |
|
|
|
{ |
|
|
|
"key": "1962345497681793025", |
|
|
|
"title": "定制游", |
|
|
|
"icon": null, |
|
|
|
"parentId": "0", |
|
|
|
"value": null, |
|
|
|
"code": null, |
|
|
|
"children": null, |
|
|
|
"leaf": true |
|
|
|
}, |
|
|
|
{ |
|
|
|
"key": "1962345589524467714", |
|
|
|
"title": "周末活动", |
|
|
|
"icon": null, |
|
|
|
"parentId": "0", |
|
|
|
"value": null, |
|
|
|
"code": null, |
|
|
|
"children": null, |
|
|
|
"leaf": true |
|
|
|
}, |
|
|
|
{ |
|
|
|
"key": "1962345642188148737", |
|
|
|
"title": "亲子活动", |
|
|
|
"icon": null, |
|
|
|
"parentId": "0", |
|
|
|
"value": null, |
|
|
|
"code": null, |
|
|
|
"children": null, |
|
|
|
"leaf": true |
|
|
|
}, |
|
|
|
{ |
|
|
|
"key": "1962345709817106434", |
|
|
|
"title": "主题研学", |
|
|
|
"icon": null, |
|
|
|
"parentId": "0", |
|
|
|
"value": null, |
|
|
|
"code": null, |
|
|
|
"children": null, |
|
|
|
"leaf": true |
|
|
|
}, |
|
|
|
{ |
|
|
|
"key": "1962346300198948866", |
|
|
|
"title": "社会实践", |
|
|
|
"icon": null, |
|
|
|
"parentId": "0", |
|
|
|
"value": null, |
|
|
|
"code": null, |
|
|
|
"children": null, |
|
|
|
"leaf": true |
|
|
|
}, |
|
|
|
{ |
|
|
|
"key": "1962346769759670273", |
|
|
|
"title": "研学交流", |
|
|
|
"icon": null, |
|
|
|
"parentId": "0", |
|
|
|
"value": null, |
|
|
|
"code": null, |
|
|
|
"children": null, |
|
|
|
"leaf": true |
|
|
|
}, |
|
|
|
{ |
|
|
|
"key": "1962346834884628481", |
|
|
|
"title": "周末研学", |
|
|
|
"icon": null, |
|
|
|
"parentId": "0", |
|
|
|
"value": null, |
|
|
|
"code": null, |
|
|
|
"children": null, |
|
|
|
"leaf": true |
|
|
|
}, |
|
|
|
{ |
|
|
|
"key": "1962346960097185793", |
|
|
|
"title": "假期专享", |
|
|
|
"icon": null, |
|
|
|
"parentId": "0", |
|
|
|
"value": null, |
|
|
|
"code": null, |
|
|
|
"children": null, |
|
|
|
"leaf": true |
|
|
|
}, |
|
|
|
{ |
|
|
|
"key": "1962347024639135745", |
|
|
|
"title": "本地研学", |
|
|
|
"icon": null, |
|
|
|
"parentId": "0", |
|
|
|
"value": null, |
|
|
|
"code": null, |
|
|
|
"children": null, |
|
|
|
"leaf": true |
|
|
|
} |
|
|
|
].map(item => { |
|
|
|
const { key, title } = item |
|
|
|
|
|
|
|
return { |
|
|
|
id: key, |
|
|
|
name: title, |
|
|
|
children: [] |
|
|
|
} |
|
|
|
}) |
|
|
|
|
|
|
|
}, |
|
|
|
async fetchFilters() { |
|
|
|
|
|
|
|
let fetchs = [ |
|
|
|
this.$fetch('queryAddressList', { pageNo: 1, pageSize: 1000, pid: '0' }), |
|
|
|
this.$fetch('queryAgeList', { pageNo: 1, pageSize: 1000 }), |
|
|
|
this.$fetch('queryTimeList', { pageNo: 1, pageSize: 1000 }), |
|
|
|
] |
|
|
|
const results = (await Promise.allSettled(fetchs)) |
|
|
|
.map(res => { |
|
|
|
return res.value.records.map(item => { |
|
|
|
return { |
|
|
|
id: item.id, |
|
|
|
label: item.title, |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
console.log('results', results) |
|
|
|
|
|
|
|
fetchs = results[0].map(item => { |
|
|
|
return this.$fetch('queryAddressList', { pageNo: 1, pageSize: 1000, pid: item.id }) |
|
|
|
}) |
|
|
|
const addressResults = (await Promise.allSettled(fetchs)) |
|
|
|
.map(res => { |
|
|
|
return res.value.records.map(item => { |
|
|
|
return { |
|
|
|
id: item.id, |
|
|
|
label: item.title, |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
console.log('addressResults', addressResults) |
|
|
|
const addressOptionsConfig = addressResults.reduce((obj, records, index) => { |
|
|
|
obj[results[0][index].id] = records |
|
|
|
return obj |
|
|
|
}, {}) |
|
|
|
|
|
|
|
this.addressOptionsConfig = addressOptionsConfig |
|
|
|
console.log('addressOptionsConfig', addressOptionsConfig) |
|
|
|
|
|
|
|
this.filters = [ |
|
|
|
{ |
|
|
|
id: '001', |
|
|
|
key: 'frontier', |
|
|
|
label: '国境', |
|
|
|
options: [ |
|
|
|
{ |
|
|
|
id: '00101', |
|
|
|
label: '国内', |
|
|
|
}, |
|
|
|
{ |
|
|
|
id: '00102', |
|
|
|
label: '国外', |
|
|
|
}, |
|
|
|
], |
|
|
|
options: results[0], |
|
|
|
}, |
|
|
|
{ |
|
|
|
id: '002', |
|
|
|
@ -400,30 +289,7 @@ |
|
|
|
{ |
|
|
|
label: '全部', |
|
|
|
}, |
|
|
|
{ |
|
|
|
id: '00201', |
|
|
|
label: '上海', |
|
|
|
}, |
|
|
|
{ |
|
|
|
id: '00202', |
|
|
|
label: '北京', |
|
|
|
}, |
|
|
|
{ |
|
|
|
id: '00203', |
|
|
|
label: '浙江省', |
|
|
|
}, |
|
|
|
{ |
|
|
|
id: '00204', |
|
|
|
label: '广东省', |
|
|
|
}, |
|
|
|
{ |
|
|
|
id: '00205', |
|
|
|
label: '广西省', |
|
|
|
}, |
|
|
|
{ |
|
|
|
id: '00206', |
|
|
|
label: '云南省', |
|
|
|
}, |
|
|
|
...addressOptionsConfig[results[0][0].id] |
|
|
|
], |
|
|
|
}, |
|
|
|
{ |
|
|
|
@ -434,22 +300,7 @@ |
|
|
|
{ |
|
|
|
label: '全部', |
|
|
|
}, |
|
|
|
{ |
|
|
|
id: '00301', |
|
|
|
label: '6-10岁', |
|
|
|
}, |
|
|
|
{ |
|
|
|
id: '00302', |
|
|
|
label: '11-14岁', |
|
|
|
}, |
|
|
|
{ |
|
|
|
id: '00303', |
|
|
|
label: '15-16岁', |
|
|
|
}, |
|
|
|
{ |
|
|
|
id: '00304', |
|
|
|
label: '17-18岁', |
|
|
|
}, |
|
|
|
...results[1] |
|
|
|
], |
|
|
|
}, |
|
|
|
{ |
|
|
|
@ -460,22 +311,7 @@ |
|
|
|
{ |
|
|
|
label: '全部', |
|
|
|
}, |
|
|
|
{ |
|
|
|
id: '00401', |
|
|
|
label: '1日', |
|
|
|
}, |
|
|
|
{ |
|
|
|
id: '00402', |
|
|
|
label: '多日', |
|
|
|
}, |
|
|
|
{ |
|
|
|
id: '00403', |
|
|
|
label: '寒假', |
|
|
|
}, |
|
|
|
{ |
|
|
|
id: '00404', |
|
|
|
label: '暑假', |
|
|
|
}, |
|
|
|
...results[2], |
|
|
|
], |
|
|
|
}, |
|
|
|
{ |
|
|
|
@ -489,6 +325,7 @@ |
|
|
|
label: '出发日期', |
|
|
|
}, |
|
|
|
] |
|
|
|
console.log('filters', this.filters) |
|
|
|
|
|
|
|
this.filters.forEach(item => { |
|
|
|
const { key, options } = item |
|
|
|
@ -500,11 +337,39 @@ |
|
|
|
this.queryParams[key] = options[0].id |
|
|
|
}) |
|
|
|
|
|
|
|
// todo: fetch |
|
|
|
}, |
|
|
|
async queryProductList(categoryId) { |
|
|
|
try { |
|
|
|
return (await this.$fetch('queryActivityList', { ...this.queryParams, categoryId }))?.records || [] |
|
|
|
const { |
|
|
|
frontier, |
|
|
|
addressId, |
|
|
|
sort, |
|
|
|
...params |
|
|
|
} = this.queryParams |
|
|
|
|
|
|
|
params.addressId = addressId || frontier |
|
|
|
params.categoryId = categoryId |
|
|
|
|
|
|
|
switch(sort) { |
|
|
|
// 销量排序(saleOrder):0-从高到低 1-从低到高 |
|
|
|
case 'sale-desc': // 销量排序 - 降序 |
|
|
|
params.saleOrder = '0' |
|
|
|
break |
|
|
|
case 'sale-asc': // 销量排序 - 升序 |
|
|
|
params.saleOrder = '1' |
|
|
|
break |
|
|
|
// 价格排序(priceOrder):0-从高到低 1-从低到高 |
|
|
|
case 'price-desc': // 销量排序 - 降序 |
|
|
|
params.priceOrder = '0' |
|
|
|
break |
|
|
|
case 'price-asc': // 销量排序 - 升序 |
|
|
|
params.priceOrder = '1' |
|
|
|
break |
|
|
|
default: |
|
|
|
break |
|
|
|
} |
|
|
|
|
|
|
|
return (await this.$fetch('queryActivityList', params))?.records || [] |
|
|
|
} catch (err) { |
|
|
|
return [] |
|
|
|
} |
|
|
|
@ -532,6 +397,33 @@ |
|
|
|
} else { |
|
|
|
delete this.queryParams[key] |
|
|
|
} |
|
|
|
|
|
|
|
if (key === 'frontier') { |
|
|
|
this.filters[1].options = [ |
|
|
|
{ |
|
|
|
label: '全部', |
|
|
|
}, |
|
|
|
...this.addressOptionsConfig[val] |
|
|
|
] |
|
|
|
delete this.queryParams.addressId |
|
|
|
} |
|
|
|
|
|
|
|
this.initList() |
|
|
|
}, |
|
|
|
onStartPriceChange(value) { |
|
|
|
if (value) { |
|
|
|
this.queryParams.priceLow = value |
|
|
|
} else { |
|
|
|
delete this.queryParams.priceLow |
|
|
|
} |
|
|
|
this.initList() |
|
|
|
}, |
|
|
|
onEndPriceChange(value) { |
|
|
|
if (value) { |
|
|
|
this.queryParams.priceHigh = value |
|
|
|
} else { |
|
|
|
delete this.queryParams.priceHigh |
|
|
|
} |
|
|
|
this.initList() |
|
|
|
}, |
|
|
|
openStartDatePicker() { |
|
|
|
@ -540,21 +432,21 @@ |
|
|
|
onStartDateChange(e) { |
|
|
|
const date = e.value |
|
|
|
|
|
|
|
this.queryParams.startDate = date |
|
|
|
this.queryParams.dateLow = $dayjs(date).format('YYYY-MM-DD') |
|
|
|
|
|
|
|
const { endDate } = this.queryParams |
|
|
|
const { dateHigh } = this.queryParams |
|
|
|
|
|
|
|
if (endDate && this.$dayjs(date).isAfter(endDate, 'day')) { |
|
|
|
this.endDate = null |
|
|
|
delete this.queryParams.endDate |
|
|
|
if (dateHigh && this.$dayjs(date).isAfter(dateHigh, 'day')) { |
|
|
|
this.dateHigh = null |
|
|
|
delete this.queryParams.dateHigh |
|
|
|
} |
|
|
|
|
|
|
|
this.initList() |
|
|
|
}, |
|
|
|
onClearStartDate() { |
|
|
|
this.startDate = null |
|
|
|
this.dateLow = null |
|
|
|
|
|
|
|
delete this.queryParams.startDate |
|
|
|
delete this.queryParams.dateLow |
|
|
|
|
|
|
|
this.initList() |
|
|
|
}, |
|
|
|
@ -564,28 +456,27 @@ |
|
|
|
onEndDateChange(e) { |
|
|
|
const date = e.value |
|
|
|
|
|
|
|
this.queryParams.endDate = date |
|
|
|
this.queryParams.dateHigh = $dayjs(date).format('YYYY-MM-DD') |
|
|
|
|
|
|
|
const { startDate } = this.queryParams |
|
|
|
const { dateLow } = this.queryParams |
|
|
|
|
|
|
|
if (startDate && this.$dayjs(date).isBefore(startDate, 'day')) { |
|
|
|
this.startDate = null |
|
|
|
delete this.queryParams.startDate |
|
|
|
if (dateLow && this.$dayjs(date).isBefore(dateLow, 'day')) { |
|
|
|
this.dateLow = null |
|
|
|
delete this.queryParams.dateLow |
|
|
|
} |
|
|
|
|
|
|
|
this.initList() |
|
|
|
}, |
|
|
|
onClearEndDate() { |
|
|
|
this.endDate = null |
|
|
|
this.dateHigh = null |
|
|
|
|
|
|
|
delete this.queryParams.endDate |
|
|
|
delete this.queryParams.dateHigh |
|
|
|
|
|
|
|
this.initList() |
|
|
|
}, |
|
|
|
onSortChange(sort) { |
|
|
|
console.log('onSortChange', sort) |
|
|
|
// todo set sort |
|
|
|
this.getData() |
|
|
|
this.initList() |
|
|
|
}, |
|
|
|
} |
|
|
|
} |
|
|
|
|