index.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. <template>
  2. <view class="msg-box">
  3. <Nav title="留言反馈" :left-show="false" titleColor="#fff"></Nav>
  4. <view class="mui-content">
  5. <view class="ln-public">
  6. 留言内容
  7. </view>
  8. <view class="msg-text" contenteditable="true" placeholder="在此输入留言内容,限200字。"></view>
  9. <view class="msg-btn" @click="sendMsg">提交</view>
  10. <view class="msg-list">
  11. <view class="msg-item" v-for="(msgItem,index) in list">
  12. <view class="msg-list-con">
  13. <view class="msg-list-tit">
  14. <view class="msg-list-name">
  15. {{msgItem.username}}
  16. </view>
  17. <view class="msg-list-time">{{msgItem.created_at}}</view>
  18. </view>
  19. <view class="msg-list-intro">{{msgItem.content}}</view>
  20. </view>
  21. <view class="msg-list-con" v-if="msgItem.reply!==''">
  22. <view class="msg-list-tit">
  23. <view class="msg-list-name">
  24. 回复
  25. </view>
  26. <view class="msg-list-time">{{msgItem.updated_at}}</view>
  27. </view>
  28. <view class="msg-list-intro">{{msgItem.reply}}</view>
  29. </view>
  30. </view>
  31. </view>
  32. <en-blank v-if="list.length<=0"></en-blank>
  33. </view>
  34. </view>
  35. </template>
  36. <script>
  37. import $ from 'jquery/src/jquery'
  38. import {addMsg, getMsgList} from "@/api/news";
  39. import tools from "@/common/js/tools";
  40. import EnBlank from "@/components/en-utils/en-blank/en-blank";
  41. export default {
  42. name: "index",
  43. components: {EnBlank},
  44. props: {},
  45. data() {
  46. return {
  47. isAjax:false,
  48. page:1,
  49. list:[],
  50. total:null
  51. }
  52. },
  53. watch: {},
  54. mounted() {
  55. this.startList()
  56. },
  57. onReachBottom() {
  58. this.getMsgList()
  59. },
  60. methods: {
  61. startList(){
  62. this.page=1;
  63. this.list=[];
  64. this.total=null;
  65. this.getMsgList()
  66. },
  67. getMsgList(){
  68. if(this.isAjax){
  69. return;
  70. }
  71. if(this.total!==null && this.total>=this.list.length){
  72. return;
  73. }
  74. getMsgList({'page':this.page}).then((res)=>{
  75. if(res.code===1){
  76. this.total=res.data.total
  77. this.list.push(...res.data.items)
  78. ++this.page
  79. }
  80. })
  81. },
  82. sendMsg(){
  83. let msg = $('.msg-text').text();
  84. if(msg===''){
  85. tools.error('请输入留言内容')
  86. return;
  87. }
  88. if(this.isAjax){
  89. return;
  90. }
  91. this.isAjax=true
  92. addMsg({'content':msg}).then((res)=>{
  93. this.isAjax=false
  94. if(res.code===1){
  95. this.list.unshift(res.data)
  96. $('.msg-text').text('');
  97. tools.success(res.msg)
  98. }else {
  99. tools.error(res.msg)
  100. }
  101. }).catch((e)=>{
  102. this.isAjax=false
  103. })
  104. }
  105. }
  106. }
  107. </script>
  108. <style scoped lang="scss">
  109. .msg-box{
  110. background: #131E30;
  111. min-height: calc(100vh - 50px);
  112. .mui-content{
  113. padding:0 10px;
  114. .ln-public {
  115. width: 100%;
  116. padding: 0 10px;
  117. font-size: 20px;
  118. line-height: 28px;
  119. font-weight: 600;
  120. margin: 20px auto;
  121. color: #D9E4F6;
  122. word-break: break-all;
  123. }
  124. .msg-text {
  125. width: calc(100% - 20px);
  126. min-height: 98px;
  127. line-height: 24px;
  128. color: #D9E4F6;
  129. padding: 10px 0;
  130. background: #061623;
  131. border: 1px solid rgba(39,60,83,0.5);
  132. margin: 10px;
  133. }
  134. .msg-btn {
  135. display: block;
  136. width: 82%;
  137. height: 42px;
  138. line-height: 42px;
  139. border: 0;
  140. border-radius: 3px;
  141. text-align: center;
  142. padding: 0;
  143. font-size: 16px;
  144. background: #007AFF;
  145. color: #FFFFFF;
  146. margin: 15px auto;
  147. margin-top: 60px;
  148. overflow: hidden;
  149. text-overflow: ellipsis;
  150. white-space: nowrap;
  151. }
  152. .msg-list {
  153. width: calc(100% - 20px);
  154. line-height: 20px;
  155. padding: 0 10px;
  156. border-top: 1px solid rgba(39,60,83,0.5);
  157. list-style-type: none;
  158. margin: 0;
  159. -webkit-padding-start: 0;
  160. .msg-item{
  161. padding: 2px 0;
  162. border-bottom: 1px solid rgba(39,60,83,0.5);
  163. color: #D9E4F6;
  164. .msg-list-con {
  165. width: 100%;
  166. overflow: auto;
  167. margin: 15px 0;
  168. .msg-list-tit {
  169. width: 100%;
  170. height: 30px;
  171. line-height: 30px;
  172. .msg-list-name {
  173. max-width: calc(100% - 120px);
  174. height: 30px;
  175. float: left;
  176. overflow: hidden;
  177. text-overflow: ellipsis;
  178. white-space: nowrap;
  179. color: #D9E4F6;
  180. }
  181. .msg-list-time {
  182. max-width: 130px;
  183. height: 30px;
  184. font-size: 12px;
  185. color: #495B73;
  186. text-align: right;
  187. float: right;
  188. overflow: hidden;
  189. }
  190. }
  191. .msg-list-intro {
  192. width: 100%;
  193. line-height: 20px;
  194. color: #495B73;
  195. text-align: justify;
  196. }
  197. }
  198. }
  199. }
  200. }
  201. }
  202. </style>