content.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. <template>
  2. <div class="vcontent">
  3. <div class="vcontentcon">
  4. <div class="vcontenttitle">
  5. 留言板
  6. </div>
  7. <div class="cbody">
  8. <ul>
  9. <li v-for="(item, i) in list" :key="i">
  10. <img :src="item.avatar || require(`@/assets/images/project/icon/usericon.png`)" alt="" />
  11. <div>
  12. <p>{{ item.message }}</p>
  13. <p>{{ item.dateline }}</p>
  14. </div>
  15. <p>{{ item.author }}</p>
  16. </li>
  17. </ul>
  18. <pagination class="paging" v-if="paging.total > 0" @changeCurrent="changeCurrent" :paging="paging" />
  19. <div class="vbtm">
  20. <div class="vtextarea">
  21. <textarea v-model="msg" rows="6" maxlength="100" cols="20" placeholder="请输入留言......"></textarea>
  22. <emoji class="emoji" @select="selectEmoji" :type="0" id="biaoqing1" />
  23. <span class="maxlength">{{ msg.length }}/100</span>
  24. </div>
  25. <div class="subtn" @click="submit">
  26. <span>提交<br />留言</span>
  27. </div>
  28. </div>
  29. </div>
  30. </div>
  31. </div>
  32. </template>
  33. <script>
  34. import { getcontentList, postcontent } from "@/config/api";
  35. import emoji from "@/components/emoji";
  36. function timestampToStr(timestamp) {
  37. let time = new Date(timestamp * 1000);
  38. let year = time.getFullYear();
  39. let month = time.getMonth() + 1;
  40. let date = time.getDate();
  41. let hours = time.getHours();
  42. let minute = time.getMinutes();
  43. let second = time.getSeconds();
  44. if (month < 10) {
  45. month = "0" + month;
  46. }
  47. if (date < 10) {
  48. date = "0" + date;
  49. }
  50. if (hours < 10) {
  51. hours = "0" + hours;
  52. }
  53. if (minute < 10) {
  54. minute = "0" + minute;
  55. }
  56. if (second < 10) {
  57. second = "0" + second;
  58. }
  59. return year + "-" + month + "-" + date + " " + hours + ":" + minute + ":" + second;
  60. }
  61. export default {
  62. data() {
  63. return {
  64. list: [],
  65. msg: "",
  66. paging: {
  67. pageSize: 10,
  68. pageNum: 1,
  69. total: 0,
  70. showSize: 4,
  71. current: 1,
  72. },
  73. };
  74. },
  75. components: { emoji },
  76. mounted() {
  77. this.getcontentList();
  78. },
  79. methods: {
  80. submit() {
  81. if (!this.msg.trim()) {
  82. this.$showTips({ content: "请输入留言内容" });
  83. } else {
  84. postcontent({ message: this.msg}, () => {
  85. this.$showTips({ content: '留言成功' });
  86. this.msg = "";
  87. this.getcontentList();
  88. });
  89. }
  90. },
  91. selectEmoji(data) {
  92. this.msg += data;
  93. },
  94. changeCurrent(data) {
  95. this.paging.current = data;
  96. this.getcontentList();
  97. },
  98. getcontentList() {
  99. getcontentList(
  100. {
  101. prepage: this.paging.pageSize,
  102. page: this.paging.current,
  103. },
  104. (res) => {
  105. this.list = res.data.content.map((item) => {
  106. return {
  107. ...item,
  108. dateline: timestampToStr(item.dateline),
  109. };
  110. });
  111. this.paging.total = res.data.total;
  112. }
  113. );
  114. },
  115. },
  116. };
  117. </script>
  118. <style lang="less" scoped>
  119. @w: 1236px;
  120. @fixw: 8px;
  121. .vcontent {
  122. width: @w;
  123. position: relative;
  124. height: 740px;
  125. pointer-events: none;
  126. .vcontentcon {
  127. pointer-events: auto;
  128. position: absolute;
  129. top: 0;
  130. left: 0;
  131. width: 100%;
  132. height: 100%;
  133. text-align: center;
  134. padding: 34px 0 0;
  135. background-image: url("~@/assets/images/proj2022/icon/tcbg.png");
  136. background-repeat: no-repeat;
  137. background-size: 100% auto;
  138. .vcontenttitle {
  139. margin: 20px 0 20px;
  140. padding-left: 220px;
  141. text-align: left;
  142. font-size: 30px;
  143. font-weight: bold;
  144. position: relative;
  145. &::after{
  146. content: '';
  147. display: inline-block;
  148. position: absolute;
  149. left: 251px;
  150. bottom: -10px;
  151. width: 30px;
  152. height: 4px;
  153. background: #399efc;
  154. }
  155. }
  156. .cbody {
  157. width: 90%;
  158. margin: 0 auto;
  159. padding: 20px 30px;
  160. .ctitle {
  161. display: flex;
  162. justify-content: space-between;
  163. padding: 0 20px;
  164. > span {
  165. &:first-of-type {
  166. font-size: 24px;
  167. }
  168. }
  169. }
  170. > ul {
  171. height: 300px;
  172. overflow-y: auto;
  173. border-bottom: 2px solid #fff;
  174. margin-top: 20px;
  175. background: rgba(12, 22, 32, 0.55);
  176. padding: 0 20px 20px;
  177. > li {
  178. display: flex;
  179. justify-content: space-between;
  180. border-bottom: 1px dashed #d8d8d8;
  181. padding: 14px 0;
  182. @wh: 50px;
  183. &:last-of-type {
  184. border-bottom: none;
  185. }
  186. > img {
  187. border-radius: 50%;
  188. width: @wh;
  189. height: @wh;
  190. flex-shrink: 0;
  191. }
  192. > div {
  193. text-align: left;
  194. flex: 10;
  195. margin-left: 20px;
  196. > p {
  197. &:first-of-type {
  198. font-size: 16px;
  199. }
  200. &:last-of-type {
  201. font-size: 14px;
  202. color: rgba(255, 255, 255, 0.7);
  203. margin-top: 10px;
  204. }
  205. }
  206. }
  207. > p {
  208. flex-shrink: 0;
  209. }
  210. }
  211. }
  212. .paging {
  213. margin-top: 4px;
  214. }
  215. .vbtm {
  216. display: flex;
  217. justify-content: space-between;
  218. align-items: center;
  219. .vtextarea {
  220. background-color: rgba(0, 0, 0, 0.5);
  221. width: 80%;
  222. margin: 18px 0;
  223. position: relative;
  224. > textarea {
  225. background: none;
  226. outline: none;
  227. width: 100%;
  228. border: none;
  229. padding: 10px 20px;
  230. }
  231. .emoji {
  232. position: absolute;
  233. bottom: 0;
  234. left: 18px;
  235. }
  236. .maxlength {
  237. position: absolute;
  238. bottom: 10px;
  239. color: #a8a8a8;
  240. right: 18px;
  241. }
  242. }
  243. .subtn {
  244. width: 18%;
  245. height: 140px;
  246. border-radius: 4px;
  247. background-image: url("~@/assets/images/proj2022/icon/tab.png");
  248. background-repeat: no-repeat;
  249. background-size: auto 100%;
  250. position: relative;
  251. cursor: pointer;
  252. > span {
  253. position: absolute;
  254. left: 24%;
  255. top: 20%;
  256. display: inline-block;
  257. font-size: 20px;
  258. font-weight: bold;
  259. }
  260. }
  261. }
  262. }
  263. }
  264. .submitbtn {
  265. position: absolute;
  266. pointer-events: auto;
  267. bottom: 34px;
  268. font-size: 26px;
  269. z-index: 1099;
  270. left: 49%;
  271. letter-spacing: 1px;
  272. cursor: pointer;
  273. transform: translateX(-50%);
  274. padding: 10px 55px;
  275. border-radius: 6px;
  276. }
  277. }
  278. </style>