index.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  1. <template>
  2. <doc-alert title="公众号图文" url="https://doc.iocoder.cn/mp/article/" />
  3. <!-- 搜索工作栏 -->
  4. <ContentWrap>
  5. <!-- TODO @芋艿:调整成 el-form 和 WxAccountSelect -->
  6. <WxAccountSelect @change="(accountId) => accountChanged(accountId)" />
  7. </ContentWrap>
  8. <!-- 列表 -->
  9. <ContentWrap>
  10. <div class="waterfall" v-loading="loading">
  11. <div
  12. class="waterfall-item"
  13. v-show="item.content && item.content.newsItem"
  14. v-for="item in list"
  15. :key="item.articleId"
  16. >
  17. <wx-news :articles="item.content.newsItem" />
  18. <el-row justify="center" class="ope-row">
  19. <el-button
  20. type="danger"
  21. circle
  22. @click="handleDelete(item)"
  23. v-hasPermi="['mp:free-publish:delete']"
  24. >
  25. <Icon icon="ep:delete" />
  26. </el-button>
  27. </el-row>
  28. </div>
  29. </div>
  30. <!-- 分页 -->
  31. <Pagination
  32. :total="total"
  33. v-model:page="queryParams.pageNo"
  34. v-model:limit="queryParams.pageSize"
  35. @pagination="getList"
  36. />
  37. </ContentWrap>
  38. </template>
  39. <script setup name="MpFreePublish">
  40. import * as FreePublishApi from '@/api/mp/freePublish'
  41. import WxNews from '@/views/mp/components/wx-news/main.vue'
  42. import WxAccountSelect from '@/views/mp/components/wx-account-select/main.vue'
  43. const message = useMessage() // 消息弹窗
  44. const { t } = useI18n() // 国际化
  45. const loading = ref(true) // 列表的加载中
  46. const total = ref(0) // 列表的总页数
  47. const list = ref([]) // 列表的数据
  48. const queryParams = reactive({
  49. pageNo: 1,
  50. pageSize: 10,
  51. accountId: undefined
  52. })
  53. /** 侦听公众号变化 **/
  54. const accountChanged = (accountId) => {
  55. queryParams.accountId = accountId
  56. getList()
  57. }
  58. /** 查询列表 */
  59. const getList = async () => {
  60. try {
  61. loading.value = true
  62. const data = await FreePublishApi.getFreePublishPage(queryParams)
  63. list.value = data.list
  64. total.value = data.total
  65. } finally {
  66. loading.value = false
  67. }
  68. }
  69. /** 删除按钮操作 */
  70. const handleDelete = async (item) => {
  71. try {
  72. // 删除的二次确认
  73. await message.delConfirm('删除后用户将无法访问此页面,确定删除?')
  74. // 发起删除
  75. await FreePublishApi.deleteFreePublish(queryParams.accountId, item.articleId)
  76. message.success(t('common.delSuccess'))
  77. // 刷新列表
  78. await getList()
  79. } catch {}
  80. }
  81. </script>
  82. <style lang="scss" scoped>
  83. .ope-row {
  84. margin-top: 5px;
  85. text-align: center;
  86. border-top: 1px solid #eaeaea;
  87. padding-top: 5px;
  88. }
  89. .item-name {
  90. font-size: 12px;
  91. overflow: hidden;
  92. text-overflow: ellipsis;
  93. white-space: nowrap;
  94. text-align: center;
  95. }
  96. .el-upload__tip {
  97. margin-left: 5px;
  98. }
  99. /* 新增图文 */
  100. .left {
  101. display: inline-block;
  102. width: 35%;
  103. vertical-align: top;
  104. margin-top: 200px;
  105. }
  106. .right {
  107. display: inline-block;
  108. width: 60%;
  109. margin-top: -40px;
  110. }
  111. .avatar-uploader {
  112. width: 20%;
  113. display: inline-block;
  114. }
  115. .avatar-uploader .el-upload {
  116. border-radius: 6px;
  117. cursor: pointer;
  118. position: relative;
  119. overflow: hidden;
  120. text-align: unset !important;
  121. }
  122. .avatar-uploader .el-upload:hover {
  123. border-color: #165dff;
  124. }
  125. .avatar-uploader-icon {
  126. border: 1px solid #d9d9d9;
  127. font-size: 28px;
  128. color: #8c939d;
  129. width: 120px;
  130. height: 120px;
  131. line-height: 120px;
  132. text-align: center;
  133. }
  134. .avatar {
  135. width: 230px;
  136. height: 120px;
  137. }
  138. .avatar1 {
  139. width: 120px;
  140. height: 120px;
  141. }
  142. .digest {
  143. width: 60%;
  144. display: inline-block;
  145. vertical-align: top;
  146. }
  147. /*新增图文*/
  148. /*瀑布流样式*/
  149. .waterfall {
  150. width: 100%;
  151. column-gap: 10px;
  152. column-count: 5;
  153. margin: 0 auto;
  154. }
  155. .waterfall-item {
  156. padding: 10px;
  157. margin-bottom: 10px;
  158. break-inside: avoid;
  159. border: 1px solid #eaeaea;
  160. }
  161. p {
  162. line-height: 30px;
  163. }
  164. @media (min-width: 992px) and (max-width: 1300px) {
  165. .waterfall {
  166. column-count: 3;
  167. }
  168. p {
  169. color: red;
  170. }
  171. }
  172. @media (min-width: 768px) and (max-width: 991px) {
  173. .waterfall {
  174. column-count: 2;
  175. }
  176. p {
  177. color: orange;
  178. }
  179. }
  180. @media (max-width: 767px) {
  181. .waterfall {
  182. column-count: 1;
  183. }
  184. }
  185. /*瀑布流样式*/
  186. .news-main {
  187. background-color: #ffffff;
  188. width: 100%;
  189. margin: auto;
  190. height: 120px;
  191. }
  192. .news-content {
  193. background-color: #acadae;
  194. width: 100%;
  195. height: 120px;
  196. position: relative;
  197. }
  198. .news-content-title {
  199. display: inline-block;
  200. font-size: 15px;
  201. color: #ffffff;
  202. position: absolute;
  203. left: 0px;
  204. bottom: 0px;
  205. background-color: black;
  206. width: 98%;
  207. padding: 1%;
  208. opacity: 0.65;
  209. overflow: hidden;
  210. text-overflow: ellipsis;
  211. white-space: nowrap;
  212. height: 25px;
  213. }
  214. .news-main-item {
  215. background-color: #ffffff;
  216. padding: 5px 0px;
  217. border-top: 1px solid #eaeaea;
  218. width: 100%;
  219. margin: auto;
  220. }
  221. .news-content-item {
  222. position: relative;
  223. margin-left: -3px;
  224. }
  225. .news-content-item-title {
  226. display: inline-block;
  227. font-size: 12px;
  228. width: 70%;
  229. }
  230. .news-content-item-img {
  231. display: inline-block;
  232. width: 25%;
  233. background-color: #acadae;
  234. }
  235. .input-tt {
  236. padding: 5px;
  237. }
  238. .activeAddNews {
  239. border: 5px solid #2bb673;
  240. }
  241. .news-main-plus {
  242. width: 280px;
  243. text-align: center;
  244. margin: auto;
  245. height: 50px;
  246. }
  247. .icon-plus {
  248. margin: 10px;
  249. font-size: 25px;
  250. }
  251. .select-item {
  252. width: 60%;
  253. padding: 10px;
  254. margin: 0 auto 10px auto;
  255. border: 1px solid #eaeaea;
  256. }
  257. .father .child {
  258. display: none;
  259. text-align: center;
  260. position: relative;
  261. bottom: 25px;
  262. }
  263. .father:hover .child {
  264. display: block;
  265. }
  266. .thumb-div {
  267. display: inline-block;
  268. width: 30%;
  269. text-align: center;
  270. }
  271. .thumb-but {
  272. margin: 5px;
  273. }
  274. .material-img {
  275. width: 100%;
  276. height: 100%;
  277. }
  278. </style>