mui.plusReady(function() { var self = plus.webview.currentWebview(); var doctorCode = self.doctorCode; var dept =self.dept; var name = self.name; var src = self.photo; if (name) { document.getElementById("doc_name").innerHTML = name + ''; } if (dept) { document.getElementById("doc_dept").innerHTML = dept; } if (src) { document.getElementById("doc_img").src = getImgUrl(src); } var userAgent = plus.storage.getItem(agentName); if(userAgent){ var jsonstr = $.parseJSON(userAgent); var uid = jsonstr.uid; var name = decodeURI(jsonstr.name); document.getElementById("labName").innerHTML = name; // var params = {}; // params.code = uid; // mui.ajax(server + "patient/info", { // data: params, // type: 'POST', // dataType: 'json', // error: function(res) { // mui.toast('用户获取失败'); // plus.nativeUI.closeWaiting(); // }, // success: function(res) { // plus.nativeUI.closeWaiting(); // if (res.status == 200) { // var name = res.data.name; // document.getElementById("labName").innerHTML = name; // } else { // mui.toast('用户获取失败') // } // } // }); } document.querySelector("#commit").addEventListener("tap", function() { var data = {}; data.doctor = doctorCode; data.content = $("#remark").val(); data.scheduling = ""; data.appo_date = "2016-05-09"; data.appo_week = 1; data.hour_begin = "08:30:00"; data.hour_end = "18:00:00"; if (validate(data)) { //验证通过执行 //upload(data); plus.nativeUI.closeWaiting(); mui.openWindow({ url: "vedio-consulting-commit-success.html", id: "vedio-consulting-commit-success", extras: { type: 1 }, waiting: { autoShow: false } }); } }); }) //验证信息 function validate(data) { if (data.content == '') { plus.nativeUI.closeWaiting(); mui.toast('请详细描述您的症状'); return false; } if (data.content.length > 500) { plus.nativeUI.closeWaiting(); mui.toast('请用500字以内完成您的症状描述'); return false; } return true; } // 上传文件 function upload(data) { plus.nativeUI.showWaiting(); var files = getImages(); if (files.length <= 0) { data.images = ""; data.imageUrls = ""; doSubmit(data); } else { var task = plus.uploader.createUpload(server + 'upload/image', { method: "POST" }, function(t, status) { //上传完成 if (status == 200) { var jsonstr = $.parseJSON(t.responseText); if(jsonstr.status == 200){ data.images = jsonstr.images; data.imageUrls = jsonstr.urls; doSubmit(data); } else { plus.nativeUI.closeWaiting(); mui.toast(jsonstr.msg); } } else { plus.nativeUI.closeWaiting(); mui.toast("上传失败:" + status); } } ); task.addData("client", "HelloH5+"); task.addData("uid", getUid()); for (var i = 0; i < files.length; i++) { var f = files[i]; task.addFile(f, {}); } task.start(); } } //提交咨询 function doSubmit(data) { sendPost('patient/consult_movi/add', data, 'json', 'post', submitFailed, submitSuccess); } function submitFailed(res) { plus.nativeUI.closeWaiting(); if (res && res.msg) { plus.nativeUI.toast(res.msg); } else { plus.nativeUI.toast("提交失败"); } } function submitSuccess(res) { plus.nativeUI.closeWaiting(); if (res.status == 200) { mui.openWindow({ url: "vedio-consulting-commit-success.html", id: "vedio-consulting-commit-success", extras: { type: 1 }, waiting: { autoShow: false } }); mui.toast('提交成功'); } else { submitFailed(res); } } function voicePop(n) { $(".win-broadcast,.win-broadcast-mb").show(); $("#voice-finish").click(function() { $("#voice" + n).show(); $(".win-broadcast,.win-broadcast-mb").hide(); }); } function voicePopClose() { $(".win-broadcast,.win-broadcast-mb").hide(); } $(function() { $('.broadcast-icon').on('click',function(){ $('.broadcast-shadow-panel').removeClass('c-hide'); }); $('.win-cancle').on('click',function(){ $('.broadcast-shadow-panel').addClass('c-hide'); }); //显示隐藏选择图片按钮 $(".add-btn").on("click", function() { //getImages(); $(".over-lay").show(); $(".ins-img-btn").show(); }); $("[data-btn=cancelOver]").on("click", function() { $(".over-lay").hide(); $(".ins-img-btn").hide(); }); }); //查看图片 function viewImg(dom) { var $img = $(dom); var thissrc = $img.attr("date"); var mWid = $(window).width(); var mHei = $(window).height(); var nHtml = '
'; $("body").append(nHtml); $(".delimgpop").click(function() { $(this).remove() }); }; //删除图片 function delImg(dom) { var $li = $(dom).parent(); $li.remove(); return; } /* 复选框兼容 */ $(document).on("click", ".input-group-pack > input[type=checkbox]", function() { var $cpChk = $(this).parent(); if ($(this).attr("checked") == "checked") { $cpChk.removeClass("checked"); $(this).removeAttr("checked"); } else { $cpChk.addClass("checked"); $(this).attr("checked", true); } }); // 拍照添加文件 function appendByCamera() { plus.camera.getCamera().captureImage(function(p) { //拍照完成,隐藏选择对话框 hideImageChooseDialog(); plus.io.resolveLocalFileSystemURL(p, function(entry) { var localurl = entry.toLocalURL(); appendFile(localurl); }); }, function(e) { //取消拍照,隐藏选择对话框 hideImageChooseDialog(); }); }; //隐藏图片方法 function hideImageChooseDialog() { $(".over-lay").hide(); $(".ins-img-btn").hide(); }; // 从相册添加文件 function appendByGallery() { plus.gallery.pick(function(p) { appendFile(p); }); } // 从相册中选择多张图片 function galleryImgs() { // 从相册中选择图片 plus.gallery.pick(function(e) { for (var i in e.files) { appendFile(e.files[i]); } }, function(e) { //取消拍照,隐藏选择对话框 hideImageChooseDialog(); }, { filter: "image", multiple: true }); } // 添加文件 function appendFile(p) { var $li = $('
  • ' + ' ' + ' ' + '
  • '); var $add_img_li = $("#add_img_li"); $add_img_li.before($li); $(".over-lay").hide(); $(".ins-img-btn").hide(); } // 产生一个随机数 function getUid() { return Math.floor(Math.random() * 100000000 + 10000000).toString(); } //获取需要上传的图片 function getImages() { var images = []; $("#img_ul").find("img").each(function() { var imgSrc = $(this).attr("src"); images.push(imgSrc); }); return images; } //字数限制 function statInputNum(textArea, numItem) { var $text = $(textArea); var max = numItem; $text.on("input propertychange", function() { var $curText = $(this); var $count = $curText.siblings(".word-count"); var curLength = $curText.val().length; if (curLength >= max) { var num = $curText.val().substr(0, max - 1); $curText.val(num); $count.text(max + "/" + max + "个字"); } else { $count.text(curLength + "/" + max + "个字"); } }); }; $.event.special.valuechange = { teardown: function(namespaces) { $(this).unbind('.valuechange'); }, handler: function(e) { $.event.special.valuechange.triggerChanged($(this)); }, add: function(obj) { $(this).on('keyup.valuechange cut.valuechange paste.valuechange input.valuechange', obj.selector, $.event.special.valuechange.handler) }, triggerChanged: function(element) { var current = element[0].contentEditable === 'true' ? element.html() : element.val(), previous = typeof element.data('previous') === 'undefined' ? element[0].defaultValue : element.data('previous') if (current !== previous) { element.trigger('valuechange', [element.data('previous')]) element.data('previous', current) } } }