Commit a0a433b6 authored by looker's avatar looker

add store

parent 7aeac2e1
......@@ -27,7 +27,16 @@ module.exports = {
autoOpenBrowser: true,
assetsSubDirectory: 'static',
assetsPublicPath: '/',
proxyTable: {},
proxyTable: {
// '/**': {
// target: 'http://127.0.0.1:3000', //目标接口域名
// changeOrigin: true, //是否跨域
// }
'/api': {
target: 'http://172.16.22.5:3000/', //目标接口域名
changeOrigin: true, //是否跨域
}
},
// CSS Sourcemaps off by default because relative paths are "buggy"
// with this option, according to the CSS-Loader README
// (https://github.com/webpack/css-loader#sourcemaps)
......
......@@ -14,7 +14,7 @@
<script>
import mycard from './components/mycard/mycard'
import toolbar from '@/page/toolbar'
import toolbar from '@/page/right-panel'
import { mapActions } from 'vuex'
export default {
components: {
......@@ -30,10 +30,8 @@ export default {
<style lang="stylus" scoped>
#app
display: flex
border-radius 50px
margin: 20px auto
width: 1260px
height: 600px
background-color: #fff
.sidebar
width: 60px
......
......@@ -29,8 +29,7 @@ export default {
'messages'
]),
...mapState([
'user',
'emojis'
'user'
])
},
mounted() {
......@@ -48,7 +47,7 @@ export default {
// 再经过v-html 渲染成真正的图片
replaceFace (con) {
if(con.includes('/:')) {
var emojis=this.emojis;
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" />');
}
......
......@@ -10,14 +10,24 @@
<router-link to="/my" class="icon iconfont icon-collection"></router-link>
</div>
<footer>
<i class="icon iconfont icon-more"></i>
<i class="icon iconfont icon-more" @click="accountFlag=!accountFlag"></i>
</footer>
<div v-if="accountFlag" style="width: 100%;height: 100%;position: fixed;top: 0;right: 0;" @click="accountFlag=!accountFlag"></div>
<div class="tool-panel" v-if="accountFlag">
<div><span class="sdsd">切换账号</span></div>
<div @click="logout"><span class="sdsd">退出登录</span></div>
</div>
</div>
</template>
<script>
import { mapState } from 'vuex'
export default {
data(){
return {
accountFlag:true
}
},
computed: {
...mapState([
'user',
......@@ -26,6 +36,23 @@ export default {
methods: {
clearSearch() {
this.$store.dispatch('search', '')
},
logout(){
this.$confirm('确定要退出ERP系统吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.$message({
type: 'success',
message: '已退出!'
});
}).catch(() => {
// this.$message({
// type: 'info',
// message: '已取消删'
// });
});
}
}
}
......@@ -67,4 +94,24 @@ export default {
bottom: 20px
width: 100%
text-align: center
.sdsd:hover{
color:#409EFF
}
.tool-panel
position:relative;
bottom:-480px;
height:80px;
width:120px;
right:-60px;
border-radius:5px;
padding-top:10px;
background: #000000;
div
bottom:-550px;
font-size:13px;
text-align:center;
height:30px;
line-height:30px;
cursor: pointer;
color:#fff;
</style>
<!-- 最左边的选择框 -->
<template>
<div class="mycard">
<header>
<img :src="user.img" class="avatar">
</header>
<div class="navbar" @click="clearSearch">
<router-link to="/chat" class="icon iconfont icon-msg" ></router-link>
<router-link to="/friend" class="icon iconfont icon-friend"></router-link>
<router-link to="/my" class="icon iconfont icon-collection"></router-link>
</div>
<footer>
<i class="icon iconfont icon-more" @click="accountFlag=!accountFlag"></i>
</footer>
<div v-if="accountFlag" style="width: 100%;height: 100%;position: fixed;top: 0;right: 0;" @click="accountFlag=!accountFlag"></div>
<div class="tool-panel" v-if="accountFlag">
<div><span class="sdsd">切换账号</span></div>
<div @click="logout"><span class="sdsd">退出登录</span></div>
</div>
</div>
</template>
<script>
import { mapState } from 'vuex'
export default {
data(){
return {
accountFlag:true
}
},
computed: {
...mapState([
'user',
])
},
methods: {
clearSearch() {
this.$store.dispatch('search', '')
},
logout(){
this.$confirm('确定要退出ERP系统吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.$message({
type: 'success',
message: '已退出!'
});
}).catch(() => {
// this.$message({
// type: 'info',
// message: '已取消删'
// });
});
}
}
}
</script>
<style lang="stylus" scoped>
@import '../../assets/fonts/iconfont.css'
.mycard
position: relative
width: 100%
height: 100%
.avatar
width: 36px
height: 36px
margin: 20px 12px 0 12px
border-radius: 2px
.navbar
width: 100%
text-align: center
.icon
display: inline-block
font-size: 26px
margin-top: 28px
padding: 0 16px
box-sizing: border-box
color: rgb(173,174,175)
opacity: 0.8
cursor: pointer
&.active
color: rgb(0,220,65)
&:hover
opacity: 1;
.icon-msg,.icon-more
font-size: 22px
.icon-msg
padding: 0 19px
footer
position: absolute
bottom: 20px
width: 100%
text-align: center
.sdsd:hover{
color:#409EFF
}
.tool-panel
position:relative;
bottom:-480px;
height:80px;
width:120px;
right:-60px;
border-radius:5px;
padding-top:10px;
background: #000000;
div
bottom:-550px;
font-size:13px;
text-align:center;
height:30px;
line-height:30px;
cursor: pointer;
color:#fff;
</style>
......@@ -3,6 +3,11 @@
<div class="text">
<div class="emoji">
<i class="icon iconfont icon-look" @click="showEmoji=!showEmoji"></i>
<img class="icon-img" align="absmiddle" src="static/icon-img/folder-open.png" alt="">
<img class="icon-img" align="absmiddle" src="static/icon-img/link.png" alt="">
<img class="icon-img" align="absmiddle" src="static/icon-img/tag.png" alt="">
<img class="icon-img" align="absmiddle" src="static/icon-img/retweet.png" alt="" @click="transfer">
<img class="icon-img" align="absmiddle" src="static/icon-img/poweroff.png" alt="" @click="closeSession">
<transition name="showbox">
<div class="emojiBox" v-show="showEmoji">
<li v-for="(item, index) in emojis">
......@@ -20,6 +25,31 @@
<div class="description">不能发送空白信息</div>
</div>
</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
v-for="group in options3"
:key="group.label"
:label="group.label">
<el-option
v-for="item in group.options"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-option-group>
</el-select>
</div>
<span slot="footer" class="dialog-footer">
<el-button @click="dialogVisible = false">取 消</el-button>
<el-button type="primary" @click="dialogVisible = false">确 定</el-button>
</span>
</el-dialog>
</div>
</template>
......@@ -33,6 +63,33 @@ export default {
frequency: 0,
warn: false,
showEmoji: false,
dialogVisible:false,
options3: [{
label: '售前',
options: [{
value: 'Shanghai',
label: '随机转机'
}, {
value: 'Beijing',
label: '张辅导费'
}]
}, {
label: '售中',
options: [{
value: 'Chengdu',
label: '随机抓捏'
}, {
value: 'Shenzhen',
label: '深圳'
}, {
value: 'Guangzhou',
label: '广州'
}, {
value: 'Dalian',
label: '大连'
}]
}],
value7: ''
};
},
computed: {
......@@ -46,6 +103,58 @@ export default {
},
methods: {
// 按回车发送信息
closeSession(){
this.$confirm('确定要结束对话吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.$message({
type: 'success',
message: '已结束!'
});
}).catch(() => {
// this.$message({
// type: 'info',
// message: '已取消删'
// });
});
},
transfer(){
this.dialogVisible = true
// let transfers = `
// `
// this.$alert(transfers, 'HTML 片段', {
// dangerouslyUseHTMLString: true
// });
// let transfers = `
// <el-collapse v-model="activeNames" @change="handleChange">
// <el-collapse-item title="一致性 Consistency" name="1">
// <el-row>
// <el-col :span="24"><div class="grid-content bg-purple-dark"></div></el-col>
// </el-row>
// </el-collapse-item>
// </el-collapse>
// `
// this.$confirm(transfers, '选择转接对象', {
// dangerouslyUseHTMLString: true,
// confirmButtonText: '确定',
// cancelButtonText: '取消',
// type: 'warning',
// center: true
// }).then(() => {
// this.$message({
// type: 'success',
// message: '删除成功!'
// });
// }).catch(() => {
// this.$message({
// type: 'info',
// message: '已取消删除'
// });
// });
},
onKeyup (e) {
if ( e.keyCode === 13 ) {
this.send()
......@@ -124,6 +233,12 @@ export default {
padding: 0 30px
box-sizing: border-box
color: #7c7c7c
.icon-img
width:20px;
height:20px;
position: relative;
top: 3px;
right: -5px;
.icon-look
cursor: pointer
&:hover
......
......@@ -70,4 +70,5 @@ export default{
width:100%;
height:729px;
overflow-y: auto;
overflow-x: hidden;
</style>
\ No newline at end of file
......@@ -8,6 +8,17 @@
<span v-if="index!=0" style="color: #007dfd">{{ite.value}}</span>
<span v-if="index==0">{{ite.value}}</span>
</div>
<el-card class="box-card" v-for="(itey) in item.dataPanel">
<div slot="header" class="clearfix">
<span>{{itey.title}}</span>
</div>
<div style="margin-bottom:20px; " v-for="(itet,o) in itey.dataItem" :key="o" class="text item">
<div v-for="(it,o) in itet">
<span>{{it.label}}:</span>
<span>{{it.value}}</span>
</div>
</div>
</el-card>
</el-collapse-item>
</el-collapse>
</div>
......@@ -49,23 +60,125 @@ export default{
]
},
{
title:'个人待办事项',
numItem:[
title:'客机统计',
dataPanel:[
{
label:'诊断方案未发送',
value:54
},
{
label:'诊断方案未确认',
value:54
title:'客机:robot1',
dataItem:[
[
{
label:'今日新粉丝咨询量',
value:0
},
{
label:'今日新粉丝收货单量',
value:0
},
{
label:'今日新粉丝转化率',
value:0
},
{
label:'今日新粉丝预收货货值',
value:0
},
],
[
{
label:'今日新粉丝咨询量',
value:0
},
{
label:'今日新粉丝收货单量',
value:0
},
{
label:'今日新粉丝转化率',
value:0
},
{
label:'今日新粉丝预收货货值',
value:0
},
],
[
{
label:'今日新粉丝咨询量',
value:0
},
{
label:'今日新粉丝收货单量',
value:0
},
{
label:'今日新粉丝转化率',
value:0
},
{
label:'今日新粉丝预收货货值',
value:0
},
]
]
},
{
label:'效果方案未发送',
value:54
},
{
label:'效果方案未确认',
value:54
title:'客机:robot2',
dataItem:[
[
{
label:'今日新粉丝咨询量',
value:0
},
{
label:'今日新粉丝收货单量',
value:0
},
{
label:'今日新粉丝转化率',
value:0
},
{
label:'今日新粉丝预收货货值',
value:0
},
],
[
{
label:'今日新粉丝咨询量',
value:0
},
{
label:'今日新粉丝收货单量',
value:0
},
{
label:'今日新粉丝转化率',
value:0
},
{
label:'今日新粉丝预收货货值',
value:0
},
],
[
{
label:'今日新粉丝咨询量',
value:0
},
{
label:'今日新粉丝收货单量',
value:0
},
{
label:'今日新粉丝转化率',
value:0
},
{
label:'今日新粉丝预收货货值',
value:0
},
]
]
}
]
},
......
<template>
<div class="tabs-body">
<el-tabs type="border-card" v-model="activeName" @tab-click="handleClick">
<el-tab-pane label="顾客" name="first">
<el-tab-pane label="看板" name="second">
<div class="tool-body">
<cuss-service></cuss-service>
<cus-users></cus-users>
</div>
</el-tab-pane>
<el-tab-pane label="看板" name="second">
<el-tab-pane label="顾客" name="first">
<div class="tool-body">
<cus-users></cus-users>
<cuss-service></cuss-service>
</div>
</el-tab-pane>
<el-tab-pane label="话术" name="third">
......
<template>
<div class="tabs-body">
<el-tabs type="border-card" v-model="activeName" @tab-click="handleClick">
<el-tab-pane label="顾客" name="first">
<div class="tool-body">
<cuss-service></cuss-service>
</div>
</el-tab-pane>
<el-tab-pane label="看板" name="second">
<div class="tool-body">
<cus-users></cus-users>
</div>
</el-tab-pane>
<el-tab-pane label="话术" name="third">
<div class="tool-body">
<takel-script></takel-script>
</div>
</el-tab-pane>
<el-tab-pane label="表情包" name="fourth">
<div class="tool-body">
<doutu-picture></doutu-picture>
</div>
</el-tab-pane>
<el-tab-pane label="对比图" name="fivth">
<div class="tool-body">
<compre-picture></compre-picture>
</div>
</el-tab-pane>
<el-tab-pane label="其他" name="sixth"><div class="tool-body">用户管理</div></el-tab-pane>
</el-tabs>
<div style="margin:50px;" v-if="false">
<el-form :model="ruleForm2" status-icon :rules="rules2" ref="ruleForm2" class="demo-ruleForm">
<el-form-item prop="pass">
<el-input type="password" placeholder="登录名" v-model="ruleForm2.pass" auto-complete="off"></el-input>
</el-form-item>
<el-form-item prop="checkPass">
<el-input type="password" placeholder="密码" v-model="ruleForm2.checkPass" auto-complete="off"></el-input>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="submitForm('ruleForm2')">登录</el-button>
</el-form-item>
</el-form>
</div>
<baozheng v-if="false"/>
<chenzheng v-if="true"/>
</div>
</template>
<script>
import cussService from './cus-service'
import cusUsers from './cus-users'
import takelScript from './takel-script'
import doutuPicture from './doutu-picture'
import comparisonMap from './comparison-map'
import comprePicture from './compre-picture'
import labelUserList from './label-userList'
import baozheng from './baozheng'
import chenzheng from './chenzheng'
export default{
data(){
return {
activeName:'second',
ruleForm2:{}
}
},
components: {
cussService,
cusUsers,
takelScript,
doutuPicture,
comparisonMap,
comprePicture,
labelUserList
baozheng,
chenzheng,
},
methods: {
handleClick(){
......
......@@ -4,7 +4,6 @@ import Router from 'vue-router'
Vue.use(Router)
const router = new Router({
// 共三个页面: 聊天页面,好友页面,个人简历分别对应一下路由
routes: [
{
path: '/chat',
......
const getters = {
searchedChatlist (state) {
let sessions = state.user.chatlist.filter(sessions => sessions.user.name.includes(state.user.searchText));
return sessions
},
// 筛选出含有搜索值的好友列表
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
},
// 通过当前选择是哪个好友匹配相应的好友
selectedFriend (state) {
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
}
}
export default getters
\ No newline at end of file
import Vue from 'vue'
import Vuex from 'vuex'
import user from './modules/user'
import getters from './getters'
Vue.use(Vuex)
const store = new Vuex.Store({
modules: {
user,
},
getters
})
store.watch(
(state) => state.user.chatlist,
(val) => {
localStorage.setItem('vue-chat', JSON.stringify(val));
},
{
deep: true
}
)
export default store
\ No newline at end of file
// import * as service from '@/api/car'
const now = new Date();
const user = {
state: {
name: 'ratel',
img: 'static/images/UserAvatar.jpg',
chatlist: [
{
id: 1,
user: {
name: '妈咪',
img: 'static/images/mother.jpg'
},
messages: [
{
content: '么么哒,妈咪爱你', //聊天内容
date: now //时间
},
{
content: '按回车可以发送信息,还可以给我发送表情哟',
date: now
}
],
index: 1 // 当前在聊天列表中的位置,从1开始
},
{
id: 2,
user: {
name: 'father',
img: 'static/images/father.jpg'
},
messages: [
{
content: 'Are you kidding me?',
date: now
}
],
index: 2
},
{
id: 3,
user: {
name: '机器人',
img: 'static/images/vue.jpg'
},
messages: [
{
content: '我会跟你聊聊天的哟',
date: now
}
],
index: 3
}
],
// 好友列表
friendlist: [
{
id: 0,
wxid: "", //微信号
initial: '新的朋友', //姓名首字母
img: 'static/images/newfriend.jpg', //头像
signature: "", //个性签名
nickname: "新的朋友", //昵称
sex: 0, //性别 1为男,0为女
remark: "新的朋友", //备注
area: "", //地区
},
{
id: 1,
wxid: "AmorAres-", //微信号
initial: 'A', //姓名首字母
img: 'static/images/小姨妈.jpg', //头像
signature: "每天我就萌萌哒", //个性签名
nickname: "Amor", //昵称
sex: 0, //性别 1为男,0为女
remark: "Amor", //备注
area: "浙江 宁波", //地区
},
{
id: 2,
wxid: "Big-fly",
initial: 'B',
img: 'static/images/大飞哥.jpg',
signature: "你不知道的js",
nickname: "fly",
sex: 1,
remark: "大飞哥",
area: "奥地利 布尔根兰",
},
{
id: 3,
wxid: "microzz",
initial: 'D',
img: 'static/images/microzz.jpg',
signature: "学习让我快乐让我成长",
nickname: "microzz",
sex: 1,
remark: "大佬",
area: "江西 赣州",
},
{
id: 4,
wxid: "hwn0366",
initial: 'F',
img: 'static/images/father.jpg',
signature: "学习让我快乐让我成长",
nickname: "丢",
sex: 1,
remark: "father",
area: "江西 抚州",
},
{
id: 5,
wxid: "orange66",
initial: 'J',
img: 'static/images/orange.jpg',
signature: "你可以笑的很阳光!",
nickname: "orange",
sex: 1,
remark: "橘子",
area: "江西 赣州",
},
{
id: 6,
wxid: "Seto_L",
img: 'static/images/加菲猫.jpg',
signature: "自强不息",
nickname: "21",
sex: 1,
remark: "加菲",
area: "北京 海淀",
},
{
id: 7,
wxid: "wxid_itjz73t1ajt722",
initial: 'M',
img: 'static/images/mother.jpg',
signature: "开开心心就好",
nickname: "娄娄",
sex: 0,
remark: "妈咪",
area: "江西 抚州",
},
{
id: 8,
wxid: "hj960503",
img: 'static/images/萌萌俊.jpg',
signature: "原谅我有点蠢。。",
nickname: "。。。。。",
sex: 1,
remark: "萌萌均",
area: "江西 萍乡",
}
],
//emoji表情
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 }
],
// 得知当前选择的是哪个对话
selectId: 1,
// 得知当前选择的是哪个好友
selectFriendId: 0
},
mutations: {
initData (state) {
let data = localStorage.getItem('vue-chat');
if (data) {
state.chatlist = JSON.parse(data);
}
},
// 获取搜索值
search (state, value) {
state.searchText = value
},
// 得知用户当前选择的是哪个对话。便于匹配对应的对话框
selectSession (state, value) {
state.selectId = value
},
// 得知用户当前选择的是哪个好友。
selectFriend (state, value) {
state.selectFriendId = value
},
// 发送信息
sendMessage (state, msg){
let result = state.chatlist.find(session => session.id === state.selectId);
result.messages.push({
content: msg.content,
date: new Date(),
self: true
});
if(result.user.name === '机器人'){
setTimeout(() => {
result.messages.push({
content: msg.reply,
date: new Date(),
self: false
});
},500)
}
},
// 选择好友后,点击发送信息。判断在聊天列表中是否有该好友,有的话跳到该好友对话。没有的话
// 添加该好友的对话 并置顶
send (state) {
let result = state.friendlist.find(friend => friend.id === state.selectFriendId)
let msg = state.chatlist.find(msg => msg.user.name === result.remark)
if( !msg ){
state.selectId = 1
for(let i = 0; i < state.chatlist.length; i++ ){
state.chatlist[i].id++;
state.chatlist[i].index++;
}
state.chatlist.unshift({
id: 1,
user: {
name: result.remark,
img: result.img
},
messages: [
{
content: '已经置顶聊天,可以给我发信息啦!',
date: new Date()
}
],
index: 1
})
}else {
state.selectId = msg.index
router.push({ path: '/chat'})
}
}
},
actions: {
search: ({ commit }, value) => {
setTimeout(() => {
commit('search', value)
}, 100)
},
selectSession: ({ commit }, value) => commit('selectSession', value),
selectFriend: ({ commit }, value) => commit('selectFriend', value),
sendMessage: ({ commit }, msg) => commit('sendMessage', msg),
send: ({ commit }) => commit('send'),
initData: ({ commit }) => commit('initData')
}
}
export default user
\ No newline at end of file
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
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