|
|
@@ -1,112 +1,98 @@
|
|
|
import PageContainerBehavior from "../../../../core/behavior/page-container.behavior";
|
|
|
-
|
|
|
+import { OfflineEvaluateModel } from "../../model/evaluate.model";
|
|
|
+import { getOrderGoodsEvaluationMethod } from "../../request";
|
|
|
+function parseMediaType(url: string): "image" | "video" {
|
|
|
+ if (!url) return "image";
|
|
|
+ const match = /[?&]type=(image|video)\b/i.exec(url);
|
|
|
+ if (match) return match[1].toLowerCase() as "image" | "video";
|
|
|
+ const lower = url.toLowerCase();
|
|
|
+ if (/\.(mp4|mov|avi|rmvb|flv|mkv|webm)$/.test(lower)) return "video";
|
|
|
+ return "image";
|
|
|
+}
|
|
|
Page({
|
|
|
behaviors: [PageContainerBehavior],
|
|
|
data: {
|
|
|
orderId: "",
|
|
|
- service: {} as { name: string; image: string; description?: string; date?: string; time?: string; operator?: string; institution?: string },
|
|
|
- scoreServiceQuality: 5,
|
|
|
- scoreAttitude: 5,
|
|
|
- scoreEnvironment: 5,
|
|
|
+ service: {} as OfflineEvaluateModel,
|
|
|
+ scoreServiceQuality: 0,
|
|
|
+ scoreAttitude: 0,
|
|
|
+ scoreEnvironment: 0,
|
|
|
rateColor: "#F7BA2A",
|
|
|
- content: "描述相符,商品质量很好,包装完整,会回购。",
|
|
|
+ content: "",
|
|
|
mediaList: [] as { path: string; type: "image" | "video" }[],
|
|
|
- showMediaCarousel: false,
|
|
|
- mediaCarouselCurrent: 0,
|
|
|
+ videoFullscreen: false,
|
|
|
},
|
|
|
- onLoad(options: Record<string, string>) {
|
|
|
- const orderId = options.orderId || options.id || "";
|
|
|
- let service: { name: string; image: string; description?: string } = {
|
|
|
- name: "",
|
|
|
- image: "",
|
|
|
- description: "",
|
|
|
- date: "",
|
|
|
- time: "",
|
|
|
- operator: "",
|
|
|
- institution: "",
|
|
|
- };
|
|
|
+ async onLoad(options: Record<string, string>) {
|
|
|
+ let service = {} as OfflineEvaluateModel;
|
|
|
console.log(options, "options.goodsInfo===");
|
|
|
if (options.goodsInfo) {
|
|
|
- try {
|
|
|
- const goods = JSON.parse(decodeURIComponent(options.goodsInfo));
|
|
|
- service = {
|
|
|
- name: goods.name || "",
|
|
|
- image: goods.image || "",
|
|
|
- description: goods.description || "",
|
|
|
- date: "2026-03-05",
|
|
|
- time: "10:00:00",
|
|
|
- operator: "张三",
|
|
|
- institution: "杭州第一人民医院",
|
|
|
- };
|
|
|
- } catch (_) {}
|
|
|
- }
|
|
|
-console.log(service, "service===");
|
|
|
- // 若传入评价详情数据则使用,否则用默认展示内容(含示例图片)
|
|
|
- let scoreServiceQuality = 2;
|
|
|
- let scoreAttitude = 4;
|
|
|
- let scoreEnvironment = 3;
|
|
|
- let content = "描述相符,商品质量很好,包装完整,会回购。";
|
|
|
- let mediaList: { path: string; type: "image" | "video" }[] = [
|
|
|
- { path: "/assets/bg/bg_dialog@2x.png", type: "image" },
|
|
|
- ];
|
|
|
- if (options.evaluateInfo) {
|
|
|
- try {
|
|
|
- const info = JSON.parse(decodeURIComponent(options.evaluateInfo));
|
|
|
- if (info.scoreServiceQuality != null) scoreServiceQuality = Number(info.scoreServiceQuality);
|
|
|
- if (info.scoreAttitude != null) scoreAttitude = Number(info.scoreAttitude);
|
|
|
- if (info.scoreEnvironment != null) scoreEnvironment = Number(info.scoreEnvironment);
|
|
|
- if (info.content != null) content = info.content;
|
|
|
- if (Array.isArray(info.mediaList) && info.mediaList.length > 0) mediaList = info.mediaList;
|
|
|
- } catch (_) {}
|
|
|
+ const goods = JSON.parse(decodeURIComponent(options.goodsInfo));
|
|
|
+ service = {
|
|
|
+ lineId: goods.id || 0,
|
|
|
+ patientConditioningRecordId: goods.patientConditioningRecordId || 0,
|
|
|
+ patientConditioningProgramId: goods.patientConditioningProgramId || 0,
|
|
|
+ operateTime: goods.operateTime || "",
|
|
|
+ operateBy: goods.operateBy || "",
|
|
|
+ conditioningProgramSupplierName: goods.conditioningProgramSupplierName || "",
|
|
|
+ image: goods.image || "",
|
|
|
+ };
|
|
|
}
|
|
|
+ console.log(service, "service===");
|
|
|
this.setData({
|
|
|
- orderId,
|
|
|
service,
|
|
|
- scoreServiceQuality,
|
|
|
- scoreAttitude,
|
|
|
- scoreEnvironment,
|
|
|
- content,
|
|
|
- mediaList,
|
|
|
});
|
|
|
+ if (service.patientConditioningRecordId) {
|
|
|
+ try {
|
|
|
+ const res = await getOrderGoodsEvaluationMethod("2", service.lineId);
|
|
|
+ console.log(res, "res===");
|
|
|
+ const mediaList: { path: string; type: "image" | "video" }[] = [];
|
|
|
+ if (res && res.data) {
|
|
|
+ if (Array.isArray(res.data.imageVideos)) {
|
|
|
+ res.data.imageVideos.forEach((url: string) => {
|
|
|
+ if (!url) return;
|
|
|
+ mediaList.push({
|
|
|
+ path: url,
|
|
|
+ type: parseMediaType(url),
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
+ this.setData({
|
|
|
+ evaluateInfo: res.data,
|
|
|
+ scoreServiceQuality: Number(res.data.complianceScore ?? 0),
|
|
|
+ scoreAttitude: Number(res.data.attitudeScore ?? 0),
|
|
|
+ scoreEnvironment: Number(res.data.environmentScore ?? 0),
|
|
|
+ content: res.data.depict || "",
|
|
|
+ mediaList,
|
|
|
+ });
|
|
|
+ }
|
|
|
+ } catch (error: any) {
|
|
|
+ console.log(error, "error===");
|
|
|
+ wx.showToast({
|
|
|
+ title: error?.errMsg || "获取评价详情失败",
|
|
|
+ icon: "none",
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
},
|
|
|
onBack() {
|
|
|
wx.navigateBack();
|
|
|
},
|
|
|
- /** 打开图片/视频统一轮播,从指定下标开始;轮播到视频时自动播放 */
|
|
|
- onPreviewMedia(e: WechatMiniprogram.TouchEvent) {
|
|
|
- const index = e.currentTarget.dataset.index as number;
|
|
|
- const { mediaList } = this.data;
|
|
|
- if (index < 0 || index >= mediaList.length) return;
|
|
|
- this.setData(
|
|
|
- { showMediaCarousel: true, mediaCarouselCurrent: index },
|
|
|
- () => {
|
|
|
- this._playVideoAtCarouselIndex(index);
|
|
|
- }
|
|
|
- );
|
|
|
- },
|
|
|
- /** 轮播切换:暂停所有视频,若当前项是视频则播放 */
|
|
|
- onMediaCarouselChange(e: WechatMiniprogram.SwiperChange) {
|
|
|
- const current = e.detail?.current ?? 0;
|
|
|
- this.setData({ mediaCarouselCurrent: current });
|
|
|
- this._pauseAllCarouselVideos();
|
|
|
- this._playVideoAtCarouselIndex(current);
|
|
|
- },
|
|
|
- onCloseMediaCarousel() {
|
|
|
- this._pauseAllCarouselVideos();
|
|
|
- this.setData({ showMediaCarousel: false });
|
|
|
+ onPreviewImage(e: WechatMiniprogram.TouchEvent) {
|
|
|
+ const url = e.currentTarget.dataset.url as string;
|
|
|
+ const urls = this.data.mediaList
|
|
|
+ .filter((m) => m.type === "image")
|
|
|
+ .map((m) => m.path);
|
|
|
+ if (url && urls.length) {
|
|
|
+ wx.previewImage({ current: url, urls });
|
|
|
+ }
|
|
|
},
|
|
|
- _playVideoAtCarouselIndex(index: number) {
|
|
|
- const list = this.data.mediaList;
|
|
|
- if (index < 0 || index >= list.length || list[index].type !== "video") return;
|
|
|
- const ctx = wx.createVideoContext("preview-video-" + index, this);
|
|
|
- ctx.play();
|
|
|
+ onPreviewVideo(e: WechatMiniprogram.TouchEvent) {
|
|
|
+ const index = e.currentTarget.dataset.index as number;
|
|
|
+ const ctx = wx.createVideoContext("offline-detail-video-" + index, this);
|
|
|
+ ctx.requestFullScreen({});
|
|
|
},
|
|
|
- _pauseAllCarouselVideos() {
|
|
|
- this.data.mediaList.forEach((item, i) => {
|
|
|
- if (item.type === "video") {
|
|
|
- const ctx = wx.createVideoContext("preview-video-" + i, this);
|
|
|
- ctx.pause();
|
|
|
- }
|
|
|
- });
|
|
|
+ onVideoFullscreenChange(e: WechatMiniprogram.VideoFullScreenChange) {
|
|
|
+ const fullScreen = !!(e.detail && e.detail.fullScreen);
|
|
|
+ this.setData({ videoFullscreen: fullScreen });
|
|
|
},
|
|
|
});
|