index.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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. if (len <= 1) {
  68. my.redirectTo({
  69. url: "/antbuilder/core/pages/home/index",
  70. });
  71. } else {
  72. my.navigateBack({
  73. delta: len - 2,
  74. });
  75. }
  76. },
  77. // 确认取消预约
  78. handleCancelBook() {
  79. my.confirm({
  80. title: "确认取消预约?",
  81. content: "已支付金额会退回原付款账户",
  82. confirmButtonText: "取消预约",
  83. cancelButtonText: "不,先留着",
  84. success: async ({ confirm }) => {
  85. if (confirm) {
  86. const {
  87. query = {
  88. orderId: "",
  89. },
  90. } = this.$page.data;
  91. await recordOpLog({ type: 195 });
  92. await getSubscribeAuth();
  93. cancelOrder({
  94. orderId: query.orderId,
  95. reason: "",
  96. }).then(() => {
  97. this.handleBack();
  98. });
  99. }
  100. },
  101. });
  102. },
  103. },
  104. });