index.js 2.0 KB

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