index.js 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. "use strict";
  2. const common_vendor = require("../common/vendor.js");
  3. const menuClick = async (e, _this, skipWay = "navigateTo") => {
  4. let itemParent = e.currentTarget ? e.currentTarget.dataset.itemParent : {};
  5. let item = e.currentTarget ? e.currentTarget.dataset.item : e;
  6. let url = item.Url;
  7. if (getApp().globalData.hasDistrict && item.MenuName == "预约挂号") {
  8. url = `/pagesPatient/st1/business/otherService/hospitalDistrict/hospitalDistrict`;
  9. }
  10. if (itemParent && itemParent.IsUse && itemParent.IsUse != "1" || item.IsUse && item.IsUse != "1") {
  11. url = `/pages/st1/business/otherService/building/building`;
  12. common_vendor.goToUrl(url);
  13. return;
  14. }
  15. if (item.MenuName == "当日挂号") {
  16. try {
  17. const limitDistance = getApp().globalData.config.pageConfiguration.signInList_config.signDistance || 1;
  18. await getHospitalLocationDistance(limitDistance);
  19. } catch (err) {
  20. await new Promise((resolve) => {
  21. common_vendor.showModal("需到院后才能挂当日号,且不支持无就诊卡进行挂号操作", resolve, {
  22. title: "温馨提示"
  23. });
  24. });
  25. }
  26. }
  27. if (item.MenuName == "来院导航") {
  28. getLocation();
  29. return;
  30. }
  31. if (item.AppId) {
  32. common_vendor.wx$1.navigateToMiniProgram({
  33. appId: item.AppId,
  34. path: item.Url
  35. });
  36. return;
  37. }
  38. if (url.startsWith("https")) {
  39. common_vendor.goToUrl(`/pages/st1/business/h5/h5?url=${encodeURIComponent(url)}`);
  40. return;
  41. }
  42. if (!common_vendor.isEmpty(item.Children)) {
  43. let queryBean = JSON.stringify(item);
  44. url = `${item.Url}`;
  45. getApp().globalData.selectUrl_x = queryBean;
  46. }
  47. let needMemberMenu = [
  48. "rechargeMoney",
  49. // 充值缴费
  50. "reportIndex",
  51. // 报告查询
  52. "appointmentRecord",
  53. // 预约记录
  54. "outpatientCosts",
  55. // 门诊清单
  56. "hospitalCosts",
  57. // 住院清单
  58. "cardRecord",
  59. // 门诊记录
  60. "hosRecord",
  61. // 住院记录
  62. "supplement",
  63. // 互联网医院提交咨询
  64. "enquireList",
  65. // 互联网医院咨询记录
  66. "doctorLike",
  67. // 互联网医院关注医生
  68. "signInList",
  69. // 在线签到
  70. "queueList",
  71. // 候诊查询
  72. "orderPayment",
  73. // 门诊结算
  74. "prescriptionList",
  75. // 当日处方
  76. "paymentRecord",
  77. // 缴费记录
  78. "personalCenter",
  79. // 个人中心
  80. "continuationList",
  81. // 在线续方
  82. "drugCredentials",
  83. // 取药凭证
  84. "settlementRecord",
  85. // 结算记录
  86. "waitRecord",
  87. // 候补记录
  88. "dischargeMedication",
  89. // 出院带药
  90. "home",
  91. // 我的随访
  92. "chat-room",
  93. // AI智能就医助手
  94. "topUpRecord",
  95. //充值记录
  96. "newPrescriptionList",
  97. //当日处方2.0
  98. "prescriptionRecipe",
  99. //处方取药2.0
  100. "medicalTech",
  101. // 医技预约
  102. "outpatientRefund",
  103. //在线退费
  104. "selfProject",
  105. // 自助开单
  106. "mdtList",
  107. // MDT列表
  108. "recordList",
  109. // MDT记录
  110. "diseaseIndex"
  111. // 罕见病
  112. ];
  113. let has = false;
  114. for (let i of needMemberMenu) {
  115. if (url.indexOf(i) != "-1") {
  116. has = true;
  117. break;
  118. }
  119. }
  120. if (has) {
  121. if (common_vendor.useIsToAuthPage()) {
  122. return;
  123. }
  124. if (await toAddMemberOrNot(url)) {
  125. return;
  126. }
  127. }
  128. common_vendor.goToUrl(url, {
  129. skipWay
  130. });
  131. };
  132. const getLocation = () => {
  133. let hospitalInfo = getApp().globalData.hospitalInfo;
  134. let data = {
  135. latitude: Number(hospitalInfo.Wd),
  136. //要去的纬度-地址
  137. longitude: Number(hospitalInfo.Jd),
  138. //要去的经度-地址
  139. name: hospitalInfo.HospitalAlias,
  140. address: hospitalInfo.HospitalAddress
  141. };
  142. locationIsauthorization("gcj02", () => {
  143. common_vendor.index.openLocation(data);
  144. });
  145. };
  146. const locationIsauthorization = (type, callBack) => {
  147. common_vendor.index.getLocation({
  148. type,
  149. success: function(res) {
  150. callBack(res);
  151. },
  152. fail: function(err) {
  153. if (err.errMsg.includes("1")) {
  154. common_vendor.showToast("访问个人地址失败,请查看是否开启地理位置权限");
  155. } else {
  156. common_vendor.showModal(
  157. "位置信息获取失败,请打开应用权限",
  158. () => {
  159. common_vendor.index.openSetting({
  160. success: function(res) {
  161. res.authSetting["scope.userLocation"];
  162. }
  163. });
  164. },
  165. {
  166. cancelText: "取消",
  167. confirmText: "打开"
  168. }
  169. );
  170. }
  171. }
  172. });
  173. };
  174. const getHospitalLocationDistance = async (limitDistance = 1) => {
  175. const { hospitalInfo } = getApp().globalData;
  176. if (common_vendor.isEmpty(hospitalInfo)) {
  177. common_vendor.showModal(`获取医院信息失败`);
  178. return;
  179. }
  180. const { Wd: hosLat, Jd: hosLng } = hospitalInfo;
  181. if (common_vendor.isEmpty(hosLat) || common_vendor.isEmpty(hosLng)) {
  182. common_vendor.showModal(`获取医院配置失败`);
  183. return;
  184. }
  185. return new Promise((resolve, reject) => {
  186. locationIsauthorization("gcj02", (res) => {
  187. let distance = common_vendor.getDistance(res.latitude, res.longitude, hosLat, hosLng);
  188. distance > limitDistance ? reject() : resolve(true);
  189. });
  190. });
  191. };
  192. const toAddMemberOrNot = async (url) => {
  193. let cardType = "1";
  194. if (getApp().globalData.withoutCard) {
  195. let needCardArr = ["appointmentRecord", "signInList", "settlementRecord"];
  196. for (let i of needCardArr) {
  197. if (url.indexOf(i) != "-1") {
  198. cardType = "";
  199. break;
  200. }
  201. }
  202. }
  203. let needHosArr = [
  204. "rechargeMoney?pageType=zyjf",
  205. "reportIndex?queryType=2",
  206. "hospitalCosts",
  207. "hosRecord",
  208. "dischargeMedication"
  209. ];
  210. for (let i of needHosArr) {
  211. if (url.indexOf(i) != "-1") {
  212. cardType = "14";
  213. break;
  214. }
  215. }
  216. let member = await common_vendor.useGetDefaultMember({
  217. isKeepPage: true,
  218. cardType,
  219. url
  220. });
  221. if (common_vendor.isEmpty(member)) {
  222. if (member !== null) {
  223. getApp().globalData.toUrl = url;
  224. getApp().globalData.cardType = cardType;
  225. common_vendor.goToUrl(
  226. `/pagesPersonal${common_vendor.index.getStorageSync("wx_Slb") ? "Slb" : ""}/st1/business/patientManagement/addMember/addMember`
  227. );
  228. }
  229. return true;
  230. }
  231. return false;
  232. };
  233. exports.menuClick = menuClick;
  234. //# sourceMappingURL=../../.sourcemap/mp-weixin/utils/index.js.map