|
@@ -4,7 +4,6 @@
|
|
|
<el-row v-loading="loading" align="middle" justify="center">
|
|
|
<el-col :span="24">
|
|
|
<el-card class="scan-card" shadow="hover">
|
|
|
-
|
|
|
<div class="scan-card-content">
|
|
|
<h1 class="title">扫码登录</h1>
|
|
|
<el-form-item label="账号" prop="account" style="width:100%" v-if="!showVerifyCode">
|
|
@@ -68,13 +67,9 @@ export default {
|
|
|
|
|
|
},
|
|
|
mounted () {
|
|
|
- // 初始化
|
|
|
- //this.initSocket(this.companyUser.userId);
|
|
|
- //console.log("userId:"+JSON.stringify(this.companyUser));
|
|
|
- console.log("qxj process:"+JSON.stringify(process));
|
|
|
- if (process.env.NODE_ENV === 'development') {
|
|
|
- this.qwForm.account = "1261818888";
|
|
|
- }
|
|
|
+ // if (process.env.NODE_ENV === 'development') {
|
|
|
+ // this.qwForm.account = "1261818888";
|
|
|
+ // }
|
|
|
},
|
|
|
methods: {
|
|
|
handleLogin() {
|
|
@@ -136,51 +131,51 @@ export default {
|
|
|
});
|
|
|
},
|
|
|
initSocket(userId) {
|
|
|
- let that=this;
|
|
|
- if(!!this.qwIm.socket){
|
|
|
- this.qwIm.initSocket(userId,true);
|
|
|
- // 监听socket连接
|
|
|
- this.qwIm.socket.onopen = function() {
|
|
|
- console.log("socket 连接成功");
|
|
|
- };
|
|
|
- // 监听socket错误信息
|
|
|
- this.qwIm.socket.onerror = function() {
|
|
|
- console.log("连接错误")
|
|
|
- };
|
|
|
- // 监听socket消息
|
|
|
- this.qwIm.socket.onmessage = function(res) {
|
|
|
- var data=JSON.parse(res.data);
|
|
|
- console.log("收到服务端内容", JSON.stringify(data));
|
|
|
- if(data.cmd=="heartbeat"){ //收到心跳数据不处理
|
|
|
- console.log("收到心跳数据 heartbeat");
|
|
|
- }
|
|
|
- if(data.cmd=="loginSucc"){
|
|
|
- var qwUserInfo=JSON.parse(data.msg);
|
|
|
- Notification.success({title: "登录成功!" });
|
|
|
- that.$store.dispatch("qwUser", qwUserInfo);
|
|
|
- that.showQRCode=false;
|
|
|
- setTimeout(() => {
|
|
|
- that.$router.push({path:'/qw/qwChat',query:{"isFromLogin":1}});
|
|
|
- }, 2000);
|
|
|
- }
|
|
|
- if(data.cmd=="verifyCode"){
|
|
|
- that.loginTips="登录";
|
|
|
- that.showQRCode=false;
|
|
|
- that.showVerifyCode=true;
|
|
|
- }
|
|
|
- // if(data.cmd=="offline"){
|
|
|
- // that.loginTips="获取验证码";
|
|
|
- // that.showQRCode=true;
|
|
|
- // that.showVerifyCode=false;
|
|
|
- // that.$store.dispatch('qwLoginOut').then(() => {
|
|
|
- // });
|
|
|
- // }
|
|
|
- };
|
|
|
- // 监听socket重连
|
|
|
- this.qwIm.socket.onreconnect = function(res) {
|
|
|
- console.log("socket 断线重连...")
|
|
|
- };
|
|
|
- }
|
|
|
+ let that=this;
|
|
|
+ if(!!this.qwIm.socket){
|
|
|
+ this.qwIm.initSocket(userId,true);
|
|
|
+ // 监听socket连接
|
|
|
+ this.qwIm.socket.onopen = function() {
|
|
|
+ console.log("socket 连接成功");
|
|
|
+ };
|
|
|
+ // 监听socket错误信息
|
|
|
+ this.qwIm.socket.onerror = function() {
|
|
|
+ console.log("连接错误")
|
|
|
+ };
|
|
|
+ // 监听socket消息
|
|
|
+ this.qwIm.socket.onmessage = function(res) {
|
|
|
+ var data=JSON.parse(res.data);
|
|
|
+ console.log("收到服务端内容", JSON.stringify(data));
|
|
|
+ if(data.cmd=="heartbeat"){ //收到心跳数据不处理
|
|
|
+ console.log("收到心跳数据 heartbeat");
|
|
|
+ }
|
|
|
+ if(data.cmd=="loginSucc"){
|
|
|
+ var qwUserInfo=JSON.parse(data.msg);
|
|
|
+ Notification.success({title: "登录成功!" });
|
|
|
+ that.$store.dispatch("qwUser", qwUserInfo);
|
|
|
+ that.showQRCode=false;
|
|
|
+ setTimeout(() => {
|
|
|
+ that.$router.push({path:'/qw/qwChat',query:{"isFromLogin":1}});
|
|
|
+ }, 2000);
|
|
|
+ }
|
|
|
+ if(data.cmd=="verifyCode"){
|
|
|
+ that.loginTips="登录";
|
|
|
+ that.showQRCode=false;
|
|
|
+ that.showVerifyCode=true;
|
|
|
+ }
|
|
|
+ // if(data.cmd=="offline"){
|
|
|
+ // that.loginTips="获取验证码";
|
|
|
+ // that.showQRCode=true;
|
|
|
+ // that.showVerifyCode=false;
|
|
|
+ // that.$store.dispatch('qwLoginOut').then(() => {
|
|
|
+ // });
|
|
|
+ // }
|
|
|
+ };
|
|
|
+ // 监听socket重连
|
|
|
+ this.qwIm.socket.onreconnect = function(res) {
|
|
|
+ console.log("socket 断线重连...")
|
|
|
+ };
|
|
|
+ }
|
|
|
},
|
|
|
open() {
|
|
|
console.log("socket连接成功");
|