add-step-pre.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. var data = {
  38. member: code,
  39. relation: relation
  40. };
  41. if(reAdd=="1") {
  42. data.reAdd = reAdd;
  43. }
  44. sendWXTempPromise(data)
  45. .then(function(res) {
  46. if(res.status=="200") {
  47. $sendWxMsg.addClass("btn-disabled");
  48. dialog({contentType:'tipsbox', skin:'bk-popup' , content:"已发送添加申请"}).show();
  49. } else {
  50. $('#next').removeClass("btn-disabled");
  51. if(res.msg){
  52. dialog({contentType:'tipsbox', skin:'bk-popup' , content:res.msg}).show();
  53. }else{
  54. dialog({contentType:'tipsbox', skin:'bk-popup' , content:"发送失败"}).show();
  55. }
  56. }
  57. })
  58. .catch(function(e) {
  59. console && console.error(e)
  60. })
  61. })
  62. }
  63. function pageInit() {
  64. baseInfoInit();
  65. bindEvents();
  66. }