List.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. <template>
  2. <div class="new-list">
  3. <div class="serch-wrapper">
  4. <div class="search">
  5. <input
  6. type="text"
  7. v-model="keyword"
  8. placeholder="请输入内容进行搜索"
  9. class=""
  10. @keyup.enter="getList(keyword)"
  11. />
  12. <img
  13. src="../../assets/img/search.png"
  14. class="hand"
  15. @click="getList(keyword)"
  16. />
  17. </div>
  18. </div>
  19. <div class="empty" v-if="newList.length == 0">暂无数据</div>
  20. <div
  21. class="new-item hand"
  22. v-for="item in newList"
  23. :key="item.id"
  24. @click="navTo('/directories/detail?id=' + item.id)"
  25. >
  26. <div class="title clamp">
  27. <span class="title-icon"></span>
  28. {{ item.title }}
  29. </div>
  30. <div class="time">
  31. {{ item.releasetime | time }}
  32. </div>
  33. </div>
  34. <el-pagination
  35. layout="prev, pager, next"
  36. :total="total"
  37. background
  38. prev-text="上一页"
  39. next-text="下一页"
  40. @current-change="currentChange"
  41. :page-size="15"
  42. hide-on-single-page
  43. ></el-pagination>
  44. </div>
  45. </template>
  46. <script>
  47. import {
  48. loadIndexs,
  49. splist,
  50. loveList,
  51. friendList,
  52. newsList,
  53. openList,
  54. getList,
  55. getArtList
  56. } from "../../request/api.js";
  57. export default {
  58. data() {
  59. return {
  60. newList: [],
  61. total: 0,
  62. page: 1,
  63. limit: 15,
  64. keyword: "",
  65. };
  66. },
  67. filters: {
  68. time(val) {
  69. let arr = val.split(" ");
  70. let str = arr[0];
  71. str = str.replace(/-/g, ".");
  72. return str;
  73. },
  74. },
  75. created() {
  76. this.getList();
  77. },
  78. methods: {
  79. navTo(url) {
  80. this.$router.push(url);
  81. },
  82. currentChange(e) {
  83. this.page = e;
  84. this.getList();
  85. },
  86. getList(keyword) {
  87. let obj = this;
  88. if (keyword) {
  89. obj.page = 1;
  90. }
  91. getArtList({
  92. ifyid: 51,
  93. page: obj.page,
  94. limit: obj.limit,
  95. key: keyword,
  96. }).then((res) => {
  97. obj.newList = res.data.list.sort(this.compare("id"));
  98. // var newArrayData=res.data.list.sort(compare('Id'))
  99. obj.total = res.data.count;
  100. });
  101. },
  102. compare(attribute) {
  103. return function (obj1, obj2) {
  104. var val1 = obj1[attribute];
  105. var val2 = obj2[attribute];
  106. if (val1 < val2) {
  107. return 1;
  108. } else if (val1 > val2) {
  109. return -1;
  110. } else {
  111. return 0;
  112. }
  113. };
  114. },
  115. },
  116. };
  117. </script>
  118. <style lang="scss" scoped>
  119. .empty {
  120. text-align: center;
  121. color: #999;
  122. height: 400px;
  123. line-height: 400px;
  124. }
  125. .new-list {
  126. position: relative;
  127. .new-item {
  128. display: flex;
  129. justify-content: space-between;
  130. font-size: 18px;
  131. font-family: PingFang SC;
  132. font-weight: 500;
  133. color: #666666;
  134. height: 40px;
  135. border-bottom: 1px solid #e5e5e5;
  136. line-height: 40px;
  137. &:hover {
  138. color: red;
  139. .title {
  140. .title-icon {
  141. border-left-color: red;
  142. }
  143. }
  144. }
  145. .title {
  146. width: 500px;
  147. .title-icon {
  148. display: inline-block;
  149. width: 0;
  150. height: 0;
  151. width: 0;
  152. height: 0;
  153. border-top: 6px solid transparent;
  154. border-left: 8px solid #d2d2d2;
  155. border-bottom: 6px solid transparent;
  156. }
  157. }
  158. }
  159. }
  160. /deep/ .el-pagination {
  161. margin-top: 50px;
  162. text-align: center;
  163. }
  164. .serch-wrapper {
  165. display: flex;
  166. height: 33px;
  167. position: absolute;
  168. top: -80px;
  169. right: -50px;
  170. .search {
  171. padding-left: 13px;
  172. padding-right: 13px;
  173. width: 295px;
  174. height: 33px;
  175. line-height: 33px;
  176. background: #ffffff;
  177. border: 1px solid #cccccc;
  178. border-radius: 10px;
  179. // margin-bottom: 10px;
  180. display: flex;
  181. justify-content: space-between;
  182. align-items: center;
  183. input {
  184. width: 235px;
  185. font-size: 16px;
  186. font-family: PingFang SC;
  187. font-weight: bold;
  188. outline: none;
  189. border: none;
  190. }
  191. img {
  192. width: 20px;
  193. height: 20px;
  194. }
  195. }
  196. }
  197. </style>