verifyRecord.ts 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. import { Post } from "../../../../lib/request/method";
  2. import { cancelAppointmentMethod } from "../../request";
  3. import { getFullImageUrl } from "../../../../utils/util";
  4. Page({
  5. data: {
  6. id: 0,
  7. recordListId: '',
  8. recordList: [],
  9. showAppointmentSuccess: true,
  10. //是否显示修改预约按钮
  11. isShowUpdateButton: false,
  12. //isShowCancleButton
  13. isShowCancleButton: false,
  14. qrCodeUrl: "",
  15. appointmentInfo: {
  16. operateTime: '',
  17. operateDuration: '',
  18. conditioningProgramSupplierName: '',
  19. cpSupplierDetailAddress: '',
  20. cpSupplierPhone: '',
  21. cpSupplierQrCode: '',
  22. },
  23. showAppointmentInfo: false,
  24. },
  25. onLoad(options: any) {
  26. if (options.id) {
  27. this.setData({
  28. id: options?.id
  29. })
  30. }
  31. },
  32. onShow() {
  33. if (this.data.id) {
  34. this.getVerifyRecordList(this.data.id);
  35. }
  36. },
  37. // 生成二维码
  38. generateQRCode(qrCodeUrl: any) {
  39. this.setData({
  40. qrCodeUrl
  41. });
  42. },
  43. // 获取核销记录列表
  44. async getVerifyRecordList(id: number) {
  45. try {
  46. const res = await Post(
  47. `/patientCrManage/pofflineCp/${id}`,
  48. {},
  49. {
  50. transform({ data }: any) {
  51. return data;
  52. },
  53. }
  54. );
  55. if (res && res.patientConditioningSwagItemOffline && JSON.stringify(res.patientConditioningSwagItemOffline) !== '{}') {
  56. this.setData({
  57. showAppointmentInfo: true,
  58. isShowUpdateButton: res.isShowUpdateButton,
  59. isShowCancleButton: res.isShowCancleButton,
  60. recordListId: res.patientConditioningSwagItemOffline.id,
  61. appointmentInfo: res.patientConditioningSwagItemOffline,
  62. });
  63. this.generateQRCode(this.data.appointmentInfo.cpSupplierQrCode);
  64. } else {
  65. this.setData({
  66. showAppointmentInfo: false,
  67. });
  68. }
  69. if (res && res.patientConditioningSwagItemOfflines && res.patientConditioningSwagItemOfflines.length > 0) {
  70. res.patientConditioningSwagItemOfflines.forEach((item: any) => {
  71. item.photo = getFullImageUrl(item.photo);
  72. });
  73. this.setData({
  74. recordList: res.patientConditioningSwagItemOfflines,
  75. });
  76. } else {
  77. this.setData({
  78. recordList: [],
  79. });
  80. }
  81. } catch (error) {
  82. console.error("核销记录列表", error);
  83. }
  84. },
  85. // 去评价
  86. onReview(e: WechatMiniprogram.TouchEvent) {
  87. const { evaluateTime } = e.currentTarget.dataset.goods;
  88. if (evaluateTime) {
  89. // 线下服务评价详情
  90. wx.navigateTo({
  91. url: `/module/order/pages/offline-evaluateDetail/offline-evaluateDetail?goodsInfo=${encodeURIComponent(JSON.stringify(e.currentTarget.dataset.goods))}`,
  92. });
  93. } else {
  94. // 去线下服务评价
  95. wx.navigateTo({
  96. url: `/module/order/pages/offline-evaluate/offline-evaluate?goodsInfo=${encodeURIComponent(JSON.stringify(e.currentTarget.dataset.goods))}`,
  97. });
  98. }
  99. },
  100. onCancelAppointment() {
  101. wx.showModal({
  102. title: "取消预约",
  103. content: "预约取消后无法恢复!",
  104. showCancel: true,
  105. confirmText: "确定",
  106. cancelText: "再想想",
  107. success: async (res) => {
  108. if (!res.confirm) return;
  109. try {
  110. wx.showLoading({ title: "取消中" });
  111. await cancelAppointmentMethod(Number(this.data.recordListId || 0));
  112. wx.hideLoading();
  113. wx.showToast({ title: "取消成功", icon: "success" });
  114. // 取消成功之后到取消预约页面
  115. setTimeout(() => {
  116. const appointmentInfoParam = encodeURIComponent(
  117. JSON.stringify(this.data.appointmentInfo || {})
  118. );
  119. wx.navigateTo({
  120. url: `/module/care/pages/cancelAppointment/cancelAppointment?appointmentInfo=${appointmentInfoParam}`,
  121. });
  122. }, 300);
  123. } catch (error: any) {
  124. wx.hideLoading();
  125. wx.showToast({
  126. title: error?.errMsg || "取消失败",
  127. icon: "none",
  128. });
  129. }
  130. },
  131. });
  132. },
  133. onModifyAppointment() {
  134. const arrangeTime =
  135. (this.data.appointmentInfo as any).arrangeTime ||
  136. (this.data.appointmentInfo as any).appointmentTime ||
  137. "";
  138. wx.navigateTo({
  139. url: `/module/order/pages/appointment/appointment?mode=edit&arrangeTime=${encodeURIComponent(arrangeTime)}`,
  140. });
  141. },
  142. });