mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-22 07:11:52 +08:00
mp:增加发送【图文】消息
This commit is contained in:
parent
5901ab6664
commit
02ccf52d6c
@ -19,6 +19,14 @@ tenant-id: {{adminTenentId}}
|
|||||||
"content": "我是内容",
|
"content": "我是内容",
|
||||||
"contentSourceUrl": "https://www.iocoder.cn",
|
"contentSourceUrl": "https://www.iocoder.cn",
|
||||||
"thumbMediaId": "r6ryvl6LrxBU0miaST4Y-pIcmK-zAAId-9TGgy-DrSLhjVuWbuT3ZBjk9K1yQ0Dn"
|
"thumbMediaId": "r6ryvl6LrxBU0miaST4Y-pIcmK-zAAId-9TGgy-DrSLhjVuWbuT3ZBjk9K1yQ0Dn"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "我是标题 2",
|
||||||
|
"author": "我是作者 2",
|
||||||
|
"digest": "我是摘要 2",
|
||||||
|
"content": "我是内容 2",
|
||||||
|
"contentSourceUrl": "https://www.iocoder.cn",
|
||||||
|
"thumbMediaId": "r6ryvl6LrxBU0miaST4Y-pIcmK-zAAId-9TGgy-DrSLhjVuWbuT3ZBjk9K1yQ0Dn"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ Authorization: Bearer {{token}}
|
|||||||
tenant-id: {{adminTenentId}}
|
tenant-id: {{adminTenentId}}
|
||||||
|
|
||||||
### 请求 /mp/free-publish/submit 接口 => 成功
|
### 请求 /mp/free-publish/submit 接口 => 成功
|
||||||
POST {{baseUrl}}/mp/free-publish/submit?accountId=1&mediaId=r6ryvl6LrxBU0miaST4Y-pEm50d1qKxNPkZVzrRZthSJHKCgiylCf4tARZfybZ_O
|
POST {{baseUrl}}/mp/free-publish/submit?accountId=1&mediaId=r6ryvl6LrxBU0miaST4Y-vilmd7iS51D8IPddxflWrau0hIQ2ovY8YanO5jlgUcM
|
||||||
Content-Type: application/json
|
Content-Type: application/json
|
||||||
Authorization: Bearer {{token}}
|
Authorization: Bearer {{token}}
|
||||||
tenant-id: {{adminTenentId}}
|
tenant-id: {{adminTenentId}}
|
||||||
|
@ -44,6 +44,7 @@ public class MpFreePublishController {
|
|||||||
} catch (WxErrorException e) {
|
} catch (WxErrorException e) {
|
||||||
throw exception(FREE_PUBLISH_LIST_FAIL, e.getError().getErrorMsg());
|
throw exception(FREE_PUBLISH_LIST_FAIL, e.getError().getErrorMsg());
|
||||||
}
|
}
|
||||||
|
// todo 芋艿:需要查询对应的缩略图,不然前端无法展示
|
||||||
|
|
||||||
// 返回分页
|
// 返回分页
|
||||||
return success(new PageResult<>(publicationRecords.getItems(), publicationRecords.getTotalCount().longValue()));
|
return success(new PageResult<>(publicationRecords.getItems(), publicationRecords.getTotalCount().longValue()));
|
||||||
|
10
yudao-ui-admin/src/api/mp/freePublish.js
Normal file
10
yudao-ui-admin/src/api/mp/freePublish.js
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
import request from '@/utils/request'
|
||||||
|
|
||||||
|
// 获得公众号素材分页
|
||||||
|
export function getFreePublishPage(query) {
|
||||||
|
return request({
|
||||||
|
url: '/mp/free-publish/page',
|
||||||
|
method: 'get',
|
||||||
|
params: query
|
||||||
|
})
|
||||||
|
}
|
@ -48,7 +48,7 @@
|
|||||||
</el-table>
|
</el-table>
|
||||||
<!-- 分页组件 -->
|
<!-- 分页组件 -->
|
||||||
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
|
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
|
||||||
@pagination="getMaterialPage"/>
|
@pagination="getPage"/>
|
||||||
</div>
|
</div>
|
||||||
<div v-else-if="objData.type === 'video'">
|
<div v-else-if="objData.type === 'video'">
|
||||||
<!-- 列表 -->
|
<!-- 列表 -->
|
||||||
@ -78,41 +78,32 @@
|
|||||||
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
|
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
|
||||||
@pagination="getMaterialPage"/>
|
@pagination="getMaterialPage"/>
|
||||||
</div>
|
</div>
|
||||||
<div v-else-if="objData.type == 'news'">
|
<div v-else-if="objData.type === 'news'">
|
||||||
<div class="waterfall" v-loading="loading">
|
<div class="waterfall" v-loading="loading">
|
||||||
<div class="waterfall-item" v-for="item in list" :key="item.mediaId" v-if="item.content && item.content.articles">
|
<div class="waterfall-item" v-for="item in list" :key="item.mediaId" v-if="item.content && item.content.newsItem">
|
||||||
<WxNews :objData="item.content.articles"></WxNews>
|
<wx-news :articles="item.content.newsItem" />
|
||||||
<el-row class="ope-row">
|
<el-row class="ope-row">
|
||||||
<el-button size="mini" type="success" @click="selectMaterial(item)">选择<i class="el-icon-circle-check el-icon--right"></i></el-button>
|
<el-button size="mini" type="success" @click="selectMaterial(item)">
|
||||||
|
选择<i class="el-icon-circle-check el-icon--right"></i>
|
||||||
|
</el-button>
|
||||||
</el-row>
|
</el-row>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="list.length <=0 && !loading" class="el-table__empty-block">
|
<!-- 分页组件 -->
|
||||||
|
<div v-if="list.length <= 0 && !loading" class="el-table__empty-block">
|
||||||
<span class="el-table__empty-text">暂无数据</span>
|
<span class="el-table__empty-text">暂无数据</span>
|
||||||
</div>
|
</div>
|
||||||
<span slot="footer" class="dialog-footer">
|
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
|
||||||
<el-pagination
|
@pagination="getMaterialPage"/>
|
||||||
@size-change="sizeChange"
|
|
||||||
:current-page.sync="page.currentPage"
|
|
||||||
:page-sizes="[10, 20]"
|
|
||||||
:page-size="page.pageSize"
|
|
||||||
layout="total, sizes, prev, pager, next, jumper"
|
|
||||||
:total="page.total"
|
|
||||||
class="pagination"
|
|
||||||
>
|
|
||||||
</el-pagination>
|
|
||||||
</span>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
// import { tableOptionVoice } from '@/const/crud/wxmp/wxmaterial_voice'
|
|
||||||
// import { tableOptionVideo } from '@/const/crud/wxmp/wxmaterial_video'
|
|
||||||
import WxNews from '@/views/mp/components/wx-news/main.vue';
|
import WxNews from '@/views/mp/components/wx-news/main.vue';
|
||||||
import WxVoicePlayer from '@/views/mp/components/wx-voice-play/main.vue';
|
import WxVoicePlayer from '@/views/mp/components/wx-voice-play/main.vue';
|
||||||
import WxVideoPlayer from '@/views/mp/components/wx-video-play/main.vue';
|
import WxVideoPlayer from '@/views/mp/components/wx-video-play/main.vue';
|
||||||
import { getMaterialPage } from "@/api/mp/material";
|
import { getMaterialPage } from "@/api/mp/material";
|
||||||
|
import {getFreePublishPage} from "@/api/mp/freePublish";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "wxMaterialSelect",
|
name: "wxMaterialSelect",
|
||||||
@ -143,56 +134,40 @@
|
|||||||
queryParams: {
|
queryParams: {
|
||||||
pageNo: 1,
|
pageNo: 1,
|
||||||
pageSize: 10,
|
pageSize: 10,
|
||||||
|
accountId: this.objData.accountId,
|
||||||
},
|
},
|
||||||
// tableOptionVoice: tableOptionVoice,
|
// tableOptionVoice: tableOptionVoice,
|
||||||
// tableOptionVideo: tableOptionVideo,
|
// tableOptionVideo: tableOptionVideo,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
this.getPage(this.page)
|
this.getPage()
|
||||||
},
|
},
|
||||||
methods:{
|
methods:{
|
||||||
selectMaterial(item){
|
selectMaterial(item) {
|
||||||
this.$emit('selectMaterial', item)
|
this.$emit('selectMaterial', item)
|
||||||
},
|
},
|
||||||
getPage(page, params) {
|
getPage() {
|
||||||
this.loading = true
|
this.loading = true
|
||||||
if(this.objData.type == 'news'){ // 【图文】
|
if (this.objData.type === 'news' && this.newsType === '1') { // 【图文】+ 【已发布】
|
||||||
if(this.newsType == '1'){
|
this.getFreePublishPage();
|
||||||
getPageNews(Object.assign({
|
} else if (this.objData.type === 'news' && this.newsType === '2') { // 【图文】+ 【草稿】
|
||||||
current: page.currentPage,
|
getPageNewsDraft(Object.assign({
|
||||||
size: page.pageSize,
|
current: page.currentPage,
|
||||||
appId:this.appId,
|
size: page.pageSize,
|
||||||
}, params)).then(response => {
|
appId:this.appId,
|
||||||
let tableData = response.data.items
|
}, params)).then(response => {
|
||||||
tableData.forEach(item => {
|
let tableData = response.data.items
|
||||||
item.mediaId = item.articleId
|
tableData.forEach(item => {
|
||||||
item.content.articles = item.content.newsItem
|
item.mediaId = item.mediaId
|
||||||
})
|
item.content.articles = item.content.newsItem
|
||||||
this.list = tableData
|
|
||||||
this.page.total = response.data.totalCount
|
|
||||||
this.page.currentPage = page.currentPage
|
|
||||||
this.page.pageSize = page.pageSize
|
|
||||||
this.loading = false
|
|
||||||
})
|
})
|
||||||
}else if(this.newsType == '2'){
|
this.list = tableData
|
||||||
getPageNewsDraft(Object.assign({
|
this.page.total = response.data.totalCount
|
||||||
current: page.currentPage,
|
this.page.currentPage = page.currentPage
|
||||||
size: page.pageSize,
|
this.page.pageSize = page.pageSize
|
||||||
appId:this.appId,
|
this.loading = false
|
||||||
}, params)).then(response => {
|
})
|
||||||
let tableData = response.data.items
|
|
||||||
tableData.forEach(item => {
|
|
||||||
item.mediaId = item.mediaId
|
|
||||||
item.content.articles = item.content.newsItem
|
|
||||||
})
|
|
||||||
this.list = tableData
|
|
||||||
this.page.total = response.data.totalCount
|
|
||||||
this.page.currentPage = page.currentPage
|
|
||||||
this.page.pageSize = page.pageSize
|
|
||||||
this.loading = false
|
|
||||||
})
|
|
||||||
}
|
|
||||||
} else { // 【素材】
|
} else { // 【素材】
|
||||||
this.getMaterialPage();
|
this.getMaterialPage();
|
||||||
}
|
}
|
||||||
@ -208,20 +183,20 @@
|
|||||||
this.loading = false
|
this.loading = false
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
sizeChange(val) {
|
getFreePublishPage() {
|
||||||
this.page.currentPage = 1
|
getFreePublishPage(this.queryParams).then(response => {
|
||||||
this.page.pageSize = val
|
// 将 thumbUrl 转成 picUrl,保证 wx-news 组件可以预览封面
|
||||||
this.getPage(this.page)
|
response.data.list.forEach(item => {
|
||||||
},
|
const newsItem = item.content.newsItem;
|
||||||
currentChange(val) {
|
newsItem.forEach(article => {
|
||||||
this.page.currentPage = val
|
article.picUrl = article.thumbUrl;
|
||||||
this.getPage(this.page)
|
})
|
||||||
},
|
})
|
||||||
/**
|
this.list = response.data.list
|
||||||
* 刷新回调
|
this.total = response.data.total
|
||||||
*/
|
}).finally(() => {
|
||||||
refreshChange(page) {
|
this.loading = false
|
||||||
this.getPage(this.page)
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -155,21 +155,23 @@ import { getUser } from "@/api/mp/user";
|
|||||||
if (!this.objData) {
|
if (!this.objData) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (this.objData.type === 'news') {
|
// 公众号限制:客服消息,公众号只允许发送一条
|
||||||
this.objData.content.articles = [this.objData.content.articles[0]]
|
if (this.objData.type === 'news'
|
||||||
|
&& this.objData.articles.length > 1) {
|
||||||
|
this.objData.articles = [this.objData.articles[0]]
|
||||||
this.$message({
|
this.$message({
|
||||||
showClose: true,
|
showClose: true,
|
||||||
message: '图文消息条数限制在1条以内,已默认发送第一条',
|
message: '图文消息条数限制在 1 条以内,已默认发送第一条',
|
||||||
type: 'success'
|
type: 'success'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 执行发送
|
||||||
this.sendLoading = true
|
this.sendLoading = true
|
||||||
sendMessage(Object.assign({
|
sendMessage(Object.assign({
|
||||||
userId: this.userId
|
userId: this.userId
|
||||||
}, {
|
}, {
|
||||||
...this.objData,
|
...this.objData
|
||||||
// content: this.objData.repContent,
|
|
||||||
// TODO 芋艿:临时适配,保证可用
|
|
||||||
})).then(response => {
|
})).then(response => {
|
||||||
this.sendLoading = false
|
this.sendLoading = false
|
||||||
// 添加到消息列表,并滚动
|
// 添加到消息列表,并滚动
|
||||||
|
@ -41,7 +41,10 @@
|
|||||||
articles: {
|
articles: {
|
||||||
type: Array // title - 标题;description - 描述;picUrl - 图片连接;url - 跳转链接
|
type: Array // title - 标题;description - 描述;picUrl - 图片连接;url - 跳转链接
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
created() {
|
||||||
|
console.log(this.articles)
|
||||||
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -118,18 +118,20 @@
|
|||||||
</el-row>
|
</el-row>
|
||||||
</el-row>
|
</el-row>
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
|
<!-- 类型 5:图文 -->
|
||||||
<el-tab-pane name="news">
|
<el-tab-pane name="news">
|
||||||
<span slot="label"><i class="el-icon-news"></i> 图文</span>
|
<span slot="label"><i class="el-icon-news"></i> 图文</span>
|
||||||
<el-row>
|
<el-row>
|
||||||
<div class="select-item" v-if="objData.content">
|
<div class="select-item" v-if="objData.articles">
|
||||||
<WxNews :objData="objData.content.articles"></WxNews>
|
<wx-news :articles="objData.articles" />
|
||||||
<el-row class="ope-row">
|
<el-row class="ope-row">
|
||||||
<el-button type="danger" icon="el-icon-delete" circle @click="deleteObj"></el-button>
|
<el-button type="danger" icon="el-icon-delete" circle @click="deleteObj" />
|
||||||
</el-row>
|
</el-row>
|
||||||
</div>
|
</div>
|
||||||
|
<!-- 选择素材 -->
|
||||||
<div v-if="!objData.content">
|
<div v-if="!objData.content">
|
||||||
<el-row style="text-align: center">
|
<el-row style="text-align: center">
|
||||||
<el-col :span="24" class="col-select2">
|
<el-col :span="24">
|
||||||
<el-button type="success" @click="openMaterial">{{newsType === '1' ? '选择已发布图文' : '选择草稿箱图文'}}<i class="el-icon-circle-check el-icon--right"></i></el-button>
|
<el-button type="success" @click="openMaterial">{{newsType === '1' ? '选择已发布图文' : '选择草稿箱图文'}}<i class="el-icon-circle-check el-icon--right"></i></el-button>
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
@ -369,7 +371,10 @@
|
|||||||
// 创建 tempObjItem 对象,并设置对应的值
|
// 创建 tempObjItem 对象,并设置对应的值
|
||||||
let tempObjItem = {}
|
let tempObjItem = {}
|
||||||
tempObjItem.type = this.objData.type;
|
tempObjItem.type = this.objData.type;
|
||||||
if (this.objData.type === 'music') { // 音乐需要特殊处理,因为选择的是图片的缩略图
|
if (this.objData.type === 'news') {
|
||||||
|
tempObjItem.articles = item.content.newsItem
|
||||||
|
this.objData.articles = item.content.newsItem
|
||||||
|
} else if (this.objData.type === 'music') { // 音乐需要特殊处理,因为选择的是图片的缩略图
|
||||||
tempObjItem.thumbMediaId = item.mediaId
|
tempObjItem.thumbMediaId = item.mediaId
|
||||||
this.objData.thumbMediaId = item.mediaId
|
this.objData.thumbMediaId = item.mediaId
|
||||||
tempObjItem.thumbMediaUrl = item.url
|
tempObjItem.thumbMediaUrl = item.url
|
||||||
@ -431,7 +436,7 @@
|
|||||||
},
|
},
|
||||||
deleteObj() {
|
deleteObj() {
|
||||||
if (this.objData.type === 'news') {
|
if (this.objData.type === 'news') {
|
||||||
this.objData.articles = []
|
this.$delete(this.objData, 'articles');
|
||||||
} else if(this.objData.type === 'image') {
|
} else if(this.objData.type === 'image') {
|
||||||
this.objData.mediaId = null
|
this.objData.mediaId = null
|
||||||
this.objData.url = null
|
this.objData.url = null
|
||||||
|
Loading…
Reference in New Issue
Block a user