123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182 |
- var $confirmBtn = $('#confirmBtn'),
- $drugsInfo = $('#drugsInfo'),
- $receiveInfo = $('#receiveInfo'),
- $logs = $('#logs'),
- $orderRecord = $('#orderRecord'),
- $takeBtn = $('#takeBtn'),
- $reachBtn = $('#reachBtn');
- var docInfo = {};
- // 医生角色: 3 健管师;2 全科医生
- var level;
- // 是否是团队长
- var isLeader;
- var hospital;
- //取药类型:1 自取 2快递配送 3健管师配送
- var dispensaryDispensaryType;
- //状态 (-3 支付过期 -2 患者自己取消 -1 审核不通过 , 0 待审核, 2调整中 10 审核通过/开方中 , 20开方完成/待支付, 21 支付失败 , 30 支付成功/待配药 , 40配药成功/待配送 41配送失败 42配送中 43配送到服务站 100配送到患者手中/已完成)
- var prescriptionStatus;
- var prescriptionExpressage;
- var prescriptionCode = '';
- var teamCode = '';
- // 医院药品接收人Code
- var acceptCode = '';
- // 药品所到达的服务站
- var acceptHospital = '';
- // 患者填写的需要送达的机构code
- var patientHospitalCode = '';
- mui.plusReady(function() {
- var cur = plus.webview.currentWebview(),
- opener = cur.opener();
- if(opener.id == "shurushuzima") {
- mui.back = backToWebviewById("home2.html")
- }
-
- docInfo = JSON.parse(plus.storage.getItem("docInfo"));
- level = docInfo.level;
- hospital = docInfo.hospital || plus.storage.getItem("hospital");
- isLeader = docInfo.isLeader;
-
- var self = plus.webview.currentWebview();
- prescriptionCode = self.prescriptionCode;
- teamCode = self.teamCode;
-
- pageInit();
- })
- function getPrescriptionFollowPromise() {
- return getReqPromise("doctor/prescriptionInfo/prescriptionFollow", {
- prescriptionCode: prescriptionCode // 处方code
- }, 'GET')
- }
- function getOrderFollowPromise() {
- return getReqPromise("doctor/prescriptionlog/orderFollow", {
- prescriptionCode: prescriptionCode // 处方code
- }, 'GET')
- }
- // 显示订单记录
- function showOrderRecord(data) {
- var html = template('record_tmpl',data);
- $orderRecord.html(html)
- }
- // 显示药品信息
- function showDrugsInfo(drugs) {
- var html = template('drug_tmpl',{list: drugs});
- $drugsInfo.html(html)
- }
- // 显示收药信息(健管师)
- function showReceiveDrugsInfoForJG(data) {
- var html = template('jgs_delivery_tmpl',data)
- $receiveInfo.html(html)
- }
- // 显示订单跟踪
- function showLogsInfo() {
- getOrderFollowPromise().then(function(res) {
- if(res.status == 200) {
- var logs = res.data;
- if(logs && logs.length) {
- var html = template('log_tmpl',{list: logs});
- $logs.html(html)
- } else {
- $logs.text("暂无信息")
- }
- }
- }).catch(function(e) {
- console && console.error(e)
- })
- }
- function bindEvents() {
- $confirmBtn.on('click', function() {
- openWebview("querenjieshou.html",{
- prescriptionCode: prescriptionCode
- })
- })
-
- $reachBtn.on('click', function() {
- openWebview("peisongma.html",{
- prescriptionCode: prescriptionCode
- })
- })
-
- $takeBtn.on('click', function() {
- openWebview("querensongda.html",{
- prescriptionCode: prescriptionCode
- })
- })
- }
- function pageInit() {
- getPrescriptionFollowPromise().then(function(res) {
- var data;
- if(res.status == 200) {
- data = res.data;
- prescriptionStatus = data.prescriptionStatus;
- dispensaryDispensaryType = data.dispensaryDispensaryType;
- prescriptionExpressage = data.prescriptionExpressage;
- acceptCode = prescriptionExpressage.acceptCode;
- acceptHospital = prescriptionExpressage.acceptHospital;
- patientHospitalCode = prescriptionExpressage.patientHospitalCode;
-
- showOrderRecord({
- payNum: (data.prescriptionExpressage && data.prescriptionExpressage.code) || "",
- prescriptionHospital: data.prescriptionHospital||"",
- prescriptionStatusName: data.prescriptionStatusName||""
- })
- showDrugsInfo(data.prescriptionInfos)
- showReceiveDrugsInfoForJG($.extend({},prescriptionExpressage,{
- dispensaryDispensaryTypeName: data.dispensaryDispensaryTypeName
- }))
-
- // 如果订单当前状态为“药品到达服务站”,且接收人为该账号人时,显示订单跟踪记录
- if(prescriptionStatus == "43" && acceptCode == docInfo.code) {
- showLogsInfo();
- } else {
- $logs.closest('.c-list').hide();
- }
-
- // 如订单当前的接收人不是该账号人或订单状态为“配送员已领药”时,显示“确认接收”按钮
- if(acceptCode != docInfo.code || prescriptionStatus == "42") {
- $confirmBtn.css('display','block');
- }
-
- // 判断药品所到达的服务站与居民选择的配送服务站是否一致,一致则显示”居民已取药“按钮,
- // 点击后跳转扫描页,扫描居民取药码确认送达。不一致则显示”确认送达服务站“按钮,点击跳转配送码页,继续送药流程
- if(prescriptionStatus == "43" && acceptHospital == patientHospitalCode) {
- $takeBtn.show()
- } else {
- $reachBtn.show()
- }
- } else {
- mui.toast(res.msg);
- }
-
- }).catch(function(e) {
- console && console.error(e)
- })
-
- bindEvents();
- }
- /*刷新事件*/
- window.addEventListener("updateOrderStatus", function refresh(e) {
- getPrescriptionFollowPromise().then(function(res) {
- if(res.status == 200) {
- showOrderRecord({
- payNum: (data.prescriptionPay && data.prescriptionPay.payNum) || "",
- prescriptionHospital: data.prescriptionHospital||"",
- prescriptionStatusName: data.prescriptionStatusName||""
- })
- } else {
- mui.toast(res.msg);
- }
- })
- });
|