Commit 1d78043a by liyuhang19990520

即时通讯需要修改的一系列功能

parent dac8cc05
/*
* @Author: your name
* @Date: 2021-08-20 16:31:17
* @LastEditTime: 2021-09-02 11:01:54
* @LastEditors: your name
* @Description: In User Settings Edit
* @FilePath: \founder_vue\babel.config.js
*/
module.exports = { module.exports = {
presets: ["@vue/cli-plugin-babel/preset"] presets: ["@vue/cli-plugin-babel/preset"],
"plugins": [
[
"component",
{
"libraryName": "element-ui",
"styleLibraryName": "theme-chalk"
}
]
]
}; };
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
"dependencies": { "dependencies": {
"core-js": "^3.6.4", "core-js": "^3.6.4",
"crypto-js": "^4.1.1", "crypto-js": "^4.1.1",
"element-ui": "^2.15.5",
"view-design": "^4.2.0", "view-design": "^4.2.0",
"vue": "^2.6.12", "vue": "^2.6.12",
"vue-router": "^3.1.6", "vue-router": "^3.1.6",
...@@ -29,6 +30,7 @@ ...@@ -29,6 +30,7 @@
"@vue/cli-service": "~4.3.0", "@vue/cli-service": "~4.3.0",
"@vue/eslint-config-prettier": "^6.0.0", "@vue/eslint-config-prettier": "^6.0.0",
"babel-eslint": "^10.1.0", "babel-eslint": "^10.1.0",
"babel-plugin-component": "^1.1.1",
"electron": "^8.0.0", "electron": "^8.0.0",
"eslint": "^6.7.2", "eslint": "^6.7.2",
"eslint-plugin-prettier": "^3.1.1", "eslint-plugin-prettier": "^3.1.1",
......
<!--
* @Author: your name
* @Date: 2021-09-02 10:28:43
* @LastEditTime: 2021-09-02 17:11:42
* @LastEditors: Please set LastEditors
* @Description: In User Settings Edit
* @FilePath: \founder_vue\src\App.vue
-->
<template> <template>
<div id="app"> <div id="app">
<router-view></router-view> <router-view></router-view>
</div> </div>
</template> </template>
<script>
export default {
name: "v-im"
};
</script>
<style lang="scss"> <style lang="scss">
html { html {
font-size: 12px; font-size: 12px;
......
/* /*
* @Author: your name * @Author: your name
* @Date: 2021-08-27 15:12:46 * @Date: 2021-08-27 15:12:46
* @LastEditTime: 2021-08-30 09:42:27 * @LastEditTime: 2021-09-02 16:30:39
* @LastEditors: your name * @LastEditors: Please set LastEditors
* @Description: In User Settings Edit * @Description: In User Settings Edit
* @FilePath: \founder_vue\src\main.js * @FilePath: \founder_vue\src\main.js
*/ */
...@@ -14,9 +14,13 @@ import ViewUI from "view-design"; ...@@ -14,9 +14,13 @@ import ViewUI from "view-design";
import "view-design/dist/styles/iview.css"; import "view-design/dist/styles/iview.css";
import { dateStr, formatDateTime } from "./utils/ChatUtils.js"; import { dateStr, formatDateTime } from "./utils/ChatUtils.js";
import cryptoJs from 'crypto-js'; import cryptoJs from 'crypto-js';
import { Icon,Loading } from 'element-ui';
Vue.use(Icon);
Vue.use(Loading);
Vue.config.productionTip = false; Vue.config.productionTip = false;
Vue.use(ViewUI); Vue.use(ViewUI);
Vue.prototype.$bus = new Vue()
Vue.prototype.$cryptoJs = cryptoJs; Vue.prototype.$cryptoJs = cryptoJs;
Vue.prototype.formatDateTime = formatDateTime; Vue.prototype.formatDateTime = formatDateTime;
Vue.prototype.dateStr = dateStr; Vue.prototype.dateStr = dateStr;
......
/*
* @Author: your name
* @Date: 2021-09-02 10:28:43
* @LastEditTime: 2021-09-02 16:48:31
* @LastEditors: your name
* @Description: In User Settings Edit
* @FilePath: \founder_vue\src\router\index.js
*/
import Vue from "vue"; import Vue from "vue";
import Router from "vue-router"; import Router from "vue-router";
import UserBox from "../views/im/layout/userBox.vue"; import UserBox from "../views/im/layout/userBox.vue";
import ChatBox from "../views/im/layout/chatBox.vue"; import ChatBox from "../views/im/layout/chatBox.vue";
import ChatGroupBox from "../views/im/layout/chatGroupBox.vue"; import ChatGroupBox from "../views/im/layout/chatGroupBox.vue";
import DeptBox from "../views/im/layout/deptBox.vue"; import DeptBox from "../views/im/layout/deptBox.vue";
import AddFriend from "../views/im/layout/addFriend.vue";
Vue.use(Router); Vue.use(Router);
...@@ -38,10 +47,20 @@ export default new Router({ ...@@ -38,10 +47,20 @@ export default new Router({
path: "chatGroupBox", path: "chatGroupBox",
name: "chatGroupBox", name: "chatGroupBox",
component: ChatGroupBox component: ChatGroupBox
} },
{
path: "addFriend",
name: "addFriend",
component: AddFriend
},
] ]
}, },
{ {
path: "/write",
name: "login-page",
component: () => import("@/views/write.vue")
},
{
path: "/", path: "/",
name: "login-page", name: "login-page",
component: require("@/views/login.vue").default component: require("@/views/login.vue").default
......
...@@ -23,12 +23,12 @@ body > div { ...@@ -23,12 +23,12 @@ body > div {
} }
.v-im { .v-im {
background-color: #fff;
width: 100%; width: 100%;
height: 100%; height: 100%;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
overflow-y: hidden; overflow-y: hidden;
background-color: #2590c2;
box-shadow: #aaaaaa 2px 2px 5px; box-shadow: #aaaaaa 2px 2px 5px;
} }
......
...@@ -378,7 +378,7 @@ export default { ...@@ -378,7 +378,7 @@ export default {
let str = "D:/temp"; let str = "D:/temp";
let fileUrl = json.data.fileUrl.replace(/\\/g, "/"); let fileUrl = json.data.fileUrl.replace(/\\/g, "/");
let url = let url =
"https://" + "http://" +
localStorage.getItem("host") + localStorage.getItem("host") +
":" + ":" +
conf.http_port + conf.http_port +
...@@ -388,7 +388,7 @@ export default { ...@@ -388,7 +388,7 @@ export default {
// 设置下载文件名 // 设置下载文件名
elink.download = '聊天记录.xls'; elink.download = '聊天记录.xls';
elink.style.display = "none"; elink.style.display = "none";
elink.href = URL.createObjectURL(blob); elink.href = url;
document.body.appendChild(elink); document.body.appendChild(elink);
elink.click(); elink.click();
document.body.removeChild(elink); document.body.removeChild(elink);
......
<template> <template>
<div> <div>
<Input <!-- <Input
search search
v-model="search" v-model="search"
placeholder="搜索" placeholder="搜索"
size="small" size="small"
class="search" class="search"
@on-focus="showSearch()" @on-focus="showSearch()"
/> /> -->
<div class="search-div" v-show="showSearchDiv"> <div class="search-div" v-show="showSearchDiv">
<div class="search-item"> <div class="search-item">
<Input <Input
......
<!--
* @Author: your name
* @Date: 2021-09-02 10:28:43
* @LastEditTime: 2021-09-02 10:44:09
* @LastEditors: your name
* @Description: In User Settings Edit
* @FilePath: \founder_vue\src\views\im\components\top.vue
-->
<template> <template>
<div class="im-top" style="-webkit-app-region: drag"> <div class="im-top" style="-webkit-app-region: drag">
<a <a
href="javascript:void(0)" href="javascript:void(0)"
@click="close"
style="-webkit-app-region: no-drag"
>
<Icon type="ios-close" class="text-right"></Icon>
</a>
<a
href="javascript:void(0)"
@click="max" @click="max"
style="-webkit-app-region: no-drag" style="-webkit-app-region: no-drag"
> >
<Icon :type="icon" class="text-right"></Icon> <Icon :type="icon" class="text-right"></Icon>
</a> </a>
<a
href="javascript:void(0)"
@click="min"
style="-webkit-app-region: no-drag"
>
<Icon type="ios-remove" class="text-right"></Icon>
</a>
</div> </div>
</template> </template>
<script> <script>
...@@ -28,7 +22,7 @@ export default { ...@@ -28,7 +22,7 @@ export default {
data() { data() {
return { return {
// 默认选中的值 // 默认选中的值
icon: "ios-square-outline" icon: "ios-browsers-outline",
}; };
}, },
methods: { methods: {
...@@ -44,8 +38,8 @@ export default { ...@@ -44,8 +38,8 @@ export default {
}, },
close() { close() {
this.winControl.close(); this.winControl.close();
} },
} },
}; };
</script> </script>
<style lang="scss"> <style lang="scss">
......
<!--
* @Author: your name
* @Date: 2021-09-02 10:28:43
* @LastEditTime: 2021-09-02 10:43:55
* @LastEditors: Please set LastEditors
* @Description: In User Settings Edit
* @FilePath: \founder_vue\src\views\im\components\welcome.vue
-->
<template> <template>
<div class="welcome-message"> <div class="welcome-message">
<img src="~@/static/icon.png" alt="icon" /> <img src="~@/static/logo.png" alt="icon" />
</div> </div>
</template> </template>
<script> <script>
...@@ -17,8 +25,8 @@ export default { ...@@ -17,8 +25,8 @@ export default {
text-align: center; text-align: center;
vertical-align: middle; vertical-align: middle;
& > img { & > img {
width: 12rem; width: 8rem;
margin-top: 10rem; margin-top: 40rem;
} }
} }
</style> </style>
/* /*
* @Author: your name * @Author: your name
* @Date: 2021-08-20 16:31:17 * @Date: 2021-08-20 16:31:17
* @LastEditTime: 2021-09-01 10:22:31 * @LastEditTime: 2021-09-02 17:30:25
* @LastEditors: Please set LastEditors * @LastEditors: Please set LastEditors
* @Description: In User Settings Edit * @Description: In User Settings Edit
* @FilePath: \V-IM-PC\src\views\im\conf\index.js * @FilePath: \V-IM-PC\src\views\im\conf\index.js
...@@ -25,16 +25,16 @@ export default { ...@@ -25,16 +25,16 @@ export default {
chatGroupUserDsh_url: '/api/chatGroupUser/dsh', chatGroupUserDsh_url: '/api/chatGroupUser/dsh',
chatGroupUserAgree_url: '/api/chatGroupUser/agree', chatGroupUserAgree_url: '/api/chatGroupUser/agree',
chatGroupDelUser_url: '/api/chatGroupUser/delete', chatGroupDelUser_url: '/api/chatGroupUser/delete',
chatGroupgetUser_url: '/api/user/getUser',
export_url: '/api/message/export', export_url: '/api/message/export',
ws_protocol: "ws", ws_protocol: "ws",
getHostUrl: function () { getHostUrl: function () {
return ( return (
// this.http_protocol + this.http_protocol +
// "://" + "://" +
// localStorage.getItem("host") + localStorage.getItem("host") +
// ":" + ":" +
// this.http_port this.http_port
"http://110.1.6.3:8084"
); );
}, },
getTokenUrl: function () { getTokenUrl: function () {
...@@ -85,6 +85,9 @@ export default { ...@@ -85,6 +85,9 @@ export default {
getExportUrl: function () { getExportUrl: function () {
return this.getHostUrl() + this.export_url; return this.getHostUrl() + this.export_url;
}, },
getUserUrl: function () {
return this.getHostUrl() + this.chatGroupgetUser_url;
},
getWsUrl: function () { getWsUrl: function () {
return ( return (
this.ws_protocol + this.ws_protocol +
......
<!--
* @Author: your name
* @Date: 2021-09-02 11:09:54
* @LastEditTime: 2021-09-02 11:50:03
* @LastEditors: Please set LastEditors
* @Description: In User Settings Edit
* @FilePath: \founder_vue\src\views\im\layout\AddFriend.vue
-->
<template>
<div>11</div>
</template>
<script>
export default {
data() {
return {
userId: ''
};
},
methods: {
addFriend(user) {
let param = new FormData();
param.append("userId", this.userId);
param.append("friendId", this.user.id);
RequestUtils.request(conf.getRegisterUrl(), param)
.then((json) => {
if (json.code == 200) {
this.$Message.success("添加成功");
this.getFriendList();
} else if (json.code == 202) {
this.$Message.warning("已添加该好友不能重复添加");
} else if (json.code == 201) {
this.$Message.error("添加失败");
}
})
.catch((err) => {
console.error(err);
});
console.log();
console.log(user);
},
},
created(){
this.userId = this.$store.state.user.id;
}
};
</script>
<style lang="scss" scoped>
</style>
\ No newline at end of file
...@@ -88,6 +88,8 @@ export default { ...@@ -88,6 +88,8 @@ export default {
if (json.code == 200) { if (json.code == 200) {
this.$Message.success("添加成功"); this.$Message.success("添加成功");
this.getFriendList(); this.getFriendList();
} else if (json.code == 202) {
this.$Message.warning("已添加该好友不能重复添加");
} else if (json.code == 201) { } else if (json.code == 201) {
this.$Message.error("添加失败"); this.$Message.error("添加失败");
} }
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
<ul class="user-list"> <ul class="user-list">
<li class="user" v-for="(user, index) in userFriendList" :key="index"> <li class="user" v-for="(user, index) in userFriendList" :key="index">
<a href="javascript:;" @click="showUser(user)"> <a href="javascript:;" @click="showUser(user)">
<img :src="host + user.avatar" /> <img :src="host1 + user.avatar" />
<b>{{ user.name }}</b> <b>{{ user.name }}</b>
<p>{{ user.sign }}</p> <p>{{ user.sign }}</p>
</a> </a>
...@@ -32,7 +32,6 @@ import Welcome from "../components/welcome.vue"; ...@@ -32,7 +32,6 @@ import Welcome from "../components/welcome.vue";
import UserInfo from "../components/userInfo.vue"; import UserInfo from "../components/userInfo.vue";
import conf from "../conf"; import conf from "../conf";
import { MessageTargetType } from "../../../utils/ChatUtils"; import { MessageTargetType } from "../../../utils/ChatUtils";
const { ChatListUtils } = require("../../../utils/ChatUtils.js"); const { ChatListUtils } = require("../../../utils/ChatUtils.js");
export default { export default {
...@@ -40,32 +39,33 @@ export default { ...@@ -40,32 +39,33 @@ export default {
Search, Search,
Top, Top,
Welcome, Welcome,
UserInfo UserInfo,
}, },
computed: { computed: {
userFriendList: { userFriendList: {
get: function() { get: function () {
return this.$store.state.userFriendList; return this.$store.state.userFriendList;
}, },
set: function(userFriendList) { set: function (userFriendList) {
this.$store.commit("setUserFriendList", userFriendList); this.$store.commit("setUserFriendList", userFriendList);
} },
} },
}, },
data() { data() {
return { return {
chat: {}, chat: {},
user: {}, user: {},
currentUser: {}, currentUser: {},
host: conf.getHostUrl(), host1: conf.getHostUrl(),
userFriends: [], userFriends: [],
first: true first: true,
boo: false,
uap: "",
}; };
}, },
methods: { methods: {
// 打开一个聊天对话框 // 打开一个聊天对话框
showChat: function(user) { showChat: function (user) {
let self = this; let self = this;
self.$router.push({ self.$router.push({
path: "/index/chatBox/", path: "/index/chatBox/",
...@@ -75,21 +75,24 @@ export default { ...@@ -75,21 +75,24 @@ export default {
user, user,
conf.getHostUrl(), conf.getHostUrl(),
MessageTargetType.FRIEND MessageTargetType.FRIEND
) ),
} },
}); });
}, },
// 打开一个用户信息对话框 // 打开一个用户信息对话框
showUser: function(user) { showUser: function (user) {
let self = this; let self = this;
self.$router.push({ self.$router.push({
path: "/index/userBox/" path: "/index/userBox/",
}); });
self.first = false; self.first = false;
self.user = user; self.user = user;
} },
} },
created() {
this.uap = this.$route.query.uap;
},
}; };
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
......
...@@ -28,8 +28,10 @@ ...@@ -28,8 +28,10 @@
<li title="创建群聊" @click="modal10 = true"> <li title="创建群聊" @click="modal10 = true">
<Icon type="ios-color-filter-outline"></Icon> <Icon type="ios-color-filter-outline"></Icon>
</li> </li>
<li title="退出" class="logout" @click="myLogout"> <li title="添加好友" class="addFriend">
<Icon type="ios-power-outline" /> <a href="javascript:void(0)" @click="modal11 = true">
<i class="el-icon-plus"></i>
</a>
</li> </li>
</ul> </ul>
</div> </div>
...@@ -82,6 +84,51 @@ ...@@ -82,6 +84,51 @@
></span> ></span>
</p> </p>
</Modal> </Modal>
<Modal
title="添加好友"
v-model="modal11"
class-name="vertical-center-modal"
@on-ok="saveGroup"
:loading="loading"
>
<p class="user-model-item">
<label>输入手机号:</label>
<span
><Input
v-model="value1"
placeholder="请输入..."
style="width: 300px; border: 1px solid #dcdee2"
></Input
></span>
<span class="search" @click="search">
<i class="el-icon-zoom-in"></i>
</span>
</p>
<div v-loading="loading1">
<div class="person" v-if="obj.name">
<div>
<div>
<img :src="host + obj.avatar" alt="" />
<div class="infor">
<p>姓名:{{ obj.name }}</p>
<p>手机号:{{ obj.mobile }}</p>
<p>邮箱:{{ obj.email }}</p>
</div>
</div>
<div class="addBtn">
<Button type="primary" @click="addFriend()">添加</Button>
</div>
</div>
</div>
<div v-else class="noneData">
<p>暂无数据</p>
</div>
</div>
<template slot="footer">
<div></div>
</template>
</Modal>
</div> </div>
</template> </template>
<script> <script>
...@@ -95,8 +142,14 @@ export default { ...@@ -95,8 +142,14 @@ export default {
user: {}, user: {},
modal: false, modal: false,
modal10: false, modal10: false,
modal11: false,
loading: true, loading: true,
loading1: false,
value: "", value: "",
userId: "",
value1: "",
obj: {},
host: conf.getHostUrl(),
}; };
}, },
methods: { methods: {
...@@ -146,12 +199,64 @@ export default { ...@@ -146,12 +199,64 @@ export default {
}); });
} }
}, },
getFriendList() {
RequestUtils.request(conf.getFriendListUrl())
.then((json) => {
if (json.code == 200) {
this.$store.commit("setUserFriendList", json.data.friends);
} else if (json.code == 201) {
this.$Message.error("列表获取失败");
}
})
.catch((err) => {
console.error(err);
});
},
search() {
let param = new FormData();
param.append("mobile", this.value1);
this.loading1 = true;
RequestUtils.request(conf.getUserUrl(), param)
.then((json) => {
if (json.code == 200) {
this.obj = json.data.user;
} else {
this.obj = {};
}
this.loading1 = false;
})
.catch((err) => {
console.error(err);
});
},
addFriend() {
let param = new FormData();
param.append("userId", this.userId);
param.append("friendId", this.obj.id);
RequestUtils.request(conf.getRegisterUrl(), param)
.then((json) => {
if (json.code == 200) {
this.$Message.success("添加成功");
this.getFriendList();
} else if (json.code == 202) {
this.$Message.warning("已添加该好友不能重复添加");
} else if (json.code == 201) {
this.$Message.error("添加失败");
}
})
.catch((err) => {
console.error(err);
});
},
}, },
created: function () { created: function () {
RequestUtils.webSocketOperation(this);
this.user = this.$store.state.user; this.user = this.$store.state.user;
this.userId = this.$store.state.user.id;
},
mounted: function () {
let self = this;
RequestUtils.webSocketOperation(self);
}, },
mounted: function () {},
}; };
</script> </script>
<style lang="scss"> <style lang="scss">
...@@ -161,7 +266,7 @@ export default { ...@@ -161,7 +266,7 @@ export default {
.v-im { .v-im {
display: flex; display: flex;
flex-direction: row; flex-direction: row;
background-color: #fff;
.left-bar { .left-bar {
background-color: #1c2438; background-color: #1c2438;
width: 6rem; width: 6rem;
...@@ -215,9 +320,68 @@ export default { ...@@ -215,9 +320,68 @@ export default {
} }
} }
} }
.addFriend {
font-size: 25px;
}
.content { .content {
flex: 1; flex: 1;
} }
a {
color: #666666;
&:hover {
color: #fff;
}
}
}
.el-icon-zoom-in {
font-size: 17px;
color: #fff;
}
.search {
padding: 8px;
border-radius: 5px;
cursor: pointer;
background-color: #409eff;
border: 1px solid #dcdee2;
margin-left: 10px;
}
.person {
margin-top: 15px;
padding-top: 10px;
border-top: 1px solid #dcdee2;
> div {
display: flex;
padding: 10px;
justify-content: space-around;
> div {
display: flex;
align-items: center;
}
img {
width: 80px;
height: 80px;
}
.infor {
margin-left: 20px;
display: flex;
flex-flow: column;
justify-content: space-around;
> p {
margin-bottom: 5px;
}
}
> .addBtn {
vertical-align: middle;
margin-left: 20px;
display: flex;
align-items: center;
}
}
}
.noneData {
text-align: center;
margin-top: 20px;
border-top: 1px solid #dcdee2;
padding-top: 16px;
} }
</style> </style>
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<div class="login"> <div class="login">
<Top></Top> <Top></Top>
<div class="logo"> <div class="logo">
<img src="~@/static/icon.png" alt="icon" /> <img src="~@/static/logo.png" alt="icon" />
</div> </div>
<div class="login-panel" style="-webkit-app-region: no-drag"> <div class="login-panel" style="-webkit-app-region: no-drag">
<div class="title">{{ app_name }} 登录</div> <div class="title">{{ app_name }} 登录</div>
...@@ -38,15 +38,15 @@ ...@@ -38,15 +38,15 @@
<div class="btn item"> <div class="btn item">
<Button type="primary" @click="login()" icon="md-contact">登录</Button> <Button type="primary" @click="login()" icon="md-contact">登录</Button>
</div> </div>
<div class="item register"> <!-- <div class="item register">
<a type="info" class="pull-right" @click="showRegister = true"> <a type="info" class="pull-right" @click="showRegister = true">
<Icon type="ios-cloud-circle" /> <Icon type="ios-cloud-circle" />
<span>注册</span> <span>注册</span>
</a> </a>
</div> </div> -->
</div> </div>
<Modal <!-- <Modal
closable closable
class="user-model" class="user-model"
v-model="showRegister" v-model="showRegister"
...@@ -74,7 +74,7 @@ ...@@ -74,7 +74,7 @@
style="margin: 1rem 0" style="margin: 1rem 0"
>保存</Button >保存</Button
> >
</Modal> </Modal> -->
</div> </div>
</template> </template>
...@@ -99,7 +99,7 @@ export default { ...@@ -99,7 +99,7 @@ export default {
showErr: false, showErr: false,
showSetting: false, showSetting: false,
showRegister: false, showRegister: false,
host: "110.1.6.3:8084", host: "192.168.0.106",
uap: "", uap: "",
}; };
}, },
...@@ -107,43 +107,37 @@ export default { ...@@ -107,43 +107,37 @@ export default {
Top, Top,
}, },
methods: { methods: {
open() { // saveRegister: function () {
this.winControl.openURL("https://gitee.com/lele-666/V-IM"); // let self = this;
}, // if (!/^1[34578]\d{9}$/.test(self.registerPhone)) {
clickUser() { // self.$Message.error("手机号码有误,请重填");
location.reload(); // return;
}, // }
saveRegister: function () { // let formData = new FormData();
let self = this; // // 请求参数 ('key',value)
if (!/^1[34578]\d{9}$/.test(self.registerPhone)) { // formData.set("phone", self.registerPhone);
self.$Message.error("手机号码有误,请重填"); // formData.set("name", self.registerUsername);
return; // formData.set("password", self.registerPassword);
} // fetch(conf.getRegisterUrl(), {
let formData = new FormData(); // method: "POST",
// 请求参数 ('key',value) // model: "cros", //跨域
formData.set("phone", self.registerPhone); // headers: {
formData.set("name", self.registerUsername); // Accept: "application/json",
formData.set("password", self.registerPassword); // },
fetch(conf.getRegisterUrl(), { // body: formData,
method: "POST", // })
model: "cros", //跨域 // .then((json) => {
headers: { // if (json.code) {
Accept: "application/json", // self.$Message.error(json.message);
}, // } else {
body: formData, // self.$Message.success("注册成功");
}) // self.showRegister = false;
.then((json) => { // }
if (json.code) { // })
self.$Message.error(json.message); // .catch(() => {
} else { // self.$Message.error("与服务器通讯失败");
self.$Message.success("注册成功"); // });
self.showRegister = false; // },
}
})
.catch(() => {
self.$Message.error("与服务器通讯失败");
});
},
login: function () { login: function () {
let self = this; let self = this;
let requestApi = RequestUtils; let requestApi = RequestUtils;
...@@ -214,6 +208,28 @@ export default { ...@@ -214,6 +208,28 @@ export default {
}); });
return encrypted.ciphertext.toString().toUpperCase(); return encrypted.ciphertext.toString().toUpperCase();
}, },
//判断方法
toLogin() {
if (this.uap) {
let data = this.Decrypt(this.uap);
console.log(data);
let arr = data.split("&");
arr.forEach((i, index) => {
arr[index] = i.split("=");
});
arr.forEach((i, s) => {
i.forEach((j, index) => {
if (j == "username") {
this.username = arr[s][index + 1];
} else if (j == "password") {
this.password = arr[s][index + 1];
}
});
});
console.log(this.username, this.password);
this.login();
}
},
}, },
created: function () { created: function () {
this.uap = this.$route.query.uap; this.uap = this.$route.query.uap;
...@@ -221,25 +237,7 @@ export default { ...@@ -221,25 +237,7 @@ export default {
localStorage.setItem("host", self.host); localStorage.setItem("host", self.host);
}, },
mounted() { mounted() {
if (this.uap) { this.toLogin();
let data = this.Decrypt(this.uap);
console.log(data);
let arr = data.split("&");
arr.forEach((i, index) => {
arr[index] = i.split("=");
});
arr.forEach((i, s) => {
i.forEach((j, index) => {
if (j == "username") {
this.username = arr[s][index + 1];
} else if (j == "password") {
this.password = arr[s][index + 1];
}
});
});
console.log(this.username, this.password);
this.login();
}
}, },
}; };
</script> </script>
......
<template>
<div class="box" v-loading="true"></div>
</template>
<script>
import Top from "./im/components/top.vue";
import conf from "./im/conf";
import RequestUtils from "../utils/RequestUtils";
import StoreUtils from "../utils/StoreUtils";
import { ErrorType } from "../utils/ChatUtils";
const CryptoJS = require("crypto-js"); //引用AES源码js
export default {
name: "login",
data() {
return {
app_name: conf.app_name,
username: "wangwu",
password: "123456",
registerPhone: "",
registerUsername: "",
registerPassword: "",
err: "",
showErr: false,
showSetting: false,
showRegister: false,
host: "192.168.0.106",
uap: "",
};
},
components: {
Top,
},
methods: {
login: function () {
let self = this;
let requestApi = RequestUtils;
requestApi
.login(self.username.trim(), self.password.trim(), self)
.then((token) => {
StoreUtils.setToken(token);
// 获取当前登录的用户,存入store
return requestApi.request(conf.getInitUrl(), new FormData());
})
.then((json) => {
console.log(json);
//个人信息
self.$store.commit("setUser", json.me);
//好友
self.$store.commit("setUserFriendList", json.friends);
//群
self.$store.commit("setChatGroupList", json.groups);
//把群组封装到map中
let chatMap = new Map();
json.groups.forEach((group) => {
chatMap.set(group.id, group);
});
self.$store.commit("setChatMap", chatMap);
// 跳转到index 页面
self.$router.push({
path: "/index/chatBox",
params: {},
});
})
.catch(function (error) {
console.error(error);
self.showErr = true;
if (ErrorType.NET_ERROR === error.toString()) {
self.err = "服务通讯失败,请检查服务设置";
} else {
self.err = error.toString();
}
});
},
//解密方法
Decrypt(word) {
const key = CryptoJS.enc.Utf8.parse("0000000671595991"); //十六位十六进制数作为密钥
const iv = CryptoJS.enc.Utf8.parse("tdrdadq59tbss5n7"); //十六位十六进制数作为密钥偏移量
let encryptedHexStr = CryptoJS.enc.Hex.parse(word);
let srcs = CryptoJS.enc.Base64.stringify(encryptedHexStr);
let decrypt = CryptoJS.AES.decrypt(srcs, key, {
iv: iv,
mode: CryptoJS.mode.CBC,
padding: CryptoJS.pad.Pkcs7,
});
let decryptedStr = decrypt.toString(CryptoJS.enc.Utf8);
return decryptedStr.toString();
},
//加密方法
Encrypt(word) {
const key = CryptoJS.enc.Utf8.parse("0000000671595991"); //十六位十六进制数作为密钥
const iv = CryptoJS.enc.Utf8.parse("tdrdadq59tbss5n7"); //十六位十六进制数作为密钥偏移量
let srcs = CryptoJS.enc.Utf8.parse(word);
let encrypted = CryptoJS.AES.encrypt(srcs, key, {
iv: iv,
mode: CryptoJS.mode.CBC,
padding: CryptoJS.pad.Pkcs7,
});
return encrypted.ciphertext.toString().toUpperCase();
},
//判断方法
toLogin() {
if (this.uap) {
let data = this.Decrypt(this.uap);
console.log(data);
let arr = data.split("&");
arr.forEach((i, index) => {
arr[index] = i.split("=");
});
arr.forEach((i, s) => {
i.forEach((j, index) => {
if (j == "username") {
this.username = arr[s][index + 1];
} else if (j == "password") {
this.password = arr[s][index + 1];
}
});
});
console.log(this.username, this.password);
setTimeout(() => {
this.login();
}, 1000);
}
},
},
created: function () {
this.uap = this.$route.query.uap;
let self = this;
localStorage.setItem("host", self.host);
},
mounted() {
this.toLogin();
},
};
</script>
<style lang="scss" scoped>
.box {
width: 100%;
height: 100vh;
}
</style>
...@@ -140,6 +140,14 @@ ...@@ -140,6 +140,14 @@
dependencies: dependencies:
"@babel/types" "^7.12.7" "@babel/types" "^7.12.7"
"@babel/helper-module-imports@7.0.0-beta.35":
version "7.0.0-beta.35"
resolved "https://registry.yarnpkg.com/@babel/helper-module-imports/-/helper-module-imports-7.0.0-beta.35.tgz#308e350e731752cdb4d0f058df1d704925c64e0a"
integrity sha512-vaC1KyIZSuyWb3Lj277fX0pxivyHwuDU4xZsofqgYAbkDxNieMg2vuhzP5AgMweMY7fCQUMTi+BgPqTLjkxXFg==
dependencies:
"@babel/types" "7.0.0-beta.35"
lodash "^4.2.0"
"@babel/helper-module-imports@^7.0.0", "@babel/helper-module-imports@^7.12.1", "@babel/helper-module-imports@^7.12.5", "@babel/helper-module-imports@^7.8.3": "@babel/helper-module-imports@^7.0.0", "@babel/helper-module-imports@^7.12.1", "@babel/helper-module-imports@^7.12.5", "@babel/helper-module-imports@^7.8.3":
version "7.12.5" version "7.12.5"
resolved "https://registry.npm.taobao.org/@babel/helper-module-imports/download/@babel/helper-module-imports-7.12.5.tgz?cache=0&sync_timestamp=1604441049232&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40babel%2Fhelper-module-imports%2Fdownload%2F%40babel%2Fhelper-module-imports-7.12.5.tgz" resolved "https://registry.npm.taobao.org/@babel/helper-module-imports/download/@babel/helper-module-imports-7.12.5.tgz?cache=0&sync_timestamp=1604441049232&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40babel%2Fhelper-module-imports%2Fdownload%2F%40babel%2Fhelper-module-imports-7.12.5.tgz"
...@@ -843,6 +851,15 @@ ...@@ -843,6 +851,15 @@
globals "^11.1.0" globals "^11.1.0"
lodash "^4.17.19" lodash "^4.17.19"
"@babel/types@7.0.0-beta.35":
version "7.0.0-beta.35"
resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.0.0-beta.35.tgz#cf933a9a9a38484ca724b335b88d83726d5ab960"
integrity sha512-y9XT11CozHDgjWcTdxmhSj13rJVXpa5ZXwjjOiTedjaM0ba5ItqdS02t31EhPl7HtOWxsZkYCCUNrSfrOisA6w==
dependencies:
esutils "^2.0.2"
lodash "^4.2.0"
to-fast-properties "^2.0.0"
"@babel/types@^7.10.4", "@babel/types@^7.10.5", "@babel/types@^7.11.0", "@babel/types@^7.12.1", "@babel/types@^7.12.10", "@babel/types@^7.12.5", "@babel/types@^7.12.7": "@babel/types@^7.10.4", "@babel/types@^7.10.5", "@babel/types@^7.11.0", "@babel/types@^7.12.1", "@babel/types@^7.12.10", "@babel/types@^7.12.5", "@babel/types@^7.12.7":
version "7.12.10" version "7.12.10"
resolved "https://registry.npm.taobao.org/@babel/types/download/@babel/types-7.12.10.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40babel%2Ftypes%2Fdownload%2F%40babel%2Ftypes-7.12.10.tgz" resolved "https://registry.npm.taobao.org/@babel/types/download/@babel/types-7.12.10.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40babel%2Ftypes%2Fdownload%2F%40babel%2Ftypes-7.12.10.tgz"
...@@ -1777,6 +1794,13 @@ async-validator@^1.10.0: ...@@ -1777,6 +1794,13 @@ async-validator@^1.10.0:
resolved "https://registry.npm.taobao.org/async-validator/download/async-validator-1.12.2.tgz?cache=0&sync_timestamp=1605751734916&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fasync-validator%2Fdownload%2Fasync-validator-1.12.2.tgz" resolved "https://registry.npm.taobao.org/async-validator/download/async-validator-1.12.2.tgz?cache=0&sync_timestamp=1605751734916&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fasync-validator%2Fdownload%2Fasync-validator-1.12.2.tgz"
integrity sha1-vq5nHnF00pOLe0tp0vt+cit/1yw= integrity sha1-vq5nHnF00pOLe0tp0vt+cit/1yw=
async-validator@~1.8.1:
version "1.8.5"
resolved "https://registry.yarnpkg.com/async-validator/-/async-validator-1.8.5.tgz#dc3e08ec1fd0dddb67e60842f02c0cd1cec6d7f0"
integrity sha512-tXBM+1m056MAX0E8TL2iCjg8WvSyXu0Zc8LNtYqrVeyoL3+esHRZ4SieE9fKQyyU09uONjnMEjrNBMqT0mbvmA==
dependencies:
babel-runtime "6.x"
async@^2.0.0, async@^2.6.2: async@^2.0.0, async@^2.6.2:
version "2.6.3" version "2.6.3"
resolved "https://registry.npm.taobao.org/async/download/async-2.6.3.tgz" resolved "https://registry.npm.taobao.org/async/download/async-2.6.3.tgz"
...@@ -1829,6 +1853,11 @@ babel-eslint@^10.1.0: ...@@ -1829,6 +1853,11 @@ babel-eslint@^10.1.0:
eslint-visitor-keys "^1.0.0" eslint-visitor-keys "^1.0.0"
resolve "^1.12.0" resolve "^1.12.0"
babel-helper-vue-jsx-merge-props@^2.0.0:
version "2.0.3"
resolved "https://registry.yarnpkg.com/babel-helper-vue-jsx-merge-props/-/babel-helper-vue-jsx-merge-props-2.0.3.tgz#22aebd3b33902328e513293a8e4992b384f9f1b6"
integrity sha512-gsLiKK7Qrb7zYJNgiXKpXblxbV5ffSwR0f5whkPAaBAR4fhi6bwRZxX9wBlIc5M/v8CCkXUbXZL4N/nSE97cqg==
babel-loader@^8.1.0: babel-loader@^8.1.0:
version "8.1.0" version "8.1.0"
resolved "https://registry.npm.taobao.org/babel-loader/download/babel-loader-8.1.0.tgz?cache=0&sync_timestamp=1606424647115&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fbabel-loader%2Fdownload%2Fbabel-loader-8.1.0.tgz" resolved "https://registry.npm.taobao.org/babel-loader/download/babel-loader-8.1.0.tgz?cache=0&sync_timestamp=1606424647115&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fbabel-loader%2Fdownload%2Fbabel-loader-8.1.0.tgz"
...@@ -1840,6 +1869,13 @@ babel-loader@^8.1.0: ...@@ -1840,6 +1869,13 @@ babel-loader@^8.1.0:
pify "^4.0.1" pify "^4.0.1"
schema-utils "^2.6.5" schema-utils "^2.6.5"
babel-plugin-component@^1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/babel-plugin-component/-/babel-plugin-component-1.1.1.tgz#9b023a23ff5c9aae0fd56c5a18b9cab8c4d45eea"
integrity sha512-WUw887kJf2GH80Ng/ZMctKZ511iamHNqPhd9uKo14yzisvV7Wt1EckIrb8oq/uCz3B3PpAW7Xfl7AkTLDYT6ag==
dependencies:
"@babel/helper-module-imports" "7.0.0-beta.35"
babel-plugin-dynamic-import-node@^2.3.0, babel-plugin-dynamic-import-node@^2.3.3: babel-plugin-dynamic-import-node@^2.3.0, babel-plugin-dynamic-import-node@^2.3.3:
version "2.3.3" version "2.3.3"
resolved "https://registry.npm.taobao.org/babel-plugin-dynamic-import-node/download/babel-plugin-dynamic-import-node-2.3.3.tgz" resolved "https://registry.npm.taobao.org/babel-plugin-dynamic-import-node/download/babel-plugin-dynamic-import-node-2.3.3.tgz"
...@@ -1847,7 +1883,7 @@ babel-plugin-dynamic-import-node@^2.3.0, babel-plugin-dynamic-import-node@^2.3.3 ...@@ -1847,7 +1883,7 @@ babel-plugin-dynamic-import-node@^2.3.0, babel-plugin-dynamic-import-node@^2.3.3
dependencies: dependencies:
object.assign "^4.1.0" object.assign "^4.1.0"
babel-runtime@^6.26.0: babel-runtime@6.x, babel-runtime@^6.26.0:
version "6.26.0" version "6.26.0"
resolved "https://registry.npm.taobao.org/babel-runtime/download/babel-runtime-6.26.0.tgz" resolved "https://registry.npm.taobao.org/babel-runtime/download/babel-runtime-6.26.0.tgz"
integrity sha1-llxwWGaOgrVde/4E/yM3vItWR/4= integrity sha1-llxwWGaOgrVde/4E/yM3vItWR/4=
...@@ -3299,7 +3335,7 @@ deep-is@~0.1.3: ...@@ -3299,7 +3335,7 @@ deep-is@~0.1.3:
resolved "https://registry.npm.taobao.org/deep-is/download/deep-is-0.1.3.tgz" resolved "https://registry.npm.taobao.org/deep-is/download/deep-is-0.1.3.tgz"
integrity sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ= integrity sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ=
deepmerge@^1.5.2: deepmerge@^1.2.0, deepmerge@^1.5.2:
version "1.5.2" version "1.5.2"
resolved "https://registry.npm.taobao.org/deepmerge/download/deepmerge-1.5.2.tgz?cache=0&sync_timestamp=1572279556265&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fdeepmerge%2Fdownload%2Fdeepmerge-1.5.2.tgz" resolved "https://registry.npm.taobao.org/deepmerge/download/deepmerge-1.5.2.tgz?cache=0&sync_timestamp=1572279556265&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fdeepmerge%2Fdownload%2Fdeepmerge-1.5.2.tgz"
integrity sha1-EEmdhohEza1P7ghC34x/bwyVp1M= integrity sha1-EEmdhohEza1P7ghC34x/bwyVp1M=
...@@ -3683,6 +3719,18 @@ element-resize-detector@^1.2.0: ...@@ -3683,6 +3719,18 @@ element-resize-detector@^1.2.0:
dependencies: dependencies:
batch-processor "1.0.0" batch-processor "1.0.0"
element-ui@^2.15.5:
version "2.15.5"
resolved "https://registry.yarnpkg.com/element-ui/-/element-ui-2.15.5.tgz#dfb376dc5cd60adab21c991bd4fac3e67e5300f4"
integrity sha512-B/YCdz2aRY2WnFXzbTRTHPKZHBD/2KV6u88EBnkaARC/Lyxnap+7vpvrcW5UNTyVwjItS5Fj1eQyRy6236lbXg==
dependencies:
async-validator "~1.8.1"
babel-helper-vue-jsx-merge-props "^2.0.0"
deepmerge "^1.2.0"
normalize-wheel "^1.0.1"
resize-observer-polyfill "^1.5.0"
throttle-debounce "^1.0.1"
elliptic@^6.5.3: elliptic@^6.5.3:
version "6.5.3" version "6.5.3"
resolved "https://registry.npm.taobao.org/elliptic/download/elliptic-6.5.3.tgz?cache=0&sync_timestamp=1592492844326&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Felliptic%2Fdownload%2Felliptic-6.5.3.tgz" resolved "https://registry.npm.taobao.org/elliptic/download/elliptic-6.5.3.tgz?cache=0&sync_timestamp=1592492844326&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Felliptic%2Fdownload%2Felliptic-6.5.3.tgz"
...@@ -6042,6 +6090,11 @@ lodash@^4.17.19, lodash@^4.17.20: ...@@ -6042,6 +6090,11 @@ lodash@^4.17.19, lodash@^4.17.20:
resolved "https://registry.npm.taobao.org/lodash/download/lodash-4.17.20.tgz?cache=0&sync_timestamp=1597336147792&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Flodash%2Fdownload%2Flodash-4.17.20.tgz" resolved "https://registry.npm.taobao.org/lodash/download/lodash-4.17.20.tgz?cache=0&sync_timestamp=1597336147792&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Flodash%2Fdownload%2Flodash-4.17.20.tgz"
integrity sha1-tEqbYpe8tpjxxRo1RaKzs2jVnFI= integrity sha1-tEqbYpe8tpjxxRo1RaKzs2jVnFI=
lodash@^4.2.0:
version "4.17.21"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c"
integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==
log-symbols@^2.2.0: log-symbols@^2.2.0:
version "2.2.0" version "2.2.0"
resolved "https://registry.npm.taobao.org/log-symbols/download/log-symbols-2.2.0.tgz?cache=0&sync_timestamp=1587898957951&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Flog-symbols%2Fdownload%2Flog-symbols-2.2.0.tgz" resolved "https://registry.npm.taobao.org/log-symbols/download/log-symbols-2.2.0.tgz?cache=0&sync_timestamp=1587898957951&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Flog-symbols%2Fdownload%2Flog-symbols-2.2.0.tgz"
...@@ -6670,6 +6723,11 @@ normalize-url@^4.1.0: ...@@ -6670,6 +6723,11 @@ normalize-url@^4.1.0:
resolved "https://registry.npm.taobao.org/normalize-url/download/normalize-url-4.5.0.tgz?cache=0&sync_timestamp=1602432879767&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fnormalize-url%2Fdownload%2Fnormalize-url-4.5.0.tgz" resolved "https://registry.npm.taobao.org/normalize-url/download/normalize-url-4.5.0.tgz?cache=0&sync_timestamp=1602432879767&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fnormalize-url%2Fdownload%2Fnormalize-url-4.5.0.tgz"
integrity sha1-RTNUCH5sqWlXvY9br3U/WYIUISk= integrity sha1-RTNUCH5sqWlXvY9br3U/WYIUISk=
normalize-wheel@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/normalize-wheel/-/normalize-wheel-1.0.1.tgz#aec886affdb045070d856447df62ecf86146ec45"
integrity sha1-rsiGr/2wRQcNhWRH32Ls+GFG7EU=
npm-conf@^1.1.3: npm-conf@^1.1.3:
version "1.1.3" version "1.1.3"
resolved "https://registry.npm.taobao.org/npm-conf/download/npm-conf-1.1.3.tgz" resolved "https://registry.npm.taobao.org/npm-conf/download/npm-conf-1.1.3.tgz"
...@@ -8136,6 +8194,11 @@ requires-port@^1.0.0: ...@@ -8136,6 +8194,11 @@ requires-port@^1.0.0:
resolved "https://registry.npm.taobao.org/requires-port/download/requires-port-1.0.0.tgz" resolved "https://registry.npm.taobao.org/requires-port/download/requires-port-1.0.0.tgz"
integrity sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8= integrity sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8=
resize-observer-polyfill@^1.5.0:
version "1.5.1"
resolved "https://registry.yarnpkg.com/resize-observer-polyfill/-/resize-observer-polyfill-1.5.1.tgz#0e9020dd3d21024458d4ebd27e23e40269810464"
integrity sha512-LwZrotdHOo12nQuZlHEmtuXdqGoOD0OhaxopaNFxWzInpEgaLWoVuAMbTzixuosCx2nEG58ngzW3vxdWoxIgdg==
resolve-cwd@^2.0.0: resolve-cwd@^2.0.0:
version "2.0.0" version "2.0.0"
resolved "https://registry.npm.taobao.org/resolve-cwd/download/resolve-cwd-2.0.0.tgz" resolved "https://registry.npm.taobao.org/resolve-cwd/download/resolve-cwd-2.0.0.tgz"
...@@ -9241,6 +9304,11 @@ thread-loader@^2.1.3: ...@@ -9241,6 +9304,11 @@ thread-loader@^2.1.3:
loader-utils "^1.1.0" loader-utils "^1.1.0"
neo-async "^2.6.0" neo-async "^2.6.0"
throttle-debounce@^1.0.1:
version "1.1.0"
resolved "https://registry.yarnpkg.com/throttle-debounce/-/throttle-debounce-1.1.0.tgz#51853da37be68a155cb6e827b3514a3c422e89cd"
integrity sha512-XH8UiPCQcWNuk2LYePibW/4qL97+ZQ1AN3FNXwZRBNPPowo/NRU5fAlDCSNBJIYCKbioZfuYtMhG4quqoJhVzg==
throttleit@0.0.2: throttleit@0.0.2:
version "0.0.2" version "0.0.2"
resolved "https://registry.npm.taobao.org/throttleit/download/throttleit-0.0.2.tgz" resolved "https://registry.npm.taobao.org/throttleit/download/throttleit-0.0.2.tgz"
......
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