Procházet zdrojové kódy

fix: 取消预约之前要进行消息推送授权

carver před 2 roky
rodič
revize
a5916642dd

+ 295 - 308
antbuilder/industry/abMall/components/order-detail/index.js

@@ -1,338 +1,325 @@
 /* eslint-disable arrow-parens */
-import { cancelOrder, orderBuyAgain, orderPayCreate, queryOrderStatus, queryForOrderDetail, confirmTakeDelivery, confirmReceiveDelivery } from './service';
-import { connect } from 'herculex';
-import { tradePay } from '../../utils/tradePay';
-import history from '../../utils/history';
-Component(connect({
-  mapStateToProps: {}
-})({
-  props: {
-    componentData: {}
-  },
-  data: {
-    loadMore: false,
-    list: [],
-    orderId: '',
-    detailData: null,
-    startPoll: false,
-    btnText: '去支付',
-    addressData: null
-  },
+import {
+	cancelOrder,
+	orderBuyAgain,
+	orderPayCreate,
+	queryOrderStatus,
+	queryForOrderDetail,
+	confirmTakeDelivery,
+	confirmReceiveDelivery,
+} from "./service";
+import { connect } from "herculex";
+import { tradePay } from "../../utils/tradePay";
+import history from "../../utils/history";
+import { getSubscribeAuth } from "../../../../core/utils/ywtService";
+Component(
+	connect({
+		mapStateToProps: {},
+	})({
+		props: {
+			componentData: {},
+		},
+		data: {
+			loadMore: false,
+			list: [],
+			orderId: "",
+			detailData: null,
+			startPoll: false,
+			btnText: "去支付",
+			addressData: null,
+		},
 
-  async didMount() {
-    // eslint-disable-next-line prefer-const
-    let {
-      orderId = '',
-      alipayTradeNo = '',
-      poll = ''
-    } = this.$page.data.query || my.getLaunchOptionsSync().query || {};
+		async didMount() {
+			// eslint-disable-next-line prefer-const
+			let {
+				orderId = "",
+				alipayTradeNo = "",
+				poll = "",
+			} = this.$page.data.query || my.getLaunchOptionsSync().query || {};
 
-    if (!orderId) {
-      orderId = getCurrentPages()[0].options.orderId || '';
-    }
+			if (!orderId) {
+				orderId = getCurrentPages()[0].options.orderId || "";
+			}
 
-    this.orderId = orderId;
-    this.alipayTradeNo = alipayTradeNo; // res :  {goods, ...rest }
+			this.orderId = orderId;
+			this.alipayTradeNo = alipayTradeNo; // res :  {goods, ...rest }
 
-    try {
-      await this.queryDetail(orderId); // // poll 有值  默认开启轮询
+			try {
+				await this.queryDetail(orderId); // // poll 有值  默认开启轮询
 
-      if (poll) {
-        my.showLoading({
-          content: '支付中...'
-        });
-        this.setData({
-          startPoll: true,
-          btnText: '支付中'
-        }); // 支付
+				if (poll) {
+					my.showLoading({
+						content: "支付中...",
+					});
+					this.setData({
+						startPoll: true,
+						btnText: "支付中",
+					}); // 支付
 
-        await tradePay(alipayTradeNo, orderId);
-      }
-    } catch (error) {
-      my.hideLoading();
-      const {
-        type = '',
-        msg = ''
-      } = error;
+					await tradePay(alipayTradeNo, orderId);
+				}
+			} catch (error) {
+				my.hideLoading();
+				const { type = "", msg = "" } = error;
 
-      if (type === 'cancel') {
-        this.setData({
-          startPoll: false,
-          btnText: '去支付'
-        });
-      }
+				if (type === "cancel") {
+					this.setData({
+						startPoll: false,
+						btnText: "去支付",
+					});
+				}
 
-      my.showToast({
-        type: 'fail',
-        content: msg || '查询订单失败'
-      });
-    }
-  },
+				my.showToast({
+					type: "fail",
+					content: msg || "查询订单失败",
+				});
+			}
+		},
 
-  didUpdate() {},
+		didUpdate() {},
 
-  methods: {
-    // 查询订单详情
-    async queryDetail(orderId) {
-      const res = await queryForOrderDetail({
-        orderId
-      }); // 订单详情
+		methods: {
+			// 查询订单详情
+			async queryDetail(orderId) {
+				const res = await queryForOrderDetail({
+					orderId,
+				}); // 订单详情
 
-      const list = res.goods;
-      const {
-        addressInfo = {}
-      } = res;
-      this.setData({
-        orderId,
-        list,
-        detailData: res,
-        addressData: {
-          name: addressInfo.userName || '',
-          mobile: addressInfo.userPhone || '',
-          latitude: addressInfo.latitude || '',
-          longitude: addressInfo.longitude || '',
-          address: addressInfo.detail || '',
-          addressNumber: addressInfo.addressNumber || '',
-          isDefault: addressInfo.status || '',
-          provinceName: addressInfo.provinceName || '',
-          cityName: addressInfo.cityName || '',
-          districtName: addressInfo.districtName || ''
-        }
-      });
-    },
+				const list = res.goods;
+				const { addressInfo = {} } = res;
+				this.setData({
+					orderId,
+					list,
+					detailData: res,
+					addressData: {
+						name: addressInfo.userName || "",
+						mobile: addressInfo.userPhone || "",
+						latitude: addressInfo.latitude || "",
+						longitude: addressInfo.longitude || "",
+						address: addressInfo.detail || "",
+						addressNumber: addressInfo.addressNumber || "",
+						isDefault: addressInfo.status || "",
+						provinceName: addressInfo.provinceName || "",
+						cityName: addressInfo.cityName || "",
+						districtName: addressInfo.districtName || "",
+					},
+				});
+			},
 
-    // 确认收货
-    async onConfirmReceiveClick() {
-      const {
-        list = []
-      } = this.data;
-      my.confirm({
-        title: '确认收货',
-        content: `当前订单共${list.length}件商品,请收到实物无误后再确认收货`,
-        success: async res => {
-          if (res.confirm) {
-            const {
-              orderId
-            } = this.data;
+			// 确认收货
+			async onConfirmReceiveClick() {
+				const { list = [] } = this.data;
+				my.confirm({
+					title: "确认收货",
+					content: `当前订单共${list.length}件商品,请收到实物无误后再确认收货`,
+					success: async (res) => {
+						if (res.confirm) {
+							const { orderId } = this.data;
 
-            try {
-              const flag = await confirmReceiveDelivery({
-                orderId
-              });
-              my.showToast({
-                content: flag ? '收货成功' : '收货失败',
-                type: 'none',
-                success: () => {
-                  this.queryDetail(orderId);
-                }
-              });
-            } catch (err) {
-              my.showToast({
-                content: '收货失败',
-                type: 'none'
-              });
-            }
-          }
-        }
-      });
-    },
+							try {
+								const flag = await confirmReceiveDelivery({
+									orderId,
+								});
+								my.showToast({
+									content: flag ? "收货成功" : "收货失败",
+									type: "none",
+									success: () => {
+										this.queryDetail(orderId);
+									},
+								});
+							} catch (err) {
+								my.showToast({
+									content: "收货失败",
+									type: "none",
+								});
+							}
+						}
+					},
+				});
+			},
 
-    // 主动提货
-    async onConfirmClick(e) {
-      const {
-        redeemQrValue
-      } = e;
-      const {
-        list = []
-      } = this.data;
-      my.confirm({
-        title: '确认提货',
-        content: `当前订单共${list.length}件商品,请收到实物无误后再确认提货`,
-        success: async res => {
-          if (res.confirm) {
-            const {
-              orderId
-            } = this.data;
+			// 主动提货
+			async onConfirmClick(e) {
+				const { redeemQrValue } = e;
+				const { list = [] } = this.data;
+				my.confirm({
+					title: "确认提货",
+					content: `当前订单共${list.length}件商品,请收到实物无误后再确认提货`,
+					success: async (res) => {
+						if (res.confirm) {
+							const { orderId } = this.data;
 
-            try {
-              const flag = await confirmTakeDelivery({
-                orderId,
-                redeemCode: redeemQrValue
-              });
-              my.showToast({
-                content: flag ? '提货成功' : '提货失败',
-                type: 'none',
-                success: () => {
-                  this.queryDetail(orderId);
-                }
-              });
-            } catch (err) {
-              my.showToast({
-                content: '提货失败',
-                type: 'none'
-              });
-            }
-          }
-        }
-      });
-    },
+							try {
+								const flag = await confirmTakeDelivery({
+									orderId,
+									redeemCode: redeemQrValue,
+								});
+								my.showToast({
+									content: flag ? "提货成功" : "提货失败",
+									type: "none",
+									success: () => {
+										this.queryDetail(orderId);
+									},
+								});
+							} catch (err) {
+								my.showToast({
+									content: "提货失败",
+									type: "none",
+								});
+							}
+						}
+					},
+				});
+			},
 
-    loadMoreItem() {
-      this.setData({
-        loadMore: true
-      });
-    },
+			loadMoreItem() {
+				this.setData({
+					loadMore: true,
+				});
+			},
 
-    // 点击取消订单按钮
-    handelCancel() {
-      my.confirm({
-        title: '',
-        content: '确认取消订单吗?',
-        confirmButtonText: '确认',
-        cancelButtonText: '取消',
-        success: result => {
-          if (result.confirm) {
-            // 发起请求
-            this.publicOrderFun(async orderId => {
-              await cancelOrder({
-                orderId
-              });
-              this.navToDetail();
-            });
-          }
-        }
-      });
-    },
+			// 点击取消订单按钮
+			handelCancel() {
+				my.confirm({
+					title: "",
+					content: "确认取消订单吗?",
+					confirmButtonText: "确认",
+					cancelButtonText: "取消",
+					success: async (result) => {
+						if (result.confirm) {
+							// 发起请求
+							await getSubscribeAuth();
+							this.publicOrderFun(async (orderId) => {
+								await cancelOrder({
+									orderId,
+								});
+								this.navToDetail();
+							});
+						}
+					},
+				});
+			},
 
-    // 轮询结束进行的操作
-    handelFunCallBack() {
-      my.hideLoading();
-      my.showToast({
-        type: 'fail',
-        content: '支付失败'
-      });
-      this.navToDetail();
-    },
+			// 轮询结束进行的操作
+			handelFunCallBack() {
+				my.hideLoading();
+				my.showToast({
+					type: "fail",
+					content: "支付失败",
+				});
+				this.navToDetail();
+			},
 
-    // 执行的判断操作
-    async handelStartFun() {
-      const {
-        payStatus = ''
-      } = await queryOrderStatus({
-        orderId: this.orderId
-      });
+			// 执行的判断操作
+			async handelStartFun() {
+				const { payStatus = "" } = await queryOrderStatus({
+					orderId: this.orderId,
+				});
 
-      if (payStatus === 'PAYED') {
-        this.setData({
-          startPoll: false,
-          btnText: '支付成功'
-        });
-        my.hideLoading();
-        my.showToast({
-          type: 'success',
-          content: '支付成功'
-        });
-        this.navToDetail();
-      }
-    },
+				if (payStatus === "PAYED") {
+					this.setData({
+						startPoll: false,
+						btnText: "支付成功",
+					});
+					my.hideLoading();
+					my.showToast({
+						type: "success",
+						content: "支付成功",
+					});
+					this.navToDetail();
+				}
+			},
 
-    // 去支付
-    handelPay() {
-      my.showLoading({
-        content: '支付中...'
-      });
-      this.publicOrderFun(async orderId => {
-        const {
-          alipayTradeNo = '',
-          status = ''
-        } = await orderPayCreate({
-          orderId
-        });
-        my.hideLoading(); // 无单号 云支付有错
+			// 去支付
+			handelPay() {
+				my.showLoading({
+					content: "支付中...",
+				});
+				this.publicOrderFun(async (orderId) => {
+					const { alipayTradeNo = "", status = "" } = await orderPayCreate({
+						orderId,
+					});
+					my.hideLoading(); // 无单号 云支付有错
 
-        if (!alipayTradeNo) {
-          return my.showToast({
-            type: 'fail',
-            content: '云支付失败'
-          });
-        } // 有支付单号 直接支付
+					if (!alipayTradeNo) {
+						return my.showToast({
+							type: "fail",
+							content: "云支付失败",
+						});
+					} // 有支付单号 直接支付
 
+					if (alipayTradeNo && status !== "PAYED") {
+						my.showLoading({
+							content: "支付中...",
+						});
+						this.setData({
+							startPoll: true,
+							btnText: "支付中",
+						});
+						await tradePay(alipayTradeNo, orderId);
+					}
+				});
+			},
 
-        if (alipayTradeNo && status !== 'PAYED') {
-          my.showLoading({
-            content: '支付中...'
-          });
-          this.setData({
-            startPoll: true,
-            btnText: '支付中'
-          });
-          await tradePay(alipayTradeNo, orderId);
-        }
-      });
-    },
+			// 再来一单
+			handelMoreOrder() {
+				this.publicOrderFun(async (orderId) => {
+					await orderBuyAgain({
+						orderId,
+					});
+					my.showToast({
+						type: "success",
+						content: "已添加至购物车",
+					});
+					my.reLaunch({
+						url: "/antbuilder/core/pages/home/index?pageCode=mall",
+					});
+				});
+			},
 
-    // 再来一单
-    handelMoreOrder() {
-      this.publicOrderFun(async orderId => {
-        await orderBuyAgain({
-          orderId
-        });
-        my.showToast({
-          type: 'success',
-          content: '已添加至购物车'
-        });
-        my.reLaunch({
-          url: '/antbuilder/core/pages/home/index?pageCode=mall'
-        });
-      });
-    },
+			copyNum() {
+				my.setClipboard({
+					text: this.data.orderId,
+				});
+				my.alert({
+					title: "复制成功",
+				});
+			},
 
-    copyNum() {
-      my.setClipboard({
-        text: this.data.orderId
-      });
-      my.alert({
-        title: '复制成功'
-      });
-    },
+			// 跳转详情方法
+			navToDetail() {
+				history.replace({
+					title: "订单详情",
+					pageType: "mallOrderDetail",
+					query: {
+						orderId: this.orderId,
+					},
+					header: "",
+				});
+			},
 
-    // 跳转详情方法
-    navToDetail() {
-      history.replace({
-        title: '订单详情',
-        pageType: 'mallOrderDetail',
-        query: {
-          orderId: this.orderId
-        },
-        header: ''
-      });
-    },
+			// 公共失败时展示toast
+			async publicOrderFun(fn) {
+				try {
+					await fn(this.orderId);
+				} catch (err) {
+					my.hideLoading();
+					const { type = "", msg = "" } = err; // 如果调取支付存在失败
 
-    // 公共失败时展示toast
-    async publicOrderFun(fn) {
-      try {
-        await fn(this.orderId);
-      } catch (err) {
-        my.hideLoading();
-        const {
-          type = '',
-          msg = ''
-        } = err; // 如果调取支付存在失败
+					if (type === "cancel") {
+						this.setData({
+							startPoll: false,
+							btnText: "去支付",
+						});
+					}
 
-        if (type === 'cancel') {
-          this.setData({
-            startPoll: false,
-            btnText: '去支付'
-          });
-        }
-
-        my.showToast({
-          type: 'fail',
-          content: msg || '请求失败'
-        });
-        this.navToDetail();
-      }
-    }
-
-  }
-}));
+					my.showToast({
+						type: "fail",
+						content: msg || "请求失败",
+					});
+					this.navToDetail();
+				}
+			},
+		},
+	})
+);

+ 48 - 48
antbuilder/industry/hospital/components/components/record-detail/index.js

@@ -1,54 +1,54 @@
-import { cancelOrder } from '../../utils/service';
+import { cancelOrder } from "../../utils/service";
 import { toast } from "../../../../../core/utils";
-Component({
-  props: {
-    showStatus: true,
-    detail: {},
-    onRefresh: () => {}
-  },
-  methods: {
-    // 取消预约
-    cancelOrder() {
-      const {
-        detail
-      } = this.props;
-      let statusStr = '';
+import { getSubscribeAuth } from "../../../../../core/utils/ywtService";
 
-      if (detail.status === 0) {
-        statusStr = '待支付';
-      } else if (detail.status === 1) {
-        statusStr = '已支付';
-      } else if (detail.status === 2) {
-        statusStr = '已取消';
-      }
+Component({
+	props: {
+		showStatus: true,
+		detail: {},
+		onRefresh: () => {},
+	},
+	methods: {
+		// 取消预约
+		cancelOrder() {
+			const { detail } = this.props;
+			let statusStr = "";
 
-      my.prompt({
-        title: '取消预约',
-        message: `当前状态为: ${statusStr}`,
-        placeholder: '请输入取消原因',
-        okButtonText: '确定',
-        cancelButtonText: '取消',
-        success: result => {
-          if (result.ok) {
-            this.cancleConfirm(result);
-          }
-        }
-      });
-    },
+			if (detail.status === 0) {
+				statusStr = "待支付";
+			} else if (detail.status === 1) {
+				statusStr = "已支付";
+			} else if (detail.status === 2) {
+				statusStr = "已取消";
+			}
 
-    async cancleConfirm(msg) {
-      const params = {
-        orderId: this.props.detail.orderId,
-        reason: msg.inputValue
-      };
-      const [err] = await cancelOrder(params);
+			my.prompt({
+				title: "取消预约",
+				message: `当前状态为: ${statusStr}`,
+				placeholder: "请输入取消原因",
+				okButtonText: "确定",
+				cancelButtonText: "取消",
+				success: async (result) => {
+					if (result.ok) {
+						await getSubscribeAuth();
+						this.cancleConfirm(result);
+					}
+				},
+			});
+		},
 
-      if (!err) {
-        toast('预约取消成功');
-        getApp().globalData.cancelReservation = true;
-        this.props.onRefresh(params.orderId);
-      }
-    }
+		async cancleConfirm(msg) {
+			const params = {
+				orderId: this.props.detail.orderId,
+				reason: msg.inputValue,
+			};
+			const [err] = await cancelOrder(params);
 
-  }
-});
+			if (!err) {
+				toast("预约取消成功");
+				getApp().globalData.cancelReservation = true;
+				this.props.onRefresh(params.orderId);
+			}
+		},
+	},
+});

+ 2 - 1
antbuilder/industry/hospitalV2/components/appointment-result/index.js

@@ -141,7 +141,7 @@ Component({
 		},
 
 		// 确认取消预约
-		onButtonClick(e) {
+		async onButtonClick(e) {
 			this.setData({
 				modalOpened: false,
 			});
@@ -152,6 +152,7 @@ Component({
 						orderId: "",
 					},
 				} = this.$page.data;
+				await getSubscribeAuth();
 				cancelOrder({
 					orderId: query.orderId,
 					reason: "",

+ 94 - 95
antbuilder/industry/hospitalV2/components/booking-detail/index.js

@@ -1,104 +1,103 @@
-import { orderDetail, cancelOrder, getHospitalInfo } from './service';
-import history from '../../utils/history';
-import { reportApi } from '../../utils/cloudMonitorHelper';
+import { orderDetail, cancelOrder, getHospitalInfo } from "./service";
+import history from "../../utils/history";
+import { reportApi } from "../../utils/cloudMonitorHelper";
+import { getSubscribeAuth } from "../../../../core/utils/ywtService";
+
 Component({
-  data: {
-    result: {},
-    modalOpened: false,
-    type: '',
-    buttons: [{
-      text: '不,先留着'
-    }, {
-      text: '取消预约',
-      extClass: 'buttonBold'
-    }],
-    hospitalDistrictId: '',
-    hospitalInfo: {}
-  },
+	data: {
+		result: {},
+		modalOpened: false,
+		type: "",
+		buttons: [
+			{
+				text: "不,先留着",
+			},
+			{
+				text: "取消预约",
+				extClass: "buttonBold",
+			},
+		],
+		hospitalDistrictId: "",
+		hospitalInfo: {},
+	},
 
-  didMount() {
-    const {
-      type,
-      hospitalDistrictId
-    } = this.$page.data.query;
-    this.setData({
-      type,
-      hospitalDistrictId
-    });
-    this.getBookingDetails();
-    this.getHospital(hospitalDistrictId);
-    /* 服务办结,核酸预约成功 */
+	didMount() {
+		const { type, hospitalDistrictId } = this.$page.data.query;
+		this.setData({
+			type,
+			hospitalDistrictId,
+		});
+		this.getBookingDetails();
+		this.getHospital(hospitalDistrictId);
+		/* 服务办结,核酸预约成功 */
 
-    reportApi('核酸预约成功');
-  },
+		reportApi("核酸预约成功");
+	},
 
-  methods: {
-    async getBookingDetails() {
-      const {
-        query = {
-          orderId: ''
-        }
-      } = this.$page.data;
-      my.showLoading();
-      orderDetail({
-        orderId: query.orderId
-      }).then(data => {
-        this.setData({
-          result: data
-        });
-        my.hideLoading();
-      });
-    },
+	methods: {
+		async getBookingDetails() {
+			const {
+				query = {
+					orderId: "",
+				},
+			} = this.$page.data;
+			my.showLoading();
+			orderDetail({
+				orderId: query.orderId,
+			}).then((data) => {
+				this.setData({
+					result: data,
+				});
+				my.hideLoading();
+			});
+		},
 
-    async getHospital(hospitalDistrictId) {
-      const hospitalInfo = await getHospitalInfo({
-        hospitalDistrictId
-      });
-      this.setData({
-        hospitalInfo: hospitalInfo.configInfo
-      });
-    },
+		async getHospital(hospitalDistrictId) {
+			const hospitalInfo = await getHospitalInfo({
+				hospitalDistrictId,
+			});
+			this.setData({
+				hospitalInfo: hospitalInfo.configInfo,
+			});
+		},
 
-    handleOpenCheck(e) {
-      const {
-        url
-      } = e.target.dataset;
-      history.toH5(url);
-    },
+		handleOpenCheck(e) {
+			const { url } = e.target.dataset;
+			history.toH5(url);
+		},
 
-    handleBack() {
-      const len = getCurrentPages().length;
-      my.navigateBack({
-        delta: len - 2
-      });
-    },
+		handleBack() {
+			const len = getCurrentPages().length;
+			my.navigateBack({
+				delta: len - 2,
+			});
+		},
 
-    // 确认取消预约
-    handleCancelBook() {
-      my.confirm({
-        title: '确认取消预约?',
-        content: '已支付金额会退回原付款账户',
-        confirmButtonText: '取消预约',
-        cancelButtonText: '不,先留着',
-        success: async ({
-          confirm
-        }) => {
-          if (confirm) {
-            const {
-              query = {
-                orderId: ''
-              }
-            } = this.$page.data;
-            cancelOrder({
-              orderId: query.orderId,
-              reason: ''
-            }).then(() => {
-              this.handleBack();
-            });
-          }
-        }
-      });
-    }
+		// 确认取消预约
+		handleCancelBook() {
+			my.confirm({
+				title: "确认取消预约?",
+				content: "已支付金额会退回原付款账户",
+				confirmButtonText: "取消预约",
+				cancelButtonText: "不,先留着",
+				success: async ({ confirm }) => {
+					if (confirm) {
+						const {
+							query = {
+								orderId: "",
+							},
+						} = this.$page.data;
+						await getSubscribeAuth();
 
-  }
-});
+						cancelOrder({
+							orderId: query.orderId,
+							reason: "",
+						}).then(() => {
+							this.handleBack();
+						});
+					}
+				},
+			});
+		},
+	},
+});