index.vue 5.7 KB

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