(function (h) {
var c = {
options: {sysName: "南方医务通"}, init: function () {
h("head title").text("南方医务通");
var s = d.version.getVer();
if (s) {
h("link").each(function () {
h(this).attr("href", h(this).attr("href") + "?v=" + s.version)
});
h("script").each(function () {
h(this).attr("src", h(this).attr("src") + "?v=" + s.version)
})
}
}
};
var o = {
js_Fx_uuid: function (t, s) {
o.ck(t, s)
}, android_Fx_uuid: function () {
try {
android.js_Fx_uuid()
} catch (s) {
o.ck()
}
}, ck: function (t, s) {
var u = {loginName: h("#loginName").val(), password: h("#password").val(), uuid: t, devType: s};
setTimeout(function () {
d.sendData(window.apiUrl+"?c=Index&a=login", u, true)
}, 100)
}
};
var d = {
version: {
getVer: function () {
var s = JSON.parse(localStorage.getItem("hzAppVer"));
if (s) {
return s
} else {
return d.version.setVer()
}
}, setVer: function () {
h.ajax({
type: "get",
url: window.apiUrl+"index.php?c=Config&a=getWebVersion",
dataType: "jsonp",
data: {},
jsonp: "callback",
async: false,
crossDomain: true,
success: function (s) {
s = s || {};
if (s.version) {
localStorage.setItem("hzAppVer", JSON.stringify(s));
return s
}
},
error: function (u, t, s) {
return null;
d.dialog(false, d.options.timeout, "网络链接失败")
},
timeout: 9000
})
}
},
options: {templateHtml: [null, null, null, null], timeout: 2500, rows: null},
scroll: function (t, z, s, w, A, x, u, v) {
var y = true;
h("#content").bind("scroll", function () {
var B = h("#content").scrollTop();
if (B >= (h("#list").height() - h("#content").height()) && y == true) {
z.rowed += z.pageSize;
if (d.options.rows && z.rowed < d.options.rows) {
d.getData(t, z, s, w, A, x, u, v)
} else {
setTimeout(function () {
d.dialog(false, d.options.timeout, "没有了")
}, 1);
y = false
}
}
})
},
dialog: function (s, v, u, t) {
h("#dialog").addClass("show");
if (s) {
if (u) {
h("#dialog .popup_layer_cont").html('
' + u + "
")
} else {
h("#dialog .popup_layer_cont").html('
数据加载中
')
}
} else {
if (u) {
h("#dialog .popup_layer_cont").html(u)
}
}
if (v) {
setTimeout(function () {
h("#dialog").removeClass("show");
if (t) {
if (window.parent) {
window.parent.location = t
} else {
window.location = t
}
}
}, v)
} else {
h("#dialog").removeClass("show")
}
},
loginSuccess: function () {
var s = JSON.parse(localStorage.getItem("hzToken"));
if (s) {
if (s.timestamp) {
h("#login").hide();
h("#loginSuccess").show();
h("#userPhoto").attr("src", s.userPhoto);
h("i.login_open").removeClass("logined");
h("i.login_open img").attr("src", s.userPhoto);
if (s.trueName == "" || !s.trueName) {
h("#userName").text(s.phone)
} else {
h("#userName").text(s.trueName)
}
}
}
},
logout: function () {
localStorage.setItem("hzToken", null);
d.dialog(false, d.options.timeout, "已成功退出", "index.html")
},
getToken: function () {
var s = JSON.parse(localStorage.getItem("hzToken"));
if (s == null) {
s = {timestamp: null, token: null, customerFamilyId: null}
} else {
s = {timestamp: s.timestamp, token: s.token, customerFamilyId: s.customerFamilyId}
}
return s
},
setToken: function (t) {
var s = false;
if (t.status == "1") {
var u = JSON.parse(localStorage.getItem("hzToken"));
u = {
timestamp: t.timestamp,
token: t.token,
userPhoto: u.userPhoto,
customerFamilyId: u.customerFamilyId,
phone: u.phone,
trueName: u.trueName
};
localStorage.setItem("hzToken", JSON.stringify(u));
s = true
} else {
localStorage.setItem("hzToken", null);
d.dialog(false, d.options.timeout, "用户未登录或已退出!", "login.html")
}
return s
},
setLoginToken: function (s) {
if (s.status == "1") {
var t = {
timestamp: s.data[0].timestamp,
token: s.data[0].token,
userPhoto: s.data[0].userPhoto,
customerFamilyId: s.data[0].customerFamilyId,
phone: s.data[0].phone,
trueName: s.data[0].trueName
};
localStorage.setItem("hzToken", JSON.stringify(t));
d.dialog(false, d.options.timeout, "登录成功", "index.html")
} else {
d.dialog(false, d.options.timeout, "用户名或密码错误")
}
},
getDataNoTemp: function (t, u, v, s) {
if (u.rowed > d.options.rows) {
d.dialog(false, 800, "没有了")
} else {
h.ajax({
type: "get",
url: t,
dataType: "jsonp",
data: h.extend(d.getToken(), u),
jsonp: "callback",
async: false,
crossDomain: true,
beforeSend: d.dialog(true),
success: function (w) {
w = w || {};
//允许医生列表页面不登录`
if((window.location.pathname=='/dept_q_list.html'||window.location.pathname=='/favorite_q_doctor_dept_list.html')&&w.dataToken.token==null){
if (w.dataInfo.status == "1") {
v.doing(w.dataInfo.data);
d.dialog(false, false, null, null)
} else {
if (s) {
d.dialog(false, d.options.timeout, s.message ? s.message : "无数据");
s.doing()
} else {
d.dialog(false, d.options.timeout, "无数据")
}
}
return false;
}
if (d.setToken(w.dataToken)) {
if (w.dataInfo.status == "1") {
v.doing(w.dataInfo.data);
d.dialog(false, false, null, null)
} else {
if (s) {
d.dialog(false, d.options.timeout, s.message ? s.message : "无数据");
s.doing()
} else {
d.dialog(false, d.options.timeout, "无数据")
}
}
}
},
error: function (y, x, w) {
d.dialog(false, d.options.timeout, "网络链接失败")
},
timeout: 9000
})
}
},
getData: function (t, A, s, x, B, y, u, w, z, v) {
if (d.options.rows ? A.rowed >= d.options.rows : false) {
d.dialog(false, d.options.timeout, "没有了")
} else {
h.ajax({
type: "get",
url: t,
dataType: "jsonp",
data: h.extend(d.getToken(), A),
jsonp: "callback",
async: false,
crossDomain: true,
beforeSend: d.dialog(true),
success: function (C) {
C = C || {};
if (!x) {
x = 0
}
if (!d.options.templateHtml[x]) {
d.options.templateHtml[x] = h(s).html();
d.options.templateHtml[x] = d.replaceEscape(d.options.templateHtml[x]);
h(s).html("");
if (C.dataInfo.rows) {
d.options.rows = parseInt(C.dataInfo.rows)
}
}
if((window.location.pathname=='/doctorWho.html'||window.location.pathname=='/doctorWhoAnother.html')&&C.dataToken.token==null){
if (C.dataInfo.status == "1") {
if (!u) {
A = null
}
if (B) {
h(s).html(d.setTemplate(d.options.templateHtml[x], C.dataInfo.data, A))
} else {
h(s).append(d.setTemplate(d.options.templateHtml[x], C.dataInfo.data, A))
}
h(s).show();
d.dialog(false, false, null, null);
if (y) {
m.icoEventCallback(y)
}
if (z) {
z.doing()
}
} else {
h(s).html("");
if (!w) {
w = "无数据"
}
d.dialog(false, d.options.timeout, w);
if (v) {
setTimeout(function () {
v.doing()
}, d.options.timeout)
}
}
return false;
}
if (d.setToken(C.dataToken)) {
if (C.dataInfo.status == "1") {
if (!u) {
A = null
}
if (B) {
h(s).html(d.setTemplate(d.options.templateHtml[x], C.dataInfo.data, A))
} else {
h(s).append(d.setTemplate(d.options.templateHtml[x], C.dataInfo.data, A))
}
h(s).show();
d.dialog(false, false, null, null);
if (y) {
m.icoEventCallback(y)
}
if (z) {
z.doing()
}
} else {
h(s).html("");
if (!w) {
w = "无数据"
}
d.dialog(false, d.options.timeout, w);
if (v) {
setTimeout(function () {
v.doing()
}, d.options.timeout)
}
}
}
},
error: function (E, D, C) {
d.dialog(false, d.options.timeout, "网络链接失败")
},
timeout: 9000
})
}
},
sendData: function (t, y, u, x, w, v, z, s) {
h.ajax({
type: "get",
url: t,
dataType: "jsonp",
data: h.extend(d.getToken(), y),
jsonp: "callback",
async: false,
crossDomain: true,
beforeSend: d.dialog(true, 2000, "处理中..."),
success: function (A) {
A = A || {};
if (u) {
d.setLoginToken(A.dataInfo);
d.version.setVer()
} else {
d.setToken(A.dataToken)
}
if (A.dataInfo.status == "1") {
if (x) {
d.dialog(false, d.options.timeout, x[1], null)
}
if (w) {
m.switchStatus(w)
}
if (v) {
m.icoEventCallback(v)
}
if (z) {
z.doing(A.dataInfo.data)
}
} else {
if (x) {
if (x[0]) {
d.dialog(false, d.options.timeout, x[0], null)
} else {
d.dialog(false, d.options.timeout, A.dataInfo.info, null)
}
} else {
d.dialog(false, d.options.timeout, A.dataInfo.info, null)
}
if (s) {
setTimeout(function () {
s.doing()
}, d.options.timeout)
}
}
},
error: function (C, B, A) {
d.dialog(false, d.options.timeout, "网络链接失败")
},
timeout: 9000
})
},
register: function (s, u, t, v, w) {
h.ajax({
type: "get",
url: s,
dataType: "jsonp",
data: u,
jsonp: "callback",
async: false,
crossDomain: true,
success: function (x) {
x = x || {};
if (x.dataInfo.status == "1") {
if (t) {
d.dialog(false, d.options.timeout, t[1], null)
}
if (v) {
v.doing(x.dataInfo.data)
}
if (w) {
if (window.parent) {
window.parent.location = w
} else {
window.location = w
}
}
} else {
if (t) {
if (t[0]) {
d.dialog(false, d.options.timeout, t[0], null)
} else {
d.dialog(false, d.options.timeout, x.dataInfo.info, null)
}
} else {
d.dialog(false, d.options.timeout, x.dataInfo.info, null)
}
if (v) {
if (v.err) {
v.err.doing(x.dataInfo.info)
}
}
}
},
error: function (z, y, x) {
d.dialog(false, d.options.timeout, "网络链接失败")
},
timeout: 19000
})
},
check: function (t, v, u, s) {
h.ajax({
type: "get",
url: t,
dataType: "jsonp",
data: v,
jsonp: "callback",
async: false,
crossDomain: true,
success: function (w) {
w = w || {};
if (w.dataInfo.status == "1") {
if (u) {
if (u[1]) {
d.dialog(false, d.options.timeout, u[1])
} else {
d.dialog(false, d.options.timeout, w.dataInfo.info)
}
}
} else {
if (u) {
if (u[0]) {
d.dialog(false, d.options.timeout, u[0])
} else {
d.dialog(false, d.options.timeout, w.dataInfo.info)
}
} else {
d.dialog(false, d.options.timeout, w.dataInfo.info)
}
if (s) {
s.doing()
}
}
},
error: function (y, x, w) {
d.dialog(false, d.options.timeout, "网络链接失败")
},
timeout: 9000
})
},
setTemplate: function (s, v, u) {
var w, t = "";
h.each(v, function (x, y) {
if (u) {
h.extend(y, u)
}
t += d.TemplateEngine(s, y)
});
return t
},
TemplateEngine: function (v, u) {
var w = /\[%([^%]+)?%]/g, s = /(^( )?(var|if|for|else|switch|case|break|{|}))(.*)?/g, x = "var r=[];\n",
z = 0, t;
var y = function (A, B) {
B ? (x += A.match(s) ? A + "\n" : "r.push(" + A + ");\n") : (x += A != "" ? 'r.push("' + A.replace(/"/g, '\\"') + '");\n' : "");
return y
};
while (t = w.exec(v)) {
y(v.slice(z, t.index))(t[1], true);
z = t.index + t[0].length
}
y(v.substr(z, v.length - z));
x += 'return r.join("");';
return new Function(x.replace(/[\r\t\n]/g, "")).apply(u)
},
replaceEscape: function (s) {
s = s.replace(/</g, "<");
s = s.replace(/>/g, ">");
s = s.replace(/&&/g, "&&");
return s
}
};
var g = {
getDaysInMonth: function (s, t) {
return 32 - new Date(s, t, 32).getDate()
}, getFirstDayOfMonth: function (t, u, s) {
var s = s || 1;
return new Date(t, u, s).getDay()
}, getToday: function () {
var s = new Date();
g.Y = s.getFullYear();
g.M = s.getMonth();
g.D = s.getDate()
}, toggle: function (s) {
var s = h(s);
if (s.hasClass("down")) {
h("#DateBox").addClass("show");
h(s).addClass("up").removeClass("down");
h(s).find(".title").html("收起")
} else {
h(s).addClass("down").removeClass("up");
h("#DateBox").removeClass("show");
h(s).find(".title").html("展开")
}
}, doHook: function () {
if (!h(this).hasClass("noNum")) {
h(".doHook").removeClass("hook");
h(this).addClass("hook").prev().addClass("rightborder").siblings().removeClass("rightborder")
}
h(".hzApp-list-calendar-master h2.title").html(h(this).attr("date"))
}, getList: function () {
var x = "";
var A = 1;
var t = new Date();
var v = g.getFirstDayOfMonth(g.Y, g.M);
for (var u = 0; u < 7; u++) {
var s = "";
switch (u) {
case 0:
s += "日";
break;
case 1:
s += "一";
break;
case 2:
s += "二";
break;
case 3:
s += "三";
break;
case 4:
s += "四";
break;
case 5:
s += "五";
break;
case 6:
s += "六";
break
}
x += '
' + s + "
"
}
for (var u = 0; u < v; u++) {
x += ' '
}
for (var u = 1; u <= g.getDaysInMonth(g.Y, g.M); u++) {
var z = new Date().toDate(g.Y + "-" + (g.M + 1) + "-1");
z.setDate(z.getDate() + (u - 1));
var y = z.format("yyyy-M-d");
if (A > g.getDaysInMonth(g.Y, g.M)) {
A = 1
}
if (v > 6) {
v = 0
}
if (g.Y == t.getFullYear() && g.M == t.getMonth() && A == t.getDate()) {
x += '
', v = "";
for (var s = 0; s < this.options.count; s++) {
v = this.options.count;
if (this.options.current == this.options.idx[s]) {
v += " current"
}
if(this.options.titles[this.options.idx[s]]=='门诊服务'){
t += '
";
this.el.html(t);
this._addEvent()
}, _addEvent: function () {
var s = this;
this.el.find(".listNav li").bind("tap", function () {
var token = window.hzAPI.getToken().token;//token
//判断token是否存在
if(!token){
window.location.href = 'login.html';
e.preventDefault();
return false;
}
var t = 0;
if (h(this).find("i").hasClass("*.home")) {
t = 1
}
if (h(this).find("i").hasClass("*.dept")) {
t = 2
}
if (h(this).find("i").hasClass("*.doctor")) {
t = 3
}
if (h(this).find("i").hasClass("*.booking")) {
t = 4
}
if (h(this).find("i").hasClass("*.like")) {
t = 5
}
if (h(this).find("i").hasClass("*.favorite")) {
t = 6
}
if (h(this).find("i").hasClass("*.drugCalendar")) {
t = 7
}
if (h(this).find("i").hasClass("*.doctorCalendar")) {
t = 8
}
window.location = s.options.urls[t]
})
}
};
var a = {
show: function () {
h("#popup_layer").addClass("show")
}, close: function () {
h("#popup_layer").removeClass("show");
h(".popup_layer_cont").html("")
}, getCount: function (s) {
var s = h.extend({}, s);
a.picker_selector_html = '
' + s.title + '
-
+
';
a.picker_selector_html += '';
a.picker_selector_html += '';
h(".popup_layer_cont").html(a.picker_selector_html);
var t = h("#counterValue");
t.val(s.obj_callback.val());
h("#counter_add").bind("tap", function () {
if (parseInt(t.val()) < 0) {
t.val(0)
}
t.val(parseInt(t.val()) + 1)
});
h("#counter_minus").bind("tap", function () {
if (parseInt(t.val()) < 0) {
t.val(0)
}
t.val(parseInt(t.val()) - 1)
});
h("#confirm_counter_picker").bind("tap", function () {
if (typeof s.obj_callback == "object") {
s.obj_callback.val(t.val())
}
a.close()
});
h("#cancel_counter_picker").bind("tap", function () {
a.close()
})
}
};
var q = {
getHours: function (t) {
var s = t.substring(0, 2);
return (s.substring(0, 1) == "0" ? s.substring(1, 2) : s)
}, getPlanFromGroups: function (w, v) {
var s = new Date().toDate(w);
var u = {morning: [], afternoon: [], evening: [], night: []};
var t = ["night", "morning", "afternoon", "evening"];
h.each(v, function (B, A) {
var x = new Date().toDate(A.startDate);
var E = new Date().toDate(A.startDate);
E.setDate(x.getDate() + A.days);
var z, C = new Array();
var y, D = 0;
if (s >= x && s <= E) {
z = A.consumptionHoursString.split(",");
C = A.quantityString.split(",");
for (i = 0; i < z.length; i++) {
y = parseInt(q.getHours(z[i]));
D = Math.floor(y / 6);
u[t[D]].push({
id: A.id,
date: null,
consumptionHours: z[i],
drugName: A.drugName,
quantity: C[i],
doseType: A.doseType,
status: "pending",
statusCn: "待服"
})
}
}
});
return u
}, getPlanFromSchedules: function (x, w) {
var t = new Date().toDate(x);
var v = {morning: [], afternoon: [], evening: [], night: []};
var u = ["night", "morning", "afternoon", "evening"];
var z = {pending: "待服", missing: "漏服", taken: "已服"};
var s, y = 0;
h.each(w, function (C, A) {
var B = new Date().toDate(A.originalDateTime);
if ((B.getFullYear() == t.getFullYear()) && (B.getMonth() == t.getMonth()) && (B.getDate() == t.getDate())) {
s = parseInt(q.getHours(A.consumptionHours));
y = Math.floor(s / 6);
v[u[y]].push({
id: A.id,
date: A.originalDateTime,
consumptionHours: A.consumptionHours,
drugName: A.drugName,
quantity: A.quantity,
doseType: A.doseType,
status: A.status,
statusCn: z[A.status]
})
}
});
return v
}, getAllPlan: function (w, u) {
var t = new Date().toDate(w);
var v, s = null;
var x = {dateTime: w, customerFamilyId: u};
if (t <= new Date()) {
v = window.apiUrl+"?c=Index&a=medicineSchedule";
s = 0
} else {
v = window.apiUrl+"?c=Index&a=medicineScheduleGroups";
s = 1
}
h.ajax({
type: "get",
url: v,
dataType: "jsonp",
data: h.extend(d.getToken(), x),
jsonp: "callback",
async: false,
crossDomain: true,
beforeSend: d.dialog(true),
success: function (y) {
y = y || {};
if (d.setToken(y.dataToken)) {
var z = null;
if (y.dataInfo.status == "1") {
if (s == 1) {
z = q.getPlanFromGroups(w, y.dataInfo.data)
} else {
z = q.getPlanFromSchedules(w, y.dataInfo.data)
}
localStorage.setItem("out", JSON.stringify(z));
q.showPlan(z);
q.resetEvent();
d.dialog(false, 300, null, null)
} else {
z = {morning: [], afternoon: [], evening: [], night: []};
q.showPlan(z);
localStorage.setItem("out", null);
d.dialog(false, 2000, "当天无服药信息")
}
}
},
error: function (A, z, y) {
d.dialog(false, 2000, "网络链接失败")
},
timeout: 9000
})
}, showPlan: function (t) {
for (var u in t) {
if (t[u].length > 0) {
h("#" + u).html('' + t[u].length + "")
} else {
h("#" + u).html("")
}
}
var s = new Date().getHours();
var v = ["nightTitle", "morningTitle", "afternoonTitle", "eveningTitle"],
w = ["night", "morning", "afternoon", "evening"];
h("#" + v[Math.floor(s / 6)]).addClass("doing");
h("#" + w[Math.floor(s / 6)]).addClass("doing")
}, resetEvent: function () {
h("#ListCycle li a").bind("tap", function () {
var s = {night: "凌晨", morning: "上午", afternoon: "下午", evening: "晚上"};
title = "服用清单 - " + g.Y + "年" + (g.M + 1) + "月" + g.D + "日 " + s[h(this).parent().attr("id")];
m.popWinLayer(h(this).attr("vhref") + "&date=" + g.Y + "-" + (g.M + 1) + "-" + g.D, title)
})
}
};
var f = {
getUrlParam: function (s) {
var t = new RegExp("(^|&)" + s + "=([^&]*)(&|$)");
var u = window.location.search.substr(1).match(t);
if (u != null) {
return u[2]
} else {
return null
}
}, setNewDrugPlanList: function (x, u) {
var y = "", t = 12 / (x - 1), s = 8, v = "08:00";
for (var w = 1; w <= x; w++) {
y += '
服用
';
s += t;
if (s > 9) {
v = s
} else {
v = "0" + s
}
v += ":00"
}
u.html(y);
u.find("li").bind("tap", function () {
l.getList(h(this).find("[name='consumptionHours']"), h(this).find("[name='quantity']"));
l.show()
})
}, getDrugHoursQuantity: function () {
var s = "", t = "";
h("#hours-quantity li").each(function (u) {
if (u > 0) {
s += ",";
t += ","
}
s += h(this).find("input[type=text][name=consumptionHours]").val();
t += h(this).find("input[type=text][name=quantity]").val()
});
return [s, t]
}, setDrugPlanList: function (x, t) {
var s = x.consumptionHoursString.split(",");
var v = x.quantityString.split(",");
var w = "";
for (var u = 0; u < s.length; u++) {
w += '
服用
'
}
t.html(w);
t.find("li").bind("tap", function () {
l.getList(h(this).find("[name='consumptionHours']"), h(this).find("[name='quantity']"));
l.show()
})
}, getSelectOptionsText: function (t) {
var s = "";
t.find("option").forEach(function (u) {
if (t.val() == h(u).val()) {
s = h(u).text()
}
});
return s
}, getClass: function (s) {
if (s) {
return "is-active"
} else {
return ""
}
}
};
var l = {
addZero: function (s) {
return (s < 10 ? "0" + s : s)
}, solarDays: function (u, t) {
var s = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
if (t == 1) {
return (((u % 4 == 0) && (u % 100 != 0) || (u % 400 == 0)) ? 29 : 28)
} else {
return (s[t])
}
}, show: function () {
h("#popup_layer").addClass("show")
}, close: function () {
h("#popup_layer").removeClass("show");
h(".popup_layer_cont").html("")
}, getList: function (t, F) {
var A = {hasSecond: false, isCustomLeftButton: false, customLeftButtonName: "清除"};
l.picker_selector_html = '
设置服用时间
';
if (A.hasSecond) {
l.picker_selector_html += '
:
';
l.picker_selector_html += '
:
'
} else {
l.picker_selector_html += '
:
'
}
l.picker_selector_html += '
';
if (A.hasSecond) {
l.picker_selector_html += '
'
}
l.picker_selector_html += '
设置服用数量
-
+
';
if (A.isCustomLeftButton) {
l.picker_selector_html += '