dcloud动态页面b2跳转刷新mui
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>手动记录</title>
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
<link href="../../css/mui.min.css" rel="stylesheet" />
<link rel="stylesheet" href="../../css/mui.picker.min.css" />
<link rel="stylesheet" href="../../css/health.css" />
</head>
<body>
<header class="mui-bar mui-bar-nav" id="bloodPressureRecord">
<a class="mui-action-back">
<b class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left c5"></b>
<h1 class="mui-title mui-text-left c5">手动记录</h1>
</a>
</header>
<div class="mui-content f14 c5">
<form class="mui-input-group" action="">
<div class="mui-input-row">
<label>收缩压(高压)</label>
<input type="text" id="systolic" class="mui-text-right" placeholder="请输入 mmHg" />
</div>
<div class="mui-input-row">
<label>舒张压(低压)</label>
<input type="text" id="diastolic" class="mui-text-right" placeholder="请输入 mmHg" />
</div>
<div class="mui-input-row">
<label>脉搏</label>
<input type="text" id="pulse" class="mui-text-right" placeholder="请输入 次/分" />
</div>
<div class="mui-row jays-mdate" id="dateBtn" data-options='{"type": "date","beginYear": 1990,"endYear": 2088}'>
<div class="mui-col-xs-6 mui-col-sm-6">
测量日期
</div>
<div id="resultDate" class="ui-alert mui-col-xs-6 mui-col-sm-6 mui-text-right">
</div>
</div>
<div class="mui-row jays-mtime" id="timeBtn" data-options='{"type": "time"}'>
<div class="mui-col-xs-6 mui-col-sm-6">
测量时间
</div>
<div id="resultTime" class="ui-alert mui-col-xs-6 mui-col-sm-6 mui-text-right">
</div>
</div>
<button id="addSub" class="mui-btn mui-btn-block jays-submit">保存</button>
</form>
</div>
<script src="../../js/mui.min.js"></script>
<script src="../../js/mui.picker.min.js"></script>
<script type="text/javascript">
(function($) {
$.init();
var resultDate = $('#resultDate')[0];
var resultTime = $('#resultTime')[0];
$('.jays-mdate')[0].addEventListener('tap', function() {
var optionsJson = this.getAttribute('data-options') || '{}';
var options = JSON.parse(optionsJson);
var id = this.getAttribute('id');
var picker = new $.DtPicker(options);
picker.show(function(rs) {
resultDate.innerText = rs.text;
picker.dispose();
});
}, false);
$('.jays-mtime')[0].addEventListener('tap', function() {
var optionsJson = this.getAttribute('data-options') || '{}';
var options = JSON.parse(optionsJson);
var id = this.getAttribute('id');
var picker = new $.DtPicker(options);
picker.show(function(rs) {
resultTime.innerText = rs.text;
picker.dispose();
});
}, false);
})(mui);
mui('body').on('tap', '#addSub', function() {
var systolicVal = document.getElementById("systolic").value;
var diastolicVal = document.getElementById("diastolic").value;
var pulseVal = document.getElementById("pulse").value;
var resultTime = document.getElementById("resultTime").innerHTML;
var resultDate = document.getElementById("resultDate").innerHTML;
mui.ajax('', {
data: {
access_token: '',
type: 7,
systolic: systolicVal,
diastolic: diastolicVal,
pulse: pulseVal,
time: resultTime,
day: resultDate
},
dataType: 'json', //服务器返回json格式数据
type: 'post', //HTTP请求类型
timeout: 10000, //超时时间设置为10秒;
//headers:{'Content-Type':'application/json'},
success: function(data) {
//console.log(JSON.stringify(data));
if(data.code == 1) {
mui.toast('记录成功');
mui.openWindow({
url: 'blood_pressure.html',
id: 'blood_pressure',
show: {
aniShow: 'slide-in-right',
duration: 200
},
waiting: {
autoShow: false
}
});
} else if(data.code == -1) {
mui.toast(data.msg);
}
},
error: function(xhr, type, errorThrown) {
mui.toast('系统异常');
}
});
});
</script>
</body>
</html>