oak-general-business/es/components/message/detail/index.js

61 lines
1.7 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

export default OakComponent({
entity: 'message',
projection: {
id: 1,
$$createAt$$: 1,
type: 1,
title: 1,
content: 1,
visitState: 1,
userId: 1,
user: {
id: 1,
name: 1,
},
router: 1,
},
isList: false,
formData: ({ data: message }) => {
return message || {};
},
listeners: {
'visitState,userId'(prev, next) {
const userId2 = this.features.token.getUserId(true);
if (next.userId === userId2) {
if (next.visitState === 'unvisited') {
this.execute('visit', false);
}
}
},
},
methods: {
async goPage() {
const { router } = this.state;
const pathname = router?.pathname;
const props = router?.props || {};
const state = router?.state;
if (!pathname) {
return;
}
try {
await this.redirectTo({
url: pathname,
...props,
}, state, true);
}
catch (err) {
if (process.env.OAK_PLATFORM === 'wechatMp') {
if (err?.errMsg?.includes('navigateTo:fail')) {
this.features.message.setMessage({
type: 'warning',
content: '该功能请去电脑端操作网址https://www.gecomebox.com/console/',
});
return;
}
}
throw err;
}
},
},
});