icssoa před 6 roky
rodič
revize
1027539e15

+ 376 - 0
admin-update/src/components/chat/index.vue

@@ -0,0 +1,376 @@
+<template>
+	<div class="cl-chat__wrap">
+		<el-dialog :visible.sync="visible" :close-on-click-modal="false" width="1000px">
+			<div class="cl-chat">
+				<div class="cl-chat__left">
+					<div class="header">
+						<el-input
+							placeholder="搜索联系人"
+							size="small"
+							prefix-icon="el-icon-search"
+						></el-input>
+					</div>
+					<div class="container">
+						<ul class="users">
+							<li
+								v-for="(item, index) in userList"
+								:key="index"
+								@click="toChat(item)"
+							>
+								<img class="avatar" :src="item.smallAvatarUrl" alt="" />
+
+								<div class="det">
+									<p>{{ item.userName }}</p>
+									<div>{{ item.source }}</div>
+								</div>
+
+								<div class="date">
+									{{ item.chatTime }}
+								</div>
+							</li>
+						</ul>
+					</div>
+				</div>
+
+				<div class="cl-chat__right">
+					<div class="header">
+						<span>闪亮亮</span>
+						<div class="icon" @click="hide()">
+							<i class="el-icon-minus"></i>
+						</div>
+					</div>
+
+					<div class="container">
+						<ul class="message">
+							<li
+								v-for="(item, index) in messageList"
+								:key="index"
+								:class="[item.my ? 'right' : 'left']"
+							>
+								<img class="avatar" src="" alt="" />
+								<div class="det">
+									<div class="label">
+										<span class="name">刘先生</span>
+										<span class="date">2020-12-22</span>
+									</div>
+									<div class="content">
+										<p class="block text" v-if="item.type == 'text'">
+											{{ item.text }}
+										</p>
+										<el-image
+											class="block pic"
+											v-else-if="item.type == 'pic'"
+											:src="item.src"
+											:preview-src-list="[item.src]"
+										></el-image>
+									</div>
+								</div>
+							</li>
+						</ul>
+					</div>
+
+					<div class="footer">
+						<ul class="tools">
+							<li>
+								<el-button size="mini">商品图</el-button>
+							</li>
+							<li>
+								<el-upload action="">
+									<el-button size="mini" icon="el-icon-picture"></el-button>
+								</el-upload>
+							</li>
+						</ul>
+
+						<el-button class="send-btn" size="small" type="primary">发送</el-button>
+					</div>
+				</div>
+			</div>
+		</el-dialog>
+
+		<el-button
+			class="cl-chat__notice"
+			v-show="!visible"
+			icon="el-icon-message-solid"
+			round
+			size="small"
+			@click="show()"
+		></el-button>
+	</div>
+</template>
+
+<script>
+export default {
+	data() {
+		return {
+			visible: false,
+			userList: [],
+			messageList: [
+				{
+					type: 'text',
+					text: '我是厦门第一'
+				},
+				{
+					type: 'pic',
+					src:
+						'https://dss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=2164724814,1401845036&fm=26&gp=0.jpg'
+				},
+				{
+					type: 'text',
+					text: '我是厦门第二',
+					my: true
+				},
+				{
+					type: 'pic',
+					src:
+						'https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=3973065280,787801978&fm=26&gp=0.jpg',
+					my: true
+				}
+			]
+		};
+	},
+
+	methods: {
+		getUserList() {
+			this.$service.chat.recentlyUser().then(res => {
+				this.userList = res;
+			});
+		},
+
+		toChat(e) {
+			this.$service.chat.begin({ id: e.id }).then(res => {
+				console.log(res);
+			});
+		},
+
+		show() {
+			this.visible = true;
+			this.getUserList();
+		},
+
+		hide() {
+			this.visible = false;
+		}
+	}
+};
+</script>
+
+<style lang="stylus" scoped>
+.cl-chat__wrap {
+    >>>.el-dialog {
+        &__header {
+            display: none;
+        }
+
+        &__body {
+            padding: 0;
+        }
+    }
+
+    .cl-chat {
+        display flex;
+        height 600px;
+
+        &__left {
+            width: 300px;
+            background-color #F7F6F9;
+
+           .header {
+               display flex;
+               align-items center;
+               height: 60px;
+               padding: 0 20px;
+               border-bottom: 1px solid #eee;
+
+               .el-input {
+                   >>>input {
+                       border-radius: 30px;
+                     background-color #E7E6E9;
+                   }
+               }
+           }
+
+           .container {
+               height: calc(100% - 60px);
+               overflow auto;
+
+                .users {
+                    display flex;
+                    flex-direction column;
+                li {
+                    list-style none;
+                    display flex;
+                    align-items center;
+                    height: 40px;
+                    padding: 10px  15px;
+                    border-bottom: 1px solid #eee;
+                    cursor pointer;
+
+                    &:hover,
+                    &.active {
+                        background-color #eee;
+                    }
+
+                    .avatar {
+                        height 40px;
+                        width 40px;
+                        border-radius: 40px;
+                        background-color #ddd;
+                    }
+
+                    .det {
+                        flex: 1;
+                        margin 0 10px;
+                    }
+
+                    .date {
+                        font-size 12px;
+                        color: #999;
+                        height 100%;
+                    }
+                }
+            }
+           }
+        }
+
+        &__right {
+            width calc(100% - 300px);
+
+            .header {
+                display flex;
+               align-items center;
+               height: 60px;
+               padding: 0 20px;
+               position relative;
+
+               .icon {
+                   position absolute;
+                   right: 0;
+                   top: 0;
+                   background-color #DAD9DC;
+                   height 30px;
+                   width: 30px;
+                   color: #fff;
+                   line-height 30px;
+                   text-align center;
+                   cursor pointer;
+
+                    &:hover {
+                       opacity 0.7;
+                    }
+               }
+            }
+
+            .container {
+                border-top: 1px solid #eee;
+                border-bottom: 1px solid #eee;
+                box-sizing border-box;
+                height calc(100% - 260px);
+                overflow auto;
+
+                .message {
+                    padding: 10px;
+
+                    li {
+                        display flex;
+                        list-style none;
+                        margin-bottom 30px;
+
+                        .avatar {
+                            height 40px;
+                            width 40px;
+                            border-radius: 40px;
+                            background-color #ddd;
+                            margin 0 10px 0 0;
+                        }
+
+                        .det {
+                            .label {
+                                display flex;
+                                align-items center;
+
+                                .name {
+                                    margin 0 10px 0 0;
+                                }
+                                .date {
+                                    font-size 12px;
+                                    color: #999;
+                                }
+                            }
+
+                            .content {
+                                display flex;
+                                color: #666;
+                                margin-top 10px;
+
+                                .block {
+                                    background-color #eee;
+                                    padding: 5px 10px;
+                                    border-radius: 3px;
+                                }
+
+                                .text {
+                                    line-height 20px;
+                                    font-size 12px;
+                                }
+
+                                .pic {
+                                    width: 50%;
+                                    padding: 10px;
+                                }
+                            }
+                        }
+
+                        &.right {
+                            flex-direction  row-reverse;
+
+                            .avatar {
+                                margin 0 0 0 10px;
+                            }
+
+                            .label {
+                                flex-direction  row-reverse;
+
+                                .name {
+                                    margin 0 0 0 10px;
+                                }
+                            }
+
+                            .content {
+                                justify-content flex-end;
+                            }
+                        }
+                    }
+                }
+            }
+
+            .footer {
+                height 200px;
+                position relative;
+
+                .tools {
+                    display flex;
+                    align-items center;
+                    height 40px;
+
+                    li {
+                        list-style none;
+                        margin-left 10px;
+                    }
+                }
+
+                .send-btn {
+                    position absolute;
+                    right 10px;
+                    bottom: 10px;
+                }
+            }
+        }
+    }
+
+    .cl-chat__notice {
+        position fixed;
+        bottom: 30px;
+        right: 20px;
+    }
+}
+</style>

+ 3 - 1
admin-update/src/cool/request/index.js

@@ -27,6 +27,7 @@ import sassFest from '@/service/sass/fest/index';
 import sassAuth from '@/service/sass/auth/index';
 
 import shop from '@/service/shop/index';
+import chat from '@/service/chat/index';
 
 export function SET_SERVICE({ store }) {
 	// const files = require.context('@/service/', true, /\.js$/);
@@ -58,7 +59,8 @@ export function SET_SERVICE({ store }) {
 		sassPtMember,
 		sassFest,
 		sassAuth,
-		shop
+		shop,
+		chat
 	};
 
 	Vue.prototype.$service = modules;

+ 5 - 1
admin-update/src/pages/layout/index.vue

@@ -28,19 +28,23 @@
 			</div>
 			<!-- </div> -->
 		</div>
+
+		<chat></chat>
 	</div>
 </template>
 
 <script>
 import Topbar from './topbar/index';
 import Slider from './slider/index';
+import Chat from '@/components/chat';
 // import Process from './process/index';
 // import { mapGetters } from 'vuex';
 
 export default {
 	components: {
 		Topbar,
-		Slider
+		Slider,
+		Chat
 		// Process
 	},
 

+ 35 - 0
admin-update/src/service/chat/index.js

@@ -0,0 +1,35 @@
+import { BaseService, Service } from '@/cool';
+
+@Service('chat')
+export class ChatService extends BaseService {
+	recentlyMessage(params) {
+		return this.request({
+			url: '/recently-message',
+			params
+		});
+	}
+
+	send(data) {
+		return this.request({
+			url: '/send',
+			method: 'POST',
+			data
+		});
+	}
+
+	recentlyUser(params) {
+		return this.request({
+			url: '/recently-user',
+			params
+		});
+	}
+
+	begin(params) {
+		return this.request({
+			url: '/begin',
+			params
+		});
+	}
+}
+
+export default new ChatService();