From 29cf770457d5a8ed240002369e8da5aa5bae6374 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Thu, 12 Jan 2023 00:24:04 +0800 Subject: [PATCH] =?UTF-8?q?mp=EF=BC=9A=E6=94=AF=E6=8C=81=20wx-reply=20?= =?UTF-8?q?=E5=8F=91=E9=80=81=E5=9B=BE=E7=89=87=E6=B6=88=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- yudao-ui-admin/src/utils/auth.js | 3 + .../src/views/mp/components/wx-msg/main.vue | 25 +- .../src/views/mp/components/wx-reply/main.vue | 299 ++++++++++++------ 3 files changed, 215 insertions(+), 112 deletions(-) diff --git a/yudao-ui-admin/src/utils/auth.js b/yudao-ui-admin/src/utils/auth.js index 15bbf661e..ac7e4b860 100644 --- a/yudao-ui-admin/src/utils/auth.js +++ b/yudao-ui-admin/src/utils/auth.js @@ -94,3 +94,6 @@ export function setTenantId(username) { export function removeTenantId() { localStorage.removeItem(TenantIdKey) } + +export class getToken { +} diff --git a/yudao-ui-admin/src/views/mp/components/wx-msg/main.vue b/yudao-ui-admin/src/views/mp/components/wx-msg/main.vue index 850b05d27..dde473aae 100644 --- a/yudao-ui-admin/src/views/mp/components/wx-msg/main.vue +++ b/yudao-ui-admin/src/views/mp/components/wx-msg/main.vue @@ -81,7 +81,7 @@
- + 发送(S)
@@ -95,6 +95,7 @@ import {getMessagePage, sendMessage} from '@/api/mp/message' import WxNews from '@/views/mp/components/wx-news/main.vue'; import WxLocation from '@/views/mp/components/wx-location/main.vue'; import WxMusic from '@/views/mp/components/wx-music/main.vue'; +import {getUser} from "@/api/mp/user"; export default { name: "wxMsg", @@ -110,7 +111,7 @@ import {getMessagePage, sendMessage} from '@/api/mp/message' userId: { type: String, required: true - } + }, }, data() { return { @@ -126,17 +127,27 @@ import {getMessagePage, sendMessage} from '@/api/mp/message' user: { // 由于微信不再提供昵称,直接使用“用户”展示 nickname: '用户', avatar: require("@/assets/images/profile.jpg"), + accountId: 0, // 公众号账号编号 }, mp: { nickname: '公众号', avatar: require("@/assets/images/wechat.png"), }, - objData:{ // 微信发送消息 - repType: 'text' + objData: { // 微信发送消息 + type: 'text', }, } }, created() { + // 获得用户信息 + getUser(this.userId).then(response => { + this.user.nickname = response.data.nickname | this.user.nickname; + this.user.avatar = response.data.avatar | this.user.avatar; + // 设置公众号账号编号 + this.objData.accountId = response.data.accountId; + }) + + // 加载消息 this.refreshChange() }, methods:{ @@ -144,7 +155,7 @@ import {getMessagePage, sendMessage} from '@/api/mp/message' if (!this.objData) { return; } - if (this.objData.repType === 'news') { + if (this.objData.type === 'news') { this.objData.content.articles = [this.objData.content.articles[0]] this.$message({ showClose: true, @@ -157,7 +168,6 @@ import {getMessagePage, sendMessage} from '@/api/mp/message' userId: this.userId }, { ...this.objData, - type: this.objData.repType, // content: this.objData.repContent, // TODO 芋艿:临时适配,保证可用 })).then(response => { @@ -167,7 +177,8 @@ import {getMessagePage, sendMessage} from '@/api/mp/message' this.scrollToBottom() // 重置 objData 状态 this.objData = { - repType: 'text' + type: 'text', + content: '', } }).catch(() => { this.sendLoading = false diff --git a/yudao-ui-admin/src/views/mp/components/wx-reply/main.vue b/yudao-ui-admin/src/views/mp/components/wx-reply/main.vue index a8e9cdf3b..615469faa 100644 --- a/yudao-ui-admin/src/views/mp/components/wx-reply/main.vue +++ b/yudao-ui-admin/src/views/mp/components/wx-reply/main.vue @@ -1,30 +1,36 @@