Skip to content

Commit 59777cd

Browse files
committed
mp:自定义菜单的图文选择
1 parent 5323b61 commit 59777cd

File tree

2 files changed

+40
-26
lines changed

2 files changed

+40
-26
lines changed

src/views/mp/components/wx-news/main.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@
4242
type: Array // title - 标题;description - 描述;picUrl - 图片连接;url - 跳转链接
4343
}
4444
},
45-
created() {
46-
console.log(this.articles)
47-
},
45+
// created() {
46+
// console.log(this.articles)
47+
// },
4848
};
4949
</script>
5050

src/views/mp/menu/index.vue

Lines changed: 37 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -113,21 +113,23 @@ SOFTWARE.
113113
</div>
114114
<div class="configur_content" v-if="tempObj.type === 'article_view_limited'">
115115
<el-row>
116-
<div class="select-item" v-if="tempObj && tempObj.content && tempObj.content.articles">
117-
<WxNews :objData="tempObj.content.articles"></WxNews>
116+
<div class="select-item" v-if="tempObj && tempObj.replyArticles">
117+
<wx-news :articles="tempObj.replyArticles" />
118118
<el-row class="ope-row">
119-
<el-button type="danger" icon="el-icon-delete" circle @click="deleteTempObj" />
119+
<el-button type="danger" icon="el-icon-delete" circle @click="deleteMaterial" />
120120
</el-row>
121121
</div>
122-
<div v-if="!tempObj.content || !tempObj.content.articles">
122+
<div v-else>
123123
<el-row>
124124
<el-col :span="24" style="text-align: center">
125-
<el-button type="success" @click="openMaterial">素材库选择<i class="el-icon-circle-check el-icon--right"></i></el-button>
125+
<el-button type="success" @click="openMaterial">
126+
素材库选择<i class="el-icon-circle-check el-icon--right"></i>
127+
</el-button>
126128
</el-col>
127129
</el-row>
128130
</div>
129131
<el-dialog title="选择图文" :visible.sync="dialogNewsVisible" width="90%">
130-
<WxMaterialSelect :objData="{repType:'news'}" @selectMaterial="selectMaterial"></WxMaterialSelect>
132+
<wx-material-select :objData="{type: 'news', accountId: this.accountId}" @selectMaterial="selectMaterial" />
131133
</el-dialog>
132134
</el-row>
133135
</div>
@@ -148,7 +150,7 @@ SOFTWARE.
148150
<script>
149151
import WxReplySelect from '@/views/mp/components/wx-reply/main.vue'
150152
import WxNews from '@/views/mp/components/wx-news/main.vue';
151-
import WxMaterialSelect from '@/views/mp/components/wx-news/main.vue'
153+
import WxMaterialSelect from '@/views/mp/components/wx-material-select/main.vue'
152154
import { deleteMenu, getMenuList, saveMenu } from "@/api/mp/menu";
153155
import { getSimpleAccounts } from "@/api/mp/account";
154156
@@ -359,10 +361,9 @@ export default {
359361
this.$delete( item, 'miniProgramPagePath')
360362
this.$delete( item, 'url')
361363
this.$delete( item, 'reply')
362-
// TODO 芋艿:需要搞的属性弄下
363-
364-
this.$delete( item, 'article_id')
365-
this.$delete( item, 'textContent')
364+
this.$delete( item, 'articleId')
365+
this.$delete( item, 'replyArticles')
366+
// 关闭配置面板
366367
this.showConfigureContent = false
367368
}
368369
@@ -471,24 +472,37 @@ export default {
471472
openMaterial() {
472473
this.dialogNewsVisible = true
473474
},
474-
selectMaterial(item){
475-
if(item.content.articles.length>1){
475+
selectMaterial(item) {
476+
const articleId = item.articleId;
477+
const articles = item.content.newsItem;
478+
// 提示,针对多图文
479+
if (articles.length > 1) {
476480
this.$alert('您选择的是多图文,将默认跳转第一篇', '提示', {
477481
confirmButtonText: '确定'
478482
})
479483
}
480484
this.dialogNewsVisible = false
481-
this.tempObj.article_id = item.articleId
482-
this.tempObj.mediaName = item.name
483-
this.tempObj.url = item.url
484-
item.mediaType = this.tempObj.mediaType
485-
item.content.articles = item.content.articles.slice(0,1)
486-
this.tempObj.content = item.content
485+
486+
// 设置菜单的回复
487+
this.tempObj.articleId = articleId;
488+
this.tempObj.replyArticles = [];
489+
articles.forEach(article => {
490+
this.tempObj.replyArticles.push({
491+
title: article.title,
492+
description: article.digest,
493+
picUrl: article.picUrl,
494+
url: article.url,
495+
})
496+
})
497+
// this.tempObj.mediaName = item.name
498+
// this.tempObj.url = item.url
499+
// item.mediaType = this.tempObj.mediaType
500+
// item.content.articles = item.content.articles.slice(0,1)
501+
// this.tempObj.content = item.content
487502
},
488-
deleteTempObj() {
489-
this.$delete(this.tempObj,'repName')
490-
this.$delete(this.tempObj,'repUrl')
491-
this.$delete(this.tempObj,'content')
503+
deleteMaterial() {
504+
this.$delete(this.tempObj,'articleId')
505+
this.$delete(this.tempObj,'replyArticles')
492506
},
493507
},
494508
}

0 commit comments

Comments
 (0)