family-detail.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. var d = dialog({contentType:'load', skin:'bk-popup'});
  2. var dd = dialog({contentType:'load', skin:'bk-popup', content:'提交中...'});
  3. var scroller1 = new IScrollPullUpDown('wrapper',{
  4. probeType:2,
  5. bounceTime: 250,
  6. bounceEasing: 'quadratic',
  7. mouseWheel:false,
  8. scrollbars:true,
  9. click:true,
  10. fadeScrollbars:true,
  11. interactiveScrollbars:false
  12. }, null, null);
  13. $(function(){
  14. // 判断是否登录
  15. checkUserAgent();
  16. // 获取缓存
  17. var relationIndex = "relation" + window.localStorage.getItem("index");
  18. var name = window.localStorage.getItem("name");
  19. var imgUrl = window.localStorage.getItem("imgUrl");
  20. var code = window.localStorage.getItem("code");
  21. var mobile = window.localStorage.getItem("mobile");
  22. var idcard = window.localStorage.getItem("idcard");
  23. var address = window.localStorage.getItem("address");
  24. var sign = window.localStorage.getItem("sign");
  25. var relation = window.localStorage.getItem(relationIndex);
  26. $("#name").html(name);
  27. $("#pic").attr("src", getImgUrl(imgUrl));
  28. $("#idcard").html(idcard);
  29. $("#mobile").html(mobile);
  30. $("#address").html(address);
  31. $("#sign").html(sign);
  32. var relationText = "";
  33. if (relation == 1) {
  34. relationText = "父亲";
  35. } else if (relation == 2) {
  36. relationText = "母亲";
  37. } else if (relation == 3) {
  38. relationText = "老公";
  39. } else if (relation == 4) {
  40. relationText = "老婆";
  41. } else if (relation == 5) {
  42. relationText = "儿子";
  43. } else if (relation == 6) {
  44. relationText = "女儿";
  45. } else {
  46. relationText = "其他";
  47. }
  48. $("#select").find("p").html(relationText);
  49. // 选择家庭关系
  50. $('#select').mobiscroll({
  51. theme: 'ios',
  52. lang: 'zh',
  53. formatValue: function(d) {
  54. return d;
  55. },
  56. customWheels: true,
  57. wheels: [
  58. [{
  59. keys: ['1', '2', '3', '4', '5', '6', '0'],
  60. values: ['父亲', '母亲', '老公', '老婆', '儿子', '女儿', '其他']
  61. }]
  62. ],
  63. onSelect: function(valueText, inst) {
  64. var values = eval("[" + valueText + "]");
  65. window.localStorage.removeItem(relationIndex);
  66. window.localStorage.setItem(relationIndex, values[0].keys);
  67. $('#select').find("p").html(values[0].values);
  68. selectKey = values[0].keys;
  69. dd.show();
  70. var data = {};
  71. data.member = code;
  72. data.relation = selectKey;
  73. sendPost("patient/family/relation_update", data, "json", "post", changeFailed, changeSuccess);
  74. }
  75. });
  76. // 删除家人
  77. $("#delete").bind("tap", function () {
  78. dialog({
  79. content:'删除家人后,无法查看家人信息,并为家人进行相关操作,是否继续删除',
  80. button: [
  81. {
  82. value: '继续删除',
  83. callback: function(){
  84. this.close();
  85. dd.show();
  86. var data = {};
  87. data.member = code;
  88. sendPost("patient/family/member_delete", data, "json", "post", deleteFailed, deleteSuccess);
  89. }
  90. },
  91. {
  92. value: '不了,谢谢',
  93. callback: function(){}
  94. }
  95. ]
  96. }).showModal();
  97. });
  98. });
  99. // 禁止拖动
  100. document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);
  101. // 修改失败
  102. function changeFailed (res) {
  103. dd.close();
  104. if (res && res.msg) {
  105. var d1 = dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:res.msg});
  106. } else {
  107. var d2 = dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'加载失败'});
  108. }
  109. }
  110. // 修改成功
  111. function changeSuccess (res) {
  112. if (res.status == 200) {
  113. dd.close();
  114. dialog({contentType:'tipsbox', skin:'bk-popup' , content:"家庭关系修改成功"}).show();
  115. } else {
  116. //非200则为失败
  117. changeFailed(res);
  118. }
  119. }
  120. // 删除失败
  121. function deleteFailed (res) {
  122. dd.close();
  123. if (res && res.msg) {
  124. var d1 = dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:res.msg});
  125. } else {
  126. var d2 = dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'加载失败'});
  127. }
  128. }
  129. // 删除成功
  130. function deleteSuccess (res) {
  131. if (res.status == 200) {
  132. dd.close();
  133. dialog({contentType:'tipsbox', skin:'bk-popup' , content:res.msg}).show();
  134. setTimeout(function(){
  135. window.location.href = "family.html";
  136. }, 1000);
  137. } else {
  138. //非200则为失败
  139. deleteFailed(res);
  140. }
  141. }