index.vue 5.5 KB

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