const tempTip={ fadingDuration:4500, inputType:'input', index:99, setIndex:function(index){ this.index=parseInt(index); }, setDuration:function(milliSec){ this.fadingDuration=parseInt(milliSec); }, setInputType:function(type){ this.inputType=type; }, showSuccess:function(text){ let tiper=$("
" + "
" + text + "
"); tiper.animate({opacity:'0'},this.fadingDuration,'swing',function () { tiper.remove(); }); $('body').append(tiper); }, show:function(text){ let tiper=$("
" + "
" + text + "
"); tiper.animate({opacity:'0'},this.fadingDuration,'swing',function () { tiper.remove(); }); $('body').append(tiper); }, okWindow:function(text,okText){ let bg=$("
" ); if(typeof(okText)=='undefined')okText='确定'; let tiper=$("
" + "
" + text + "

" + "
"); tiper.find('.okWindow').on('click',function () { tiper.off('click'); tiper.remove(); bg.remove(); }); $('html').css('height', '100%').append(bg); $('body').append(tiper) }, waitingTip:function(text){ let bg=$("
" ); let tipper=$("
" + "
" + text + "
"); tipper.animate({opacity:'0'},this.fadingDuration,'swing',function () { tipper.remove(); bg.remove(); }); $('html').css('height', '100%').append(bg); $('body').append(tipper); }, cancelWaitingTip:function(){ let bg=$(".tipperBg"); let tipper=$(".tipper"); tipper.remove(); bg.remove(); }, confirm:function(text,yesFunc,noFunc,yesText,noText){ if(typeof(yesText)==='undefined')yesText='确定'; if(typeof(noText)==='undefined')noText='取消'; let bg=$("
" ); let tiper=$("
" + "
" + text + "
" + "
" + "
"); let $ok = tiper.find('.ok'); let $cancel = tiper.find('.cancel'); $ok.on('click',function () { $ok.off('click'); $cancel.off('click'); tiper.remove(); bg.remove(); yesFunc(); }); $cancel.on('click',function () { $ok.off('click'); $cancel.off('click'); tiper.remove(); bg.remove(); if(typeof noFunc!='undefined') noFunc(); }); $('html').css('height', '100%').append(bg); $('body').append(tiper); }, inputVal:function(tipText,resultFunc){ let bg=$("
" ); let tiper=$("
" + "
" + tipText + "
" + "
" + "
"); let $ok = tiper.find('.ok'); let $input = tiper.find('.input'); $ok.on('click',function () { $ok.off('click'); tiper.remove(); bg.remove(); resultFunc($input.val()) }); $('html').css('height', '100%').append(bg); $('body').append(tiper); $input.focus() }, postBasicRequest(url, params, successExe, isPriority = false, isMultipart = false) { if (isPriority)this.setIndex(1099); let header = {}; if (isMultipart)header = {'Content-Type': 'multipart/form-data'}; window.axios.post(url,params,header).then(res=> { if (res.data.success){ let successMsg = successExe(res.data.data); if (successMsg){ this.setDuration(2000); this.showSuccess(successMsg); } return; } this.setDuration(3000); this.show(res.data.data); }).catch(err=> { console.log(err); this.setDuration(3000); this.show('网络异常:'+err); }); }, showErrorAudio:function (){ let src='/sound/滴答电子.mp3'; let audio= new Audio(src); setTimeout(function (){ audio.play(); }) window.navigator.vibrate(1000); } }; module.exports=tempTip;