add-step-pre.js 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. var code = window.localStorage.getItem("familyCode"),
  2. name = window.localStorage.getItem("familyName"),
  3. mobile = window.localStorage.getItem("familyMobile"),
  4. imgUrl = window.localStorage.getItem("familyImgUrl"),
  5. relation = window.localStorage.getItem("familyRelation");
  6. var dd = dialog({contentType:'load', skin:'bk-popup', content:'发送中...'});
  7. var $sendWxMsg = $('#sendWxMsg'); // 发送添加申请按钮
  8. var Request = GetRequest();
  9. var reAdd = Request.reAdd;
  10. pageInit();
  11. function sendWXTempPromise(data) {
  12. return new Promise(function(resolve, reject) {
  13. sendPost("patient/family/sendWXTemp", data , "json", "POST",
  14. function failed (res) {
  15. dd.close();
  16. if (res && res.msg) {
  17. dialog({contentType:'tipsbox', skin:'bk-popup' , content:res.msg}).show();
  18. } else {
  19. dialog({contentType:'tipsbox', skin:'bk-popup' , content:'发送失败'}).show();
  20. }
  21. }, function(res) {
  22. resolve(res)
  23. });
  24. })
  25. }
  26. function baseInfoInit() {
  27. var temp = name + ' <span>(' + mobile + ')</span>';
  28. // 头像为空设置默认头像
  29. if(imgUrl == undefined || imgUrl == null || imgUrl == ""){
  30. imgUrl = "../../../images/p-default.png";
  31. }
  32. $("#people").html(temp);
  33. $("#imgUrl").attr("src", getImgUrl(imgUrl));
  34. }
  35. function bindEvents() {
  36. $sendWxMsg.on('click',function() {
  37. if($(this).hasClass("btn-disabled")){
  38. return false;
  39. }
  40. $(this).addClass("btn-disabled");
  41. var data = {
  42. member: code,
  43. relation: relation
  44. };
  45. if(reAdd=="1") {
  46. data.reAdd = reAdd;
  47. }
  48. sendWXTempPromise(data)
  49. .then(function(res) {
  50. if(res.status=="200") {
  51. // $sendWxMsg.addClass("btn-disabled");
  52. dialog({contentType:'tipsbox', skin:'bk-popup' , content:"已发送添加申请"}).show();
  53. } else {
  54. $('#sendWxMsg').removeClass("btn-disabled");
  55. if(res.msg){
  56. dialog({contentType:'tipsbox', skin:'bk-popup' , content:res.msg}).show();
  57. }else{
  58. dialog({contentType:'tipsbox', skin:'bk-popup' , content:"发送失败"}).show();
  59. }
  60. }
  61. })
  62. .catch(function(e) {
  63. console && console.error(e)
  64. })
  65. })
  66. }
  67. function pageInit() {
  68. baseInfoInit();
  69. bindEvents();
  70. }