content.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. <template>
  2. <div class="vcontent" :style="{backgroundImage:`url(${require(`@/assets/images/proj2022/mobile/tab_shu@2x.png`)})`}">
  3. <div class="vcontentcon">
  4. <div class="cbody">
  5. <div class="ctitle">
  6. <span>留言板</span>
  7. <span v-if="list.length>0">共{{list.length}}位网友参与留言</span>
  8. <span v-else>暂无留言</span>
  9. </div>
  10. <ul v-infinite-scroll="getcontentList" infinite-scroll-disabled="busy" infinite-scroll-distance="10">
  11. <li v-for="(item,i) in list" :key="i">
  12. <img :src="require(`@/assets/images/project/icon/usericon.png`)" alt="">
  13. <div>
  14. <div>
  15. <p>{{item.userName}}</p>
  16. <p>{{item.createDate}}</p>
  17. </div>
  18. <p>{{item.content}}</p>
  19. </div>
  20. </li>
  21. <li class="loading" v-if="busy"><span>加载中...</span></li>
  22. </ul>
  23. <div class="vtextarea">
  24. <input v-model="msg" maxlength="100" placeholder="请输入留言......" />
  25. <span class="primary" @click="submit">发 表</span>
  26. </div>
  27. </div>
  28. </div>
  29. </div>
  30. </template>
  31. <script>
  32. import { getcontentList,postcontent } from "@/config/api";
  33. export default {
  34. data(){
  35. return {
  36. list:[],
  37. msg:'',
  38. paging: {
  39. pageSize: 10,
  40. pageNum: 1,
  41. total: 0,
  42. showSize: 4,
  43. current: 1,
  44. },
  45. busy:false,
  46. hadloadAll:false
  47. }
  48. },
  49. mounted(){
  50. this.getcontentList()
  51. },
  52. methods:{
  53. submit(){
  54. if (!this.msg.trim()) {
  55. return this.$showTips({content:'请输入留言内容'})
  56. }
  57. else{
  58. postcontent({content:this.msg},res=>{
  59. this.$showTips({content:res.msg})
  60. this.msg = ''
  61. this.getcontentList()
  62. })
  63. }
  64. },
  65. getcontentList(){
  66. if (this.hadloadAll) return
  67. this.busy = true
  68. getcontentList({
  69. pageSize:this.paging.pageSize,
  70. page:this.paging.current
  71. },res=>{
  72. this.list = this.list.concat(res.data.comments)
  73. this.busy = false
  74. this.paging.total = res.data.totalCount
  75. this.paging.current++
  76. if (res.data.comments.length <= 0) {
  77. this.hadloadAll = true
  78. }
  79. })
  80. }
  81. }
  82. }
  83. </script>
  84. <style lang="less" scoped>
  85. @w:100%;
  86. @fixw:8px;
  87. .vcontent{
  88. width: @w;
  89. position: relative;
  90. height: 100%;
  91. background-size: 100% auto;
  92. .vcontentcon{
  93. width: 100%;
  94. height: 100%;
  95. text-align: center;
  96. padding: 40px 0 0;
  97. .cbody{
  98. width: 100%;
  99. height: 100%;
  100. margin: 0 auto;
  101. .ctitle{
  102. padding: 0 20px;
  103. text-align: left;
  104. >span{
  105. display: block;
  106. &:first-of-type{
  107. margin-bottom: 2px;
  108. font-family: "pangmen";
  109. font-weight: normal;
  110. font-size: 24px;
  111. }
  112. &:last-of-type{
  113. font-size: 12px;
  114. color: rgba(255, 255, 255, 0.7);
  115. }
  116. }
  117. }
  118. >ul{
  119. height: calc(100% - 180px);
  120. width: 100%;
  121. overflow-x: hidden;
  122. overflow-y: auto;
  123. margin: 20px auto 30px;
  124. padding: 0 20px 20px;
  125. >li{
  126. display: flex;
  127. justify-content: space-between;
  128. border-bottom: 1px dashed #D8D8D8;
  129. padding: 14px 0;
  130. width: 100%;
  131. @wh:46px;
  132. >img{
  133. border-radius: 6px;
  134. width: @wh;
  135. height: @wh;
  136. flex-shrink: 0;
  137. }
  138. >div{
  139. flex: 10;
  140. margin-left: 20px;
  141. >div{
  142. display: flex;
  143. align-items: center;
  144. justify-content: space-between;
  145. >p{
  146. &:first-of-type{
  147. font-size: 16px;
  148. }
  149. &:last-of-type{
  150. font-size: 12px;
  151. color: rgba(255, 255, 255, 0.7);
  152. }
  153. }
  154. }
  155. >p{
  156. color: rgba(255, 255, 255, 0.7);
  157. font-size: 12px;
  158. width: 100%;
  159. margin-top: 10px;
  160. text-align: left;
  161. }
  162. }
  163. }
  164. .loading{
  165. width: 100%;
  166. >span{
  167. width: 100%;
  168. }
  169. }
  170. }
  171. .paging{
  172. margin-top: 4px;
  173. }
  174. .vtextarea{
  175. width: 100%;
  176. margin: 0 auto;
  177. position: relative;
  178. display: flex;
  179. justify-content: space-between;
  180. align-items: center;
  181. height: 34px;
  182. padding: 0 20px;
  183. >input{
  184. background: none;
  185. outline:none;
  186. width: 100%;
  187. height: 100%;
  188. border: none;
  189. padding: 0 20px;
  190. border-radius: 20px;
  191. background-color: rgba(255, 255, 255, 0.3);
  192. }
  193. >span{
  194. display: inline-block;
  195. min-width: 60px;
  196. flex-shrink: 0;
  197. border-radius: 2px;
  198. margin-left: 10px;
  199. height: 34px;
  200. line-height: 34px;
  201. }
  202. }
  203. }
  204. }
  205. }
  206. </style>