UPDATE
This commit is contained in:
+158
-133
@@ -4,13 +4,19 @@
|
|||||||
<lemon-imui
|
<lemon-imui
|
||||||
:user="user"
|
:user="user"
|
||||||
ref="IMUI"
|
ref="IMUI"
|
||||||
|
:hide-menu="hideMenu"
|
||||||
|
:hide-menu-avatar="hideMenuAvatar"
|
||||||
@change-menu="handleChangeMenu"
|
@change-menu="handleChangeMenu"
|
||||||
@change-contact="handleChangeContact"
|
@change-contact="handleChangeContact"
|
||||||
@pull-messages="handlePullMessages"
|
@pull-messages="handlePullMessages"
|
||||||
|
@message-click="handleMessageClick"
|
||||||
@send="handleSend"
|
@send="handleSend"
|
||||||
>
|
>
|
||||||
<template #cover>
|
<template #cover>
|
||||||
<h1 style="text-indent:20px">自定义封面内容</h1>
|
<div class="cover">
|
||||||
|
<i class="lemon-icon-message"></i>
|
||||||
|
<p><b>Lemon</b> IMUI</p>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<!-- <template #contact-info="contact">
|
<!-- <template #contact-info="contact">
|
||||||
<span style="color:blue">contact-info {{ contact }}</span>
|
<span style="color:blue">contact-info {{ contact }}</span>
|
||||||
@@ -25,11 +31,24 @@
|
|||||||
<span>{{ contact.displayName }}</span>
|
<span>{{ contact.displayName }}</span>
|
||||||
<small class="more" @click="changeDrawer(contact)">…</small>
|
<small class="more" @click="changeDrawer(contact)">…</small>
|
||||||
</template>
|
</template>
|
||||||
|
<template #contact-info="contact">
|
||||||
|
自定义联系人信息 {{ contact.displayName }}
|
||||||
|
</template>
|
||||||
|
<template #message-sidebar>
|
||||||
|
<div class="bar">自定义消息顶部</div>
|
||||||
|
</template>
|
||||||
|
<template #contact-sidebar>
|
||||||
|
<div class="bar">自定义联系人顶部</div>
|
||||||
|
</template>
|
||||||
</lemon-imui>
|
</lemon-imui>
|
||||||
|
|
||||||
<div class="action">
|
<div class="action">
|
||||||
<lemon-button @click="appendMessage">发送消息</lemon-button>
|
<lemon-button @click="appendMessage">发送消息</lemon-button>
|
||||||
<lemon-button @click="updateContact">修改联系人信息</lemon-button>
|
<lemon-button @click="updateContact">修改联系人信息</lemon-button>
|
||||||
|
<lemon-button @click="changeMenuVisible">切换导航显示</lemon-button>
|
||||||
|
<lemon-button @click="changeMenuAvatarVisible"
|
||||||
|
>切换头像显示</lemon-button
|
||||||
|
>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -40,32 +59,33 @@ const getTime = () => {
|
|||||||
return new Date().getTime();
|
return new Date().getTime();
|
||||||
};
|
};
|
||||||
const generateRandId = () => {
|
const generateRandId = () => {
|
||||||
return Number(
|
return Math.random()
|
||||||
Math.random()
|
.toString(36)
|
||||||
.toString()
|
.substr(-8);
|
||||||
.substr(3, length) + Date.now()
|
|
||||||
).toString(36);
|
|
||||||
};
|
};
|
||||||
const generateRandWord = () => {
|
const generateRandWord = () => {
|
||||||
return Math.random()
|
return Math.random()
|
||||||
.toString(36)
|
.toString(36)
|
||||||
.substr(2);
|
.substr(2);
|
||||||
};
|
};
|
||||||
const generateMessage = () => {
|
const generateMessage = (toContactId = "", fromUser) => {
|
||||||
|
if (!fromUser) {
|
||||||
|
fromUser = {
|
||||||
|
id: "system",
|
||||||
|
displayName: "系统测试",
|
||||||
|
avatar: "http://upload.qqbodys.com/allimg/1710/1035512943-0.jpg"
|
||||||
|
};
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
id: generateRandId(),
|
id: generateRandId(),
|
||||||
status: "succeed",
|
status: "succeed",
|
||||||
type: "text",
|
type: "text",
|
||||||
sendTime: getTime(),
|
sendTime: getTime(),
|
||||||
content: generateRandWord(),
|
content: generateRandWord(),
|
||||||
toContactId: "123",
|
|
||||||
//fileSize: 1231,
|
//fileSize: 1231,
|
||||||
//fileName: "asdasd.doc",
|
//fileName: "asdasd.doc",
|
||||||
fromUser: {
|
toContactId,
|
||||||
id: "222",
|
fromUser
|
||||||
displayName: "系统测试",
|
|
||||||
avatar: "http://upload.qqbodys.com/allimg/1710/1035512943-0.jpg"
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -73,17 +93,19 @@ export default {
|
|||||||
name: "app",
|
name: "app",
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
hideMenuAvatar: false,
|
||||||
|
hideMenu: false,
|
||||||
user: {
|
user: {
|
||||||
id: "superadmin",
|
id: "superadmin",
|
||||||
displayName: "IMUI super",
|
displayName: "June",
|
||||||
avatar:
|
avatar:
|
||||||
"http://upload.qqbodys.com/img/weixin/20170804/ji5qxg1am5ztm.jpg"
|
"https://gss2.bdstatic.com/-fo3dSag_xI4khGkpoWK1HF6hhy/baike/w%3D268%3Bg%3D0/sign=69e1a1a4b78f8c54e3d3c22902124ac8/060828381f30e9247e29fb7b4f086e061c95f7ef.jpg"
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
const contactData1 = {
|
const contactData1 = {
|
||||||
id: "1",
|
id: "contact-1",
|
||||||
displayName: "工作协作群",
|
displayName: "工作协作群",
|
||||||
avatar: "http://upload.qqbodys.com/img/weixin/20170804/ji5qxg1am5ztm.jpg",
|
avatar: "http://upload.qqbodys.com/img/weixin/20170804/ji5qxg1am5ztm.jpg",
|
||||||
type: "single",
|
type: "single",
|
||||||
@@ -93,11 +115,11 @@ export default {
|
|||||||
lastContent: "2"
|
lastContent: "2"
|
||||||
};
|
};
|
||||||
const contactData2 = {
|
const contactData2 = {
|
||||||
id: "2",
|
id: "contact-2",
|
||||||
displayName: "狗蛋Li。",
|
displayName: "自定义内容",
|
||||||
avatar: "http://upload.qqbodys.com/img/weixin/20170807/jibfvfd00npin.jpg",
|
avatar: "http://upload.qqbodys.com/img/weixin/20170807/jibfvfd00npin.jpg",
|
||||||
type: "single",
|
type: "single",
|
||||||
index: "B",
|
//index: "Z",
|
||||||
click(next) {
|
click(next) {
|
||||||
next();
|
next();
|
||||||
},
|
},
|
||||||
@@ -109,7 +131,7 @@ export default {
|
|||||||
unread: 2
|
unread: 2
|
||||||
};
|
};
|
||||||
const contactData3 = {
|
const contactData3 = {
|
||||||
id: "3",
|
id: "contact-3",
|
||||||
displayName: "铁牛",
|
displayName: "铁牛",
|
||||||
avatar: "http://upload.qqbodys.com/img/weixin/20170803/jiq4nzrkrnd0e.jpg",
|
avatar: "http://upload.qqbodys.com/img/weixin/20170803/jiq4nzrkrnd0e.jpg",
|
||||||
type: "many",
|
type: "many",
|
||||||
@@ -121,33 +143,6 @@ export default {
|
|||||||
|
|
||||||
const { IMUI } = this.$refs;
|
const { IMUI } = this.$refs;
|
||||||
|
|
||||||
setTimeout(() => {
|
|
||||||
//IMUI.openDrawer();
|
|
||||||
// IMUI.openDrawer(() => {
|
|
||||||
// return [
|
|
||||||
// <h1>123</h1>,
|
|
||||||
// <h1>123</h1>,
|
|
||||||
// <h1>123</h1>,
|
|
||||||
// <h1>123</h1>,
|
|
||||||
// <h1>123</h1>,
|
|
||||||
// <h1>123</h1>,
|
|
||||||
// <h1>123</h1>,
|
|
||||||
// <h1>123</h1>,
|
|
||||||
// <h1>123</h1>,
|
|
||||||
// <h1>123</h1>,
|
|
||||||
// <h1>123</h1>,
|
|
||||||
// <h1>123</h1>,
|
|
||||||
// <h1>123</h1>,
|
|
||||||
// <h1>123</h1>
|
|
||||||
// ];
|
|
||||||
// });
|
|
||||||
// setTimeout(() => {
|
|
||||||
// IMUI.openDrawer(() => {
|
|
||||||
// return <h1>124563</h1>;
|
|
||||||
// });
|
|
||||||
// }, 2000);
|
|
||||||
}, 2000);
|
|
||||||
//[contactData1, contactData2, contactData3]
|
|
||||||
let data = [
|
let data = [
|
||||||
{ ...contactData1 },
|
{ ...contactData1 },
|
||||||
{ ...contactData2 },
|
{ ...contactData2 },
|
||||||
@@ -164,13 +159,54 @@ export default {
|
|||||||
name: "contacts"
|
name: "contacts"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "自定义按钮",
|
name: "custom1",
|
||||||
|
title: "自定义按钮1",
|
||||||
|
unread: 0,
|
||||||
|
render: menu => {
|
||||||
|
return <i class="lemon-icon-attah" />;
|
||||||
|
},
|
||||||
|
renderContainer: () => {
|
||||||
|
return (
|
||||||
|
<div class="article">
|
||||||
|
<ul>
|
||||||
|
<li class="article-item">
|
||||||
|
<h2>人民日报谈网红带货:产品真的值得买吗?</h2>
|
||||||
|
</li>
|
||||||
|
<li class="article-item">
|
||||||
|
甘肃夏河县发生5.7级地震 暂未接到人员伤亡报告
|
||||||
|
</li>
|
||||||
|
<li class="article-item">
|
||||||
|
北方多地风力仍强沙尘相伴,东北内蒙古等地迎雨雪
|
||||||
|
</li>
|
||||||
|
<li class="article-item">
|
||||||
|
英货车案:越南警方采集疑死者家属DNA作比对
|
||||||
|
</li>
|
||||||
|
<li class="article-item">
|
||||||
|
知名连锁咖啡店的蛋糕吃出活虫 曝光内幕太震惊
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<lemon-contact
|
||||||
|
props={{ contact: contactData1 }}
|
||||||
|
style="margin:20px"
|
||||||
|
/>
|
||||||
|
<lemon-contact
|
||||||
|
props={{ contact: contactData3 }}
|
||||||
|
style="margin:20px"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
isBottom: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "custom2",
|
||||||
|
title: "自定义按钮2",
|
||||||
unread: 0,
|
unread: 0,
|
||||||
click: () => {
|
click: () => {
|
||||||
alert("点击了自定义按钮");
|
alert("拦截导航点击事件");
|
||||||
},
|
},
|
||||||
render: menu => {
|
render: menu => {
|
||||||
return <span>T</span>;
|
return <i class="lemon-icon-group" />;
|
||||||
},
|
},
|
||||||
isBottom: true
|
isBottom: true
|
||||||
}
|
}
|
||||||
@@ -463,6 +499,28 @@ export default {
|
|||||||
]);
|
]);
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
handleMessageClick(e, key, message) {
|
||||||
|
const { IMUI } = this.$refs;
|
||||||
|
|
||||||
|
if (key == "status") {
|
||||||
|
IMUI.updateMessage(message.id, message.toContactId, {
|
||||||
|
status: "going",
|
||||||
|
content: "正在重新发送消息..."
|
||||||
|
});
|
||||||
|
setTimeout(() => {
|
||||||
|
IMUI.updateMessage(message.id, message.toContactId, {
|
||||||
|
status: "succeed",
|
||||||
|
content: "发送成功"
|
||||||
|
});
|
||||||
|
}, 2000);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
changeMenuAvatarVisible() {
|
||||||
|
this.hideMenuAvatar = !this.hideMenuAvatar;
|
||||||
|
},
|
||||||
|
changeMenuVisible() {
|
||||||
|
this.hideMenu = !this.hideMenu;
|
||||||
|
},
|
||||||
appendMessage() {
|
appendMessage() {
|
||||||
const { IMUI } = this.$refs;
|
const { IMUI } = this.$refs;
|
||||||
const contact = IMUI.currentContact;
|
const contact = IMUI.currentContact;
|
||||||
@@ -513,94 +571,33 @@ export default {
|
|||||||
}, 1000);
|
}, 1000);
|
||||||
},
|
},
|
||||||
handlePullMessages(contact, next) {
|
handlePullMessages(contact, next) {
|
||||||
|
const { IMUI } = this.$refs;
|
||||||
|
const otheruser = {
|
||||||
|
id: "hehe",
|
||||||
|
displayName: "I KNOEW",
|
||||||
|
avatar:
|
||||||
|
"https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=4085009425,1005454674&fm=26&gp=0.jpg"
|
||||||
|
};
|
||||||
console.log("Event:pull-messages");
|
console.log("Event:pull-messages");
|
||||||
const messages = [
|
const messages = [
|
||||||
|
generateMessage(IMUI.currentContactId, this.user),
|
||||||
|
generateMessage(IMUI.currentContactId, otheruser),
|
||||||
|
generateMessage(IMUI.currentContactId, this.user),
|
||||||
|
generateMessage(IMUI.currentContactId, otheruser),
|
||||||
|
generateMessage(IMUI.currentContactId, this.user),
|
||||||
|
generateMessage(IMUI.currentContactId, this.user),
|
||||||
|
generateMessage(IMUI.currentContactId, otheruser),
|
||||||
{
|
{
|
||||||
id: "8ad7e98e-5225-4892-8131-4b2ee7797599",
|
...generateMessage(IMUI.currentContactId, this.user),
|
||||||
type: "text",
|
...{ status: "failed" }
|
||||||
status: "succeed",
|
|
||||||
sendTime: 1564926674646,
|
|
||||||
fromContactId: "superadmin",
|
|
||||||
fromUser: {
|
|
||||||
id: "hehe",
|
|
||||||
displayName: "I KNOEW",
|
|
||||||
avatar:
|
|
||||||
"https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=4085009425,1005454674&fm=26&gp=0.jpg"
|
|
||||||
},
|
|
||||||
content: "测试消息哦..."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "8ad7e98e-5225-4892-8131-4b2ee7797599",
|
|
||||||
type: "text",
|
|
||||||
status: "succeed",
|
|
||||||
sendTime: 1564926674646,
|
|
||||||
fromContactId: "superadmin",
|
|
||||||
fromUser: {
|
|
||||||
id: "superadmin",
|
|
||||||
displayName: "超级飞机",
|
|
||||||
avatar:
|
|
||||||
"https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=4085009425,1005454674&fm=26&gp=0.jpg"
|
|
||||||
},
|
|
||||||
content: "测试消息哦..."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "8ad7e98e-5225-4892-8131-4b2ee7797599",
|
|
||||||
type: "text",
|
|
||||||
status: "succeed",
|
|
||||||
sendTime: 1564926674646,
|
|
||||||
fromContactId: "superadmin",
|
|
||||||
fromUser: {
|
|
||||||
id: "hehe",
|
|
||||||
displayName: "I KNOEW",
|
|
||||||
avatar:
|
|
||||||
"https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=4085009425,1005454674&fm=26&gp=0.jpg"
|
|
||||||
},
|
|
||||||
content: "测试消息哦..."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "8ad7e98e-5225-4892-8131-4b2ee7797599",
|
|
||||||
type: "text",
|
|
||||||
status: "succeed",
|
|
||||||
sendTime: 1564926674646,
|
|
||||||
fromContactId: "superadmin",
|
|
||||||
fromUser: {
|
|
||||||
id: "superadmin",
|
|
||||||
displayName: "超级飞机",
|
|
||||||
avatar:
|
|
||||||
"https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=4085009425,1005454674&fm=26&gp=0.jpg"
|
|
||||||
},
|
|
||||||
content: "测试消息哦..."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "8ad7e98e-5225-4892-8131-4b2ee7797599",
|
|
||||||
type: "text",
|
|
||||||
status: "succeed",
|
|
||||||
sendTime: 1564926674646,
|
|
||||||
fromContactId: "superadmin",
|
|
||||||
fromUser: {
|
|
||||||
id: "hehe",
|
|
||||||
displayName: "I KNOEW",
|
|
||||||
avatar:
|
|
||||||
"https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=4085009425,1005454674&fm=26&gp=0.jpg"
|
|
||||||
},
|
|
||||||
content: "测试消息哦..."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "8ad7e98e-5225-4892-8131-4b2ee7797599",
|
|
||||||
type: "text",
|
|
||||||
status: "succeed",
|
|
||||||
sendTime: 1564926674646,
|
|
||||||
fromContactId: "superadmin",
|
|
||||||
fromUser: {
|
|
||||||
id: "superadmin",
|
|
||||||
displayName: "超级飞机",
|
|
||||||
avatar:
|
|
||||||
"https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=4085009425,1005454674&fm=26&gp=0.jpg"
|
|
||||||
},
|
|
||||||
content: "测试消息哦..."
|
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
next(messages);
|
|
||||||
|
console.log(messages);
|
||||||
|
let isEnd = false;
|
||||||
|
if (IMUI.getMessages(IMUI.currentContactId).length > 20) isEnd = true;
|
||||||
|
|
||||||
|
next(messages, isEnd);
|
||||||
},
|
},
|
||||||
handleChangeMenu() {
|
handleChangeMenu() {
|
||||||
console.log("Event:change-menu");
|
console.log("Event:change-menu");
|
||||||
@@ -636,4 +633,32 @@ body
|
|||||||
color #999
|
color #999
|
||||||
&:active
|
&:active
|
||||||
color #000
|
color #000
|
||||||
|
.bar
|
||||||
|
text-align center
|
||||||
|
line-height 30px
|
||||||
|
background #fff
|
||||||
|
margin 15px
|
||||||
|
color #666
|
||||||
|
user-select none
|
||||||
|
font-size 12px
|
||||||
|
.cover
|
||||||
|
text-align center
|
||||||
|
user-select none
|
||||||
|
position absolute
|
||||||
|
top 50%
|
||||||
|
left 50%
|
||||||
|
transform translate(-50%,-50%)
|
||||||
|
i
|
||||||
|
font-size 84px
|
||||||
|
color #e6e6e6
|
||||||
|
p
|
||||||
|
font-size 18px
|
||||||
|
color #ddd
|
||||||
|
line-height 50px
|
||||||
|
.article-item
|
||||||
|
line-height 34px
|
||||||
|
cursor pointer
|
||||||
|
&:hover
|
||||||
|
text-decoration underline
|
||||||
|
color #318efd
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
Vendored
-1
File diff suppressed because one or more lines are too long
Vendored
+1
File diff suppressed because one or more lines are too long
Vendored
+1
-1
@@ -1 +1 @@
|
|||||||
<!DOCTYPE html><html lang=en><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><meta name=viewport content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no"><link rel=icon href=favicon.ico><title>Lemon-IMUI</title><link href=css/index.2750e9e8.css rel=preload as=style><link href=js/chunk-vendors.99d7e0a4.js rel=preload as=script><link href=js/index.e213c5da.js rel=preload as=script><link href=css/index.2750e9e8.css rel=stylesheet></head><body><noscript><strong>We're sorry but flat-im doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id=app></div><script src=js/chunk-vendors.99d7e0a4.js></script><script src=js/index.e213c5da.js></script></body></html>
|
<!DOCTYPE html><html lang=en><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><meta name=viewport content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no"><link rel=icon href=favicon.ico><title>Lemon-IMUI</title><link href=css/index.e7f71477.css rel=preload as=style><link href=js/chunk-vendors.e4810482.js rel=preload as=script><link href=js/index.f29ec4b1.js rel=preload as=script><link href=css/index.e7f71477.css rel=stylesheet></head><body><noscript><strong>We're sorry but flat-im doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id=app></div><script src=js/chunk-vendors.e4810482.js></script><script src=js/index.f29ec4b1.js></script></body></html>
|
||||||
+1
-1
File diff suppressed because one or more lines are too long
Vendored
-1
File diff suppressed because one or more lines are too long
Vendored
+1
File diff suppressed because one or more lines are too long
@@ -50,6 +50,7 @@ export default {
|
|||||||
* 初始化时是否隐藏导航按钮上的头像
|
* 初始化时是否隐藏导航按钮上的头像
|
||||||
*/
|
*/
|
||||||
hideMenuAvatar: Boolean,
|
hideMenuAvatar: Boolean,
|
||||||
|
hideMenu: Boolean,
|
||||||
user: {
|
user: {
|
||||||
type: Object,
|
type: Object,
|
||||||
default: () => {
|
default: () => {
|
||||||
@@ -198,37 +199,17 @@ export default {
|
|||||||
file
|
file
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
_handleReachTop(next) {
|
_emitPullMessages(next) {
|
||||||
// const messages = {
|
|
||||||
// id: "8ad7e98e-5225-4892-8131-4b2ee7797599",
|
|
||||||
// type: "text",
|
|
||||||
// status: "succeed",
|
|
||||||
// sendTime: 1564926674646,
|
|
||||||
// fromContactId: "superadmin",
|
|
||||||
// fromUser: {
|
|
||||||
// id: "hehe",
|
|
||||||
// displayName: "I KNOEW",
|
|
||||||
// avatar:
|
|
||||||
// "https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=4085009425,1005454674&fm=26&gp=0.jpg"
|
|
||||||
// },
|
|
||||||
// content: "测试消息哦..."
|
|
||||||
// };
|
|
||||||
this.$emit(
|
this.$emit(
|
||||||
"pull-messages",
|
"pull-messages",
|
||||||
this.currentContact,
|
this.currentContact,
|
||||||
(messages, isEnd = false) => {
|
(messages, isEnd = false) => {
|
||||||
this._addMessage(
|
this._addMessage(messages, this.currentContactId, 0);
|
||||||
Array(10).fill(messages[1]),
|
|
||||||
this.currentContactId,
|
|
||||||
0
|
|
||||||
);
|
|
||||||
CacheMessageLoaded.set(this.currentContactId, isEnd);
|
CacheMessageLoaded.set(this.currentContactId, isEnd);
|
||||||
|
if (isEnd == true) this.$refs.messages.loaded();
|
||||||
next(isEnd);
|
next(isEnd);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
// setTimeout(() => {
|
|
||||||
// CacheMessageLoaded.set(this.currentContactId, isEnd);
|
|
||||||
// }, 2000);
|
|
||||||
},
|
},
|
||||||
clearCacheContainer(name) {
|
clearCacheContainer(name) {
|
||||||
CacheContactContainer.remove(name);
|
CacheContactContainer.remove(name);
|
||||||
@@ -249,16 +230,17 @@ export default {
|
|||||||
_renderMenu() {
|
_renderMenu() {
|
||||||
const menuItem = this._renderMenuItem();
|
const menuItem = this._renderMenuItem();
|
||||||
return (
|
return (
|
||||||
<div class="lemon-menu">
|
<div class="lemon-menu" v-show={!this.hideMenu}>
|
||||||
{this.hideMenuAvatar == false && (
|
{
|
||||||
<lemon-avatar
|
<lemon-avatar
|
||||||
|
v-show={!this.hideMenuAvatar}
|
||||||
on-click={e => {
|
on-click={e => {
|
||||||
console.log("menu avatar click");
|
console.log("menu avatar click");
|
||||||
}}
|
}}
|
||||||
class="lemon-menu__avatar"
|
class="lemon-menu__avatar"
|
||||||
src="https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=400062461,2874561526&fm=26&gp=0.jpg"
|
src={this.user.avatar}
|
||||||
/>
|
/>
|
||||||
)}
|
}
|
||||||
{menuItem.top}
|
{menuItem.top}
|
||||||
{this.$slots.menu}
|
{this.$slots.menu}
|
||||||
<div class="lemon-menu__bottom">
|
<div class="lemon-menu__bottom">
|
||||||
@@ -301,6 +283,8 @@ export default {
|
|||||||
},
|
},
|
||||||
_renderSidebarMessage() {
|
_renderSidebarMessage() {
|
||||||
return this._renderSidebar(
|
return this._renderSidebar(
|
||||||
|
[
|
||||||
|
useScopedSlot(this.$scopedSlots["message-sidebar"]),
|
||||||
this.lastMessages.map(contact => {
|
this.lastMessages.map(contact => {
|
||||||
return this._renderContact(
|
return this._renderContact(
|
||||||
{
|
{
|
||||||
@@ -309,7 +293,8 @@ export default {
|
|||||||
},
|
},
|
||||||
() => this.changeContact(contact.id)
|
() => this.changeContact(contact.id)
|
||||||
);
|
);
|
||||||
}),
|
})
|
||||||
|
],
|
||||||
DEFAULT_MENU_LASTMESSAGES
|
DEFAULT_MENU_LASTMESSAGES
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
@@ -342,7 +327,10 @@ export default {
|
|||||||
_renderSidebarContact() {
|
_renderSidebarContact() {
|
||||||
let prevIndex;
|
let prevIndex;
|
||||||
return this._renderSidebar(
|
return this._renderSidebar(
|
||||||
|
[
|
||||||
|
useScopedSlot(this.$scopedSlots["contact-sidebar"]),
|
||||||
this.contacts.map(contact => {
|
this.contacts.map(contact => {
|
||||||
|
if (!contact.index) return;
|
||||||
contact.index = contact.index.replace(/\[[0-9]*\]/, "");
|
contact.index = contact.index.replace(/\[[0-9]*\]/, "");
|
||||||
const node = [
|
const node = [
|
||||||
contact.index !== prevIndex && (
|
contact.index !== prevIndex && (
|
||||||
@@ -358,7 +346,8 @@ export default {
|
|||||||
];
|
];
|
||||||
prevIndex = contact.index;
|
prevIndex = contact.index;
|
||||||
return node;
|
return node;
|
||||||
}),
|
})
|
||||||
|
],
|
||||||
DEFAULT_MENU_CONTACTS
|
DEFAULT_MENU_CONTACTS
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
@@ -425,7 +414,7 @@ export default {
|
|||||||
ref="messages"
|
ref="messages"
|
||||||
time-format={this.messageTimeFormat}
|
time-format={this.messageTimeFormat}
|
||||||
reverse-user-id={this.user.id}
|
reverse-user-id={this.user.id}
|
||||||
on-reach-top={this._handleReachTop}
|
on-reach-top={this._emitPullMessages}
|
||||||
messages={this.currentMessages}
|
messages={this.currentMessages}
|
||||||
/>
|
/>
|
||||||
<lemon-editor
|
<lemon-editor
|
||||||
@@ -436,7 +425,7 @@ export default {
|
|||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
nodes.push(
|
nodes.push(
|
||||||
<div class={cls} v-show={!curact.id}>
|
<div class={cls} v-show={!curact.id && this.currentIsDefSidebar}>
|
||||||
{this.$slots.cover}
|
{this.$slots.cover}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
@@ -455,8 +444,7 @@ export default {
|
|||||||
this.changeContact(curact.id, DEFAULT_MENU_LASTMESSAGES);
|
this.changeContact(curact.id, DEFAULT_MENU_LASTMESSAGES);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{" "}
|
发送消息
|
||||||
发送消息{" "}
|
|
||||||
</lemon-button>
|
</lemon-button>
|
||||||
</div>,
|
</div>,
|
||||||
curact
|
curact
|
||||||
@@ -537,16 +525,11 @@ export default {
|
|||||||
this.$refs.messages.resetLoadState();
|
this.$refs.messages.resetLoadState();
|
||||||
}
|
}
|
||||||
if (!messages[contactId]) {
|
if (!messages[contactId]) {
|
||||||
this.$emit(
|
this._emitPullMessages(isEnd => this.messageViewToBottom());
|
||||||
"pull-messages",
|
|
||||||
this.currentContact,
|
|
||||||
(messages, isEnd) => {
|
|
||||||
this._addMessage(messages, contactId, 0);
|
|
||||||
this.messageViewToBottom();
|
|
||||||
}
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
|
setTimeout(() => {
|
||||||
this.messageViewToBottom();
|
this.messageViewToBottom();
|
||||||
|
}, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -570,10 +553,11 @@ export default {
|
|||||||
updateMessage(messageId, contactId, data) {
|
updateMessage(messageId, contactId, data) {
|
||||||
const index = this.findMessageIndexById(messageId, contactId);
|
const index = this.findMessageIndexById(messageId, contactId);
|
||||||
if (index !== -1) {
|
if (index !== -1) {
|
||||||
messages[contactId][index] = {
|
messages[contactId][index] = Object.assign(
|
||||||
...messages[contactId][index],
|
messages[contactId][index],
|
||||||
...data
|
data
|
||||||
};
|
);
|
||||||
|
console.log('--------',messages[contactId][index]);
|
||||||
this.forceUpdateMessage(messageId);
|
this.forceUpdateMessage(messageId);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -684,6 +668,7 @@ export default {
|
|||||||
*/
|
*/
|
||||||
sortContacts() {
|
sortContacts() {
|
||||||
this.contacts.sort((a, b) => {
|
this.contacts.sort((a, b) => {
|
||||||
|
if (!a.index) return;
|
||||||
return a.index.localeCompare(b.index);
|
return a.index.localeCompare(b.index);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@@ -740,8 +725,8 @@ export default {
|
|||||||
* 返回所有消息
|
* 返回所有消息
|
||||||
* @return {Object<Contact.id,Message>}
|
* @return {Object<Contact.id,Message>}
|
||||||
*/
|
*/
|
||||||
getMessages() {
|
getMessages(contactId) {
|
||||||
return messages;
|
return (contactId ? messages[contactId] : messages) || [];
|
||||||
},
|
},
|
||||||
// appendContact(data) {
|
// appendContact(data) {
|
||||||
// this._addContact(data, 0);
|
// this._addContact(data, 0);
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
name: "lemonMessageBasic",
|
name: "lemonMessageBasic",
|
||||||
|
inject: ["IMUI"],
|
||||||
props: {
|
props: {
|
||||||
message: {
|
message: {
|
||||||
type: Object,
|
type: Object,
|
||||||
@@ -35,16 +36,16 @@ export default {
|
|||||||
size={36}
|
size={36}
|
||||||
shape="square"
|
shape="square"
|
||||||
src={fromUser.avatar}
|
src={fromUser.avatar}
|
||||||
on-click={() => {
|
on-click={e => {
|
||||||
console.log("message avatar click");
|
this._emitClick(e, "avatar");
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="lemon-message__inner">
|
<div class="lemon-message__inner">
|
||||||
<div class="lemon-message__title">
|
<div class="lemon-message__title">
|
||||||
<span
|
<span
|
||||||
on-click={() => {
|
on-click={e => {
|
||||||
console.log("message displayname click");
|
this._emitClick(e, "displayName");
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{fromUser.displayName}
|
{fromUser.displayName}
|
||||||
@@ -53,13 +54,20 @@ export default {
|
|||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
class="lemon-message__content"
|
class="lemon-message__content"
|
||||||
on-click={() => {
|
on-click={e => {
|
||||||
console.log("message content click");
|
this._emitClick(e, "content");
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{this.useScopedSlots("content", this.message)}
|
{this.useScopedSlots("content", this.message)}
|
||||||
</div>
|
</div>
|
||||||
<div class="lemon-message__status">{this._renderStatue(status)}</div>
|
<div
|
||||||
|
class="lemon-message__status"
|
||||||
|
on-click={e => {
|
||||||
|
this._emitClick(e, "status");
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{this._renderStatue(status)}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
@@ -69,6 +77,9 @@ export default {
|
|||||||
computed: {},
|
computed: {},
|
||||||
watch: {},
|
watch: {},
|
||||||
methods: {
|
methods: {
|
||||||
|
_emitClick(e, key) {
|
||||||
|
this.IMUI.$emit("message-click", e, key, this.message);
|
||||||
|
},
|
||||||
_renderStatue(status) {
|
_renderStatue(status) {
|
||||||
if (status == "going") {
|
if (status == "going") {
|
||||||
return <i class="lemon-icon-loading lemonani-spin" />;
|
return <i class="lemon-icon-loading lemonani-spin" />;
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
<script>
|
<script>
|
||||||
import IMUIProxy from "mixins/IMUIProxy";
|
|
||||||
export default {
|
export default {
|
||||||
name: "lemonMessageText",
|
name: "lemonMessageText",
|
||||||
inheritAttrs: false,
|
inheritAttrs: false,
|
||||||
mixins: [IMUIProxy],
|
inject: ["IMUI"],
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<lemon-message-basic
|
<lemon-message-basic
|
||||||
|
|||||||
@@ -22,8 +22,8 @@ export default {
|
|||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
loading: false,
|
_loading: false,
|
||||||
loadend: false
|
_loadend: false
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
render() {
|
render() {
|
||||||
@@ -32,10 +32,10 @@ export default {
|
|||||||
<div
|
<div
|
||||||
class={[
|
class={[
|
||||||
"lemon-messages__load",
|
"lemon-messages__load",
|
||||||
`lemon-messages__load--${this.loadend ? "end" : "ing"}`
|
`lemon-messages__load--${this._loadend ? "end" : "ing"}`
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
{this.loadend ? this._renderLoadEnd() : this._renderLoading()}
|
{this._loadend ? this._renderLoadEnd() : this._renderLoading()}
|
||||||
</div>
|
</div>
|
||||||
{this.messages.map((message, index) => {
|
{this.messages.map((message, index) => {
|
||||||
const node = [];
|
const node = [];
|
||||||
@@ -86,35 +86,40 @@ export default {
|
|||||||
return <i class="lemon-icon-loading lemonani-spin" />;
|
return <i class="lemon-icon-loading lemonani-spin" />;
|
||||||
},
|
},
|
||||||
_renderLoadEnd() {
|
_renderLoadEnd() {
|
||||||
return <span>暂无消息</span>;
|
return <span>暂无更多消息</span>;
|
||||||
|
},
|
||||||
|
loaded() {
|
||||||
|
this._loadend = true;
|
||||||
},
|
},
|
||||||
resetLoadState() {
|
resetLoadState() {
|
||||||
this.loading = false;
|
this._loading = false;
|
||||||
this.loadend = false;
|
this._loadend = false;
|
||||||
},
|
},
|
||||||
async _handleScroll(e) {
|
async _handleScroll(e) {
|
||||||
const { target } = e;
|
const { target } = e;
|
||||||
if (
|
if (
|
||||||
target.scrollTop == 0 &&
|
target.scrollTop == 0 &&
|
||||||
this.loading == false &&
|
this._loading == false &&
|
||||||
this.loadend == false
|
this._loadend == false
|
||||||
) {
|
) {
|
||||||
this.loading = true;
|
this._loading = true;
|
||||||
await this.$nextTick();
|
await this.$nextTick();
|
||||||
const hst = target.scrollHeight;
|
const hst = target.scrollHeight;
|
||||||
|
|
||||||
this.$emit("reach-top", async isEnd => {
|
this.$emit("reach-top", async isEnd => {
|
||||||
await this.$nextTick();
|
await this.$nextTick();
|
||||||
target.scrollTop = target.scrollHeight - hst;
|
target.scrollTop = target.scrollHeight - hst;
|
||||||
this.loading = false;
|
this._loading = false;
|
||||||
this.loadend = !!isEnd;
|
this._loadend = !!isEnd;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async scrollToBottom() {
|
async scrollToBottom() {
|
||||||
await this.$nextTick();
|
await this.$nextTick();
|
||||||
const { wrap } = this.$refs;
|
const { wrap } = this.$refs;
|
||||||
if (wrap) wrap.scrollTop = wrap.scrollHeight;
|
if (wrap) {
|
||||||
|
wrap.scrollTop = wrap.scrollHeight;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created() {},
|
created() {},
|
||||||
@@ -133,6 +138,7 @@ export default {
|
|||||||
text-align center
|
text-align center
|
||||||
font-size 12px
|
font-size 12px
|
||||||
+e(load)
|
+e(load)
|
||||||
|
user-select none
|
||||||
font-size 12px
|
font-size 12px
|
||||||
text-align center
|
text-align center
|
||||||
color #999
|
color #999
|
||||||
|
|||||||
@@ -1,4 +0,0 @@
|
|||||||
export default {
|
|
||||||
inject: ["IMUI"],
|
|
||||||
methods: {}
|
|
||||||
};
|
|
||||||
Reference in New Issue
Block a user