index.ts 7.4 KB

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