index.ts 7.6 KB

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