pagesNetHosFn.ts 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363
  1. import { common } from '@/uni-app-base/utils';
  2. import icon from '@/utils/icon';
  3. // TODO: 需要创建 pagesNetHos 相关的 API 服务
  4. // import { cancelConsultWater } from '@/pagesNetHos/service/doctor';
  5. // import { HisYyWaterList_V2, regSign } from '@/pagesNetHos/service/enquire';
  6. // import { GetSysConfigEntity, orderCancel, orderListLocal } from '@/pagesNetHos/service/record';
  7. import { getOrderStateName } from './getState';
  8. import { strChineseFirstPY } from './code';
  9. /**
  10. * 页面公用逻辑函数
  11. */
  12. const app = getApp();
  13. /**
  14. * 获取首字母
  15. */
  16. export const getFirst = function (str: string): string {
  17. if (typeof (str) != "string") {
  18. return '';
  19. }
  20. var word = str.charAt(0);
  21. return checkUnicode(word);
  22. };
  23. /**
  24. * 转换字符
  25. */
  26. export const checkUnicode = function (word: string): string {
  27. var code = word.charCodeAt(0);
  28. if (code > 40869 || 40869 < 19968) {
  29. return '';
  30. }
  31. return strChineseFirstPY.charAt(code - 19968);
  32. };
  33. /**
  34. * 处理医生返回值
  35. */
  36. export const doctorListHandle = function (list: any[]): any[] {
  37. if (common.isEmpty(list)) {
  38. return list;
  39. }
  40. for (let i of list) {
  41. if (i.DoctorPhotourl) {
  42. if (i.DoctorPhotourl.indexOf("http") == -1) {
  43. // TODO: 需要获取 API 根路径
  44. // i.DoctorPhotourl = api.ApiRootUrl + i.DoctorPhotourl.replace(/\\/g, "/");
  45. }
  46. } else {
  47. i.DoctorPhotourl = icon.equire_doctor;
  48. }
  49. // 计算价格
  50. i.phoneFeeDiy = i.PhoneFee ? common.centToYuan(i.PhoneFee).toFixed(2) : 0;
  51. i.videoFeeDiy = i.VideoFee ? common.centToYuan(i.VideoFee).toFixed(2) : 0;
  52. i.consultFeeDiy = i.ConsultFee ? common.centToYuan(i.ConsultFee).toFixed(2) : 0;
  53. let AvgAppraiseScore = '-';
  54. // 用于做排序判断
  55. let AvgAppraiseScoreTag = 0;
  56. if (i.AppraiseCount > 0 && i.AppraiseScore > 0) {
  57. AvgAppraiseScore = (i.AppraiseScore / i.AppraiseCount / 5 * 100).toFixed(0) + "%";
  58. AvgAppraiseScoreTag = Number((i.AppraiseScore / i.AppraiseCount / 5 * 100).toFixed(0));
  59. }
  60. i.AvgAppraiseScore = AvgAppraiseScore;
  61. i.AvgAppraiseScoreTag = AvgAppraiseScoreTag;
  62. // 计算好评率
  63. if (true) {
  64. // TODO: 需要从 app.globalData.config 获取配置
  65. const config = (app.globalData as any).config;
  66. if (config?.net_pageConfiguration_patient?.currency_config) {
  67. let highCount = config.net_pageConfiguration_patient.currency_config.iniHighAppraiseCount + (i.HighAppraiseCountCons || 0);
  68. let totalCount = config.net_pageConfiguration_patient.currency_config.iniHighAppraiseCount + (i.AppraiseCount !== undefined ? i.AppraiseCount : i.AppraiseCountCons || 0);
  69. let percentage = (highCount / totalCount) * 100;
  70. if (Number.isNaN(percentage)) {
  71. i.percentage = '100%';
  72. } else {
  73. i.percentage = Math.ceil(percentage) + "%";
  74. }
  75. }
  76. }
  77. i.scoreDiy = "5.0";
  78. if ((i.AppraiseCount !== undefined ? i.AppraiseCount : i.AppraiseCountCons) && (i.AppraiseScore !== undefined ? i.AppraiseScore : i.AppraiseScoreCons)) {
  79. // 评分
  80. i.scoreDiy = Math.ceil((i.AppraiseScore !== undefined ? i.AppraiseScore : i.AppraiseScoreCons) / (i.AppraiseCount !== undefined ? i.AppraiseCount : i.AppraiseCountCons)).toFixed(1);
  81. }
  82. if (i.AppraiseRule) {
  83. try {
  84. i.AppraiseRule = JSON.parse(i.AppraiseRule);
  85. } catch (err) {
  86. console.log('i.AppraiseRule格式化失败');
  87. }
  88. }
  89. try {
  90. i.DoctorName = i.DoctorName.split('-')[0];
  91. } catch (err) { }
  92. }
  93. return list;
  94. };
  95. /**
  96. * 咨询记录返回值处理
  97. */
  98. export const consultListHandle = function (list: any[]): any[] {
  99. let arr = [
  100. { status: 0, name: "未支付", isShow: 0 },
  101. { status: 1, name: "待接单", isShow: 0 },
  102. { status: 2, name: "进行中", isShow: 0 },
  103. { status: 3, name: "已结束", isShow: 0 },
  104. { status: 4, name: "超时未支付", isShow: 0 },
  105. { status: 5, name: "已评价", isShow: 0 },
  106. { status: 6, name: "仲裁中", isShow: 0 },
  107. { status: 7, name: "仲裁被驳回", isShow: 0 },
  108. { status: 8, name: "仲裁成功", isShow: 0 },
  109. { status: 9, name: "超时未接单", isShow: 0 },
  110. { status: 10, name: "已退费", isShow: 0 },
  111. { status: 11, name: "接单驳回", isShow: 0 },
  112. { status: 12, name: "视频未接通", isShow: 0 },
  113. { status: 13, name: "视频已中断", isShow: 0 },
  114. { status: 14, name: "已终结", isShow: 0 },
  115. { status: 15, name: "医生团队待接单", isShow: 0 },
  116. { status: 16, name: "待签到", isShow: 0 },
  117. { status: 17, name: "已取消", isShow: 0 },
  118. { status: 18, name: "超时未签到", isShow: 0 }
  119. ];
  120. for (let item of list) {
  121. item.FirstMsgContent = item.FirstMsgContent ? JSON.parse(item.FirstMsgContent) : [];
  122. item.MedicalInfo = item.MedicalInfo ? JSON.parse(item.MedicalInfo) : {};
  123. item.Yuan = common.centToYuan(item.ConsultFee);
  124. let firstMsgContentDiy: any = {};
  125. for (let msgItem of item.FirstMsgContent) {
  126. firstMsgContentDiy[msgItem.key] = msgItem.value;
  127. }
  128. item.firstMsgContentDiy = firstMsgContentDiy;
  129. if (item.DoctorPhotourl) {
  130. if (item.DoctorPhotourl.indexOf("http") == -1) {
  131. // TODO: 需要获取 API 根路径
  132. // item.DoctorPhotourl = api.ApiRootUrl + item.DoctorPhotourl.replace(/\\/g, "/");
  133. }
  134. } else {
  135. item.DoctorPhotourl = icon.equire_doctor;
  136. }
  137. if (item.ConsultType == 1) {
  138. item.consultNameDiy = '图文咨询';
  139. } else if (item.ConsultType == 2) {
  140. item.consultNameDiy = '视频咨询';
  141. } else if (item.ConsultType == 3) {
  142. item.consultNameDiy = '电话咨询';
  143. }
  144. item.consultFeeDiy = item.ConsultFee ? common.centToYuan(item.ConsultFee).toFixed(2) : 0;
  145. for (let i of arr) {
  146. if (i.status == item.Status) {
  147. item.statusDiy = i.name;
  148. break;
  149. }
  150. }
  151. }
  152. return list;
  153. };
  154. /**
  155. * 取消咨询订单
  156. */
  157. export const cancelConsultOrder = async function (data: any, callBack?: () => void, type?: string): Promise<void> {
  158. console.log(data, 'data');
  159. let tip = '您正在进行退号操作,为了避免误操作带来的不必要损失,系统需要您再次确认,谢谢!';
  160. if (type == 'qxzx') {
  161. tip = '您正在进行取消操作,为了避免误操作带来的不必要损失,系统需要您再次确认,谢谢!';
  162. }
  163. common.showModal(tip, async () => {
  164. // TODO: 需要实现 API 调用
  165. // const { resData } = await cancelConsultWater(data);
  166. // if (resData.RespCode == '10000') {
  167. // if (callBack instanceof Function) {
  168. // callBack();
  169. // }
  170. // }
  171. }, {
  172. cancelText: "取消"
  173. });
  174. };
  175. /**
  176. * 签到
  177. */
  178. export const signOrCancel = async function (e: any, context?: any): Promise<void> {
  179. // 列表为item 详情为orderInfo
  180. let item = e.currentTarget?.dataset?.item || (context?.data?.orderInfo) || (context?.data?.conItem);
  181. let { currentUser } = app.globalData as any;
  182. let waterData = {
  183. OrderId: item.YyWaterId,
  184. MemberId: item.MemberId,
  185. sourceType: '006',
  186. cardEncryptionStore: currentUser?.encryptionStore || '',
  187. memberEncryptionStore: currentUser?.baseMemberEncryptionStore || '',
  188. hosId: (app.globalData as any).hosId
  189. };
  190. // TODO: 需要实现 API 调用
  191. // const { resp: waterResp } = await HisYyWaterList_V2(waterData, { showLoading: false });
  192. // if (!common.isEmpty(waterResp)) {
  193. // let data = {
  194. // HosId: (app.globalData as any).hosId,
  195. // OrderId: item.YyWaterId || waterResp[0].orderId,
  196. // MemberId: waterResp[0].MemberId || item.MemberId,
  197. // CardNo: waterResp[0].CardNo || waterResp[0].cardNo,
  198. // CardType: waterResp[0].CType || waterResp[0].cardType || "1",
  199. // HisOrderId: waterResp[0].HisOrderId || waterResp[0].hisOrderId,
  200. // SourceType: waterResp[0].sourceType || "006",
  201. // ChannelId: (app.globalData as any).channelId,
  202. // DeptCode: waterResp[0].DeptCode || waterResp[0].deptCode,
  203. // DoctorCode: waterResp[0].DoctorCode || waterResp[0].doctorCode,
  204. // DeptName: waterResp[0].DeptName || waterResp[0].deptName,
  205. // RegisterDate: waterResp[0].Registerdate || common.getDate(),
  206. // QueueNo: item.sqNo || waterResp[0].sqNo,
  207. // Store: {
  208. // cardEncryptionStore: currentUser?.encryptionStore || '',
  209. // baseMemberEncryptionStore: currentUser?.baseMemberEncryptionStore || ''
  210. // }
  211. // };
  212. // const { resp, resData } = await regSign(data, { showLoading: false });
  213. // if (!common.isEmpty(resp)) {
  214. // (app as any).connectWebsocket(true);
  215. // common.goToUrl(`/pagesNetHos/st1/business/doctor/waiting/waiting`);
  216. // } else {
  217. // common.showToast(resData.RespMessage);
  218. // }
  219. // }
  220. };
  221. /**
  222. * 查询配置
  223. */
  224. export const getSysConfigEntity = function (): Promise<any> {
  225. let data = { ParamKey: "PRESC_CONFIG_KEY" };
  226. return new Promise(async resolve => {
  227. // TODO: 需要实现 API 调用
  228. // const { resData } = await GetSysConfigEntity(data);
  229. // if (resData.RespCode == '10000') {
  230. // if (common.isNotEmpty(resData.Data)) {
  231. // resData.Data[0].ParamValue = JSON.parse(resData.Data[0].ParamValue);
  232. // }
  233. // resolve(resData.Data[0].ParamValue);
  234. // } else {
  235. // common.showToast(resData.RespMessage);
  236. // resolve(undefined);
  237. // }
  238. resolve(undefined);
  239. });
  240. };
  241. /**
  242. * 取消订单
  243. */
  244. export const cancelOrder = function (item: any, callback?: () => void): void {
  245. /**取消订单 */
  246. common.showModal('是否确定取消该订单?', async () => {
  247. let orderCancelData = {
  248. OperatorName: item.OperatorName,
  249. OperatorId: item.OperatorId,
  250. OrderId: item.OrderId
  251. };
  252. // TODO: 需要实现 API 调用
  253. // const { resData } = await orderCancel(orderCancelData, item.ServiceId);
  254. // if (resData.RespCode === '10000') {
  255. // /**取消成功 */
  256. // common.showModal('订单已取消', callback, {
  257. // confirmText: '好的'
  258. // });
  259. // } else {
  260. // common.showToast(resData.RespMessage);
  261. // }
  262. }, {
  263. cancelText: '取消',
  264. confirmText: '确定'
  265. });
  266. };
  267. /**
  268. * 获取订单列表
  269. * serviceId
  270. * pIndex 默认查询第0页
  271. */
  272. export const orderListLocal = async function (queryData: any): Promise<{ list: any[]; showNoData: boolean }> {
  273. // TODO: 需要实现 API 调用
  274. // const { resp: listResp } = await orderListLocal(queryData);
  275. let listResp: any[] = [];
  276. let showNoData = true;
  277. let list: any[] = [];
  278. if (!common.isEmpty(listResp)) {
  279. listResp.map(item => {
  280. item.StateTxt = getOrderStateName(item.ServiceId, item.IsOnlinePay, item.PayState, item.BizState, item.OverState);
  281. if (!common.isEmpty(item.OrderMemo)) {
  282. item.OrderMemo = JSON.parse(item.OrderMemo);
  283. item.OrderMemo.formatWeek = common.dateFormat(new Date(item.OrderMemo.RegDate)).week;
  284. }
  285. });
  286. }
  287. // 预约记录过滤已锁号
  288. listResp = listResp.filter(item => item && item.StateTxt != '已锁号');
  289. if (!common.isEmpty(listResp)) {
  290. list = listResp;
  291. showNoData = false;
  292. }
  293. return {
  294. list,
  295. showNoData
  296. };
  297. };
  298. /**
  299. * 判断是否有待支付订单
  300. */
  301. export const hasOrderToBePaid = async function (serviceId: string, memberId?: string): Promise<boolean> {
  302. let queryData = {
  303. BeginDate: common.dateFormat(new Date(Date.now() - (30 * 24 * 60 * 60 * 1000))).formatYear, //开始时间
  304. EndDate: common.dateFormat(new Date(Date.now() + (24 * 60 * 60 * 1000))).formatYear, //结束时间加一天
  305. MemberId: memberId || ((app.globalData as any).currentUser && (app.globalData as any).currentUser.MemberId),
  306. BizState: '0',
  307. OverState: '0',
  308. PayState: '0',
  309. ServiceId: serviceId,
  310. OpenId: uni.getStorageSync('openid'),
  311. CardNo: '',
  312. CardType: '',
  313. Page: {
  314. PIndex: 0,
  315. PSize: 10
  316. }
  317. };
  318. // TODO: 需要实现 API 调用
  319. // const { resp: listResp } = await orderListLocal(queryData);
  320. let listResp: any[] = [];
  321. listResp = listResp.filter(item => item.IsOnlinePay == '1');
  322. if (!common.isEmpty(listResp)) {
  323. /**默认跳转预约挂号 预约挂号查询时传入0和009 与case判断不符 默认为预约记录路径*/
  324. let url = `/pagesNetHos/st1/business/record/appointmentRecord/appointmentRecord`;
  325. switch (serviceId) {
  326. /**门诊住院充值 */
  327. case '006':
  328. case '007':
  329. url = `/pagesNetHos/st1/business/record/topUpRecord/topUpRecord?serviceId=${serviceId}`;
  330. break;
  331. /**门诊结算 */
  332. case '011':
  333. case '008':
  334. /**图文,视频咨询 */
  335. case '019,024':
  336. case '040':
  337. url = `/pagesNetHos/st1/business/record/paymentRecord/paymentRecord`;
  338. break;
  339. }
  340. common.showModal(`您当前存在待支付订单,请前往订单管理中进行处理,谢谢您的合作!`, () => {
  341. common.goToUrl(url);
  342. }, {
  343. cancelText: '取消'
  344. });
  345. return true;
  346. }
  347. return false;
  348. };