concern-info.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. var msgId,
  2. concernCode;
  3. mui.init();
  4. mui.plusReady(function(){
  5. var self = plus.webview.currentWebview();
  6. msgId = self.msgId;
  7. concernCode = self.concernCode;
  8. setMessageRead();
  9. getTemplateHelper();
  10. backParent();
  11. });
  12. function setMessageRead(){
  13. var url = "/doctor/message/read_health",
  14. params = {
  15. msgid: msgId
  16. };
  17. sendPost(url, params, null, function(res){
  18. if(res.status == 200){
  19. getInfo();
  20. }else{
  21. mui.toast(res.msg);
  22. }
  23. }, 'POST', '', true)
  24. }
  25. function backParent(){
  26. var old_back = mui.back;
  27. mui.back = function() {
  28. var self = plus.webview.currentWebview();
  29. if(self.opener && self.opener()){
  30. mui.fire(self.opener(), "refreshMessage");
  31. }
  32. old_back();
  33. }
  34. }
  35. function getInfo(){
  36. var url = "/doctor/concern/findByCode",
  37. params = {
  38. concernCode: concernCode
  39. };
  40. sendGet(url, params, null, function(res){
  41. if(res.status == 200){
  42. var obj = res.data;
  43. obj.idcardStr = getFormatStr(obj.idcard, 6, 8);
  44. obj.sscStr = getFormatStr(obj.ssc, 4, 4);
  45. obj.mobileStr = getFormatStr(obj.mobile, 3, 4);
  46. var html = template("info-tmp", res.data);
  47. $("#main").empty().append(html);
  48. }else{
  49. mui.toast(res.msg);
  50. }
  51. }, true);
  52. }
  53. function getFormatStr(str, startIndex, length){
  54. //从字符串的第几位开始,长度为多少的字符串,转换为*
  55. var sb = str.substr(startIndex, length),
  56. reg = new RegExp(sb,"gi"),
  57. rs = "";
  58. for(i=0; i<length; i++){
  59. rs += "*";
  60. }
  61. return str.replace(reg, rs);
  62. }
  63. function getTemplateHelper(){
  64. template.helper("getPhoto", function(str){
  65. return getImgUrl(str);
  66. });
  67. template.helper("getSexName", function(type){
  68. if(type == '1'){
  69. return "男";
  70. }else if(type == "2"){
  71. return "女";
  72. }else{
  73. return "未知";
  74. }
  75. })
  76. }