h5-cli
Version:
hello
235 lines (199 loc) • 10.5 kB
JavaScript
"use strict";
define(function (require, exports, module) {
var VModule = require("component/VModule");
var vaccineList = require("vaccine-list");
var SAVE_KEY = "vaccine";
var page = VModule.render({
init: function init() {
this.state = {
loading: true
};
this.unionId = this.query.unionId;
this.corpId = this.query.corpId || this.corpId;
if (this.unionId != 60) {
$('#J_Page').html("\n <section class=\"ui-notice\" >\n <i></i>\n <p>\u5F53\u524D\u57CE\u5E02\u672A\u5F00\u901A\u6B64\u670D\u52A1\uFF0C\u656C\u8BF7\u671F\u5F85</p>\n </section>\n ");
return;
}
//\u83b7\u53d6\u4e0a\u4e00\u6b21\u7f13\u5b58\u7684\u5c31\u8bca\u4ebaid
this.cachePatientId = this.getcachePatientId();
this.initModule(this.state, '#J_Page');
this.moduleDidMount();
},
getcachePatientId: function getcachePatientId() {
return this.cache.getCacheModule(SAVE_KEY).get("patient").value;
},
moduleDidMount: function moduleDidMount() {
//\u83b7\u53d6\u513f\u7ae5\u5c31\u8bca\u4eba\u5217\u8868
this.setState({ loading: true });
this.get("/user-web/restapi/patient/getList", {
unionId: this.unionId,
//corpId: this.corpId,
patientType: 3 //1\u5168\u90e8 2\u6210\u4eba 3\u513f\u7ae5
});
},
//\u9009\u62e9\u5b8c\u5c31\u8bca\u4eba\u56de\u6765
onActivation: function onActivation() {
var patientId = this.getcachePatientId();
if (this.cachePatientId != patientId) {
this.cachePatientId = patientId;
this.moduleDidMount();
}
},
//\u5339\u914d\u7f13\u5b58\u4e2d\u7684\u5c31\u8bca\u4eba
matchingCachePatint: function matchingCachePatint(patientList, patientId) {
for (var i = 0; i < patientList.length; i++) {
//\u663e\u793a\u4e0a\u4e00\u6b21\u7684\u5c31\u8bca\u4eba\u75ab\u82d7\u8ba1\u5212
if (patientList[i].id == patientId) {
//\u663e\u793a\u5217\u8868
return patientList[i];
break;
}
}
return patientList[0];
},
onSuccess: function onSuccess(result) {
var patientList = result.data;
if (patientList.length) {
result.loading = false;
this.setState(result);
//\u5f53\u524d\u5217\u8868\u548c\u7f13\u5b58\u4e2d\u7684\u5c31\u8bca\u4eba\u5339\u914d\uff0c\u5426\u5219\u663e\u793a\u7b2c1\u4e2a\u5c31\u8bca\u4eba
var patient = this.matchingCachePatint(patientList, this.cachePatientId);
vaccineList.init(patient.id, patient.patientName);
} else {
//\u663e\u793a\u6ca1\u6709\u4eba
this.setState({ success: false, loading: false });
}
},
onError: function onError(result) {
result.loading = false;
this.errorHandle(result);
this.setState(result);
},
//render\u51fd\u6570\u7406\u8bba\u4e0a\u4e0d\u4f1a\u8c03\u7528
render: function render(state) {
return "";
},
renderError: function renderError(state) {
return "\n <div class=\"no-child\">\n <div class=\"add-child\">\n <div class=\"add-child-imge\"></div>\n <div class=\"add-child-notice\">\u60A8\u5C1A\u672A\u6DFB\u52A00\u81F37\u5C81\u5C31\u8BCA\u4EBA</div>\n <div class=\"add-child-prompt\">\u8BF7\u5148\u6DFB\u52A0\u5C31\u8BCA\u4EBA\u5E76\u7ED1\u5B9A\u5C31\u8BCA\u5361</div>\n <div class=\"ui-btn-wrap\">\n <a class=\"ui-btn ui-btn-primary btn-add\" \n href=\"../add-patient.html?" + this.util.flat({ unionId: this.unionId, target: "_blank" }) + "\"\n >\n \u6DFB\u52A0\u5C31\u8BCA\u4EBA\n </a>\n </div>\n </div>\n </div>\n ";
}
});
//\u9875\u9762
page.init();
window.aaaa = page;
module.exports = page;
});
//\u5f53\u524d\u75ab\u82d7list
define("vaccine-list", function (require, exports, module) {
var VModule = require("component/VModule");
var SAVE_KEY = "vaccine";
var page = VModule.render({
init: function init(patientId, patientName) {
this.state = {
loading: true
};
this.patientId = patientId;
this.patientName = patientName;
this.unionId = this.query.unionId;
//\u7b2c\u4e8c\u6b21\u8c03\u7528 \u4e0d\u5728\u521d\u59cb\u5316 module
if (!this.module) {
this.initModule(this.state, '#J_Page');
}
this.moduleDidMount();
},
moduleDidMount: function moduleDidMount() {
//\u5373\u5c06\u63a5\u79cd\u7684\u9488\u6b21
// var result = {
// "success": true,
// "resultCode": "100",
// "msg": "\u6210\u529f",
// "data": {
// childInfo:{
// "name":"test",
// "birthday":"2016-01-01",
// "sex":"\u7537",
// "institutionName":"\u63a5\u79cd\u673a\u6784\u7f16\u53f7"
// },
// scheduleList:[
// {
// "vaccineName":"\u75ab\u82d7\u540d\u79f0",
// "stepIndex":"\u9488\u6b21",
// "estimateDate":"2016-01-01",
// "isInoc":"0" //0\u8868\u793a\u672a\u63a5\u79cd\uff0c1\uff1a\u5df2\u63a5\u79cd
// },
// {
// "vaccineName":"\u75ab\u82d7\u540d\u79f0",
// "stepIndex":"\u9488\u6b21",
// "estimateDate":"2016-01-01",
// "isInoc":"0" //0\u8868\u793a\u672a\u63a5\u79cd\uff0c1\uff1a\u5df2\u63a5\u79cd
// }
// ]
// },
// "startTime": 1470220741958,
// "timeConsum": 71
// };
// this.onSuccess( result )
this.setState({ loading: true });
this.get("/user-web/restapi/vaccine/schedule/next", {
patientId: this.patientId,
corpUnionId: this.unionId,
unionId: this.unionId
});
},
onSuccess: function onSuccess(result) {
result.loading = false;
this.setState(result);
},
render: function render(state) {
/**
childInfo = {
"name":"test",
"birthday":"2016-01-01",
"sex":"\u7537",
"institutionName":"\u63a5\u79cd\u673a\u6784\u7f16\u53f7"
}
*/
var childInfo = state.data.childInfo || {};
/*
scheduleList = [
{
"vaccineName":"\u75ab\u82d7\u540d\u79f0"\uff0c
"stepIndex":"\u9488\u6b21",
"estimateDate":"2016-01-01",
"isInoc":"0" //0\u8868\u793a\u672a\u63a5\u79cd\uff0c1\uff1a\u5df2\u63a5\u79cd
}
]
*/
var scheduleList = state.data.scheduleList || [];
/**
<div class="nobinding-card">
<div class="nobinding-inner">
<div class="nobinding-imge"></div>
<div class="nobinding-notice">\u60a8\u5c1a\u672a\u7ed1\u5b9a\u5c31\u8bca\u5361</div>
<div class="nobinding-prompt">\u7ed1\u5b9a\u540e\u53ef\u4eab\u53d7\u4fbf\u6377\u7684\u9884\u9632\u63a5\u79cd\u670d\u52a1</div>
<div class="ui-btn-wrap">
<button class="ui-btn ui-btn-primary btn-nobinding">
\u7acb\u5373\u7ed1\u5b9a
</button>
</div>
</div>
</div>
*/
//1200 100 \u672a\u7ed1\u5b9a\u5c31\u8bca\u5361
var bindCard = state.data.bindCard;
return "\n <div class=\"vaccine-manage \">\n <a class=\"user-message\" href=\"../patient-list.html?" + this.util.flat({ unionId: this.unionId, selectView: "1", target: "_blank", saveKey: SAVE_KEY, patientType: 3 }) + "\">\n <div class=\"user-name\">" + childInfo.name + "</div>\n <div class=\"hospital-address\">" + (childInfo.institutionName || "\u65e0") + "</div>\n <div class=\"jump-corner\"></div>\n </a>\n " + this.renderData(bindCard, scheduleList, childInfo) + "\n </div>\n ";
},
renderData: function renderData(bindCard, scheduleList, childInfo) {
if (!bindCard) {
return "\n <div class=\"nobinding-card\">\n <div class=\"nobinding-inner\">\n <div class=\"nobinding-imge\"></div>\n <div class=\"nobinding-notice\">\u5C1A\u672A\u7ED1\u5B9A\u5C31\u8BCA\u5361</div>\n <div class=\"nobinding-prompt\">\u7ED1\u5B9A\u540E\u53EF\u4EAB\u53D7\u4FBF\u6377\u7684\u9884\u9632\u63A5\u79CD\u670D\u52A1</div>\n <div class=\"ui-btn-wrap\">\n <a href=\"../add-patient.html?" + this.util.flat({ unionId: this.unionId, id: this.patientId, target: "_blank" }) + "\" class=\"ui-btn ui-btn-primary btn-nobinding\">\n \u7ACB\u5373\u7ED1\u5B9A\n </a>\n </div>\n </div>\n </div>\n ";
}
if (scheduleList.length) {
return "\n <div class=\"vaccine-plan-list\">\n <div class=\"vaccine-plan-title\">\u60A8\u7684\u4E0B\u4E00\u6B21\u63A5\u79CD\u75AB\u82D7\u4E3A\uFF1A</div>\n </div>\n <div class=\"vaccine-plan-inner\">\n " + scheduleList.map(function (item) {
return "\n <div class=\"vaccine-item " + (item.isInoc == 0 ? "vaccine-no" : "") + "\">\n <div class=\"vaccine-name\">" + item.vaccineName + "</div>\n <div class=\"ui-flex vaccine-message\">\n <div class=\"message-anyagent\">" + item.stepIndex + "</div>\n <div class=\"message-time\">" + item.estimateDate + "</div>\n </div>\n </div>\n ";
}).join("") + "\n <div class=\"ui-footer ui-footer-stable ui-btn-group ui-border-t btn-check\">\n <a href=\"vaccine-all.html?" + this.util.flat({ unionId: this.unionId, patientId: this.patientId, target: "_blank" }) + "\" class=\"ui-btn-lg ui-btn-primary\">\n \u67E5\u770B\u63A5\u79CD\u8BA1\u5212\n </a>\n </div>\n ";
} else {
return "\n <section class=\"ui-notice\" >\n <i></i>\n <p>\u6682\u65E0\u75AB\u82D7\u63A5\u79CD\u8BA1\u5212</p>\n </section>\n ";
}
}
});
module.exports = page;
});