| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147 |
- import { Post } from "../../../../lib/request/method";
- import { cancelAppointmentMethod } from "../../request";
- import { getFullImageUrl } from "../../../../utils/util";
- Page({
- data: {
- id: 0,
- recordListId: '',
- recordList: [],
- showAppointmentSuccess: true,
- //是否显示修改预约按钮
- isShowUpdateButton: false,
- //isShowCancleButton
- isShowCancleButton: false,
- qrCodeUrl: "",
- appointmentInfo: {
- operateTime: '',
- operateDuration: '',
- conditioningProgramSupplierName: '',
- cpSupplierDetailAddress: '',
- cpSupplierPhone: '',
- cpSupplierQrCode: '',
- },
- showAppointmentInfo: false,
- },
- onLoad(options: any) {
- if (options.id) {
- this.setData({
- id: options?.id
- })
- }
- },
- onShow() {
- if (this.data.id) {
- this.getVerifyRecordList(this.data.id);
- }
- },
- // 生成二维码
- generateQRCode(qrCodeUrl: any) {
- this.setData({
- qrCodeUrl
- });
- },
- // 获取核销记录列表
- async getVerifyRecordList(id: number) {
- try {
- const res = await Post(
- `/patientCrManage/pofflineCp/${id}`,
- {},
- {
- transform({ data }: any) {
- return data;
- },
- }
- );
- if (res && res.patientConditioningSwagItemOffline && JSON.stringify(res.patientConditioningSwagItemOffline) !== '{}') {
- this.setData({
- showAppointmentInfo: true,
- isShowUpdateButton: res.isShowUpdateButton,
- isShowCancleButton: res.isShowCancleButton,
- recordListId: res.patientConditioningSwagItemOffline.id,
- appointmentInfo: res.patientConditioningSwagItemOffline,
- });
- this.generateQRCode(this.data.appointmentInfo.cpSupplierQrCode);
- } else {
- this.setData({
- showAppointmentInfo: false,
- });
- }
- if (res && res.patientConditioningSwagItemOfflines && res.patientConditioningSwagItemOfflines.length > 0) {
- res.patientConditioningSwagItemOfflines.forEach((item: any) => {
- item.photo = getFullImageUrl(item.photo);
- });
- this.setData({
- recordList: res.patientConditioningSwagItemOfflines,
- });
- } else {
- this.setData({
- recordList: [],
- });
- }
- } catch (error) {
- console.error("核销记录列表", error);
- }
- },
- // 去评价
- onReview(e: WechatMiniprogram.TouchEvent) {
- const { evaluateTime } = e.currentTarget.dataset.goods;
- if (evaluateTime) {
- // 线下服务评价详情
- wx.navigateTo({
- url: `/module/order/pages/offline-evaluateDetail/offline-evaluateDetail?goodsInfo=${encodeURIComponent(JSON.stringify(e.currentTarget.dataset.goods))}`,
- });
- } else {
- // 去线下服务评价
- wx.navigateTo({
- url: `/module/order/pages/offline-evaluate/offline-evaluate?goodsInfo=${encodeURIComponent(JSON.stringify(e.currentTarget.dataset.goods))}`,
- });
- }
- },
- onCancelAppointment() {
- wx.showModal({
- title: "取消预约",
- content: "预约取消后无法恢复!",
- showCancel: true,
- confirmText: "确定",
- cancelText: "再想想",
- success: async (res) => {
- if (!res.confirm) return;
- try {
- wx.showLoading({ title: "取消中" });
- await cancelAppointmentMethod(Number(this.data.recordListId || 0));
- wx.hideLoading();
- wx.showToast({ title: "取消成功", icon: "success" });
- // 取消成功之后到取消预约页面
- setTimeout(() => {
- const appointmentInfoParam = encodeURIComponent(
- JSON.stringify(this.data.appointmentInfo || {})
- );
- wx.navigateTo({
- url: `/module/care/pages/cancelAppointment/cancelAppointment?appointmentInfo=${appointmentInfoParam}`,
- });
- }, 300);
- } catch (error: any) {
- wx.hideLoading();
- wx.showToast({
- title: error?.errMsg || "取消失败",
- icon: "none",
- });
- }
- },
- });
- },
- onModifyAppointment() {
- const arrangeTime =
- (this.data.appointmentInfo as any).arrangeTime ||
- (this.data.appointmentInfo as any).appointmentTime ||
- "";
- wx.navigateTo({
- url: `/module/order/pages/appointment/appointment?mode=edit&arrangeTime=${encodeURIComponent(arrangeTime)}`,
- });
- },
- });
|