videoList.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. <template>
  2. <div id="list">
  3. <el-row>
  4. <el-col :span="24">
  5. <el-col :span="24">
  6. <top :infoMes="infoMes"></top>
  7. </el-col>
  8. <el-col :span="24">
  9. <menus></menus>
  10. </el-col>
  11. <el-col :span="24" class="info">
  12. <div class="w_1200">
  13. <el-col :span="24" class="container">
  14. <span v-if="display == 'list'">
  15. <el-col :span="24" class="two">
  16. <infoList :column_name="title" :infoList="videoList" :total="total" @clickDetail="clickDetail"></infoList>
  17. </el-col>
  18. </span>
  19. <span v-else>
  20. <el-col :span="24" class="three">
  21. <el-col :span="24" class="btn">
  22. <el-button type="primary" size="mini" @click="back()">返回</el-button>
  23. </el-col>
  24. <infoDetail :detail="videodetail"></infoDetail>
  25. </el-col>
  26. </span>
  27. </el-col>
  28. </div>
  29. </el-col>
  30. <el-col :span="24">
  31. <foot :infoMes="infoMes"></foot>
  32. </el-col>
  33. </el-col>
  34. </el-row>
  35. </div>
  36. </template>
  37. <script>
  38. import { mapState, createNamespacedHelpers } from 'vuex';
  39. import top from '../../components/common/top.vue';
  40. import menus from '../../components/common/menus.vue';
  41. import foot from '../../components/common/foot1.vue';
  42. const { mapActions: video } = createNamespacedHelpers('video');
  43. const { mapActions: siteInfo } = createNamespacedHelpers('siteInfo');
  44. import infoList from './parts/videoLists.vue';
  45. import infoDetail from './parts/videoDetail.vue';
  46. export default {
  47. metaInfo() {
  48. return { title: this.$route.meta.title };
  49. },
  50. name: 'videoList',
  51. props: {},
  52. components: {
  53. top,
  54. menus,
  55. foot,
  56. infoList,
  57. infoDetail,
  58. },
  59. data: function() {
  60. return {
  61. //信息
  62. infoMes: {},
  63. // 右侧头部栏目
  64. title: '',
  65. total: 0,
  66. //详情
  67. detail: {},
  68. videoList: [],
  69. // list:列表,detail:详情
  70. display: 'list',
  71. videodetail: {},
  72. };
  73. },
  74. created() {
  75. this.search();
  76. },
  77. methods: {
  78. ...video({ videoquery: 'query', videocreate: 'create', videofetch: 'fetch', videoupdate: 'update', videodelete: 'delete' }),
  79. ...siteInfo({ sitequery: 'query' }),
  80. async search() {
  81. if (this.id) {
  82. this.display = 'detail';
  83. this.menuIndex = this.site;
  84. this.searchDetail(this.id);
  85. } else {
  86. this.display = 'list';
  87. }
  88. const res = await this.videoquery();
  89. if (res.errcode === 0) {
  90. this.$set(this, `videoList`, res.data);
  91. this.$set(this, `title`, res.data[0].title);
  92. this.$set(this, `total`, res.total);
  93. }
  94. },
  95. //查详情
  96. async searchDetail(id) {
  97. const res = await this.videofetch(id);
  98. if (res) {
  99. this.$set(this, `videodetail`, res.data);
  100. }
  101. },
  102. // 点击进入详情
  103. clickDetail(id) {
  104. this.display = 'detail';
  105. this.searchDetail(id);
  106. },
  107. back() {
  108. this.display = 'list';
  109. // this.searchList(this.site);
  110. },
  111. },
  112. computed: {
  113. ...mapState(['user']),
  114. id() {
  115. return this.$route.query.id;
  116. },
  117. },
  118. };
  119. </script>
  120. <style lang="less" scoped>
  121. .w_1200 {
  122. width: 1200px;
  123. margin: 0 auto;
  124. }
  125. .info {
  126. margin-top: 10px;
  127. margin-bottom: 10px;
  128. .container {
  129. .three {
  130. background-color: #fff;
  131. padding: 10px;
  132. overflow: hidden;
  133. min-height: 623px;
  134. .btn {
  135. text-align: right;
  136. padding: 10px 0px;
  137. }
  138. }
  139. }
  140. }
  141. </style>