add-step3.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. var dd = dialog({contentType:'load', skin:'bk-popup', content:'提交中...'});
  2. var scroller1 = new IScrollPullUpDown('wrapper',{
  3. probeType:2,
  4. bounceTime: 250,
  5. bounceEasing: 'quadratic',
  6. mouseWheel:false,
  7. click:true,
  8. scrollbars:true,
  9. fadeScrollbars:true,
  10. interactiveScrollbars:false
  11. }, null, null);
  12. $(function(){
  13. // 判断是否登录
  14. checkUserAgent();
  15. var code = window.localStorage.getItem("familyCode");
  16. var name = window.localStorage.getItem("familyName");
  17. var imgUrl = window.localStorage.getItem("familyImgUrl");
  18. var relation = window.localStorage.getItem("familyRelation");
  19. // 头像为空设置默认头像
  20. if(imgUrl == undefined || imgUrl == null || imgUrl == ""){
  21. imgUrl = "../../../images/p-default.png";
  22. }
  23. $("#name").html(name);
  24. $("#imgUrl").attr("src", getImgUrl(imgUrl));
  25. // 确认提交
  26. $("#submit").bind("tap", function () {
  27. var password = $("#password").val();
  28. if (password.trim() == "") {
  29. dialog({contentType:'tipsbox', skin:'bk-popup' , content:'密码不能为空'}).show();
  30. return false;
  31. }
  32. dd.show();
  33. var data = {};
  34. data.member = code;
  35. data.password = password;
  36. data.relation = relation;
  37. sendPost("patient/family/member_add", data, "json", "post", addFailed, addSuccesss);
  38. });
  39. });
  40. // 禁止拖动
  41. document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);
  42. // 添加成功
  43. function addSuccesss (res) {
  44. if (res.status == 200) {
  45. dd.close();
  46. var d3 = dialog({contentType:'tipsbox', skin:'bk-popup' , content:res.msg}).show();
  47. setTimeout(function () {
  48. window.location.href = "family.html";
  49. }, 1000);
  50. } else {
  51. //非200则为失败
  52. addFailed(res);
  53. }
  54. }
  55. // 添加失败
  56. function addFailed (res) {
  57. dd.close();
  58. if (res && res.msg) {
  59. var d1 = dialog({contentType:'tipsbox', skin:'bk-popup' , content:res.msg}).show();
  60. } else {
  61. var d2 = dialog({contentType:'tipsbox', skin:'bk-popup' , content:'加载失败'}).show();
  62. }
  63. }