H5Mall.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. <template>
  2. <div class="H5Mall">
  3. <div class="mainBody">
  4. <div
  5. class="item"
  6. @click="() => toH5Editor(item)"
  7. v-for="(item, index) in list"
  8. :key="index"
  9. >
  10. <component :is="components[item.type]" :item="item"></component>
  11. <div class="main_item" v-text="item.title"></div>
  12. <div class="body">
  13. <img style="width: 20px; float: left" :src="defaultIcon" />
  14. <span>
  15. <img style="width: 20px" :src="eyeIcon" />
  16. <span style="vertical-align: middle" v-text="item.hot"></span>
  17. </span>
  18. </div>
  19. </div>
  20. </div>
  21. <el-button @click="showData" class="createPageList"> 已生成页面 </el-button>
  22. <el-dialog v-model="show" title="已创建页面">
  23. <el-table :data="localList">
  24. <el-table-column property="title" label="页面名称" />
  25. <el-table-column label="状态">
  26. <template #default="scope">
  27. {{ h5Status[scope.row.h5Status] }}
  28. </template>
  29. </el-table-column>
  30. <el-table-column property="url" label="操作">
  31. <template #default="scope">
  32. <el-button v-if="scope.row.url" type="primary" link @click="() => openurl(scope.row.url)"> 打开 </el-button>
  33. <el-button link type="primary" @click="() => editBL(scope)">
  34. 修改
  35. </el-button>
  36. </template>
  37. </el-table-column>
  38. </el-table>
  39. </el-dialog>
  40. </div>
  41. </template>
  42. <script setup>
  43. import { ref } from 'vue';
  44. import { useRouter } from 'vue-router';
  45. import defaultIcon from '../../assets/img/default_user.png';
  46. import eyeIcon from '../../assets/img/eye.png';
  47. import H5 from './components/H5.vue';
  48. import LONGPAGE from './components/LONGPAGE.vue';
  49. import POSTER from './components/POSTER.vue';
  50. import { getTemplateList, getPersonalList } from '../../api/index.js';
  51. const components = {
  52. H5,
  53. LONGPAGE,
  54. POSTER,
  55. };
  56. const router = useRouter();
  57. // const route = useRoute();
  58. const show = ref(false);
  59. const localList = ref([]);
  60. const list = ref([]);
  61. const h5Status = ['生成中', '已生成'];
  62. getTemplateList({}).then(r => {
  63. list.value = r || [];
  64. });
  65. const toH5Editor = item => {
  66. router.push({
  67. path: '/h5editor',
  68. query: {
  69. item: JSON.stringify(item),
  70. },
  71. });
  72. };
  73. const showData = () => {
  74. getPersonalList({ data: {} }).then(r => {
  75. localList.value = r;
  76. show.value = true;
  77. });
  78. };
  79. const editBL = item => {
  80. router.push({
  81. path: '/h5editor',
  82. query: {
  83. item: JSON.stringify(item.row),
  84. },
  85. });
  86. };
  87. const openurl = url => window.open(url);
  88. </script>
  89. <style scoped>
  90. .H5Mall {
  91. padding: 1em;
  92. height: 100%;
  93. }
  94. .mainBody {
  95. font-weight: 500;
  96. padding: 1em 0 1em 1em;
  97. }
  98. .mainBody .item {
  99. display: inline-block;
  100. width: 184px;
  101. height: 363px;
  102. transition: all 0.3s;
  103. border-radius: 2px;
  104. vertical-align: middle;
  105. margin-right: 1em;
  106. border-radius: 5px;
  107. overflow: hidden;
  108. cursor: pointer;
  109. box-shadow: var(--el-box-shadow-lighter);
  110. }
  111. .el-image {
  112. height: 280px;
  113. }
  114. .main_item {
  115. color: #666;
  116. padding: 0 5px;
  117. margin: 5px 0;
  118. font-size: 14px;
  119. overflow: hidden;
  120. white-space: nowrap;
  121. text-overflow: ellipsis;
  122. }
  123. .mainBody .item:hover {
  124. box-shadow: var(--el-box-shadow);
  125. margin-top: -15px;
  126. }
  127. .mainBody .body {
  128. padding: 0 5px;
  129. text-align: right;
  130. }
  131. .mainBody img {
  132. vertical-align: middle;
  133. }
  134. .createPageList {
  135. position: absolute;
  136. top: 1em;
  137. right: 1em;
  138. }
  139. </style>