| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243 |
- import { common } from '@kasite/uni-app-base/utils';
- import { useIsToAuthPage, useGetDefaultMember } from '../hook';
- export { common } from '@kasite/uni-app-base/utils';
- export const menuClick = async (e, _this, skipWay = 'navigateTo') => {
- let itemParent = e.currentTarget ? e.currentTarget.dataset.itemParent : {};
- let item = e.currentTarget ? e.currentTarget.dataset.item : e;
- let url = item.Url;
- // 判断为分院区
- if (getApp().globalData.hasDistrict && item.MenuName == '预约挂号') {
- url = `/pagesPatient/st1/business/otherService/hospitalDistrict/hospitalDistrict`;
- }
- /**判断是否使用 */
- if (
- (itemParent && itemParent.IsUse && itemParent.IsUse != '1') ||
- (item.IsUse && item.IsUse != '1')
- ) {
- url = `/pages/st1/business/otherService/building/building`;
- common.goToUrl(url);
- return;
- }
- // 当日挂号需要判断距离
- if (item.MenuName == '当日挂号') {
- try {
- const limitDistance =
- getApp().globalData.config.pageConfiguration.signInList_config.signDistance || 1; // 判断半径(取签到距离配置)
- await getHospitalLocationDistance(limitDistance);
- } catch (err) {
- await new Promise((resolve) => {
- common.showModal('需到院后才能挂当日号,且不支持无就诊卡进行挂号操作', resolve, {
- title: '温馨提示',
- });
- });
- }
- }
- /**来院导航 */
- if (item.MenuName == '来院导航') {
- getLocation();
- return;
- }
- /**跳转小程序 */
- if (item.AppId) {
- wx.navigateToMiniProgram({
- appId: item.AppId,
- path: item.Url,
- });
- return;
- }
- /**判跳转第三方地址 */
- if (url.startsWith('https')) {
- common.goToUrl(`/pages/st1/business/h5/h5?url=${encodeURIComponent(url)}`);
- return;
- }
- /**如果有二级菜单页 */
- if (!common.isEmpty(item.Children)) {
- let queryBean = JSON.stringify(item);
- url = `${item.Url}`;
- /**queryBena太长无法传值 赋值给globalData */
- getApp().globalData.selectUrl_x = queryBean;
- }
- /**
- * 以下菜单 判断是否有就诊人 没有则进入添加页面
- */
- let needMemberMenu = [
- 'rechargeMoney', // 充值缴费
- 'reportIndex', // 报告查询
- 'appointmentRecord', // 预约记录
- 'outpatientCosts', // 门诊清单
- 'hospitalCosts', // 住院清单
- 'cardRecord', // 门诊记录
- 'hosRecord', // 住院记录
- 'supplement', // 互联网医院提交咨询
- 'enquireList', // 互联网医院咨询记录
- 'doctorLike', // 互联网医院关注医生
- 'signInList', // 在线签到
- 'queueList', // 候诊查询
- 'orderPayment', // 门诊结算
- 'prescriptionList', // 当日处方
- 'paymentRecord', // 缴费记录
- 'personalCenter', // 个人中心
- 'continuationList', // 在线续方
- 'drugCredentials', // 取药凭证
- 'settlementRecord', // 结算记录
- 'waitRecord', // 候补记录
- 'dischargeMedication', // 出院带药
- 'home', // 我的随访
- 'chat-room', // AI智能就医助手
- 'topUpRecord', //充值记录
- 'newPrescriptionList', //当日处方2.0
- 'prescriptionRecipe', //处方取药2.0
- 'medicalTech', // 医技预约
- 'outpatientRefund', //在线退费
- 'selfProject', // 自助开单
- 'mdtList', // MDT列表
- 'recordList', // MDT记录
- 'diseaseIndex', // 罕见病
- ];
- let has = false;
- for (let i of needMemberMenu) {
- if (url.indexOf(i) != '-1') {
- has = true;
- break;
- }
- }
- if (has) {
- // 是否需要跳转授权页
- if (useIsToAuthPage()) {
- return;
- }
- /**如果当前menu在上面数组中 判断是否有就诊人 有就诊人根据条件判断是否需要就诊卡、住院号、授权信息
- * 不满足条件跳转到相应添加就诊卡或添加住院号页面
- */
- if (await toAddMemberOrNot(url)) {
- return;
- }
- }
- common.goToUrl(url, {
- skipWay: skipWay,
- });
- };
- /** 来院导航 */
- export const getLocation = () => {
- let hospitalInfo = getApp().globalData.hospitalInfo;
- let data = {
- latitude: Number(hospitalInfo.Wd), //要去的纬度-地址
- longitude: Number(hospitalInfo.Jd), //要去的经度-地址
- name: hospitalInfo.HospitalAlias,
- address: hospitalInfo.HospitalAddress,
- };
- locationIsauthorization('gcj02', () => {
- uni.openLocation(data);
- });
- };
- /** 地理位置是否授权 */
- const locationIsauthorization = (type, callBack) => {
- uni.getLocation({
- type: type,
- success: function (res) {
- callBack(res);
- },
- fail: function (err) {
- if (err.errMsg.includes('1')) {
- common.showToast('访问个人地址失败,请查看是否开启地理位置权限');
- } else {
- common.showModal(
- '位置信息获取失败,请打开应用权限',
- () => {
- uni.openSetting({
- success: function (res) {
- res.authSetting['scope.userLocation'];
- },
- });
- },
- {
- cancelText: '取消',
- confirmText: '打开',
- }
- );
- }
- },
- });
- };
- /**
- * 获取当前位置与医院的距离
- * @param {Number} distance 距离半径(单位:公里)
- */
- export const getHospitalLocationDistance = async (limitDistance = 1) => {
- const { hospitalInfo } = getApp().globalData; // 获取医院信息
- if (common.isEmpty(hospitalInfo)) {
- common.showModal(`获取医院信息失败`);
- return;
- }
- const { Wd: hosLat, Jd: hosLng } = hospitalInfo;
- if (common.isEmpty(hosLat) || common.isEmpty(hosLng)) {
- common.showModal(`获取医院配置失败`);
- return;
- }
- return new Promise((resolve, reject) => {
- locationIsauthorization('gcj02', (res) => {
- let distance = common.getDistance(res.latitude, res.longitude, hosLat, hosLng);
- distance > limitDistance ? reject() : resolve(true);
- });
- });
- };
- /**
- * 判断当前是否有就诊人 没有则前往添加页面
- * 返回url 或 undefined
- */
- export const toAddMemberOrNot = async (url) => {
- let cardType = '1';
- /**如果支持无卡预约 以下菜单不判断是否有就诊卡:挂号记录 在线签到 结算记录*/
- if (getApp().globalData.withoutCard) {
- let needCardArr = ['appointmentRecord', 'signInList', 'settlementRecord'];
- for (let i of needCardArr) {
- if (url.indexOf(i) != '-1') {
- cardType = '';
- break;
- }
- }
- }
- /**以下菜单需要住院号:住院充值 住院报告 住院清单 住院记录 出院带药*/
- let needHosArr = [
- 'rechargeMoney?pageType=zyjf',
- 'reportIndex?queryType=2',
- 'hospitalCosts',
- 'hosRecord',
- 'dischargeMedication',
- ];
- for (let i of needHosArr) {
- if (url.indexOf(i) != '-1') {
- cardType = '14';
- break;
- }
- }
- let member = await useGetDefaultMember({
- isKeepPage: true,
- cardType: cardType,
- url: url,
- });
- if (common.isEmpty(member)) {
- // 判断如果是不全等于null 是跳转添加界面 ,因如果全等于null安卓机跳转中间件
- if (member !== null) {
- getApp().globalData.toUrl = url;
- getApp().globalData.cardType = cardType;
- common.goToUrl(
- `/pagesPersonal${
- uni.getStorageSync('wx_Slb') ? 'Slb' : ''
- }/st1/business/patientManagement/addMember/addMember`
- );
- }
- return true;
- }
- return false;
- };
|