assign-consulting-detail.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403
  1. mui.plusReady(function() {
  2. var self = plus.webview.currentWebview();
  3. var name = self.name;
  4. var photo = self.src;
  5. var cost = self.money;
  6. var depart = self.depart;
  7. if (name) {
  8. document.getElementById("doc_name").innerText = name;
  9. }
  10. if (photo) {
  11. document.getElementById("doc_pic").src = photo;
  12. }
  13. if (cost) {
  14. document.getElementById("doc_cost").innerHTML = cost;
  15. }
  16. if (depart) {
  17. document.getElementById("doc_dept").innerText = depart + " 心血管内科";
  18. }
  19. // var self = plus.webview.currentWebview();
  20. //设置医生信息
  21. if (self.doctorName) {
  22. document.getElementById("doc_name").innerHTML = self.doctorName;
  23. document.getElementById("doc_name").setAttribute("data-code", self.doctorCode);
  24. }
  25. if (self.doctorDept) {
  26. document.getElementById("doc_dept").innerHTML = self.doctorDept;
  27. }
  28. if (self.doctorPic) {
  29. document.getElementById("doc_pic").setAttribute("src", self.doctorPic);
  30. }
  31. if (self.cost == "0") {
  32. document.getElementById("doc_cost").innerHTML = '<span class="c-ff8100">限免</span>';
  33. } else {
  34. document.getElementById("doc_cost").innerHTML = '<span class="c-ff8100">' + self.cost + '</span>元/次';
  35. }
  36. //医生主页链接
  37. document.getElementById('doc_info').addEventListener("tap", function() {
  38. mui.openWindow({
  39. url: '../../zndz/html/doctor-home.html',
  40. id: 'doctor-home',
  41. extras: {
  42. name: self.doctorName,
  43. photo: self.doctorPic
  44. },
  45. waiting: {
  46. autoShow: false
  47. }
  48. });
  49. });
  50. //var userAgent = {uid:'111',imei:'222',token:'333'};
  51. // 设置userAgent
  52. //plus.navigator.setUserAgent(userAgent);
  53. document.querySelector("#consult_commit").addEventListener("tap", function() {
  54. var detail = plus.webview.getWebviewById("assign-consulting-detail");
  55. var assignConsult = plus.webview.getWebviewById("assign-consulting-free");
  56. var dh = plus.webview.getWebviewById("doctor-home");
  57. //医生信息
  58. //var doctorInfo = detail.info;
  59. var data = {};
  60. //data.doctor = "1";
  61. data.doctor = commonDoctorCode;
  62. data.disease = "";
  63. data.type = 1; //咨询类别 0公共咨询,1医生,2团队)
  64. //data.user = $("input[data-time=illName]").attr('data-user');
  65. data.user = commonUserCode;
  66. data.name = $("input[data-time=illName]").val();
  67. data.age = $('#age_value').val();
  68. //data.ageUnit = $('#age_unit').val();
  69. data.province = $('#area_province').val();
  70. data.city = $("#area_city").val();
  71. data.fbrq = $('input[data-time=illTime]').val();
  72. data.symptoms = $("#symptoms").val();
  73. data.visitsDoctor = $("#visits_doctor").val();
  74. data.wouldHelp = $("#would_help").val();
  75. data.sex = $('input:radio[name="r0"]:checked').val();
  76. //data.read = 0;//0已读,1未读
  77. if (document.getElementById("read_check").checked) {
  78. data.read = 0;
  79. } else {
  80. data.read = 1;
  81. }
  82. //data.consultType = 'self';
  83. if (data.user == '为其他人咨询') {
  84. //data.consultType = 'other';
  85. }
  86. if (validate(data)) {
  87. //验证通过执行
  88. upload(data, self, detail, dh);
  89. }
  90. /*mui.openWindow({
  91. url: "assign-consulting-commit-success.html",
  92. id: "assign-consulting-commit-success"
  93. })*/
  94. });
  95. });
  96. // 上传文件
  97. function upload(data, self, detail, dh) {
  98. plus.nativeUI.showWaiting();
  99. var files = getImages();
  100. if (files.length <= 0) {
  101. //mui.toast("没有添加上传文件!");
  102. data.imageCodes = "";
  103. doSubmit(data, self, detail, dh);
  104. //return;
  105. } else {
  106. //mui.toast("开始上传")
  107. //var wt=plus.nativeUI.showWaiting();
  108. var task = plus.uploader.createUpload(commonServerUrl + '/ssgg/upload/image', {
  109. method: "POST"
  110. },
  111. function(t, status) { //上传完成
  112. plus.nativeUI.closeWaiting();
  113. if (status == 200) {
  114. //mui.toast("上传成功:" + t.responseText);
  115. var res = eval('(' + t.responseText + ')');
  116. data.imageCodes = res.images;
  117. doSubmit(data, self, detail, dh);
  118. //plus.storage.setItem("uploader",t.responseText);
  119. /*var w=plus.webview.create("uploader_ret.html","uploader_ret.html",{scrollIndicator:'none',scalable:false});
  120. w.addEventListener("loaded",function(){
  121. wt.close();
  122. w.show("slide-in-right",300);
  123. },false);*/
  124. //wt.close();
  125. } else {
  126. mui.toast("上传失败:" + status);
  127. //wt.close();
  128. }
  129. }
  130. );
  131. task.addData("client", "HelloH5+");
  132. task.addData("uid", getUid());
  133. for (var i = 0; i < files.length; i++) {
  134. var f = files[i];
  135. task.addFile(f, {});
  136. }
  137. task.start();
  138. }
  139. }
  140. //验证信息
  141. function validate(data) {
  142. // if (data.user == '') {
  143. // mui.toast('请填写咨询患者!');
  144. // return false;
  145. // }
  146. // if (data.fbrq == '') {
  147. // mui.toast('请填写发病日期!');
  148. // return false;
  149. // }
  150. // if (data.symptoms == '') {
  151. // mui.toast('请填写主要症状!');
  152. // $("#symptoms").focus();
  153. // return false;
  154. // } else if (data.symptoms.length < 10) {
  155. // mui.toast('主要症状至少填写10个字!');
  156. // $("#symptoms").focus();
  157. // return false;
  158. // }
  159. // if (data.wouldHelp == '') {
  160. // mui.toast('请填写所需帮助!');
  161. // $("#would_help").focus();
  162. // return false;
  163. // } else if (data.wouldHelp.length < 10) {
  164. // mui.toast('所需帮助至少填写10个字!');
  165. // $("#would_help").focus();
  166. // return false;
  167. // }
  168. return true;
  169. }
  170. //提交咨询
  171. function doSubmit(params) {
  172. sendPost('patient/consult/commit', params, 'json', 'post', submitFailed, submitSuccess);
  173. }
  174. function submitFailed(res) {
  175. plus.nativeUI.closeWaiting();
  176. if (res && res.msg) {
  177. plus.nativeUI.toast(res.msg);
  178. } else {
  179. plus.nativeUI.toast("保存失败");
  180. }
  181. }
  182. function submitSuccess(res) {
  183. plus.nativeUI.closeWaiting();
  184. if (res.status == 200) {
  185. mui.openWindow({
  186. url: "assign-consulting-commit-success.html",
  187. id: "assign-consulting-commit-success",
  188. waiting: {
  189. autoShow: false
  190. }
  191. });
  192. mui.toast('提交成功!');
  193. // var wb = plus.webview.getWebviewById("2-12-professor-list");
  194. // if(wb){
  195. // wb.close("none");
  196. // }
  197. } else {
  198. submitFailed(res);
  199. }
  200. }
  201. //function voicePop() {
  202. // setTimeout(function() {
  203. // $(".win-broadcast,.win-broadcast-mb").show();
  204. // }, 300);
  205. //}
  206. function voicePop(n) {
  207. $(".win-broadcast,.win-broadcast-mb").show();
  208. $("#voice-finish").click(function() {
  209. $("#voice" + n).show();
  210. $(".win-broadcast,.win-broadcast-mb").hide();
  211. });
  212. }
  213. function voicePopClose() {
  214. $(".win-broadcast,.win-broadcast-mb").hide();
  215. }
  216. $(function() {
  217. //显示隐藏选择图片按钮
  218. $(".add-btn").on("click", function() {
  219. //getImages();
  220. $(".over-lay").show();
  221. $(".ins-img-btn").show();
  222. });
  223. $("[data-btn=cancelOver]").on("click", function() {
  224. $(".over-lay").hide();
  225. $(".ins-img-btn").hide();
  226. });
  227. //字数限制(指定限制字数的节点和最大字数)
  228. statInputNum(".r-textarea", 300);
  229. });
  230. //字数限制
  231. function statInputNum(textArea, numItem) {
  232. var $text = $(textArea);
  233. var max = numItem;
  234. $text.on("input propertychange", function() {
  235. var $curText = $(this);
  236. var $count = $curText.parents("li").siblings("li").find(".word-count");
  237. var curLength = $curText.val().length;
  238. if (curLength >= max) {
  239. var num = $curText.val().substr(0, max - 1);
  240. $curText.val(num);
  241. $count.text(max + "/" + max);
  242. } else {
  243. $count.text(curLength + "/" + max);
  244. }
  245. });
  246. };
  247. //查看图片
  248. function viewImg(dom) {
  249. var $img = $(dom);
  250. var thissrc = $img.attr("date");
  251. var mWid = $(window).width();
  252. var mHei = $(window).height();
  253. var nHtml = '<div class="delimgpop"><div class="del-img-box"><div class="del-img-con"><img class="del-pop-img" src="' + thissrc + '" style="max-width:' + mWid + 'px; max-height:' + mHei + 'px;"></div></div></div>';
  254. $("body").append(nHtml);
  255. $(".delimgpop").click(function() {
  256. $(this).remove()
  257. });
  258. };
  259. //删除图片
  260. function delImg(dom) {
  261. var $li = $(dom).parent();
  262. $li.remove();
  263. return;
  264. }
  265. //选择发病时间
  266. var hh = $('li.ill-time').mobiscroll({
  267. theme: 'ios',
  268. lang: 'zh',
  269. formatValue: function(d) {
  270. return d.join(',');
  271. },
  272. customWheels: true,
  273. wheels: [
  274. [{
  275. keys: ['0', '1', '2', '3', '4', '5'],
  276. values: ['最近24小时', '最近一周', '最近三个月', '最近一年', '一年以上', '不清楚']
  277. }]
  278. ],
  279. onSelect: function(valueText, inst) {
  280. var dd = eval("[" + valueText + "]");
  281. $('input[data-time=illTime]').val(dd[0].values);
  282. }
  283. });
  284. var jj = $('li.ill-name').mobiscroll({
  285. theme: 'ios',
  286. lang: 'zh',
  287. formatValue: function(d) {
  288. return d.join(',');
  289. },
  290. customWheels: true,
  291. wheels: [
  292. [{
  293. keys: ['0', '1', '2', '3'],
  294. values: ['李碧玉', '杨旭', '杨天琪', '杨慧琳']
  295. }]
  296. ],
  297. onSelect: function(valueText, inst) {
  298. var dd = eval("[" + valueText + "]");
  299. $('input[data-time=illName]').val(dd[0].values);
  300. $('input[data-time=illName]').attr('data-user', dd[0].keys);
  301. if (dd[0].values == "为其他人咨询") {
  302. $(".ax-consultation").show();
  303. } else {
  304. $(".ax-consultation").hide();
  305. }
  306. }
  307. });
  308. /* 复选框兼容 */
  309. $(document).on("click", ".input-group-pack > input[type=checkbox]", function() {
  310. var $cpChk = $(this).parent();
  311. if ($(this).attr("checked") == "checked") {
  312. $cpChk.removeClass("checked");
  313. $(this).removeAttr("checked");
  314. } else {
  315. $cpChk.addClass("checked");
  316. $(this).attr("checked", true);
  317. }
  318. });
  319. //咨询说明
  320. $("#askintro").click(function() {
  321. var zxNotes = dialog({
  322. title: "<h2 class='c-37a6ed'>咨询说明</h2>",
  323. titlePadding: "10px 0 0 0",
  324. padding: "0 15px 10px 15px",
  325. contentBlock: true,
  326. content: "<div class='scroll-include'><ul class='zx-notes'><li>1.请详细描述问题,合理使用标点符号,便于专家更好了解患者情况。</li><li>2.医生平时工作繁忙,在空余之时会第一时间回复您的问题,请耐心等待</li><li>3.郑重申明:网上交流不能替代医生面诊,医生的咨询建议仅供参考,具体诊疗请一定到正规医院在专业医生指导下进行!医生言论仅代表其个人观点,不代表本站同意其说法,本站不承担由此引起的法律责任。</li><li>4.咨询内容不得带有任何非法、骚扰、中伤他人、辱骂、伤害、庸俗、淫秽等刺激性文字及非健康咨询方面的内容,一经发现,本站有权删除相关咨询内容。</li></ul></div>",
  327. okValue: "确定",
  328. ok: function() {}
  329. }).showModal();
  330. var scScroll = new IScroll('.scroll-include', {
  331. click: true
  332. });
  333. zxNotes.show(scScroll.refresh())
  334. });
  335. // 拍照添加文件
  336. function appendByCamera() {
  337. plus.camera.getCamera().captureImage(function(p) {
  338. //拍照完成,隐藏选择对话框
  339. hideImageChooseDialog();
  340. plus.io.resolveLocalFileSystemURL(p, function(entry) {
  341. var localurl = entry.toLocalURL();
  342. appendFile(localurl);
  343. });
  344. }, function(e) {
  345. //取消拍照,隐藏选择对话框
  346. hideImageChooseDialog();
  347. });
  348. };
  349. //隐藏图片方法
  350. function hideImageChooseDialog() {
  351. $(".over-lay").hide();
  352. $(".ins-img-btn").hide();
  353. };
  354. // 从相册添加文件
  355. function appendByGallery() {
  356. plus.gallery.pick(function(p) {
  357. appendFile(p);
  358. });
  359. }
  360. // 从相册中选择多张图片
  361. function galleryImgs() {
  362. // 从相册中选择图片
  363. plus.gallery.pick(function(e) {
  364. for (var i in e.files) {
  365. appendFile(e.files[i]);
  366. }
  367. }, function(e) {
  368. console.log("取消选择图片");
  369. }, {
  370. filter: "image",
  371. multiple: true
  372. });
  373. }
  374. // 添加文件
  375. function appendFile(p) {
  376. var $li = $('<li>' + ' <img src="' + p + '" date="' + p + '" onclick="viewImg(this)">' + ' <a href="javascript:;" class="del-img" onclick="delImg(this)"><i class="iconfont icon-laji"></i></a>' + '</li>');
  377. var $add_img_li = $("#add_img_li");
  378. $add_img_li.before($li);
  379. $(".over-lay").hide();
  380. $(".ins-img-btn").hide();
  381. }
  382. // 产生一个随机数
  383. function getUid() {
  384. return Math.floor(Math.random() * 100000000 + 10000000).toString();
  385. }
  386. //获取需要上传的图片
  387. function getImages() {
  388. var images = [];
  389. $("#img_ul").find("img").each(function() {
  390. var imgSrc = $(this).attr("src");
  391. images.push(imgSrc);
  392. });
  393. return images;
  394. }