Commit 70752c4d by Sixong.Zhu

消息适配

parent defd3bfd
......@@ -14,6 +14,7 @@ const mapping = new Map<MessageType, string>([
[MessageType.PayV1, '付款通知'],
[MessageType.Refund, '退款通知'],
[MessageType.RefundV1, '退款通知'],
[MessageType.Notify, '通知'],
])
export function parserMessage(type: MessageType, rawMsg: string) {
......
<template>
<div class="msg-detail inline-text" v-html="notifyMessage"></div>
</template>
<script lang="ts">
import { Component } from "vue-property-decorator";
import BaseMessage from "./index";
@Component({ components: {} })
export default class Index extends BaseMessage {
private get notifyData() {
return this.messageBody.msg as {
text: string;
remark: string;
resultId: string;
};
}
private get notifyMessage() {
return this.notifyData
? this.notifyData.text ||
`${this.notifyData.remark}, 工单ID ${
this.notifyData.resultId || "无"
}`
: "[通知消息]";
}
}
</script>
<style lang="less" scoped>
.inline-text {
display: inline-block;
white-space: pre-wrap;
text-align: left;
/deep/ .highlight {
color: #e87005;
}
}
</style>
\ No newline at end of file
......@@ -46,11 +46,11 @@
}
private get title() {
return this.payData.itemName;
return this.payData.itemName || this.payData.totalName;
}
private get amount() {
return +this.payData.amount;
return +this.payData.amount || this.payData.totalMoney;
}
private get status() {
......
......@@ -165,6 +165,7 @@
import MyWelfareMessage from "./message-item/my-welfare-message.vue";
import QuestionAnswerMessage from "./message-item/question-answer-message.vue";
import PayMessage from "./message-item/pay-message.vue";
import NotifyMessage from "./message-item/notify-message.vue";
import { ChatRole } from "@/customer-service/model";
import { getUserMapping } from "../utils/user-info";
import Xim from "@/customer-service/xim";
......@@ -187,6 +188,8 @@
[dto.MessageType.PayV1, "pay-message"],
[dto.MessageType.Refund, "pay-message"],
[dto.MessageType.RefundV1, "pay-message"],
[dto.MessageType.PayResult, "notify-message"],
[dto.MessageType.Notify, "notify-message"],
]);
@Component({
......@@ -204,6 +207,7 @@
QuestionAnswerMessage,
ActionMessage,
PayMessage,
NotifyMessage
},
})
export default class Message extends Vue {
......
......@@ -117,6 +117,7 @@ export const enum MessageType {
MpNavigate = "mp-navigate",
PayV1 = 'gpay',
Pay = "gpay2",
PayResult = "gresult",
RefundV1 = 'grefund',
Refund = "grefund2",
Card = 'card'
......
......@@ -11,30 +11,36 @@ export type UserMapping = {
const userMapping: UserMapping = {};
interface UserInfo {
avatar_url: string;
email: string;
id: string;
mobile: string;
realname: string;
uniplatId: string;
username: string;
}
export const getUserMapping = () => userMapping;
export async function getUserInfo(eid: string, sdk?: UniplatSdk) {
if (userMapping[eid]) {
return userMapping[eid];
}
if (!+eid) {
return { name: '', phone: '', icon: '' };
if (!+eid || +eid < 0) {
return { name: "", phone: "", icon: "" };
}
const info = await (sdk || Chat.getSdk())
.domainService('passport', 'anonymous', `oidc.account/user_info?id=${eid}`)
.request<any, any, {
avatar_url: string;
email: string;
id: string;
mobile: string;
realname: string;
uniplatId: string;
username: string;
}>('get');
.domainService(
"passport",
"anonymous",
`oidc.account/user_info?id=${eid}`
)
.request<any, any, UserInfo>("get");
const data = {
name: info.username || info.realname || info.mobile || info.mobile,
phone: info.mobile,
icon: info.avatar_url
icon: info.avatar_url,
};
userMapping[eid] = data;
return data;
......
......@@ -2,7 +2,7 @@ import {
MessageHandled,
MessageType,
PayMethod,
PayStatus
PayStatus,
} from "@/customer-service/model";
export interface Chat {
......@@ -208,6 +208,15 @@ export interface PayMessageBody {
itemName: string;
amount: string;
paymentId: string;
/**
* 对应v1版本itemName
*/
totalName?: string;
/**
* 对应v1版本amount
*/
totalMoney?: string;
}
export interface CsUser {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment