feat:"完成页面接口的对接"

This commit is contained in:
2026-01-29 17:58:19 +08:00
parent 2774a539bf
commit 2b69da3c15
98 changed files with 9504 additions and 592 deletions

View File

@@ -1,6 +1,7 @@
"use strict";
const common_vendor = require("../../common/vendor.js");
const api_index = require("../../api/index.js");
const utils_config = require("../../utils/config.js");
if (!Array) {
const _easycom_before_after_1 = common_vendor.resolveComponent("before-after");
_easycom_before_after_1();
@@ -21,6 +22,7 @@ class CaseDetail extends UTS.UTSType {
categoryName: { type: String, optional: false },
beforeImages: { type: UTS.UTSType.withGenerics(Array, [String]), optional: false },
afterImages: { type: UTS.UTSType.withGenerics(Array, [String]), optional: false },
compareAfterImages: { type: UTS.UTSType.withGenerics(Array, [String]), optional: false },
description: { type: String, optional: false },
material: { type: String, optional: false },
duration: { type: String, optional: false },
@@ -42,6 +44,7 @@ class CaseDetail extends UTS.UTSType {
this.categoryName = this.__props__.categoryName;
this.beforeImages = this.__props__.beforeImages;
this.afterImages = this.__props__.afterImages;
this.compareAfterImages = this.__props__.compareAfterImages;
this.description = this.__props__.description;
this.material = this.__props__.material;
this.duration = this.__props__.duration;
@@ -63,6 +66,7 @@ const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
categoryName: "",
beforeImages: [],
afterImages: [],
compareAfterImages: [],
description: "",
material: "",
duration: "",
@@ -76,37 +80,57 @@ const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
return common_vendor.__awaiter(this, void 0, void 0, function* () {
try {
const res = yield api_index.getCaseDetail(caseId.value);
const data = res.data;
caseDetail.value = new CaseDetail(
{
id: data["id"],
title: data["title"],
category: data["category"],
categoryName: data["categoryName"],
beforeImages: data["beforeImages"],
afterImages: data["afterImages"],
description: data["description"],
material: data["material"],
duration: data["duration"],
price: data["price"],
views: data["views"],
likes: data["likes"],
createTime: data["createTime"]
}
// 更新标题
);
common_vendor.index.setNavigationBarTitle({
title: caseDetail.value.title
if (res.code === 0 && res.data != null) {
const data = res.data;
const images = data["images"] || [];
const beforeImages = data["beforeImages"] || [];
const afterImages = data["afterImages"] || [];
const createdAt = data["createdAt"] || "";
const displayAfterImages = afterImages.length > 0 ? afterImages : images;
const compareAfterImages = afterImages.length > 0 ? afterImages : [];
caseDetail.value = new CaseDetail(
{
id: String(data["id"]),
title: data["title"],
category: data["serviceType"] || "",
categoryName: utils_config.getServiceTypeName(data["serviceType"]),
beforeImages,
afterImages: displayAfterImages,
compareAfterImages,
description: data["description"],
material: data["materials"] || "优质材料",
duration: (data["duration"] || 0) + "天",
price: data["price"] != null ? "¥" + data["price"] : "面议",
views: data["views"] || 0,
likes: data["likes"] || 0,
createTime: createdAt.split("T")[0] || ""
}
// 更新标题
);
common_vendor.index.setNavigationBarTitle({
title: caseDetail.value.title
});
} else {
common_vendor.index.showToast({
title: res.message || "加载失败",
icon: "none"
});
}
} catch (error) {
common_vendor.index.__f__("error", "at pages/cases/detail.uvue:197", "获取案例详情失败:", error);
common_vendor.index.showToast({
title: "加载失败",
icon: "none"
});
} catch (e) {
common_vendor.index.__f__("error", "at pages/cases/detail.uvue:173", "获取案例详情失败", e);
}
});
};
const previewImages = (index) => {
const urls = caseDetail.value.afterImages || [];
const current = urls[index] || urls[0] || "";
common_vendor.index.previewImage({
current: index,
urls: caseDetail.value.afterImages
current,
urls
});
};
const handleFavorite = () => {
@@ -164,7 +188,7 @@ const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
f: common_vendor.t(common_vendor.unref(caseDetail).likes),
g: common_vendor.p({
beforeImage: common_vendor.unref(caseDetail).beforeImages[0] || "",
afterImage: common_vendor.unref(caseDetail).afterImages[0] || "",
afterImage: common_vendor.unref(caseDetail).compareAfterImages[0] || "",
showTitle: true
}),
h: common_vendor.t(common_vendor.unref(caseDetail).material),

View File

@@ -1 +1 @@
<view id="{{q}}" change:eS="{{uV.sS}}" eS="{{$eS[q]}}" change:eA="{{uV.sA}}" eA="{{$eA[q]}}" class="{{['page', virtualHostClass]}}" style="{{virtualHostStyle}}" hidden="{{virtualHostHidden || false}}"><scroll-view class="page-scroll" scroll-y enable-flex="true" enhanced="true"><view class="gallery-section"><swiper class="gallery-swiper" circular indicator-dots indicator-color="rgba(255,255,255,0.5)" indicator-active-color="#ffffff"><swiper-item wx:for="{{a}}" wx:for-item="item" wx:key="c"><image class="gallery-image" src="{{item.a}}" mode="aspectFill" bindtap="{{item.b}}"></image></swiper-item></swiper><view class="gallery-tag"><text class="gallery-tag-text">{{b}}</text></view></view><view class="info-section"><text class="case-title">{{c}}</text><view class="case-meta"><text class="case-price">{{d}}</text><view class="case-stats"><text class="stat-text">👁 {{e}}</text><text class="stat-text">❤ {{f}}</text></view></view></view><view class="compare-section"><before-after u-i="eec33e1e-0" bind:__l="__l" u-p="{{g||''}}"></before-after></view><view class="detail-section"><view class="detail-header"><text class="detail-title">翻新详情</text></view><view class="detail-list"><view class="detail-item"><text class="detail-label">使用材质</text><text class="detail-value">{{h}}</text></view><view class="detail-item"><text class="detail-label">翻新工期</text><text class="detail-value">{{i}}</text></view><view class="detail-item"><text class="detail-label">完成日期</text><text class="detail-value">{{j}}</text></view></view><view class="detail-desc"><text class="desc-title">案例描述</text><text class="desc-content">{{k}}</text></view></view><view class="bottom-space"></view></scroll-view><view class="bottom-bar"><view class="bar-left"><view class="bar-btn" bindtap="{{m}}"><text class="bar-icon">{{l}}</text><text class="bar-label">收藏</text></view><view class="bar-btn" bindtap="{{n}}"><text class="bar-icon">📤</text><text class="bar-label">分享</text></view></view><view class="bar-right"><view class="contact-btn" bindtap="{{o}}"><text class="contact-text">在线咨询</text></view><view class="booking-btn" bindtap="{{p}}"><text class="booking-text">立即预约</text></view></view></view></view><wxs src="/common/uniView.wxs" module="uV"/>
<view id="{{q}}" change:eS="{{uV.sS}}" eS="{{$eS[q]}}" change:eA="{{uV.sA}}" eA="{{$eA[q]}}" class="{{['page', virtualHostClass]}}" style="{{virtualHostStyle}}" hidden="{{virtualHostHidden || false}}"><scroll-view class="page-scroll" scroll-y enable-flex="true" enhanced="true"><view class="gallery-section"><swiper class="gallery-swiper" circular indicator-dots indicator-color="rgba(255,255,255,0.5)" indicator-active-color="#ffffff"><swiper-item wx:for="{{a}}" wx:for-item="item" wx:key="c"><image class="gallery-image" src="{{item.a}}" mode="aspectFill" bindtap="{{item.b}}"></image></swiper-item></swiper><view class="gallery-tag"><text class="gallery-tag-text">{{b}}</text></view></view><view class="info-section"><text class="case-title">{{c}}</text><view class="case-meta"><text class="case-price">{{d}}</text><view class="case-stats"><text class="stat-text">👁 {{e}}</text><text class="stat-text">❤ {{f}}</text></view></view></view><view class="compare-section"><before-after u-i="1bc77b3c-0" bind:__l="__l" u-p="{{g||''}}"></before-after></view><view class="detail-section"><view class="detail-header"><text class="detail-title">翻新详情</text></view><view class="detail-list"><view class="detail-item"><text class="detail-label">使用材质</text><text class="detail-value">{{h}}</text></view><view class="detail-item"><text class="detail-label">翻新工期</text><text class="detail-value">{{i}}</text></view><view class="detail-item"><text class="detail-label">完成日期</text><text class="detail-value">{{j}}</text></view></view><view class="detail-desc"><text class="desc-title">案例描述</text><text class="desc-content">{{k}}</text></view></view><view class="bottom-space"></view></scroll-view><view class="bottom-bar"><view class="bar-left"><view class="bar-btn" bindtap="{{m}}"><text class="bar-icon">{{l}}</text><text class="bar-label">收藏</text></view><view class="bar-btn" bindtap="{{n}}"><text class="bar-icon">📤</text><text class="bar-label">分享</text></view></view><view class="bar-right"><view class="contact-btn" bindtap="{{o}}"><text class="contact-text">在线咨询</text></view><view class="booking-btn" bindtap="{{p}}"><text class="booking-text">立即预约</text></view></view></view></view><wxs src="/common/uniView.wxs" module="uV"/>

View File

@@ -93,6 +93,7 @@ const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
page.value = 1;
caseList.value = [];
noMore.value = false;
common_vendor.index.__f__("log", "at pages/cases/list.uvue:114", 111);
fetchCaseList();
};
const fetchCaseList = () => {
@@ -102,38 +103,49 @@ const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
loading.value = true;
try {
const params = new UTSJSONObject({
category: currentCategory.value,
serviceType: currentCategory.value != "all" ? currentCategory.value : void 0,
page: page.value,
pageSize: utils_config.PAGE_SIZE
limit: utils_config.PAGE_SIZE,
status: "published"
});
const res = yield api_index.getCaseList(params);
const data = res.data;
const list = data["items"] || [];
total.value = data["total"] || 0;
const newList = list.map((item) => {
return new CaseItem({
id: item["id"],
title: item["title"],
category: item["category"],
categoryName: item["categoryName"],
coverImage: item["coverImage"],
material: item["material"],
duration: item["duration"],
price: item["price"],
views: item["views"],
likes: item["likes"]
if (res.code == 0 && res.data != null) {
const data = res.data;
const list = data["list"] || [];
total.value = data["total"] || 0;
const newList = list.map((item) => {
const images = item["images"] || [];
const afterImages = item["afterImages"] || [];
const beforeImages = item["beforeImages"] || [];
const coverImage = images.length > 0 ? images[0] : afterImages.length > 0 ? afterImages[0] : beforeImages.length > 0 ? beforeImages[0] : "";
return new CaseItem({
id: String(item["id"]),
title: item["title"],
category: item["serviceType"],
categoryName: utils_config.getServiceTypeName(item["serviceType"]),
coverImage,
material: item["materials"] || "暂无",
duration: (item["duration"] || 0) + "天",
price: item["price"] != null ? "¥" + item["price"] : "面议",
views: item["views"] || 0,
likes: item["likes"] || 0
});
});
});
if (page.value == 1) {
caseList.value = newList;
} else {
caseList.value = [...caseList.value, ...newList];
}
if (caseList.value.length >= total.value) {
noMore.value = true;
if (page.value == 1) {
caseList.value = newList;
} else {
caseList.value = [...caseList.value, ...newList];
}
if (caseList.value.length >= total.value) {
noMore.value = true;
}
}
} catch (e) {
common_vendor.index.__f__("error", "at pages/cases/list.uvue:160", "获取案例列表失败", e);
common_vendor.index.__f__("error", "at pages/cases/list.uvue:170", "获取案例列表失败", e);
common_vendor.index.showToast({
title: "加载失败",
icon: "none"
});
}
loading.value = false;
});
@@ -171,7 +183,7 @@ const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
return {
a: item.id,
b: common_vendor.o(goToDetail, item.id),
c: "15d594f8-0-" + i0,
c: "32628196-0-" + i0,
d: common_vendor.p({
caseData: item
})