Skip to content

Commit e82f57c

Browse files
committed
mp:增加图文草稿箱的删除、发布功能
1 parent 11c0b42 commit e82f57c

File tree

3 files changed

+42
-43
lines changed

3 files changed

+42
-43
lines changed

src/api/mp/draft.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,11 @@ export function updateDraft(accountId, mediaId, articles) {
2828
data: articles
2929
})
3030
}
31+
32+
// 删除草稿
33+
export function deleteDraft(accountId, mediaId) {
34+
return request({
35+
url: '/mp/draft/delete?accountId=' + accountId + '&mediaId=' + mediaId,
36+
method: 'delete',
37+
})
38+
}

src/api/mp/freePublish.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,11 @@ export function deleteFreePublish(accountId, articleId) {
1616
method: 'delete'
1717
})
1818
}
19+
20+
// 发布公众号素材
21+
export function submitFreePublish(accountId, mediaId) {
22+
return request({
23+
url: '/mp/free-publish/submit?accountId=' + accountId + '&mediaId=' + mediaId,
24+
method: 'post'
25+
})
26+
}

src/views/mp/draft/index.vue

Lines changed: 26 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2222
SOFTWARE.
2323
芋道源码:
2424
① 优化代码,和项目的代码保持一致
25+
② 清理冗余代码,保证代码整洁
26+
③ 增加注释,提升可读性
2527
-->
2628
<template>
2729
<div class="app-container">
@@ -53,11 +55,11 @@ SOFTWARE.
5355
<div v-if="item.content && item.content.newsItem" class="waterfall-item" v-for="item in list"
5456
:key='item.articleId'>
5557
<wx-news :articles="item.content.newsItem" />
56-
<!-- TODO 芋艿:权限、样式(搜索框之类的) -->
58+
<!-- 操作按钮 -->
5759
<el-row class="ope-row">
58-
<el-button type="success" circle @click="handlePublishNews(item)">发布</el-button>
59-
<el-button type="primary" icon="el-icon-edit" circle @click="handleUpdate(item)"></el-button>
60-
<el-button type="danger" icon="el-icon-delete" circle @click="delMaterial(item)"></el-button>
60+
<el-button type="success" circle @click="handlePublish(item)" v-hasPermi="['mp:free-publish:submit']">发布</el-button>
61+
<el-button type="primary" icon="el-icon-edit" circle @click="handleUpdate(item)" v-hasPermi="['mp:draft:update']" />
62+
<el-button type="danger" icon="el-icon-delete" circle @click="handleDelete(item)" v-hasPermi="['mp:draft:delete']" />
6163
</el-row>
6264
</div>
6365
</div>
@@ -147,7 +149,6 @@ SOFTWARE.
147149
<wx-editor v-model="articlesAdd[isActiveAddNews].content" :account-id="this.uploadData.accountId"
148150
v-if="hackResetEditor"/>
149151
</el-row>
150-
<!-- 原文地址 -->
151152
</div>
152153
<div slot="footer" class="dialog-footer">
153154
<el-button @click="dialogNewsVisible = false">取 消</el-button>
@@ -158,13 +159,13 @@ SOFTWARE.
158159
</template>
159160

160161
<script>
161-
// import { getPage as getPage1 } from '@/api/wxmp/wxmaterial'
162162
import WxEditor from '@/views/mp/components/wx-editor/WxEditor.vue';
163163
import WxNews from '@/views/mp/components/wx-news/main.vue';
164164
import WxMaterialSelect from '@/views/mp/components/wx-material-select/main.vue'
165165
import { getAccessToken } from '@/utils/auth'
166-
import {createDraft, getDraftPage, updateDraft} from "@/api/mp/draft";
166+
import {createDraft, deleteDraft, getDraftPage, updateDraft} from "@/api/mp/draft";
167167
import { getSimpleAccounts } from "@/api/mp/account";
168+
import {deleteFreePublish, submitFreePublish} from "@/api/mp/freePublish";
168169
169170
export default {
170171
name: 'mpDraft',
@@ -221,7 +222,7 @@ export default {
221222
this.setAccountId(this.accounts[0].id);
222223
}
223224
// 加载数据
224-
// this.getList(); // TODO 芋艿:开发完,放出来
225+
this.getList();
225226
})
226227
},
227228
methods: {
@@ -434,44 +435,26 @@ export default {
434435
},
435436
436437
// ======================== 草稿箱发布 ========================
437-
handlePublishNews(item){
438-
this.$confirm('你正在通过发布的方式发表内容。 发布不占用群发次数,一天可多次发布。已发布内容不会推送给用户,也不会展示在公众号主页中。 发布后,你可以前往发表记录获取链接,也可以将发布内容添加到自定义菜单、自动回复、话题和页面模板中。', '提示', {
439-
confirmButtonText: '确定',
440-
cancelButtonText: '取消',
441-
type: 'warning'
438+
handlePublish(item) {
439+
const accountId = this.queryParams.accountId;
440+
const mediaId = item.mediaId;
441+
const content = '你正在通过发布的方式发表内容。 发布不占用群发次数,一天可多次发布。已发布内容不会推送给用户,也不会展示在公众号主页中。 发布后,你可以前往发表记录获取链接,也可以将发布内容添加到自定义菜单、自动回复、话题和页面模板中。';
442+
this.$modal.confirm(content).then(function() {
443+
return submitFreePublish(accountId, mediaId);
442444
}).then(() => {
443-
this.loading = true
444-
publish(item.mediaId).then(response => {
445-
this.loading = false
446-
this.$message.success('发布任务提交成功')
447-
this.getList(this.queryParams)
448-
}).catch(() => {
449-
this.loading = false
450-
})
451-
}).catch(() => {
452-
})
445+
this.getList();
446+
this.$modal.msgSuccess("发布成功");
447+
}).catch(() => {});
453448
},
454-
delMaterial(item){
455-
this.$confirm('此操作将永久删除该草稿, 是否继续?', '提示', {
456-
confirmButtonText: '确定',
457-
cancelButtonText: '取消',
458-
type: 'warning'
449+
handleDelete(item) {
450+
const accountId = this.queryParams.accountId;
451+
const mediaId = item.mediaId;
452+
this.$modal.confirm('此操作将永久删除该草稿, 是否继续?').then(function() {
453+
return deleteDraft(accountId, mediaId);
459454
}).then(() => {
460-
this.loading = true
461-
delObj({
462-
id:item.mediaId
463-
}).then(response => {
464-
this.loading = false
465-
if(response.code == 200){
466-
this.getList(this.queryParams)
467-
}else{
468-
this.loading = false
469-
this.$message.error('删除出错:' + response.msg)
470-
}
471-
}).catch(() => {
472-
this.loading = false
473-
})
474-
})
455+
this.getList();
456+
this.$modal.msgSuccess("删除成功");
457+
}).catch(() => {});
475458
},
476459
}
477460
}

0 commit comments

Comments
 (0)