index.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <template>
  2. <div>
  3. <!-- 页面头部 -->
  4. <AdvertisingHead></AdvertisingHead>
  5. <div class="topicBox">
  6. <el-tabs v-model="activeName" class="demo-tabs" @tab-click="getTopicsList">
  7. <el-tab-pane :label="item.label" :name="item.value" v-for="item in typeList" >
  8. <div class="topicList">
  9. </div>
  10. <!-- <div class="topicInner">
  11. <el-table :data="listData" border row-key="id">
  12. <el-table-column prop="title" label="话题"/>
  13. <el-table-column prop="user_name" label="作者"/>
  14. <el-table-column label="状态">
  15. <template #default="{row}">
  16. <span v-if="row.status == '1'" style="color: #666;">未审核</span>
  17. <span v-if="row.status == '2'" style="color: green;">已通过</span>
  18. <span v-if="row.status == '3'" style="color: red;">已拒绝</span>
  19. </template>
  20. </el-table-column>
  21. <el-table-column prop="created_at" label="创建时间"/>
  22. <el-table-column prop="updated_at" label="更新时间"/>
  23. <el-table-column label="操作">
  24. <template #default="{ row }">
  25. <NuxtLink :to="`/topic/${row.id}`">详情</NuxtLink>
  26. </template>
  27. </el-table-column>
  28. </el-table>
  29. </div> -->
  30. <div class="paginationBox">
  31. <el-pagination background layout="prev, pager, next" :total="currentPage" />
  32. </div>
  33. </el-tab-pane>
  34. </el-tabs>
  35. </div>
  36. <!-- 页面底部 -->
  37. <AdvertisingFoot></AdvertisingFoot>
  38. </div>
  39. </template>
  40. <script setup>
  41. //1.引用模块 start ---------------------------------------->
  42. //使用ref和reactive动态变量
  43. import { ref, reactive,onMounted } from 'vue'
  44. //使用官方ssr请求模块
  45. import { useNuxtApp,useFetch } from '#app'
  46. //使用element-plus组件
  47. import { ElTabs, ElTabPane, ElTable, ElTableColumn, ElPagination } from 'element-plus';
  48. import request from '@/api/api';
  49. //1.引用模块 end ---------------------------------------->
  50. //2.页面数据 start ---------------------------------------->
  51. const activeName = ref(1)
  52. const listData = ref([])//商圈列表
  53. const typeList= ref([])//商圈分类
  54. const statusList = ref([])//商圈状态
  55. const currentPage = ref(0)
  56. //2.页面数据 end ---------------------------------------->
  57. //3.请求商圈列表 start ---------------------------------------->
  58. const searchApi = reactive({
  59. title:"",//标题
  60. type:"",//课题分类
  61. nickname:"",//作者
  62. status:"",//审核状态
  63. page:1,//当前是第几页
  64. page_size:10,//一共多少条
  65. });
  66. const getTopicsList = () => {
  67. searchApi.type = activeName;
  68. request('chat/getTopicsList',searchApi).then(res=>{
  69. listData.value = res._rawValue.data.data;
  70. currentPage.value = res._rawValue.data.total;
  71. })
  72. }
  73. getTopicsList();
  74. //3.请求商圈列表 end ---------------------------------------->
  75. //4.获取分类和状态 start ---------------------------------------->
  76. const topicType = () => {
  77. request('chat/topicType').then(res=>{
  78. typeList.value = res._rawValue.data;
  79. })
  80. }
  81. topicType();
  82. const topicStatus = () => {
  83. request('chat/topicStatus').then(res=>{
  84. statusList.value = res._rawValue.data;
  85. })
  86. }
  87. topicStatus();
  88. //4.获取分类和状态 end ---------------------------------------->
  89. //回复商圈
  90. // axios.post(`/chat/addReply`).then(response=>{
  91. // // console.log(response.data.rows);
  92. // newsList.value = response.data.rows;
  93. // }).catch(error => {
  94. // console.error(error);
  95. // })
  96. </script>
  97. <style lang="less" scoped>
  98. .demo-tabs > .el-tabs__content {
  99. padding: 32px;
  100. color: #6b778c;
  101. font-size: 32px;
  102. font-weight: 600;
  103. }
  104. .topicBox {
  105. width: 1200px;
  106. margin: 40px auto;
  107. }
  108. .paginationBox {
  109. display: flex;
  110. justify-content: center;
  111. margin-top: 20px;
  112. }
  113. </style>