index.js 2.2 KB

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