family-detail.js 3.9 KB

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