| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978 |
- /**
- * 页面公用逻辑函数
- */
- import { common } from '@kasite/uni-app-base/utils';
- import icon from './icon.js';
- import { request } from '@kasite/uni-app-base';
- import { REQUEST_CONFIG } from '@/config';
- // Helper to simulate old base API return structure
- const callApi = async (url, data) => {
- try {
- const resData = await request.doPost(`${REQUEST_CONFIG.BASE_URL}${url}`, data);
- return { resp: resData.Data, resData };
- } catch (e) {
- console.error('API Call Error', url, e);
- return { resp: null, resData: { RespCode: -1 } };
- }
- };
- const app = getApp();
- export default {
- // 判断app状态进行跳转
- async judgeAppStatus() {
- const {
- fixedAppjsGlobalData
- } = uni.getStorageSync("frontEndConfig")
- const {
- status,
- content
- } = await callApi('wsgw/basic/basicApi/GetAppStatus/callApiJSON.do', {
- appId: fixedAppjsGlobalData?.appId
- }).then(r => r.resp || {});
-
- switch (status) {
- case "maintain":
- uni.reLaunch({
- url: `/pages/st1/business/errorPage/maintain/maintain?content=${content}`,
- });
- break;
- case "offline":
- uni.reLaunch({
- url: "/pages/st1/business/errorPage/offline/offline",
- });
- break;
- default:
- break;
- }
- },
- /**
- * 首页 更多 个人中心 菜单点击
- */
- async menuClick(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 this.getHospitalLocationDistance(limitDistance);
- } catch (err) {
- await new Promise((resolve) => {
- common.showModal('需到院后才能挂当日号,且不支持无就诊卡进行挂号操作', resolve, {
- title: '温馨提示'
- });
- })
- }
- }
- /**来院导航 */
- if (item.MenuName == '来院导航') {
- this.getLocation()
- return;
- }
- /**跳转小程序 */
- if (item.AppId) {
- uni.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 (this.isToAuthPage()) {
- return;
- }
- /**如果当前menu在上面数组中 判断是否有就诊人 有就诊人根据条件判断是否需要就诊卡、住院号、授权信息
- * 不满足条件跳转到相应添加就诊卡或添加住院号页面
- */
- if (await this.toAddMemberOrNot(url)) {
- return
- }
- }
- common.goToUrl(url, {
- skipWay: skipWay
- })
- },
- /**
- * 是否需要跳转授权页
- */
- isToAuthPage() {
- // 判断小程序登录返回的wechatOpenid是否为null,null没有关注公众号,需要跳转授权页面进行授权处理
- if (uni.getStorageSync('wechatOpenid') === null && getApp().globalData.officialAuthOn) {
- common.goToUrl(`/pages/st1/business/h5/h5?type=0`, {
- skipWay: 'redirectTo'
- })
- return true;
- }
- // 判断没有获取登录Account信息
- if(common.isEmpty(getApp().globalData.userAccount)){
- this.isLoginAccount()
- return true;
- }
- return false
- },
- /**
- * 判断当前是否有就诊人 没有则前往添加页面
- * 返回url 或 undefined
- */
- async toAddMemberOrNot(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 this.getDefaultMember({
- 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
- },
- /**
- * 获取并全局默认操作人
- * 默认卡号可以为空 默认获取报告单
- * url(保留要跳转的页面)
- * cardType(查询类型) 1查询就诊卡 14查询住院号 空查询就诊人
- * isKeepPage(是否保留选择界面)
- */
- async getDefaultMember(data = {}) {
- getApp().globalData.cardType = null
- let member = {}
- let defaultInfo = await this.getMember('defaultInfo', data.cardType)
- if (!common.isEmpty(defaultInfo)) {
- member = await this.currentUsersFilter(defaultInfo, data.cardType)
- // 判断返回为空 或者 要查询到的是有卡类型的,当时过滤时返回的是没有的卡号的
- if (common.isEmpty(member) || (common.isNotEmpty(data.cardType) && common.isEmpty(member.cardNo))) {
- if (common.isNotEmpty(data.url)) {
- getApp().globalData.toUrl = data.url;
- }
- let type = data.cardType == 1 ? 'card' : data.cardType == 14 ? 'hospital' : 'member'
- let skipWay = data.isKeepPage ? 'navigateTo' : 'redirectTo'
- common.goToUrl(`/pagesPersonal${uni.getStorageSync('wx_Slb')?'Slb':''}/st1/business/patientManagement/selecteCardOrHos/selecteCardOrHos?type=${type}`, {
- skipWay: skipWay
- })
- return null
- }
- }
- getApp().globalData.currentUser = member
- return member
- },
- /**
- * 如果toUrl有值 即为添加就诊卡后跳转进toUrl页面 或 cardDeleted为true时(点击过删除按钮)
- * 需要判断卡列表是否为空 为空返回上一页
- * _this 当前调用页面
- */
- async cardListIsEmpty(cardType, _this) {
- if (getApp().globalData.toUrl) {
- getApp().globalData.toUrl = ""
- let member = await this.getDefaultMember({
- cardType: cardType,
- });
- if (common.isEmpty(member)) {
- common.showModal(`该功能需要添加就诊卡`, () => {
- common.navigateBack(1)
- })
- return true;
- }
- }
- return false;
- },
- // cardType (type为获取默认操作人,才有效果,1:获取默认人下默认就诊卡;14:取默认人下默认住院号)
- async getMember(type = 'memberList', cardType = 1) {
- // type 值
- // memberList: 查询就诊人列表,仅返回就诊人列表
- // cardList: 查询就诊人列表并循环查询卡列表,返回所有就诊人下的所有卡
- // defaultList: 查询就诊人列表,返回所有人列表,如果有默认就诊人就返回默认就诊人的就诊卡,如果没有就选第0条
- // defaultInfo: 获取默认人下的所有卡,搭配cardType并过滤不是默认卡,仅返回默认cardTyp类型组合的一个对象
- return new Promise(async (resolve, reject) => {
- let resp = await uni.getStorageSync('memberList') || []
- let memberList = []
- let currentUser = {}
- if (!resp.length && getApp().globalData.userAccount) {
- await this.preserMember()
- resp = uni.getStorageSync('memberList')
- }
- if (common.isNotEmpty(resp)) {
- memberList = resp
- // 判断为获取默认就诊人
- if (type == 'defaultInfo') {
- let memberLists = memberList.filter(item => item.userMemberList[0].isDefaultMember == 1)
- // 判断过滤默认操作人
- if (common.isNotEmpty(memberLists)) {
- currentUser = memberLists[0]
- } else {
- // 没有默认操作人查询人列表第一条
- currentUser = memberList[0]
- }
- if (common.isNotEmpty(cardType)) {
- let resp = await this.queryMemberCardList_V3(currentUser.memberId)
- if (common.isNotEmpty(resp)) {
- currentUser.data_1 = resp
- }
- }
- resolve(currentUser)
- }
- // 判断为获取默认列表 返回所有人列表,如果有默认就诊人就返回默认就诊人的就诊卡,如果没有就选第0条
- if (type == 'defaultList') {
- let memberListIndex = 0
- let userInfo = memberList[memberListIndex]
- memberList.forEach((item, index) => {
- if (item.userMemberList[0].isDefaultMember == 1) {
- userInfo = item
- memberListIndex = index
- }
- })
- let resp = await this.queryMemberCardList_V3(userInfo.memberId)
- if (common.isNotEmpty(resp)) {
- memberList[memberListIndex].data_1 = resp
- }
- resolve(memberList)
- }
- // 判断为获取所有人下所有卡列数据
- if (type == 'cardList') {
- for (var item of memberList) {
- let resp = await this.queryMemberCardList_V3(item.memberId)
- if (common.isNotEmpty(resp)) {
- item.Data_1 = resp
- } else {
- item.Data_1 = []
- }
- }
- }
- resolve(memberList)
- } else {
- resolve([])
- }
- })
- },
- // 获取就诊人下的his卡信息
- async queryMemberCardList_V3(memberId) {
- return new Promise(async (resolve, reject) => {
- let querData = {
- hosId: getApp().globalData.hosId,
- memberId: memberId,
- cardNoFormatDesensitization: "false"
- }
- let {
- resp,
- resData
- } = await callApi('wsgw/accountMember/api/QueryMemberCardList_V3/callApiJSON.do', querData)
- if (resData.RespCode == 10000 && common.isNotEmpty(resp)) {
- resolve(resp)
- } else {
- resolve([])
- }
- })
- },
- // 过滤使用人信息
- async currentUsersFilter(currentUsers, cardType) {
- return new Promise(async (resolve, reject) => {
- let currentUser = {}
- let cardUser = {}
- // 判断存在数据进行过滤
- if (currentUsers.data_1) {
- let cardDataList = []
- for (var item of currentUsers.data_1) {
- if (item.cardType == cardType) {
- cardDataList.push(item)
- }
- if (item.isDefault == 1 && item.cardType == cardType) {
- cardUser = item
- }
- }
- if (common.isEmpty(cardUser)) {
- cardUser = cardDataList[0]
- }
- if (common.isNotEmpty(cardUser)) {
- currentUser = common.mergeObject(currentUsers, cardUser)
- } else {
- if (common.isEmpty(cardType)) {
- currentUser = currentUsers
- }
- }
- } else if (common.isNotEmpty(currentUsers)) {
- currentUser = currentUsers
- }
- resolve(currentUser)
- })
- },
- //查询并保存全局所有就诊人数据信息 (就诊人改变后都要重新调用,并保存一遍)
- async preserMember() {
- let queryData = {
- isCache: false,
- isEncrypt: true,
- hosId: getApp().globalData.districtId || getApp().globalData.hosId,
- openid: uni.getStorageSync('openid'),
- }
- let {
- resp,
- resData
- } = await callApi('wsgw/accountMember/api/QueryBaseMemberList_V3/callApiJSON.do', queryData)
- // 请求成功且有返回值保存全局就诊人数据列表
- getApp().globalData.currentUser = null;
- if (resData.RespCode == 10000 && common.isNotEmpty(resp)) {
- uni.setStorageSync('memberList', resp)
- } else {
- // 否则保存空
- uni.setStorageSync('memberList', null)
- }
- },
- /**
- * 倒计时
- */
- countDown(timer) {
- // This assumes this context has setData (Options API or legacy Page)
- if (this.data && this.data.seconds <= 0) {
- this.setData({
- seconds: 120
- })
- }
- let seconds = this.data ? this.data.seconds : 0;
- if (timer) {
- clearInterval(timer)
- }
- timer = setInterval(() => {
- if (seconds > 0) {
- seconds--
- } else {
- seconds = 0
- clearInterval(timer)
- }
- if (this.setData) {
- this.setData({
- seconds
- })
- }
- }, 1000)
- },
- /**
- * 来院导航
- */
- getLocation() {
- let hospitalInfo = getApp().globalData.hospitalInfo;
- let data = {
- latitude: Number(hospitalInfo.Wd), //要去的纬度-地址
- longitude: Number(hospitalInfo.Jd), //要去的经度-地址
- name: hospitalInfo.HospitalAlias,
- address: hospitalInfo.HospitalAddress
- }
- this.locationIsauthorization('gcj02', () => {
- uni.openLocation(data)
- })
- },
- /**
- * 地理位置是否授权
- */
- 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: '打开'
- })
- }
- }
- });
- },
- // 判断当前业务页面用户是否需要授权
- isPageUserAuth(currentUser, _this) {
- return new Promise(async (resolve, reject) => {
- // 返回值
- let has = false
- // 获取统一要授权的业务页面配置信息
- let authBusinessPageObj = getApp().globalData.config.pageConfiguration.currency_config.authBusinessPage
- // 获取当前业务页面地址
- let pages = getCurrentPages()
- let currentPage = pages[pages.length - 1]
- let businessPageUrls = currentPage.route.split("/");
- let pageObjName = businessPageUrls[businessPageUrls.length - 1]
- // 获取当前业务页面配置的授权信息
- let authLevel = authBusinessPageObj[pageObjName]
- // 判断 authLevel不为空且当前用户信息小余当前业务需要授权的业务等级,代表当前业务页面需要先授权
- if (common.isNotEmpty(authLevel)) {
- let res = await callApi('wsgw/accountMember/api/QueryAccountUserLevel/callApiJSON.do', {
- openId: uni.getStorageSync('openid'),
- memberId: currentUser.memberId,
- }).then(r => r.resp)
-
- has = res && res[0] && res[0].accountUserLevel < authLevel ? true : false
- }
- _this.setData({
- authorize: has,
- authLevel: authLevel
- })
- resolve(has)
- })
- },
- /**
- 判断当前用户是否被本人授权
- currentUser:查询的用户
- checkKey :{
- Book: 预约挂号授权
- Charge: 充值缴费授权
- }
- isShowMode: 是否弹窗提示
- */
- isCurrentUserAuth(currentUser, checkKey, isShowMode) {
- return new Promise(async (resolve, reject) => {
- // 判断如果是本人,不读取授权认证,皆为通过
- if (currentUser.memberType == 1) {
- resolve(false)
- } else {
- // 没有accountSn就代表没有验证过本人,不做授权判断
- if (common.isEmpty(currentUser.accountSn)) {
- resolve(false)
- }
- //否者就不是本人,查询授权数据信息,判断是否授权
- let {
- resp,
- resData
- } = await callApi('wsgw/accountMember/api/QueryAccountAuthDetail/callApiJSON.do', {
- accountSn: currentUser.accountSn,
- memberId: currentUser.memberId,
- seniorOpen: 1
- })
- let has = false
- if (resData.RespCode == '10000') {
- let authInfo = resp[0]
- // 判断当前用户 已开 启高级授权
- if (authInfo.SeniorOpen == 1) {
- // 判断 不在 授权时限内
- if (common.isNotEmpty(authInfo.SeniorTime) && common.getTowNumDay(authInfo.SeniorTime, common.getDate()) < 0) {
- has = true
- }
- } else {
- if (authInfo[checkKey + 'Open'] == 0 || (authInfo[checkKey + 'Open'] == 1 && common.isNotEmpty(authInfo[checkKey + 'Time']) && common.getTowNumDay(authInfo[checkKey + 'Time'], common.getDate()) < 0)) {
- // 判断普通授权,根据
- has = true
- }
- }
- if (has && isShowMode) {
- common.showModal('当前亲友成员未被授权,请联系本人授权后,在代为操作')
- }
- resolve(has)
- } else {
- resolve(false)
- }
- }
- })
- },
- // 是否登陆账号
- isLoginAccount() {
- const userAccount = getApp().globalData.userAccount || {}
- if (!Object.keys(userAccount).length) {
- // 未登陆账号,跳转到登陆页面
- common.goToUrl('/pages/st1/business/login/authorization/authorization')
- }
- },
- // OpenID 获取账号信息
- async getAccountByOpenid(clear) {
- const userAccout = getApp().globalData.userAccount
- if (userAccout && !clear) {
- return userAccout
- }
- if (userAccout && userAccout.keep) {
- delete userAccout.keep
- return userAccout
- }
- const {
- resp
- } = await callApi('wsgw/accountMember/api/GetLastLoginAccount/callApiJSON.do', {
- openId: uni.getStorageSync("openid")
- })
- if (resp) {
- getApp().globalData.userAccount = resp.length ? resp[0] : null
- }
- },
- // 手机号 获取账号信息,没有账号信息则默认新增
- async getAccountByPhone(code) {
- const {
- fixedAppjsGlobalData,
- webUiDiy
- } = uni.getStorageSync("frontEndConfig")
- // 获取账号信息
- const openid = uni.getStorageSync("openid")
- const {
- resp
- } = await callApi('wsgw/accountMember/api/CreateAccount/callApiJSON.do', {
- openId: openid,
- code,
- smallProConfigKey: fixedAppjsGlobalData?.configKey,
- })
- if (!resp) return
- // 如果没有最后一次登录信息,直接跳转
- // 或者没开短信验证,则不做验证,直接返回前面的页面
- // 或者openId 一直
- if (!resp[0].lastLoginInfo || !webUiDiy.pageConfiguration?.login_config?.messageSys || openid == resp[0].lastLoginInfo.openId) {
- getApp().globalData.userAccount = Object.assign({}, resp[0], {
- keep: true
- })
- uni.navigateBack()
- return
- }
- // 对比OpenId,不一致则跳转到短信登录验证页面
- if (openid != resp[0].lastLoginInfo.openId) {
- uni.redirectTo({
- url: `/pages/st1/business/login/verify/verify?accountSn=${resp[0].accountSn}&phone=${resp[0].mobile}`
- })
- }
- },
- async loadViewMenu() {
- const { resp } = await callApi('wsgw/basic/basicApi/CacheGetValue/callApiJSON.do', {
- key: 'smallproViewMenu'
- })
- if (resp && resp.length) {
- const menu = JSON.parse(resp[0].Value || "[]")
- menu.length && uni.setStorageSync('menuList', menu)
- }
- },
- /**
- * 获取当前位置与医院的距离
- * @param {Number} distance 距离半径(单位:公里)
- */
- getHospitalLocationDistance(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) => {
- this.locationIsauthorization('gcj02', (res) => {
- let distance = common.getDistance(res.latitude, res.longitude, hosLat, hosLng);
- distance > limitDistance ? reject() : resolve();
- })
- })
- },
- /**
- * 处理首页和医院概况轮播图片地址
- */
- handlePhoto() {
- let photoArr = []
- let hospitalInfo = common.deepCopy(app.globalData.hospitalInfo);
- if (!common.isEmpty(hospitalInfo.PhotoUrl)) {
- hospitalInfo.PhotoUrl = JSON.parse(hospitalInfo.PhotoUrl)
- /**处理图片url */
- for (let i in hospitalInfo.PhotoUrl) {
- hospitalInfo.PhotoUrl[i] = hospitalInfo.PhotoUrl[i].indexOf('http') != '-1' ? hospitalInfo.PhotoUrl[i] : `${REQUEST_CONFIG.BASE_URL}${hospitalInfo.PhotoUrl[i]}`
- photoArr.push(hospitalInfo.PhotoUrl[i])
- }
- }
- return photoArr
- },
- /**
- * 调起人脸识别
- */
- startFacialRecognitionVerify(data) {
- return new Promise((resolve, reject) => {
- // #ifdef MP-WEIXIN
- wx.startFacialRecognitionVerify({
- name: data.memberName,
- idCardNumber: data.idCardNo,
- checkAliveType: 1,
- success: function (res) {
- resolve({
- success: true,
- value: res
- })
- },
- fail: function (res) {
- reject({
- success: false,
- value: res
- })
- }
- })
- // #endif
- // #ifndef MP-WEIXIN
- common.showToast('非微信小程序环境不支持人脸识别');
- reject({ success: false, msg: 'Not supported' });
- // #endif
- })
- },
- // 处理医生返回值
- doctorListHandle(list) {
- if (common.isEmpty(list)) {
- return list
- }
- for (let i of list) {
- if (i.DoctorPhotourl) {
- if (i.DoctorPhotourl.indexOf("http")) {
- i.DoctorPhotourl = REQUEST_CONFIG.BASE_URL + i.DoctorPhotourl.replace(/\\/g, "/")
- }
- } else {
- i.DoctorPhotourl = icon.equire_doctor
- }
- // 计算价格
- i.phoneFeeDiy = i.PhoneFee ? common.centToYuan(i.PhoneFee).toFixed(2) : 0
- i.videoFeeDiy = i.VideoFee ? common.centToYuan(i.VideoFee).toFixed(2) : 0
- i.consultFeeDiy = i.ConsultFee ? common.centToYuan(i.ConsultFee).toFixed(2) : 0
- let AvgAppraiseScore = '-';
- // 用于做排序判断
- let AvgAppraiseScoreTag = 0;
- if (i.AppraiseCount > 0 && i.AppraiseScore > 0) {
- AvgAppraiseScore = (i.AppraiseScore / i.AppraiseCount / 5 * 100).toFixed(0) + "%";
- AvgAppraiseScoreTag = (i.AppraiseScore / i.AppraiseCount / 5 * 100).toFixed(0);
- }
- i.AvgAppraiseScore = AvgAppraiseScore;
- i.AvgAppraiseScoreTag = AvgAppraiseScoreTag;
- // 计算好评率
- if (true) {
- let highCount = getApp().globalData.config.net_pageConfiguration_patient.currency_config.iniHighAppraiseCount + i.HighAppraiseCountCons
- let totalCount = getApp().globalData.config.net_pageConfiguration_patient.currency_config.iniHighAppraiseCount + (i.AppraiseCount !== undefined ? i.AppraiseCount : i.AppraiseCountCons)
- let percentage = (highCount / totalCount) * 100
- if (Number.isNaN(percentage)) {
- i.percentage = '100%'
- } else {
- i.percentage = Math.ceil(percentage) > 100 ? 100 + "%" : Math.ceil(percentage) + "%"
- }
- }
- i.scoreDiy = "5.0"
- if ((i.AppraiseCount !== undefined ? i.AppraiseCount : i.AppraiseCountCons) && (i.AppraiseScore !== undefined ? i.AppraiseScore : i.AppraiseScoreCons)) {
- // 评分
- i.scoreDiy = Math.ceil((i.AppraiseScore !== undefined ? i.AppraiseScore : i.AppraiseScoreCons) / (i.AppraiseCount !== undefined ? i.AppraiseCount : i.AppraiseCountCons)).toFixed(1)
- }
- if (i.AppraiseRule) {
- try {
- i.AppraiseRule = JSON.parse(i.AppraiseRule)
- } catch (err) {
- console.log('i.AppraiseRule格式化失败')
- }
- }
- }
- return list
- },
- /** 查询患者分类列表
- * 规则:
- * 返参ClassificationType等于2为复诊患者规则,带入就诊记录(已签到)进行结果判断,符合则为复诊患者
- * 若接口返回空,则为初诊患者
- */
- async queryPatientClassifiyList(member, doctorCode, self) {
- return new Promise(async (resolve, reject) => {
- let data = {
- Status: 1
- }
- let {
- resp,
- resData
- } = await callApi('wsgw/yy/yygh/QueryPatientClassifiyList/callApiJSON.do', data)
- console.log("QueryPatientClassifiyList=====", resp)
- if (resData.RespCode == "10000") {
- if (common.isNotEmpty(resp)) {
- // 筛选出复诊患者规则
- let visit = resp.filter((item) => {
- return item.ClassificationType == 2
- })
- console.log("visit=====", visit)
- // 有复诊规则,执行预约记录的规则匹配逻辑
- if (common.isNotEmpty(visit)) {
- self.setData({
- patientClassificationId: 2
- })
- try {
- member.memberOtherInfo = JSON.parse(member.memberOtherInfo)
- console.log("true")
- } catch {
- member.memberOtherInfo = member.memberOtherInfo
- console.log("false")
- }
- console.log("member=======", member)
- resolve(await this.queryOutpatientVisitList(member, visit[0], doctorCode))
- } else {
- self.setData({
- patientClassificationId: 1
- })
- resolve(false)
- }
- } else {
- resolve(false)
- }
- } else {
- resolve(false)
- }
- })
- },
- /** 查询his预约记录并判断是否为复诊患者 */
- async queryOutpatientVisitList(member, rule, doctorCode) {
- return new Promise(async (resolve, reject) => {
- let day = common.mul(rule.IntervalNum, 30)
- var reqData = {
- HosId: getApp().globalData.districtId || getApp().globalData.hosId,
- StartDate: common.aFewDaysago(day),
- EndDate: common.newDay(),
- IgnoreHosId: true,
- QueryAll: getApp().globalData.districtId || getApp().globalData.hosId,
- MemberId: member.memberId,
- CardType: member.cardType || "1",
- CardNo: member.memberOtherInfo.defaultCard.cardNo,
- Store: {
- cardEncryptionStore: member.encryptionStore || '',
- baseMemberEncryptionStore: member.baseMemberEncryptionStore
- }
- }
- let {
- resp,
- resData
- } = await callApi('wsgw/member/memberApi/QueryOutpatientVisitList/callApiJSON.do', reqData)
- console.log("QueryOutpatientVisitList=====", resp)
- if (resData.RespCode == "10000") {
- if (common.isNotEmpty(resp)) {
- resp = resp.filter((item) => {
- return item.CardNo == member.cardNo
- })
- if (common.isNotEmpty(resp)) {
- // 返回列表
- if (member.List) {
- resolve(resp)
- return
- }
- // 需判断就诊记录和对应医生的匹配次数
- if (common.isNotEmpty(doctorCode)) {
- let docRecord = resp.filter((item) => {
- return item.DoctorCode == doctorCode
- })
- if (docRecord.length >= rule.HistoryMedicalTimesNum) {
- resolve(true)
- } else {
- resolve(false)
- }
- }
- // 直接判断就诊次数和配置中的是不是匹配
- else {
- if (resp.length >= rule.HistoryMedicalTimesNum) {
- resolve(true)
- } else {
- resolve(false)
- }
- }
- } else {
- resolve(false)
- }
- } else {
- resolve(false)
- }
- } else {
- resolve(false)
- }
- })
- },
- /**
- * 查询医生排班公共方法
- * @param {Object} data - 查询参数
- * @param {Object} options - 额外配置参数
- * @returns {Array} - 处理后的医生排班数据
- */
- async queryClinicDoctorSchedule(resp, options = {}) {
- if (!common.isEmpty(resp)) {
- for (let i of resp) {
- if (i.Data_1 && !common.isEmpty(i.Data_1)) {
- i.Data_1.map(item => {
- item.RegDateDiy = item.RegDate.substring(5),
- item.WeekName = item.RegDate == common.newDay() ? '今天' : item.WeekName
- })
- }
- /**如果医生头像没有域名 添加域名 */
- if (i.PhotoUrl && i.PhotoUrl.indexOf('http') == '-1') {
- i.PhotoUrl = REQUEST_CONFIG.BASE_URL + i.PhotoUrl
- }
- i.PhotoUrl = i.PhotoUrl.replace(/\\/g, '/')
- if (i.Data_1.length > 6) {
- i.Data_1_Diy = i.Data_1.slice(0, 5);
- i.showAllSchedu = false
- } else {
- i.Data_1_Diy = i.Data_1;
- i.showAllSchedu = true;
- }
- }
- }
- resp.map(item => {
- let obj = [{
- Check: true,
- DeptName: item.DeptName,
- DeptCode: item.DeptCode,
- DoctorName: item.DoctorName,
- DoctorCode: item.DoctorCode,
- Data_1: item.Data_1,
- Data_1_Diy: item.Data_1_Diy,
- showAllSchedu: item.showAllSchedu,
- }]
- item.Scheduling = obj
- item.HosId = options.hosId
- item.ChoiceHosId = options.hosId
- })
- return resp
- },
- /**
- * 医生与诊疗组匹配
- * @param {Array} doctors - 医生列表
- * @param {Array} groupList - 诊疗组列表
- */
- matchDoctorsWithGroup(doctors, groupList) {
- if (!groupList || !Array.isArray(groupList)) return;
- // 创建一个Map来存储诊疗组信息,key为医生代码
- const doctorGroupMap = new Map();
- // 遍历所有诊疗组,收集医生与诊疗组的对应关系
- groupList.forEach(group => {
- if (group.doctorList && Array.isArray(group.doctorList)) {
- group.doctorList.forEach(doctor => {
- if (doctor.code) {
- doctorGroupMap.set(doctor.code, group);
- }
- });
- }
- });
- // 标记医生是否属于诊疗组,并赋值诊疗组信息
- doctors.forEach(doctor => {
- const groupInfo = doctorGroupMap.get(doctor.DoctorCode);
- doctor.IsGroup = !!groupInfo;
- if (groupInfo) {
- doctor.GroupInfo = groupInfo;
- }
- });
- },
- /** 全局开启分享 */
- overShareMenu() {
- // #ifdef MP-WEIXIN
- wx.onAppRoute(() => {
- //获取加载的页面
- let pages = getCurrentPages(),
- //获取当前页面的对象
- view = pages[pages.length - 1];
- if (view && view.onShareAppMessage) {
- wx.showShareMenu({
- withShareTicket: true,
- menus: ['shareAppMessage', 'shareTimeline']
- })
- }
- })
- // #endif
- }
- }
|