Преглед на файлове

fix: 添加订阅接口

carver преди 2 години
родител
ревизия
7d54c16af7

+ 16 - 1
antbuilder/core/utils/ywtService.js

@@ -1,5 +1,6 @@
 import { ywtRequest } from "./request";
 
+// 进行授权
 export async function ywtAuth(data) {
 	const [err, res] = await ywtRequest({
 		url: "/auth/bind",
@@ -10,6 +11,7 @@ export async function ywtAuth(data) {
 	return [null, res];
 }
 
+// 获取挂号时段
 export async function doctorSchedule(data) {
 	const [err, res] = await ywtRequest({
 		url: "/register/doctorSchedule",
@@ -20,6 +22,7 @@ export async function doctorSchedule(data) {
 	return [null, res];
 }
 
+// 获取就医须知
 export async function getRegisteredAnnouncement(data) {
 	const [err, res] = await ywtRequest({
 		url: "/register/getRegisteredAnnouncement",
@@ -30,6 +33,7 @@ export async function getRegisteredAnnouncement(data) {
 	return [null, res];
 }
 
+// 获取就诊指南
 export async function getGuideList(data) {
 	const [err, res] = await ywtRequest({
 		url: "/commonAnnouncement/getGuideList",
@@ -38,4 +42,15 @@ export async function getGuideList(data) {
 	});
 	if (err || !res) return [err, null];
 	return [null, res];
-}
+}
+
+// 支付完成后提交 authCode
+export async function submitAuthCode(data) {
+	const [err, res] = await ywtRequest({
+		url: "/auth/submitAuthCode",
+		method: "post",
+		data,
+	});
+	if (err || !res) return [err, null];
+	return [null, res];
+}

+ 11 - 3
antbuilder/industry/hospitalV2/components/appointment-result/index.js

@@ -5,6 +5,7 @@ import history from "../../utils/history";
 import { tradePay } from "../../utils/tradePay";
 import { reportApi } from "../../utils/cloudMonitorHelper";
 import { getAuthUser } from "../../../../core/utils/jsapi";
+import { submitAuthCode } from "../../../../core/utils/ywtService";
 Component({
 	props: {},
 	data: {
@@ -182,7 +183,6 @@ Component({
 		// 消息订阅授权
 		async grantSubscribe(orderId) {
 			// todo 添加智能推送接口
-			console.log("orderId =====>", orderId);
 			const [err, authResult] = await getAuthUser([
 				"auth_user",
 				"hospital_order",
@@ -192,9 +192,17 @@ Component({
 					type: "fail",
 					content: "智能消息推送授权失败",
 				});
+			} else {
+				const [error, result] = await submitAuthCode({
+					authCode: authResult.authCode,
+				});
+				if (!error) {
+					my.showToast({
+						type: "success",
+						content: "消息订阅成功",
+					});
+				}
 			}
-			console.log("authResult ===>", authResult.authCode);
-			console.log("预约成功后调起消息订阅授权");
 		},
 
 		// 发起倒计时

+ 0 - 1
antbuilder/industry/hospitalV2/components/deposit-list/index.js

@@ -61,7 +61,6 @@ Component({
 					value: item.inpatientId,
 					label: item.inpatientName,
 				}));
-				console.log("typeOptions ==>", typeOptions);
 				this.setData({
 					typeOptions,
 					defaultName:

+ 31 - 3
antbuilder/industry/hospitalV2/components/hospital-project/index.js

@@ -10,6 +10,7 @@ import { getPatientList } from "../edit-patient/service";
 import history from "../../utils/history";
 import { tradePay } from "../../utils/tradePay";
 import { reportCmPV_YL } from "../../utils/cloudMonitorHelper";
+import { submitAuthCode } from "../../../../core/utils/ywtService";
 const deptCodeMap = {
 	黄石总院: 500,
 	沙河分院: 499,
@@ -107,7 +108,6 @@ Component(
 				const { questionList: formList } = await getQuestionnaire({
 					hospitalDistrictId,
 				});
-				console.log("query", query);
 				const projects = await getItemList({
 					hospitalDistrictId,
 					deptCode: deptCodeMap[query.hospitalName],
@@ -331,17 +331,25 @@ Component(
 							}
 						)
 							.then(async () => {
-								// todo 添加智能推送接口
 								const [err, authResult] = await getAuthUser([
 									"auth_user",
 									"hospital_order",
 								]);
-								console.log("authResult ===>", authResult.authCode);
 								if (err) {
 									my.showToast({
 										type: "fail",
 										content: "智能消息推送授权失败",
 									});
+								} else {
+									const [error, result] = await submitAuthCode({
+										authCode: authResult.authCode,
+									});
+									if (!error) {
+										my.showToast({
+											type: "success",
+											content: "消息订阅成功",
+										});
+									}
 								}
 								history.replace({
 									query: {
@@ -359,6 +367,26 @@ Component(
 								});
 							});
 					} else {
+						const [err, authResult] = await getAuthUser([
+							"auth_user",
+							"hospital_order",
+						]);
+						if (err) {
+							my.showToast({
+								type: "fail",
+								content: "智能消息推送授权失败",
+							});
+						} else {
+							const [error, result] = await submitAuthCode({
+								authCode: authResult.authCode,
+							});
+							if (!error) {
+								my.showToast({
+									type: "success",
+									content: "消息订阅成功",
+								});
+							}
+						}
 						history.replace({
 							query: {
 								hospitalDistrictId,

+ 98 - 106
antbuilder/industry/hospitalV2/components/index-head/indexHead.js

@@ -1,120 +1,112 @@
 import { prefixPagePath } from "../../../../core/utils";
-import { createSubscribe } from 'applet-page-component';
-import { reportCmPV_YL } from '../../utils/cloudMonitorHelper';
+import { createSubscribe } from "applet-page-component";
+import { reportCmPV_YL } from "../../utils/cloudMonitorHelper";
 const app = getApp();
 
-const getRect = id => new Promise(resolve => {
-  my.createSelectorQuery().select(`#${id}`).boundingClientRect().exec(resolve);
-});
+const getRect = (id) =>
+	new Promise((resolve) => {
+		my.createSelectorQuery()
+			.select(`#${id}`)
+			.boundingClientRect()
+			.exec(resolve);
+	});
 
-const getExtInfo = item => {
-  const {
-    componentExtInfo
-  } = item;
-  return componentExtInfo;
+const getExtInfo = (item) => {
+	const { componentExtInfo } = item;
+	return componentExtInfo;
 };
 
-Component(createSubscribe({
-  // eslint-disable-next-line no-unused-vars
-  async onPageScroll(_, {
-    scrollTop
-  }) {
-    const {
-      id,
-      isScrollOver
-    } = this.data;
-    let contentHeight = 0;
+Component(
+	createSubscribe({
+		// eslint-disable-next-line no-unused-vars
+		async onPageScroll(_, { scrollTop }) {
+			const { id, isScrollOver } = this.data;
+			let contentHeight = 0;
 
-    if (this.contentHeight) {
-      // eslint-disable-next-line prefer-destructuring
-      contentHeight = this.contentHeight;
-    } else {
-      const res = await getRect(id);
-      const [rect] = res;
-      const {
-        height = 0
-      } = rect || {};
-      contentHeight = height;
-    }
-    /* 这里动态设置标题栏 */
+			if (this.contentHeight) {
+				// eslint-disable-next-line prefer-destructuring
+				contentHeight = this.contentHeight;
+			} else {
+				const res = await getRect(id);
+				const [rect] = res;
+				const { height = 0 } = rect || {};
+				contentHeight = height;
+			}
+			/* 这里动态设置标题栏 */
 
+			if (scrollTop > contentHeight) {
+				if (!isScrollOver) {
+					const { componentData } = this.props;
+					const { title } = getExtInfo(componentData);
+					my.setNavigationBar({
+						title,
+					});
+					this.setData({
+						isScrollOver: true,
+					});
+				}
+			} else if (isScrollOver) {
+				my.setNavigationBar({
+					title: " ",
+				});
+				this.setData({
+					isScrollOver: false,
+				});
+			} else {
+				my.setNavigationBar({
+					title: " ",
+				});
+			}
+		},
+	})({
+		props: {
+			componentData: {},
+		},
+		data: {
+			navHeight: 72,
 
-    if (scrollTop > contentHeight) {
-      if (!isScrollOver) {
-        const {
-          componentData
-        } = this.props;
-        const {
-          title
-        } = getExtInfo(componentData);
-        my.setNavigationBar({
-          title
-        });
-        this.setData({
-          isScrollOver: true
-        });
-      }
-    } else if (isScrollOver) {
-      my.setNavigationBar({
-        title: ' '
-      });
-      this.setData({
-        isScrollOver: false
-      });
-    }
-  }
+			/* 消息通知是否显示 */
+			showMsg: true,
+			isScrollOver: false,
+			id: `index_heart_${Date.now()}`,
+			imgSrcPrefix: app.globalData.imgSrcPrefix,
+		},
 
-})({
-  props: {
-    componentData: {}
-  },
-  data: {
-    navHeight: 72,
+		didMount() {},
 
-    /* 消息通知是否显示 */
-    showMsg: true,
-    isScrollOver: false,
-    id: `index_heart_${Date.now()}`,
-    imgSrcPrefix: app.globalData.imgSrcPrefix
-  },
+		methods: {
+			/**
+			 * 关闭消息通知
+			 */
+			closeMsgBtn() {
+				this.setData({
+					showMsg: false,
+				});
+			},
 
-  didMount() {},
+			/**
+			 * 跳转到医院特色
+			 */
+			goToDetail() {
+				const pageCode = "hospital-characteristics";
+				my.navigateTo({
+					url: `${prefixPagePath}/one/index?pageCode=${pageCode}`,
+				});
+				/* 服务预警,医院介绍 */
 
-  methods: {
-    /**
-     * 关闭消息通知
-     */
-    closeMsgBtn() {
-      this.setData({
-        showMsg: false
-      });
-    },
+				reportCmPV_YL({
+					title: "医院介绍",
+				});
+			},
 
-    /**
-     * 跳转到医院特色
-     */
-    goToDetail() {
-      const pageCode = 'hospital-characteristics';
-      my.navigateTo({
-        url: `${prefixPagePath}/one/index?pageCode=${pageCode}`
-      });
-      /* 服务预警,医院介绍 */
-
-      reportCmPV_YL({
-        title: '医院介绍'
-      });
-    },
-
-    /**
-     * 获取头部初始头部初始padding-top
-     */
-    onCallback({
-      height
-    }) {
-      this.setData({
-        navHeight: height
-      });
-    }
-
-  }
-}));
+			/**
+			 * 获取头部初始头部初始padding-top
+			 */
+			onCallback({ height }) {
+				this.setData({
+					navHeight: height,
+				});
+			},
+		},
+	})
+);

+ 1 - 1
antbuilder/industry/hospitalV2/components/index-head/indexHead.sjs

@@ -57,7 +57,7 @@ const getSubTitle = (item) => {
 
 const getTitle = (item) => {
 	const { title } = getExtInfo(item);
-	return title || "";
+	return title || "首页";
 };
 
 export default {

+ 1 - 1
antbuilder/industry/hospitalV2/components/order-pay/index.js

@@ -156,7 +156,7 @@ Component(
 							).then(() => {
 								this.toDetail(data.orderId); // 支付成功以后,唤起消息订阅
 
-								this.subscribe.subscribeMessage();
+								// this.subscribe.subscribeMessage();
 							});
 						} else {
 							this.toDetail(data.orderId);

+ 8 - 8
antbuilder/industry/hospitalV2/components/pay-result/index.js

@@ -1,6 +1,6 @@
 import { getDepositDetails, getsubscribeID } from "./service";
 import { reportApi } from "../../utils/cloudMonitorHelper";
-// import { getAuthUser } from "../../../../core/utils/jsapi";
+import { getAuthUser } from "../../../../core/utils/jsapi";
 Component({
 	data: {
 		showSubscrible: true,
@@ -68,13 +68,13 @@ Component({
 				// 		console.log("authCode ===>", res.authCode);
 				// 	},
 				// });
-				// const [err, authResult] = await getAuthUser([
-				// 	"auth_user",
-				// 	"hospital_order",
-				// ]);
-				// console.log("authResult ===>", authResult.authCode);
-				// const subscribeID = await getsubscribeID();
-				// await this.requestSubscribeMessageFn(subscribeID.depositTemplateId);
+				const [err, authResult] = await getAuthUser([
+					"auth_user",
+					"hospital_order",
+				]);
+				console.log("authResult ===>", authResult.authCode);
+				const subscribeID = await getsubscribeID();
+				await this.requestSubscribeMessageFn(subscribeID.depositTemplateId);
 			} catch (error) {
 				console.log(error, "error");
 			}