tab.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. <template>
  2. <div id="">
  3. <van-tabs
  4. @click="onClickTab"
  5. color="#333"
  6. title-active-color="#fff"
  7. animated
  8. >
  9. <van-tab
  10. v-for="(item, index) in tab"
  11. :key="index"
  12. :title="item.label"
  13. :name="item.name"
  14. >
  15. <van-empty
  16. description="暂无数据"
  17. v-if="notList[item.name].length == 0"
  18. />
  19. <el-main v-else v-loading="loading" class="notList_box">
  20. <div
  21. class="notList_style"
  22. v-for="(items, indexs) in notList[item.name]"
  23. :key="indexs"
  24. @click="jumpInfo(items)"
  25. >
  26. <i></i>
  27. <div class="title">{{ items.Title }}</div>
  28. <span class="time">{{
  29. $methods.onlyFormaHao(items.NewsCreateTime, false)
  30. }}</span>
  31. </div>
  32. <div style="text-align: center" v-if="notList[item.name].length > 0">
  33. <el-pagination
  34. :pager-count="3"
  35. class="paginations"
  36. @current-change="handleCurrentChange($event, item.name)"
  37. :current-page.sync="formData1.pageindex"
  38. :page-size="formData1.pagesize"
  39. layout="total, prev, pager, next"
  40. :total="total"
  41. >
  42. </el-pagination>
  43. </div>
  44. </el-main>
  45. </van-tab>
  46. </van-tabs>
  47. </div>
  48. </template>
  49. <script>
  50. export default {
  51. data() {
  52. return {
  53. loading: false,
  54. activeTab: "",
  55. tab: [
  56. { label: "最新动态", name: "d0" },
  57. { label: "政策要闻", name: "d1" },
  58. { label: "通知公告", name: "d2" },
  59. { label: "协会动态", name: "d3" },
  60. // { label: "行业报告", name: "d4" },
  61. ],
  62. notList: {
  63. d0: [],
  64. d1: [],
  65. d2: [],
  66. d3: [],
  67. d4: [],
  68. },
  69. total: 0,
  70. formData1: {
  71. pagesize: 10, //每页内容条数
  72. pageindex: 1, //当前第几页
  73. },
  74. };
  75. },
  76. created() {
  77. this.onClickTab("d0");
  78. },
  79. methods: {
  80. //通知列表
  81. getList(name) {
  82. return new Promise((resolve, reject) => {
  83. var data = {
  84. ...this.formData1,
  85. };
  86. if (name == "d0") {
  87. this.$api
  88. .XfWebApiGetNewsReList(data)
  89. .then((res) => {
  90. this.notList[name] = res.Data.List || [];
  91. this.total = res.Data.TotalCount;
  92. })
  93. .finally(() => {
  94. this.loading = false;
  95. resolve();
  96. });
  97. } else {
  98. switch (name) {
  99. case "d1":
  100. data.seat = 1;
  101. break;
  102. case "d2":
  103. data.seat = 2;
  104. break;
  105. case "d3":
  106. data.seat = 3;
  107. break;
  108. case "d4":
  109. data.seat = 4;
  110. break;
  111. default:
  112. break;
  113. }
  114. this.loading = true;
  115. this.$api
  116. .XfWebApiGetNewPositionList(data)
  117. .then((res) => {
  118. this.notList[name] = res.Data.List || [];
  119. this.total = res.Data.TotalCount;
  120. })
  121. .finally(() => {
  122. this.loading = false;
  123. resolve();
  124. });
  125. }
  126. });
  127. },
  128. //Tab切换
  129. async onClickTab(name, title) {
  130. if (name == this.activeTab) return;
  131. this.formData1 = {
  132. pagesize: 10, //每页内容条数
  133. pageindex: 1, //当前第几页
  134. };
  135. await this.getList(name);
  136. this.activeTab = name;
  137. },
  138. handleCurrentChange(e, name) {
  139. this.formData1.pageindex = e;
  140. this.getList(name);
  141. },
  142. //跳转详情页
  143. jumpInfo(e) {
  144. this.$router.push({
  145. path: "info",
  146. query: {
  147. MenuId: e.MenuId,
  148. NewsId: e.NewsId,
  149. },
  150. });
  151. },
  152. },
  153. };
  154. </script>
  155. <style lang="scss" scoped>
  156. ::v-deep .van-tabs__nav--line {
  157. border-bottom: 2px solid #1890ff !important;
  158. padding-bottom: 0px;
  159. box-sizing: border-box;
  160. }
  161. ::v-deep .van-tab--active {
  162. background-color: #1890ff;
  163. }
  164. ::v-deep .van-tabs__line {
  165. display: none;
  166. }
  167. .notList_box {
  168. padding: 48px 30px;
  169. .notList_style {
  170. display: flex;
  171. align-items: center;
  172. margin-bottom: 50px;
  173. &:first-child{
  174. margin-top: 10px;
  175. }
  176. & > i {
  177. width: 10px;
  178. height: 10px;
  179. background-color: rgb(158, 156, 156);
  180. border-radius: 50%;
  181. margin-right: 14px;
  182. flex-shrink: 0;
  183. }
  184. & > .title {
  185. flex: 1;
  186. word-break: break-all;
  187. text-overflow: ellipsis;
  188. overflow: hidden;
  189. display: -webkit-box;
  190. -webkit-line-clamp: 1;
  191. -webkit-box-orient: vertical;
  192. color: #222;
  193. font-weight: 500;
  194. font-size: 28px;
  195. margin-right: 20px;
  196. }
  197. & > .time {
  198. color: #636b75;
  199. font-size: 24px;
  200. flex-shrink: 0;
  201. }
  202. }
  203. }
  204. </style>