195 lines
6.8 KiB
JavaScript
195 lines
6.8 KiB
JavaScript
"use strict";
|
|
var __async = (__this, __arguments, generator) => {
|
|
return new Promise((resolve, reject) => {
|
|
var fulfilled = (value) => {
|
|
try {
|
|
step(generator.next(value));
|
|
} catch (e) {
|
|
reject(e);
|
|
}
|
|
};
|
|
var rejected = (value) => {
|
|
try {
|
|
step(generator.throw(value));
|
|
} catch (e) {
|
|
reject(e);
|
|
}
|
|
};
|
|
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
});
|
|
};
|
|
const common_vendor = require("../../common/vendor.js");
|
|
const utils_http = require("../../utils/http.js");
|
|
const utils_commUtils = require("../../utils/commUtils.js");
|
|
if (!Array) {
|
|
const _easycom_wd_icon2 = common_vendor.resolveComponent("wd-icon");
|
|
const _easycom_wd_loadmore2 = common_vendor.resolveComponent("wd-loadmore");
|
|
const _component_layout_default_uni = common_vendor.resolveComponent("layout-default-uni");
|
|
(_easycom_wd_icon2 + _easycom_wd_loadmore2 + _component_layout_default_uni)();
|
|
}
|
|
const _easycom_wd_icon = () => "../../node-modules/wot-design-uni/components/wd-icon/wd-icon.js";
|
|
const _easycom_wd_loadmore = () => "../../node-modules/wot-design-uni/components/wd-loadmore/wd-loadmore.js";
|
|
if (!Math) {
|
|
(_easycom_wd_icon + PetSitterCard + _easycom_wd_loadmore + EmptyState)();
|
|
}
|
|
const PetSitterCard = () => "../../components/PetSitterCard.js";
|
|
const EmptyState = () => "../../components/EmptyState.js";
|
|
const _sfc_main = {
|
|
__name: "search",
|
|
setup(__props) {
|
|
const searchTerm = common_vendor.ref("");
|
|
const priceSortAsc = common_vendor.ref(true);
|
|
const petSitters = common_vendor.ref([]);
|
|
const page = common_vendor.ref(1);
|
|
const loading = common_vendor.ref(false);
|
|
const noMoreData = common_vendor.ref(false);
|
|
const serviceTypes = common_vendor.ref([
|
|
{ name: "interaction", label: "宠物互动", icon: "@/static/home/book.png" },
|
|
{ name: "nanny", label: "宠物月嫂", icon: "@/static/home/pb.png" },
|
|
{ name: "canteen", label: "宠物美容", icon: "@/static/home/yl.png" },
|
|
{ name: "training", label: "社交教培", icon: "@/static/home/mr.png" },
|
|
{ name: "cleaning", label: "宠物清洁", icon: "@/static/home/yl.png" }
|
|
]);
|
|
const selectedService = common_vendor.ref(serviceTypes.value[0].label);
|
|
const sortField = common_vendor.ref("");
|
|
const sortOrder = common_vendor.ref("");
|
|
const fetchPetSitters = () => __async(this, null, function* () {
|
|
if (loading.value)
|
|
return;
|
|
loading.value = true;
|
|
try {
|
|
const response = yield utils_http.httpPost(
|
|
"/personal-service/list",
|
|
{
|
|
current: page.value,
|
|
size: 10,
|
|
data: {
|
|
serviceName: searchTerm.value,
|
|
type: selectedService.value
|
|
}
|
|
},
|
|
{
|
|
sortField: sortField.value,
|
|
sortOrder: sortOrder.value
|
|
}
|
|
);
|
|
if (response.code === 200) {
|
|
if (page.value === 1) {
|
|
petSitters.value = response.records;
|
|
} else {
|
|
petSitters.value = [...petSitters.value, ...response.records];
|
|
}
|
|
if (response.records.length < 10) {
|
|
noMoreData.value = true;
|
|
}
|
|
} else {
|
|
console.error("获取宠托师数据失败", response.message);
|
|
}
|
|
} catch (error) {
|
|
console.error("获取宠托师数据失败", error);
|
|
} finally {
|
|
loading.value = false;
|
|
}
|
|
});
|
|
const loadMore = () => __async(this, null, function* () {
|
|
if (!noMoreData.value) {
|
|
page.value += 1;
|
|
fetchPetSitters();
|
|
}
|
|
});
|
|
const sortByPrice = () => __async(this, null, function* () {
|
|
priceSortAsc.value = !priceSortAsc.value;
|
|
sortField.value = "price";
|
|
sortOrder.value = priceSortAsc.value ? "asc" : "desc";
|
|
page.value = 1;
|
|
noMoreData.value = false;
|
|
yield fetchPetSitters();
|
|
});
|
|
const sortByLatest = () => __async(this, null, function* () {
|
|
sortField.value = "createTime";
|
|
sortOrder.value = "desc";
|
|
page.value = 1;
|
|
noMoreData.value = false;
|
|
yield fetchPetSitters();
|
|
});
|
|
const sortByDistance = () => {
|
|
};
|
|
const filterByService = (serviceName) => __async(this, null, function* () {
|
|
selectedService.value = serviceName;
|
|
page.value = 1;
|
|
noMoreData.value = false;
|
|
fetchPetSitters();
|
|
});
|
|
const onSearch = () => {
|
|
page.value = 1;
|
|
noMoreData.value = false;
|
|
fetchPetSitters();
|
|
};
|
|
common_vendor.onLoad(() => {
|
|
fetchPetSitters();
|
|
});
|
|
return (_ctx, _cache) => {
|
|
return common_vendor.e({
|
|
a: common_vendor.p({
|
|
name: "search",
|
|
size: "40"
|
|
}),
|
|
b: common_vendor.o([($event) => searchTerm.value = $event.detail.value, onSearch]),
|
|
c: searchTerm.value,
|
|
d: common_vendor.o(sortByDistance),
|
|
e: common_vendor.p({
|
|
name: _ctx.priceSortIcon,
|
|
size: "20"
|
|
}),
|
|
f: common_vendor.o(sortByPrice),
|
|
g: common_vendor.o(sortByLatest),
|
|
h: common_vendor.p({
|
|
name: "arrow-down",
|
|
size: "20"
|
|
}),
|
|
i: common_vendor.f(serviceTypes.value, (serviceType, k0, i0) => {
|
|
return {
|
|
a: common_vendor.n(selectedService.value === serviceType.label ? "text-white" : "text-gray-500"),
|
|
b: "206ae70f-4-" + i0 + ",206ae70f-0",
|
|
c: common_vendor.p({
|
|
name: common_vendor.unref(utils_commUtils.imgUrl)(serviceType.icon),
|
|
size: 48
|
|
}),
|
|
d: common_vendor.n(selectedService.value === serviceType.name ? "bg-_a__a_ffc107_a_" : "bg-gray-200"),
|
|
e: common_vendor.t(serviceType.label),
|
|
f: common_vendor.n(selectedService.value === serviceType.label ? "text-_a__a_ffc107_a_" : "text-gray-500"),
|
|
g: serviceType.name,
|
|
h: common_vendor.o(($event) => filterByService(serviceType.label), serviceType.name)
|
|
};
|
|
}),
|
|
j: petSitters.value.length > 0
|
|
}, petSitters.value.length > 0 ? {
|
|
k: common_vendor.f(petSitters.value, (petSitter, index, i0) => {
|
|
return {
|
|
a: "206ae70f-5-" + i0 + ",206ae70f-0",
|
|
b: common_vendor.p({
|
|
petSitter
|
|
}),
|
|
c: index
|
|
};
|
|
}),
|
|
l: common_vendor.o(loadMore),
|
|
m: common_vendor.p({
|
|
loading: loading.value,
|
|
finished: noMoreData.value,
|
|
["finished-text"]: "没有更多数据了"
|
|
})
|
|
} : {
|
|
n: common_vendor.p({
|
|
type: "search",
|
|
message: "暂无相关服务"
|
|
})
|
|
});
|
|
};
|
|
}
|
|
};
|
|
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-206ae70f"]]);
|
|
wx.createPage(MiniProgramPage);
|
|
//# sourceMappingURL=search.js.map
|