WXViewerUtils.java 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /**
  2. *
  3. */
  4. package com.xcgl.weixin.utils;
  5. import com.xcgl.weixin.entity.WXMultiRowViewer;
  6. import com.xcgl.weixin.entity.WXMultiRowViewerDto;
  7. import org.apache.commons.lang3.StringUtils;
  8. import java.util.List;
  9. /**
  10. * @author xzx
  11. *
  12. * 2019年1月5日
  13. *
  14. */
  15. public class WXViewerUtils {
  16. /**
  17. *
  18. * @param viewerDtos
  19. * @return
  20. */
  21. public static String getWXMultiRowViewerHtml(WXMultiRowViewer viewer) {
  22. StringBuffer sb = new StringBuffer();
  23. if(viewer.getWarning() != null && viewer.getWarning().length()>0) {
  24. sb.append("<div class=\"mui-card\" style=\"margin-bottom: 10px;\">");
  25. // start li
  26. sb.append(" <li class=\"mui-table-view-cell\">");
  27. //start mui-table
  28. sb.append(" <div class=\"mui-table\">");
  29. // start mui-table-cell
  30. sb.append("<div class=\"mui-table-cell mui-col-xs-10\">");
  31. // start main content
  32. sb.append("<h5 class=\"mui-ellipsis-4\" style=\"color: red;font-style:italic\">");
  33. sb.append("提示:").append(viewer.getWarning());
  34. // sb.append("!");
  35. // end main content
  36. sb.append("</h5>");
  37. // end mui-table-cell
  38. sb.append("</div>");
  39. // end mui-table
  40. sb.append("</div>");
  41. // end li
  42. sb.append(" </li>");
  43. // end card
  44. sb.append("</div>");
  45. }
  46. List<WXMultiRowViewerDto> dtos = viewer.getRows();
  47. if(dtos != null && dtos.size()>0) {
  48. for(WXMultiRowViewerDto dto : dtos) {
  49. if(dto.getDivTitle()!=null && dto.getDivTitle().length()>0) {
  50. sb.append(" <div class=\"divtitle\">");
  51. if(dto.isDeleteView()) {
  52. sb.append("<s>");
  53. }
  54. sb.append(dto.getDivTitle());
  55. if(dto.isDeleteView()) {
  56. sb.append("</s>");
  57. }
  58. sb.append("</div>");
  59. }
  60. // // start card
  61. // sb.append("<div class=\"mui-card\" style=\"margin-bottom: 35px;\">");
  62. // start li
  63. sb.append(" <li class=\"mui-table-view-cell\">");
  64. //start mui-table
  65. sb.append(" <div class=\"mui-table\">");
  66. // start mui-table-cell
  67. sb.append("<div class=\"mui-table-cell mui-col-xs-10\" ");
  68. if(StringUtils.isNotEmpty(dto.getOnclick())){
  69. sb.append(" onclick='").append(dto.getOnclick()).append("'");
  70. }
  71. sb.append(" >");
  72. // start main content
  73. if(dto.isDeleteView()) {
  74. sb.append("<s>");
  75. }
  76. sb.append("<h4 class=\"mui-ellipsis-4\">");
  77. if(StringUtils.isNotEmpty(dto.getHiddenText())){
  78. sb.append("<input id = \"hidden\" name=\"hidden\" type=\"hidden\" value=\""+dto.getHiddenText()+"\"/>");
  79. }
  80. if(dto.getMainContent() == null || dto.getMainContent().length() == 0) {
  81. sb.append("无");
  82. }else {
  83. sb.append(dto.getMainContent());
  84. }
  85. // end main content
  86. sb.append("</h4>");
  87. if(dto.isDeleteView()) {
  88. sb.append("</s>");
  89. }
  90. if(dto.getSecondContent() != null && dto.getSecondContent().length()>0) {
  91. sb.append(" <h5>");
  92. sb.append(dto.getSecondContent());
  93. sb.append(" </h5>");
  94. }
  95. if(dto.getThirdContent() != null && dto.getThirdContent().length()>0) {
  96. sb.append(" <p class=\"mui-h6 mui-ellipsis\">");
  97. sb.append(dto.getThirdContent());
  98. sb.append(" </p>");
  99. }
  100. // end mui-table-cell
  101. sb.append("</div>");
  102. if(dto.getRightTag() != null && dto.getRightTag().length()>0) {
  103. sb.append("<div class=\"mui-table-cell mui-col-xs-2 mui-text-right\"><span class=\"mui-h5\">");
  104. if(dto.isDeleteView()) {
  105. sb.append("<s>");
  106. }
  107. sb.append(dto.getRightTag());
  108. if(dto.isDeleteView()) {
  109. sb.append("</s>");
  110. }
  111. sb.append("</span></div>");
  112. }
  113. // end mui-table
  114. // sb.append("</div>");
  115. // end li
  116. sb.append(" </li>");
  117. // end card
  118. sb.append("</div>");
  119. }
  120. }
  121. return sb.toString();
  122. }
  123. }