123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129 |
- (function ( $, win) {
- $(function () {
- var d = dialog({contentType:'load', skin:'bk-popup'});
- var Request = GetRequest();
- var type = Request["type"],
- sncode = Request["sncode"],
- categoryCode = Request["categoryCode"],
- $yqName = $('.yq-name'),
- $szTime = $('.sz-time'),
- $ttSendBtn = $('.tt-send-btn'),
- tips = ['早餐前血糖', '早餐后血糖', '午餐前血糖', '午餐后血糖', '晚餐前血糖', '晚餐后血糖', '睡前血糖'];
-
- function checkDate( v, index) {
- if (v == '') {
- switch (index) {
- case 0:
- dialog({contentType:'tipsbox', skin:'bk-popup',bottom:true , content:tips[index]}).show();
- break;
- case 1:
- dialog({contentType:'tipsbox', skin:'bk-popup',bottom:true , content:tips[index]}).show();
- break;
- case 2:
- dialog({contentType:'tipsbox', skin:'bk-popup',bottom:true , content:tips[index]}).show();
- break;
- case 3:
- dialog({contentType:'tipsbox', skin:'bk-popup',bottom:true , content:tips[index]}).show();
- break;
- case 4:
- dialog({contentType:'tipsbox', skin:'bk-popup',bottom:true , content:tips[index]}).show();
- break;
- case 5:
- dialog({contentType:'tipsbox', skin:'bk-popup',bottom:true , content:tips[index]}).show();
- break;
- case 6:
- dialog({contentType:'tipsbox', skin:'bk-popup',bottom:true , content:tips[index]}).show();
- break;
- }
- d.close();
- return true;
- }
- return false;
- }
-
- //添加数据
- function addData () {
- d.show();
- var o = {},
- isTrue = false,
- isGo = false;
- o.deviceSN = sncode;
- o.categoryCode = categoryCode; //设备分类 血糖仪1 血压计 2
- o.userType = "-1"; //是否多用户
- $.each( $szTime, function (index) {
- var tArr = ($(this).val()).split('-');
- if (!isTrue) {
- isTrue = checkDate( $(this).val(), index);
- isGo = checkDate( $(this).val(), index);
- switch (index) {
- case 0:
- o.fastingStart = tArr[0] + ':00';
- o.fastingEnd = tArr[1] + ':59';
- break;
- case 1:
- o.afterBreakfastStart = tArr[0] + ':00';
- o.afterBreakfastEnd = tArr[1] + ':59';
- break;
- case 2:
- o.beforeLunchStart = tArr[0] + ':00';
- o.beforeLunchEnd = tArr[1] + ':59';
- break;
- case 3:
- o.afterLunchStart = tArr[0] + ':00';
- o.afterLunchEnd = tArr[1] + ':59';
- break;
- case 4:
- o.beforeDinnerStart = tArr[0] + ':00';
- o.beforeDinnerEnd = tArr[1] + ':59';
- break;
- case 5:
- o.afterDinnerStart = tArr[0] + ':00';
- o.afterDinnerEnd = tArr[1] + ':59';
- break;
- case 6:
- o.beforeSleepStart = tArr[0] + ':00';
- o.beforeSleepEnd = tArr[1] + ':59';
- break;
- }
- }
- });
- if (!isGo) {
- console.log(o)
- sendPost("patient/device/setBloodTime", o, "json", "get", function(res){
- d.close();
- dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'保存失败'}).show();
- }, function (res) {
- d.close();
- if (res.status == 200) {
- dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:res.msg}).show();
- setTimeout(function(){
- window.location.href='my-equipments.html';
- },1000);
- } else {
- dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'保存失败'}).show();
- }
- });
- }
- }
- function pushHistory() {
- var state = {
- title: "title",
- url: "#"
- };
- window.history.pushState(state, "title", "#");
- }
- pushHistory();
-
- function bindEvent () {
- setTimeout( function () {
- window.addEventListener("popstate", function(e) {
- location.href = 'my-equipments.html';
- }, false);
- }, 300);
- $ttSendBtn.on( 'click', function () {
- addData();
- });
- }
- bindEvent();
- });
- })( jQuery, window);
|