Commit 82649518 authored by looker's avatar looker

add tag

parent 3faa4225
......@@ -2,5 +2,7 @@ var merge = require('webpack-merge')
var prodEnv = require('./prod.env')
module.exports = merge(prodEnv, {
NODE_ENV: '"development"'
NODE_ENV: '"development"',
WX_ADDRESS: '"http://imdev.chenzhen.shop:9093/"',
IMG_ADDRESS:'"http://chat-x.oss-cn-beijing.aliyuncs.com/"'
})
......@@ -23,7 +23,7 @@ module.exports = {
},
dev: {
env: require('./dev.env'),
port: 8080,
port: 8078,
autoOpenBrowser: true,
assetsSubDirectory: 'static',
assetsPublicPath: '/',
......@@ -34,7 +34,8 @@ module.exports = {
// }
'/api': {
pathRewrite: { '^/api': '' },
target: 'http://imweb.chenzhen.shop',
// target: 'http://imweb.chenzhen.shop',
target: 'http://imdev.chenzhen.shop/',
changeOrigin: true, //是否跨域
}
},
......
module.exports = {
NODE_ENV: '"production"'
NODE_ENV: '"production"',
WX_ADDRESS: "http://imweb.chenzhen.shop:9093",
IMG_ADDRESS:'"http://chat-x.oss-cn-beijing.aliyuncs.com/"'
}
......@@ -5635,6 +5635,12 @@
"minimist": "0.0.8"
}
},
"moment": {
"version": "2.24.0",
"resolved": "https://registry.npmjs.org/moment/-/moment-2.24.0.tgz",
"integrity": "sha512-bV7f+6l2QigeBBZSM/6yTNq4P2fNpSWj/0e7jQcy87A8e7o2nAfP/34/2ky5Vw4B9S446EtIhodAzkFCcR4dQg==",
"dev": true
},
"move-concurrently": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/move-concurrently/-/move-concurrently-1.0.1.tgz",
......
<!-- 聊天列表 -->
<template>
<div class="msglist">
<ul>
<li v-for="item in searchedChatlist" class="sessionlist" :class="{ active: item.id === selectId }" @click="selectSession(item.id)">
<ul v-if="user.whichPane==panelStatus.CHART">
<li v-for="item in chatlist" class="sessionlist" :class="{ active: item.id === user.selectId }" @click="selectSession(item)">
<div class="list-left">
<img class="avatar" width="42" height="42" :alt="item.user.name" :src="item.user.img">
</div>
<div class="list-right">
<p class="name">{{item.user.name}}</p>
<span class="time">{{item.messages[item.messages.length-1].date | time}}</span>
<p class="lastmsg">{{item.messages[item.messages.length-1].content}}</p>
<span class="time">{{item.queryData | time}}</span>
<p class="lastmsg">{{item.messages[item.messages.length-1]?'':item.messages[item.messages.length-1].content}}</p>
</div>
</li>
</ul>
<ul v-if="user.whichPane==panelStatus.SEARCH">
<li v-for="item in searchChatlist" class="sessionlist" :class="{ active: item.id === user.selectId }" @click="selectSession(item)">
<div class="list-left">
<img class="avatar" width="42" height="42" :alt="item.user.name" :src="item.user.img">
</div>
<div class="list-right">
<p class="name">{{item.user.name}}</p>
<span class="time">{{item.queryData | time}}</span>
<p class="lastmsg">{{item.messages[item.messages.length-1]?'':item.messages[item.messages.length-1].content}}</p>
</div>
</li>
</ul>
......@@ -18,14 +30,18 @@
<script>
import { mapState, mapActions ,mapGetters } from 'vuex'
import { panelStatus } from '@/utils/common'
export default {
computed: {
panelStatus(){
return panelStatus
},
...mapState([
'selectId',
'searchText'
'user',
]),
...mapGetters([
'searchedChatlist'
'searchChatlist',
'chatlist'
])
},
methods: {
......@@ -33,18 +49,23 @@ export default {
'selectSession',
])
},
mounted() {
let obj = this.searchedChatlist[0]
this.selectSession(obj)
},
filters: {
// 将日期过滤为 hour:minutes
time (date) {
if (typeof date === 'string') {
date = new Date(date);
}
time (date) {
if(date){
date = new Date(parseInt(date) * 1000);
if(date.getMinutes()<10){
return date.getHours() + ':0' +date.getMinutes();
}else{
return date.getHours() + ':' + date.getMinutes();
}
}else{
return ""
}
}
},
}
</script>
......
<!-- 消息框 -->
<template>
<div class="message">
<header class="header">
<div class="friendname">{{selectedChat.user.name}}</div>
</header>
<div class="message-wrapper" ref="list">
<ul v-if="selectedChat">
<li v-for="item in selectedChat.messages" class="message-item">
<div class="time"><span>{{item.date | time}}</span></div>
<div class="main" :class="{ self: item.self }">
<img class="avatar" width="36" height="36" :src="item.self ? user.img : selectedChat.user.img" />
<div class="content">
<div class="text" v-html="replaceFace(item.content)"></div>
<div>
<div class="message" v-if="user.whichPane==panelStatus.CHART">
<header class="header">
<div class="friendname">{{selectedChat&&selectedChat.user.name}}</div>
</header>
<div class="message-wrapper" ref="list">
<ul v-if="selectedChat">
<li v-for="item in messages" class="message-item">
<div v-if="item.type==1" class="main" :class="{ self: item.isSend }">
<img class="avatar" width="36" height="36" :src="item.isSend ? user.img : selectedChat.user.img" />
<div class="time"><span>{{item.createTime | time}}</span></div>
<div class="content">
<div class="text" v-html="replaceFace(item.content)"></div>
</div>
</div>
<div v-if="item.type==3" class="main" :class="{ self: item.isSend }">
<img class="avatar" width="36" height="36" :src="item.isSend ? user.img : selectedChat.user.img" />
<div class="time"><span>{{item.createTime | time}}</span></div>
<div class="content">
<div class="img"><img style="width:300px;
height:300px;" :src="imgUrl+item.imageUrl" alt=""></div>
</div>
</div>
</li>
</ul>
</div>
</div>
<div class="message" v-if="user.whichPane==panelStatus.SEARCH">
<header class="header">
<div class="friendname">{{selectedSearchChat&&selectedSearchChat.user.name}}</div>
</header>
<div class="message-wrapper" ref="list">
<ul v-if="selectedSearchChat">
<li v-for="item in messages" class="message-item">
<div v-if="item.type==1" class="main" :class="{ self: item.isSend }">
<img class="avatar" width="36" height="36" :src="item.isSend ? user.img : selectedSearchChat.user.img" />
<div class="time"><span>{{item.createTime | time}}</span></div>
<div class="content">
<div class="text" v-html="replaceFace(item.content)"></div>
</div>
</div>
<div v-if="item.type==3" class="main" :class="{ self: item.isSend }">
<img class="avatar" width="36" height="36" :src="item.isSend ? user.img : selectedSearchChat.user.img" />
<div class="time"><span>{{item.createTime | time}}</span></div>
<div class="content">
<div class="img"><img style="width:300px;
height:300px;" :src="imgUrl+item.imageUrl" alt=""></div>
</div>
</div>
</div>
</li>
</ul>
</div>
</div>
</li>
</ul>
</div>
</div>
</div>
</template>
<script>
import moment from 'moment'
import { panelStatus } from '@/utils/common'
import { mapGetters, mapState } from 'vuex'
export default {
data(){
return {
imgUrl:process.env.IMG_ADDRESS
}
},
computed: {
panelStatus(){
return panelStatus
},
...mapGetters([
'selectedChat',
'selectedSearchChat',
'messages'
]),
...mapState([
......@@ -33,12 +81,12 @@ export default {
])
},
mounted() {
// 在页面加载时让信息滚动到最下面
setTimeout(() => this.$refs.list.scrollTop = this.$refs.list.scrollHeight, 0)
// console.log(this.$refs)
// setTimeout(() => this.$refs.list.scrollTop = this.$refs.list.scrollHeight, 0)
},
watch: {
// 发送信息后,让信息滚动到最下面
messages() {
console.log(44444444)
setTimeout(() => this.$refs.list.scrollTop = this.$refs.list.scrollHeight, 0)
}
},
......@@ -46,7 +94,7 @@ export default {
// 在发送信息之后,将输入的内容中属于表情的部分替换成emoji图片标签
// 再经过v-html 渲染成真正的图片
replaceFace (con) {
if(con.includes('/:')) {
if(con&&con.includes('/:')) {
var emojis=this.user.emojis;
for(var i=0;i<emojis.length;i++){
con = con.replace(emojis[i].reg, '<img src="static/emoji/' + emojis[i].file +'" alt="" style="vertical-align: middle; width: 24px; height: 24px" />');
......@@ -59,14 +107,14 @@ export default {
filters: {
// 将日期过滤为 hour:minutes
time (date) {
if (typeof date === 'string') {
date = new Date(date);
}
if(date.getMinutes()<10){
return date.getHours() + ':0' +date.getMinutes();
}else{
return date.getHours() + ':' + date.getMinutes();
}
date = new Date(parseInt(date+'') * 1000);
return moment(date).format('YYYY-MM-DD HH:mm:ss')
// if(date.getMinutes()<10){
// return date.getHours() + ':0' +date.getMinutes();
// }else{
// return date.getHours() + ':' + date.getMinutes();
// }
}
}
}
......@@ -96,13 +144,11 @@ export default {
width: 100%
font-size: 12px
margin: 7px auto
text-align: center
span
display: inline-block
padding: 4px 6px
color: #fff
color: #797979
border-radius: 3px
background-color: #dcdcdc
.main
.avatar
float: left
......@@ -141,4 +187,5 @@ export default {
vertical-align: middle
border-right-color: transparent
border-left-color: #b2e281
</style>
......@@ -25,7 +25,7 @@ import { mapState } from 'vuex'
export default {
data(){
return {
accountFlag:true
accountFlag:false
}
},
computed: {
......
......@@ -13,7 +13,14 @@
export default {
methods: {
change () {
this.$store.dispatch('search', this.search)
const text = this.search
if(text.replace(/^\s\s*/, '').replace(/\s\s*$/, '')==''){
console.log(66666666666666666)
this.$store.dispatch('changeChartPanel')
}else{
this.$store.dispatch('searchSession', this.search)
}
},
del () {
this.search= ''
......
......@@ -24,12 +24,12 @@
<div class="warn" v-show="warn">
<div class="description">不能发送空白信息</div>
</div>
</transition>
</transition>
<el-dialog
title="选择转接对象"
:visible.sync="dialogVisible"
width="30%"
:before-close="handleClose">
>
<div>
<el-select style="width: 100%;" v-model="value7" placeholder="请选择">
<el-option-group
......@@ -61,6 +61,8 @@ export default {
content: '',
reply: '未找到',
frequency: 0,
sendType:1,
imageUrl:'',
warn: false,
showEmoji: false,
dialogVisible:false,
......@@ -95,7 +97,7 @@ export default {
computed: {
...mapState([
'selectId',
'emojis'
'user'
]),
...mapGetters([
'selectedChat',
......@@ -169,26 +171,14 @@ export default {
this.warn = false;
}, 1000)
}else{
if(this.selectedChat.user.name === '机器人'){
this.$http.get(`https://zhaoplus.com/api/AI?search=${this.content}`).then(res => {
this.reply = res.data.result.text
if(this.content.includes('/:')){
this.reply = '嘻嘻'
}
var msg = {
content: this.content,
reply: this.reply
}
this.$store.dispatch('sendMessage', msg)
this.content = ''
})
}else{
var msg = {
content: this.content,
}
this.$store.dispatch('sendMessage', msg)
this.content = ''
var msg = {
id:this.user.selectId,
type:this.sendType,
content: this.content,
imageUrl:this.imageUrl
}
this.$store.dispatch('sendMessage', msg)
this.content = ''
}
}
},
......
......@@ -8,6 +8,7 @@ import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
Vue.config.productionTip = false
Vue.config.devtools = true
Vue.use(ElementUI)
/* eslint-disable no-new */
const vm = new Vue({
......
const url={}
url.login = '/api/y/customer/passport/sign'
url.wsUrl = "http://imweb.chenzhen.shop:9093"
url.wsUrl = "http://imdev.chenzhen.shop:9093/"
// url.wsUrl = process.env.WX_ADDRESS
export default url
\ No newline at end of file
import { panelStatus } from '@/utils/common'
const getters = {
searchedChatlist (state) {
let sessions = state.user.chatlist.filter(sessions => sessions.user.name.includes(state.user.searchText));
return sessions
chatlist (state) {
return state.user.chatlist
},
// 筛选出含有搜索值的好友列表
searchedFriendlist (state) {
let friends = state.user.friendlist.filter(friends => friends.remark.includes(state.user.searchText));
return friends
searchChatlist (state) {
return state.user.searchChatlist
},
// 通过当前选择是哪个对话匹配相应的对话
// searchedFriendlist (state) {
// let friends = state.user.friendlist.filter(friends => friends.remark.includes(state.user.searchText));
// return friends
// },
selectedChat (state) {
let session = state.user.chatlist.find(session => session.id === state.user.selectId);
return session
let temp = state.user.chatlist.find(session => session.id === state.user.selectId);
return temp
},
selectedSearchChat(state){
let temp = state.user.searchChatlist.find(session => session.id === state.user.selectId);
return temp
},
// 通过当前选择是哪个好友匹配相应的好友
selectedFriend (state) {
let friend = state.user.friendlist.find(friend => friend.id === state.user.selectFriendId);
return friend
let friend = state.user.friendlist.find(friend => friend.id === state.user.selectFriendId);
return friend
},
messages (state) {
let session = state.user.chatlist.find(session => session.id === state.user.selectId);
console.log(session)
return session.messages
return session&&session.messages
}
}
export default getters
\ No newline at end of file
This diff is collapsed.
......@@ -29,4 +29,56 @@ export function getCommercialId() {
export function setCommercialId(token) {
return Cookies.set(commercialIdKey, token)
}
\ No newline at end of file
}
export const emojis = [
{ file: '100.gif', code: '/::)', title: '微笑',reg:/\/::\)/g },
{ file: '101.gif', code: '/::~', title: '伤心',reg:/\/::~/g },
{ file: '102.gif', code: '/::B', title: '美女',reg:/\/::B/g },
{ file: '103.gif', code: '/::|', title: '发呆',reg:/\/::\|/g },
{ file: '104.gif', code: '/:8-)', title: '墨镜',reg:/\/:8-\)/g },
{ file: '105.gif', code: '/::<', title: '哭',reg:/\/::</g },
{ file: '106.gif', code: '/::$', title: '羞',reg:/\/::\$/g },
{ file: '107.gif', code: '/::X', title: '哑',reg:/\/::X/g },
{ file: '108.gif', code: '/::Z', title: '睡',reg:/\/::Z/g },
{ file: '109.gif', code: '/::\'(', title: '哭',reg:/\/::'\(/g },
{ file: '110.gif', code: '/::-|', title: '囧',reg:/\/::-\|/g },
{ file: '111.gif', code: '/::@', title: '怒',reg:/\/::@/g },
{ file: '112.gif', code: '/::P', title: '调皮',reg:/\/::P/g },
{ file: '113.gif', code: '/::D', title: '笑',reg:/\/::D/g },
{ file: '114.gif', code: '/::O', title: '惊讶',reg:/\/::O/g },
{ file: '115.gif', code: '/::(', title: '难过',reg:/\/::\(/g },
{ file: '116.gif', code: '/::+', title: '酷',reg:/\/::\+/g },
{ file: '117.gif', code: '/:--b', title: '汗',reg:/\/:--b/g },
{ file: '118.gif', code: '/::Q', title: '抓狂',reg:/\/::Q/g },
{ file: '119.gif', code: '/::T', title: '吐',reg:/\/::T/g },
{ file: '120.gif', code: '/:,@P', title: '笑',reg:/\/:,@P/g },
{ file: '121.gif', code: '/:,@-D', title: '快乐',reg:/\/:,@-D/g },
{ file: '122.gif', code: '/::d', title: '奇',reg:/\/::d/g },
{ file: '123.gif', code: '/:,@o', title: '傲' ,reg:/\/:,@o/g},
{ file: '124.gif', code: '/::g', title: '饿',reg:/\/::g/g },
{ file: '125.gif', code: '/:|-)', title: '累' ,reg:/\/:\|-\)/g},
{ file: '126.gif', code: '/::!', title: '吓',reg:/\/::!/g },
{ file: '127.gif', code: '/::L', title: '汗',reg:/\/::L/g },
{ file: '128.gif', code: '/::>', title: '高兴',reg:/\/::>/g },
{ file: '129.gif', code: '/::,@', title: '闲',reg:/\/::,@/g },
{ file: '130.gif', code: '/:,@f', title: '努力',reg:/\/:,@f/g },
{ file: '131.gif', code: '/::-S', title: '骂',reg:/\/::-S/g },
{ file: '133.gif', code: '/:,@x', title: '秘密',reg:/\/:,@x/g },
{ file: '134.gif', code: '/:,@@', title: '乱',reg:/\/:,@@/g },
{ file: '135.gif', code: '/::8', title: '疯',reg:/\/::8/g },
{ file: '136.gif', code: '/:,@!', title: '哀',reg:/\/:,@!/g },
{ file: '137.gif', code: '/:!!!', title: '鬼',reg:/\/:!!!/g },
{ file: '138.gif', code: '/:xx', title: '打击',reg:/\/:xx/g },
{ file: '139.gif', code: '/:bye', title: 'bye',reg:/\/:bye/g },
{ file: '142.gif', code: '/:handclap', title: '鼓掌',reg:/\/:handclap/g },
{ file: '145.gif', code: '/:<@', title: '什么',reg:/\/:<@/g },
{ file: '147.gif', code: '/::-O', title: '累',reg:/\/::-O/g },
{ file: '153.gif', code: '/:@x', title: '吓',reg:/\/:@x/g },
{ file: '155.gif', code: '/:pd', title: '刀',reg:/\/:pd/g },
{ file: '156.gif', code: '/:<W>', title: '水果',reg:/\/:<W>/g },
{ file: '157.gif', code: '/:beer', title: '酒',reg:/\/:beer/g },
{ file: '158.gif', code: '/:basketb', title: '篮球',reg:/\/:basketb/g },
{ file: '159.gif', code: '/:oo', title: '乒乓',reg:/\/:oo/g },
{ file: '195.gif', code: '/:circle', title: '跳舞',reg:/\/:circle/g },
{ file: '160.gif', code: '/:coffee', title: '咖啡',reg:/\/:coffee/g }
]
import axios from "axios"
import aliOss from "ali-oss"
let Authorization = null
let Common = {}
window.common = Common
// const ajaxUrl = "http://172.16.22.234:19891";
const ajaxUrl = "/api"
// const ajaxUrl = "http://localhost";
Common.ajax = axios.create({
baseURL: ajaxUrl,
timeout: 120000,
headers: {
"Cache-Control": "no-cache,no-store,must-revalidate,max-age=-1,private"
}
})
// Common.wsUrl = "http://172.16.22.234:9093";
Common.wsUrl = "http://imweb.chenzhen.shop"
Common.bag = {
host: "https://baozheng.cc"
// host: "http://172.16.22.3:19893"
// host: "http://172.16.22.234:9093"
}
Common.bag.ajax = axios.create({
baseURL: Common.bag.host,
timeout: 120000,
headers: {
"Cache-Control": "no-cache,no-store,must-revalidate,max-age=-1,private"
}
// withCredentials: true
})
Common.bag.ajax.interceptors.response.use((response) => {
// console.log(response)
return response
}, (error) => {
if (error.response && error.response.status == 401) {
window.vm.bagLogin()
}
return Promise.reject(error)
})
Common.chenzhen = {}
Common.chenzhen.ajax = axios.create({
// baseURL: "http://172.16.22.234:19893",
// baseURL: "http://127.0.0.1:4396",
baseURL: "http://imweb.chenzhen.shop",
timeout: 30000,
headers: {
"Cache-Control": "no-cache,no-store,must-revalidate,max-age=-1,private"
}
})
Common.chenzhen.ajax.interceptors.request.use((body) => {
body.headers.Authorization = localStorage.getItem("chenzhen-token")
return body
}, (error) => {
return Promise.reject(error)
})
Common.chenzhen.ajax.interceptors.response.use((response) => {
if (response.data.code === 800) {
localStorage.clear()
window.vm.chenzhenLogin()
}
return response
}, (error) => {
return Promise.reject(error)
})
Common.chat = {
host: "http://imweb.chenzhen.shop"
}
Common.chat.ajax = axios.create({
baseURL: Common.chat.host,
timeout: 120000,
headers: {
"Cache-Control": "no-cache,no-store,must-revalidate,max-age=-1,private"
}
})
Common.six_day = 6 * 24 * 60 * 60 * 1000
Common.wsClient = null
Common.sendMessage = (message) => {
return new Promise((resolve, reject) => {
if (Common.wsClient == null || Common.wsClient.disconnected) {
reject("No socket connection.")
} else {
// console.log(message)
let options = {
eventType: "messages/create",
message: message
}
Common.wsClient.emit("appevent", options)
resolve()
}
})
}
Common.ossClient = new aliOss({
region: "oss-cn-beijing",
accessKeyId: "LTAImsrYiikk7t3f",
accessKeySecret: "XtgwITVY6Apb7H1hOO3LRZNxE0Onpb",
bucket: "chat-x"
})
Common.ossUrl = "http://chat-x.oss-cn-beijing.aliyuncs.com/"
export default Common
export const panelStatus = {
SEARCH:'SEARCH',//SEARCH搜索列表
CHART:'CHART'//CHART回话列表
}
\ No newline at end of file
export const compare =(po)=>{
return function(a,b){
let temp1 = a[po];
let temp2 = b[po];
return temp1-temp2
}
}
\ No newline at end of file
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 to comment