index.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. import { orderDetail, cancelOrder, getHospitalInfo } from "./service";
  2. import history from "../../utils/history";
  3. import { reportApi } from "../../utils/cloudMonitorHelper";
  4. import {
  5. getSubscribeAuth,
  6. recordOpLog,
  7. } from "../../../../core/utils/ywtService";
  8. Component({
  9. data: {
  10. result: {},
  11. modalOpened: false,
  12. type: "",
  13. buttons: [
  14. {
  15. text: "不,先留着",
  16. },
  17. {
  18. text: "取消预约",
  19. extClass: "buttonBold",
  20. },
  21. ],
  22. hospitalDistrictId: "",
  23. hospitalInfo: {},
  24. },
  25. didMount() {
  26. const { type, hospitalDistrictId } = this.$page.data.query;
  27. this.setData({
  28. type,
  29. hospitalDistrictId,
  30. });
  31. this.getBookingDetails();
  32. this.getHospital(hospitalDistrictId);
  33. /* 服务办结,核酸预约成功 */
  34. reportApi("核酸预约成功");
  35. },
  36. methods: {
  37. async getBookingDetails() {
  38. const {
  39. query = {
  40. orderId: "",
  41. },
  42. } = this.$page.data;
  43. my.showLoading();
  44. orderDetail({
  45. orderId: query.orderId,
  46. }).then((data) => {
  47. this.setData({
  48. result: data,
  49. });
  50. my.hideLoading();
  51. });
  52. },
  53. async getHospital(hospitalDistrictId) {
  54. const hospitalInfo = await getHospitalInfo({
  55. hospitalDistrictId,
  56. });
  57. this.setData({
  58. hospitalInfo: hospitalInfo.configInfo,
  59. });
  60. },
  61. handleOpenCheck(e) {
  62. const { url } = e.target.dataset;
  63. history.toH5(url);
  64. },
  65. handleBack() {
  66. const len = getCurrentPages().length;
  67. my.navigateBack({
  68. delta: len - 2,
  69. });
  70. },
  71. // 确认取消预约
  72. handleCancelBook() {
  73. my.confirm({
  74. title: "确认取消预约?",
  75. content: "已支付金额会退回原付款账户",
  76. confirmButtonText: "取消预约",
  77. cancelButtonText: "不,先留着",
  78. success: async ({ confirm }) => {
  79. if (confirm) {
  80. const {
  81. query = {
  82. orderId: "",
  83. },
  84. } = this.$page.data;
  85. await recordOpLog({ type: 191 });
  86. await getSubscribeAuth();
  87. cancelOrder({
  88. orderId: query.orderId,
  89. reason: "",
  90. }).then(() => {
  91. this.handleBack();
  92. });
  93. }
  94. },
  95. });
  96. },
  97. },
  98. });