| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- 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 OfflineEvaluateModel,
- scoreServiceQuality: 0,
- scoreAttitude: 0,
- scoreEnvironment: 0,
- rateColor: "#F7BA2A",
- content: "",
- mediaList: [] as { path: string; type: "image" | "video" }[],
- videoFullscreen: false,
- },
- async onLoad(options: Record<string, string>) {
- let service = {} as OfflineEvaluateModel;
- console.log(options, "options.goodsInfo===");
- if (options.goodsInfo) {
- 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({
- service,
- });
- 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();
- },
- 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 });
- }
- },
- onPreviewVideo(e: WechatMiniprogram.TouchEvent) {
- const index = e.currentTarget.dataset.index as number;
- const ctx = wx.createVideoContext("offline-detail-video-" + index, this);
- ctx.requestFullScreen({});
- },
- onVideoFullscreenChange(e: WechatMiniprogram.VideoFullScreenChange) {
- const fullScreen = !!(e.detail && e.detail.fullScreen);
- this.setData({ videoFullscreen: fullScreen });
- },
- });
|