my-detail-bak.js 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465
  1. var d = dialog({contentType:'load', skin:'bk-popup'});
  2. var d1 = dialog({contentType:'load', skin:'bk-popup',content:'退出中..'});
  3. var pagetype = 4;
  4. var openid =null;
  5. var userAgent = window.localStorage.getItem(agentName);
  6. var firstUid = window.localStorage.getItem("firstUid");
  7. var serviceLabel="";
  8. var bindCardUrl = "",
  9. bindCardStatus;
  10. $(function() {
  11. checkUserAgent();
  12. });
  13. //appendFamilyMember($('#memberContainer'),function(){
  14. // queryInit();
  15. // clearCommittee()
  16. // var jsonstr = $.parseJSON(window.localStorage.getItem(agentName));
  17. // if(jsonstr.uid == jsonstr.represented){
  18. // $('#divChangeLogin').show()
  19. // //判断是否可以在线支付
  20. // if(canPayOnline){
  21. // $("#elecard").show();
  22. // }else{
  23. // $("#elecard").hide();
  24. // }
  25. // }else{
  26. // $('#divChangeLogin').hide()
  27. // $("#elecard").hide();
  28. // }
  29. //},function(){
  30. // //判断有授权家人,修改样式
  31. // if($('#memberContainer').is(':hidden')){
  32. // $('#content').css('padding-top','0px');
  33. // }else{
  34. // $('#content').css('padding-top','90px');
  35. // }
  36. //});
  37. function queryInit(){
  38. d.show();
  39. var jsonstr = $.parseJSON(userAgent);
  40. openid = jsonstr.openid;
  41. if(firstUid == null || firstUid == undefined){
  42. document.getElementById("divChangeLogin").style.display='none';
  43. }
  44. // isRepresent(function() {
  45. //查询用户信息
  46. query();
  47. getWeixinSign();
  48. bindEvents();
  49. //选择居委会
  50. selectCommittee()
  51. // })
  52. }
  53. //获得微信sdk信息
  54. function getWeixinSign(){
  55. var params1 = {};
  56. params1.pageUrl = server + "wx/html/grzx/html/my-detail.html&state=STATE";
  57. $.ajax(server + "weixin/getSign", {
  58. data: params1,
  59. dataType: "json",
  60. type: "post",
  61. success: function(res){
  62. if (res.status == 200) {
  63. var t = res.data.timestamp;
  64. var noncestr = res.data.noncestr;
  65. var signature = res.data.signature;
  66. wx.config({
  67. //debug: true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
  68. appId: appId, // 必填,公众号的唯一标识
  69. timestamp: t, // 必填,生成签名的时间戳
  70. nonceStr: noncestr, // 必填,生成签名的随机串
  71. signature: signature,// 必填,签名,见附录1
  72. jsApiList: [
  73. 'chooseImage',
  74. 'uploadImage'
  75. ] // 必填,需要使用的JS接口列表,所有JS接口列表见附录2
  76. });
  77. }
  78. }
  79. });
  80. }
  81. //跳转到三师信息
  82. function changeSanshi(){
  83. window.location.href = "../../qygl/html/signing-doctors.html";
  84. }
  85. //跳转到家庭签约信息
  86. function changeJtqy(signedStatus){
  87. if(signedStatus) {
  88. window.location.href = "../../ssgg/html/doctor-homepage-new.html"
  89. } else {
  90. window.location.href = "../../qygl/html/signing-doctors.html"
  91. }
  92. }
  93. //查询列表
  94. function query() {
  95. // var data={};
  96. // sendPost('patient/baseinfo', data, 'json', 'post', queryFailed, querySuccess);
  97. //初始查询患者基本信息,然后调用接口判断该患者是否已绑定电子社保卡
  98. var reqParams = [{
  99. url: "patient/baseinfo",
  100. data: {},
  101. reqType: 'post'
  102. }]
  103. getReqPromises(reqParams).then(function(ress){
  104. querySuccess(ress[0]);
  105. //处理绑卡
  106. // var res2 = ress[1];
  107. // if(res2.data.bindStatus == '030007'){
  108. // bindCardStatus = false;
  109. // bindCardUrl = res2.data.sicardUrl;
  110. // }else if(res2.data.bindStatus == '000000'){
  111. // bindCardStatus = true;
  112. // bindCardUrl = res2.data.sicardUrl;
  113. // }else{
  114. // dialog({contentType:'tipsbox', skin:'bk-popup' , content:res2.msg}).show();
  115. // }
  116. // //判断是否可以在线支付
  117. // if(canPayOnline){
  118. // $("#elecard").show();
  119. // $("#elecardStatus").text(bindCardStatus? "已绑定" : "未绑定");
  120. // }else{
  121. // $("#elecard").hide();
  122. // }
  123. });
  124. }
  125. function queryFailed(res) {
  126. d.close();
  127. if (res && res.msg) {
  128. dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:res.msg}).show();
  129. } else {
  130. dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'初始化失败'}).show();
  131. }
  132. }
  133. function querySuccess(res) {
  134. d.close();
  135. if (res.status == 200) {
  136. setValue(res.data);
  137. // if($("#ssc").val() != ""){
  138. // $("#ssc").attr("readonly","readonly");
  139. // }
  140. //取药码
  141. if(res.data.prescription == 1){
  142. $('#myMedicine').show()
  143. }else{
  144. $('#myMedicine').hide()
  145. }
  146. }
  147. }
  148. function bindEvents(){
  149. $("#backLogin").click(function (){
  150. dialog({
  151. content:'您确定继续退出登录吗?',
  152. ok: function (){
  153. d1.show()
  154. sendPost("patient/wxloginout",{},"JSON","POST",function(res){
  155. d1.close()
  156. if (res && res.msg) {
  157. dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:res.msg}).show();
  158. } else {
  159. dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'退出登录失败!'}).show();
  160. }
  161. },function(res){
  162. d1.close()
  163. if(res.status==200){
  164. clearAgent();
  165. window.localStorage.removeItem("isTiXingVideoFaSong");//清除咨询详情移动网络下,用户点击不再提醒后的处理,换账号登陆后,还可以重新提醒
  166. var url = window.location.href;
  167. saveAgentPage(url);
  168. location.replace("../../home/html/login.html?openid="+openid+"&loginType=password");
  169. }else{
  170. if (res && res.msg) {
  171. dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:res.msg}).show();
  172. } else {
  173. dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'退出登录失败!'}).show();
  174. }
  175. }
  176. })
  177. },
  178. cancel: function () {
  179. return;
  180. }
  181. }).showModal();
  182. });
  183. //绑定电子社保卡
  184. $('#elecard').on('tap',function(){
  185. if(!bindCardStatus){
  186. dialog({
  187. content: '当前未绑定电子社保卡,无法进行线上缴费,是否立即绑定',
  188. cancelValue: '不了,谢谢',
  189. cancel: function () {},
  190. okValue:'是',
  191. ok: function (){
  192. window.location.href = bindCardUrl;
  193. }
  194. }).showModal();
  195. }else {
  196. window.location.href = bindCardUrl;
  197. }
  198. });
  199. //电子健康卡点击事件
  200. $("#healthcard").on('tap', function(){
  201. window.location.href = "my-health-card.html"
  202. // d.show();
  203. // var url = "/patient/ehc/redirecturl";
  204. // sendPost(url, {}, 'json', 'post', queryFailed, function(res){
  205. // if(res.status == 200){
  206. // d.close();
  207. // window.location.href = res.data;
  208. // }else{
  209. // queryFailed(res);
  210. // }
  211. // })
  212. })
  213. }
  214. //初始化页面数据
  215. function setValue(data){
  216. var photo = data.photo;
  217. var name = data.name;
  218. var sex = data.sex;
  219. var mobile = data.mobile;
  220. var idcard = data.idcard;
  221. var ssc = data.ssc;
  222. var address = data.address;
  223. var sign = Number(data.sign);
  224. var service=data.labelName;
  225. serviceLabel=data.label;
  226. var sexName = "女";
  227. if(sex == 1) {
  228. sexName = "男";
  229. }
  230. if(!photo){
  231. photo = "../../../images/p-default.png";
  232. }
  233. if(!name) name = "";
  234. if(!mobile) mobile = "";
  235. if(!idcard) idcard = "";
  236. if(!ssc) ssc = "";
  237. if(!address) address = "";
  238. if(!service) {service="必填";$("#service").addClass("li-circle");}else{
  239. $("#service").removeClass("li-circle");
  240. }
  241. document.getElementById("photo").src = getImgUrl(photo);
  242. document.getElementById("name").value = name;
  243. document.getElementById("sex").innerHTML = sexName;
  244. document.getElementById("mobile").innerHTML = mobile;
  245. document.getElementById("idcard").innerHTML = idcard;
  246. document.getElementById("ssc").innerHTML = ssc;
  247. document.getElementById("address").innerHTML = address;
  248. document.getElementById("service").innerHTML = service;
  249. $('#committee').text(data.countryName);
  250. }
  251. // 添加文件
  252. function appendFile(p) {
  253. document.getElementById("photo").src = p;
  254. $("#photo").attr("data-src",p);
  255. }
  256. //获取需要上传的图片
  257. function getImages() {
  258. var images = [];
  259. var imgSrc = $("#photo").attr("data-src");
  260. images.push(imgSrc);
  261. return images;
  262. }
  263. //剪切图片
  264. function clip_photo(){
  265. $("#content").addClass("c-hide");
  266. $("#clipPanel").removeClass("c-hide");
  267. var photo = document.getElementById('file_head');
  268. lrz(photo.files[0]).then(function (rst) {
  269. var url = rst.base64;
  270. new AlloyCrop({
  271. image_src: url,
  272. width: document.documentElement.clientWidth,
  273. height: document.documentElement.clientWidth,
  274. ok_text: "保存",
  275. cancel_text: "取消",
  276. ok: function (base64, canvas) {
  277. $("#content").removeClass("c-hide");
  278. var data=base64.split(',')[1];
  279. data=window.atob(data);
  280. var ia = new Uint8Array(data.length);
  281. for (var i = 0; i < data.length; i++) {
  282. ia[i] = data.charCodeAt(i);
  283. }
  284. var blob=new Blob([ia],{type:"image/png",endings:'transparent'});
  285. var fd=new FormData();
  286. fd.append('file',blob,'image.png');
  287. var new_url = URL.createObjectURL(blob);
  288. appendFile(new_url);
  289. $.ajax(server + 'upload/image', {
  290. data: fd,
  291. dataType: 'json',
  292. contentType: false,
  293. cache: false,
  294. processData: false,
  295. beforeSend: function(request) {
  296. request.setRequestHeader("userAgent", userAgent);
  297. },
  298. type: 'post',
  299. error: function(res) {
  300. if(res.status == 999 || res.status == 998 || res.status == 997){
  301. loginUrl(res.status);
  302. return;
  303. }
  304. clickCount = 0;
  305. },
  306. success: function(res) {
  307. if(res.status == 999 || res.status == 998 || res.status == 997){
  308. loginUrl(res.status);
  309. return;
  310. }
  311. var params = {};
  312. params.photo = res.urls;
  313. var patientUrl = res.urls;
  314. sendPost('patient/save', params, 'json', 'post', submitFailed, submitSuccess);
  315. clickCount = 0;
  316. }
  317. });
  318. },
  319. cancel: function () {
  320. $("#content").removeClass("c-hide");
  321. window.location.reload();
  322. }
  323. });
  324. })
  325. .catch(function (err){
  326. // 处理失败会执行
  327. console.log(err);
  328. });
  329. }
  330. // 上传头像
  331. var serverId = "";
  332. function chooseImage(){
  333. wx.chooseImage({
  334. count: 1,
  335. success: function (res) {
  336. appendFile(res.localIds[0]);
  337. uploadImage();
  338. }
  339. });
  340. }
  341. //获取微信上传图片的媒体ID
  342. function uploadImage(){
  343. var images = getImages();
  344. if (images.length == 0) {
  345. return;
  346. }
  347. var i = 0, length = images.length;
  348. serverId = "";
  349. function upload() {
  350. wx.uploadImage({
  351. localId: images[i],
  352. success: function (res) {
  353. i++;
  354. if(serverId.length == 0){
  355. serverId = res.serverId;
  356. }
  357. else{
  358. serverId =serverId + "," + res.serverId;
  359. }
  360. if (i < length) {
  361. upload();
  362. }
  363. if(i == images.length){
  364. update_photo();
  365. }
  366. },
  367. fail: function (res) {
  368. alert(JSON.stringify(res));
  369. }
  370. });
  371. }
  372. upload();
  373. }
  374. //上传图片到服务器上
  375. function update_photo(){
  376. var params = {};
  377. params.mediaIds = serverId;
  378. sendPost('patient/save', params, 'json', 'post', submitFailed, submitSuccess);
  379. }
  380. //上传失败
  381. function submitFailed(res) {
  382. if (res && res.msg) {
  383. dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:res.msg}).show();
  384. } else {
  385. dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'上传失败'}).show();
  386. }
  387. }
  388. //上传成功
  389. function submitSuccess(res) {
  390. if (res.status == 200) {
  391. $("#content").removeClass("c-hide");
  392. $("#clipPanel").addClass("c-hide");
  393. } else {
  394. submitFailed(res);
  395. }
  396. }
  397. //查看图片
  398. function viewImg(dom) {
  399. var $img = $(dom);
  400. var thissrc = $img.attr("data-src");
  401. var mWid = $(window).width();
  402. var mHei = $(window).height();
  403. 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>';
  404. $("body").append(nHtml);
  405. $(".delimgpop").click(function() {
  406. $(this).remove()
  407. });
  408. };
  409. function myMedicine(){
  410. window.location.href = "../../prescription/html/my-medicine-code.html";
  411. }
  412. function myFeedback(){
  413. window.location.href = "../../yjfk/html/feedback.html";
  414. }
  415. function updatePwd(){
  416. var mobile = $('#mobile').html();
  417. window.location.href = "shezhimima.html?type=" + pagetype + "&openid=" + openid + "&mobile="+ mobile + "&1=1";
  418. }
  419. function updateAddress(){
  420. var address = $('#address').html();
  421. var paramAgent = "{\"type\":" + pagetype + ",\"openid\":\"" + openid + "\",\"address\":\"" + encodeURI(address) + "\"}";
  422. window.localStorage.setItem("paramAgent", paramAgent);
  423. window.location.href = "xiugaidizhi.html?type=" + pagetype + "&openid=" + openid + "&mobile="+ mobile + "&1=1";
  424. }
  425. function updateMobile(){
  426. var mobile = $.trim($('#mobile').html());
  427. if(mobile.length==0)
  428. window.location.href = "bangdingsj.html?type=" + pagetype + "&openid=" + openid + "&1=1";
  429. else
  430. window.location.href = "shenfenyz.html?type=" + pagetype + "&openid=" + openid + "&mobile="+ mobile + "&1=1";
  431. }
  432. function updateSSC(){
  433. var ssc = $.trim($('#ssc').html());
  434. window.location.href = "update-ssc.html?type=" + pagetype + "&openid=" + openid + "&ssc="+ ssc + "&1=1";
  435. }
  436. function updateService(){
  437. window.location.href = "updateService.html?type=" + pagetype + "&openid=" + openid + "&service=" + serviceLabel + "&1=1";
  438. }