templateHelp.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. function setExpenses (expensesStatus) {
  2. switch(expensesStatus) {
  3. case "1":
  4. return "已缴费";
  5. case "2":
  6. return "已退费";
  7. default:
  8. return "未缴费"
  9. }
  10. }
  11. template.helper("setExpenses", setExpenses);
  12. function setKeyword (keyword) {
  13. var key = keyword.split(",");
  14. var keyArry=[];
  15. for(var j in key){
  16. keyArry.push("<span>#"+key[j]+"#</span>")
  17. }
  18. return keyArry.join("");
  19. }
  20. template.helper("setKeyword", setKeyword);
  21. function setContent (content) {
  22. if(content.length>50){
  23. content = content.substring(0,40)+"......";
  24. }
  25. return content;
  26. }
  27. template.helper("setContent", setContent);
  28. function setAge(age) {
  29. if(age == 0) {
  30. return "<1";
  31. }
  32. if(age == -1)
  33. return "未知";
  34. return age;
  35. }
  36. template.helper("setAge", setAge);
  37. function setSex(s) {
  38. if(s == 1) {
  39. return "男";
  40. } else if(s == 2) {
  41. return "女";
  42. }
  43. }
  44. template.helper("setSex", setSex);
  45. function setLevel(l) {
  46. if(l == 1) {
  47. return "专科医生";
  48. } else if(l == 2) {
  49. return "全科医生";
  50. } else if(l == 3){
  51. return "健康管理师";
  52. }
  53. }
  54. template.helper("setLevel", setLevel);
  55. template.helper("setLabels", function(la){
  56. if(!la) {
  57. return "";
  58. }
  59. return la.join("、");
  60. });
  61. template.helper("setDisease", function(d) {
  62. switch(d) {
  63. case 0:
  64. return "健康";
  65. break;
  66. case 1:
  67. return "高血压";
  68. break;
  69. case 2:
  70. return "糖尿病";
  71. break;
  72. }
  73. });
  74. template.helper("setSignType", function(t) {
  75. if (t == 1) {
  76. return "三师";
  77. } else if (t == 2) {
  78. return "家庭";
  79. }
  80. });
  81. template.helper("setPatiPic", function(p, sex) {
  82. if(!p || p.length == 0) {
  83. return "../../../images/p-female.png";
  84. } else {
  85. return getImgUrl(p);
  86. }
  87. });
  88. template.helper('setInfo', function(v){
  89. return JSON.stringify(v);
  90. })
  91. template.helper("setDocPic", setTemDocPhoto);
  92. function setTemDocPhoto(p, sex, docType){
  93. if (!p || p.length == 0) {
  94. return setDocPhoto(sex, docType);
  95. }
  96. return getImgUrl(p);
  97. }
  98. function setDocPhoto(sex, docType){
  99. docType = docType || plus.storage.getItem("docType");
  100. if(docType=="10"){
  101. return sex==2? "../../../images/s-female.png" : "../../../images/s-male.png";
  102. }
  103. return sex==2? "../../../images/d-female.png" : "../../../images/d-male.png";
  104. }