var isGet,//0不需要请求
code,
type;
var typeArr=[{'code':1,'name':'电话回复'},{'code':2,'name':'客服回复'}]
var stateArr=[{'code':1,'name':'完成'},{'code':2,'name':'无法联系'}]
var reasonArr=[{'code':1,'name':'预约成功'},{'code':2,'name':'预约失败'}]
var yuyueArr=[{'code':1,'name':'没有号源'},{'code':2,'name':'病人取消'}]
mui.plusReady(function(){
var self = plus.webview.currentWebview();
type = self.type;
code = self.code;
var html = template('text_tmp',{data:{time:getNowDate()},type:type})
$('#show_content').html(html)
bindEvents();
})
function bindEvents(){
initMobiscroll(typeArr,$("#handle_type"),'')
initMobiscroll(stateArr,$("#handle_result"),'')
initMobiscroll(yuyueArr,$("#handle_cause"),'')
$("#submitBtn").on('click', function(){
if(type == 0){
var dealType = $('#handle_type').attr('data-id');
var dealState = $('#handle_result').attr('data-id');
if(!dealType){
mui.toast('请选择处理方式')
return
}
if(!dealState){
mui.toast('请选择处理结果')
return
}
var params = {
code:code,
dealType:dealType,
dealState:dealState,
dealContent:$('#handle_text').val().trim()
}
plus.nativeUI.showWaiting();
sendPost("doctor/pcCustomer/dealConsultCallService",params, function(){
plus.nativeUI.closeWaiting();
mui.toast("请求失败");
}, function(res){
plus.nativeUI.closeWaiting();
if(res.status == 200){
mui.toast('保存成功')
refreshHz()
closePage()
}else{
mui.toast('保存失败')
}
})
}
if(type == 1){
var dealCause = $('#handle_cause').attr('data-id');
if(!dealCause){
mui.toast('请选择原因')
return
}
var params = {
code:code,
type:2,//预约失败
dealReason:dealCause,
dealContent:$('#handle_yytext').val().trim()
}
plus.nativeUI.showWaiting();
sendPost("doctor/pcCustomer/dealAppointCallService",params, function(){
plus.nativeUI.closeWaiting();
mui.toast("请求失败");
}, function(res){
plus.nativeUI.closeWaiting();
if(res.status == 200){
mui.toast('保存成功')
refreshHz()
closePage()
}else{
mui.toast('保存失败')
}
})
}
})
}
function initMobiscroll(data,$id,curid){
var html = '';
$.map(data,function(item,index){
if(item.code == curid){
html += '';
}else{
html += '';
}
})
$id.html(html);
$id.mobiscroll().select({
theme: 'ios',
lang: 'zh',
display: 'bottom',
placeholder:'请选择',
rows:4,
onSelect: function ( valueText, inst) {
$id.attr('data-id',inst._tempValue)
}
})
}
//刷新事件
function refreshHz(){
var page = plus.webview.getWebviewById("xietongfuwu-management");
if(page){ mui.fire(page, "refreshXietong") }
var page1 = plus.webview.getWebviewById("xietongfuwu-message");
if(page1){ mui.fire(page1, "refreshXTmsg") }
}
//关闭页面
function closePage(){
var page = plus.webview.getWebviewById("xietongfuwu-detail");
if(page){ page.close('none') }
var page1 = plus.webview.getWebviewById("appointment-register");
if(page1){ page1.close('none') }
var page2 = plus.webview.getWebviewById("hospital-dept");
if(page2){ page2.close('none') }
var page3 = plus.webview.getWebviewById("xietongfuwu-yy");
if(page3){ page3.close('none') }
var page4 = plus.webview.getWebviewById("select-doctor");
if(page4){ page4.close('none') }
var page5 = plus.webview.getWebviewById("doctor-detail");
if(page5){ page5.close('none') }
var page6 = plus.webview.getWebviewById("info-confirm");
if(page6){ page6.close('none') }
var page7 = plus.webview.getWebviewById("detail-appointment");
if(page7){ page7.close('none') }
setTimeout(function(){ mui.back() },1000)
}
//现在时间
function getNowDate() {
var date = new Date();
var year = date.getFullYear();
var month = date.getMonth() + 1;
var day = date.getDate();
var hour = date.getHours();
var minute = date.getMinutes();
var second = date.getSeconds();
return year+'-'+(month<10?'0'+month:month)+'-'+(day<10?'0'+day:day)+' '+(hour<10?'0'+hour:hour)+':'+(minute<10?'0'+minute:minute)+':'+(second<10?'0'+second:second);
}