index.ts 7.0 KB

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