提交 8fa1cd1f 作者: 毛细亚

更换登录方式

上级 a50001c9
...@@ -4,11 +4,11 @@ ...@@ -4,11 +4,11 @@
<div class="loginContentContainer"> <div class="loginContentContainer">
<p class="loginContentTitle">选择客服:</p> <p class="loginContentTitle">选择客服:</p>
<div class="loginContentInput rowFlex alignCenter"> <div class="loginContentInput rowFlex alignCenter">
<el-select v-model="cser_user_id" placeholder="请选择客服"> <el-select v-model="cser_user_id" filterable placeholder="请选择客服">
<el-option v-for="item in userList" :key="item.zq_user_id" clearable :label="item.name" :value="item.zq_user_id"> <el-option v-for="item in userList" :key="item.zq_user_id" clearable :label="item.name" :value="item.zq_user_id">
</el-option> </el-option>
</el-select> </el-select>
<el-button type="primary" style="margin-left: 10px;" size="small" @click="userStartLogin">点击登录</el-button> <el-button type="primary" style="margin-left: 10px;" size="small" @click="loginConfirm">点击登录</el-button>
</div> </div>
</div> </div>
</div> </div>
...@@ -62,11 +62,10 @@ export default { ...@@ -62,11 +62,10 @@ export default {
if (this.token && userid) { // 已经钉钉扫码过 重新获取授权 获取签名 注册企微js-sdk if (this.token && userid) { // 已经钉钉扫码过 重新获取授权 获取签名 注册企微js-sdk
this.getUserList(userid) this.getUserList(userid)
await this.getSignature(); await this.getSignature();
} else { } else if(!userid) {
if (!userid) { //没有企微授权过 并且 钉钉扫码成功 开始微信授权
console.log(4)
await this.startWeComSilentAuth(); await this.startWeComSilentAuth();
} }else if(!this.token){
this.getUserList(userid)
} }
}, },
...@@ -75,7 +74,6 @@ export default { ...@@ -75,7 +74,6 @@ export default {
const corp_id = Cookies.get('corp_id') || this.urlParams.corp_id const corp_id = Cookies.get('corp_id') || this.urlParams.corp_id
const res = await getUserList({ userid: userid,corp_id:corp_id }); const res = await getUserList({ userid: userid,corp_id:corp_id });
this.userList = res.data this.userList = res.data
console.log(res, '获取客服人员列表')
}, },
async userStartLogin(){ async userStartLogin(){
if(!this.cser_user_id){ if(!this.cser_user_id){
...@@ -89,8 +87,15 @@ export default { ...@@ -89,8 +87,15 @@ export default {
try { try {
const res = await cserSelected({ cser_id: cser_user.zq_user_id, corp_id: corp_id,userid:userid }); const res = await cserSelected({ cser_id: cser_user.zq_user_id, corp_id: corp_id,userid:userid });
console.log(res, '选择客服人员登录') console.log(res, '选择客服人员登录')
if(res.status_code === 1 ){ if(res.status_code === 1 && res.data.tokens ){
this.handleDingCallback(res) this.$message({
type: 'warning',
message: `当前【${cser_user.name}】已上线,下班后请记得点击下线哦~`,
duration: 3 * 1000
})
setTimeout(() => {
this.handleDingCallback(res.data.tokens )
}, 2000)
}else{ }else{
this.$message.error(res.msg) this.$message.error(res.msg)
setTimeout(() => { setTimeout(() => {
...@@ -105,6 +110,18 @@ export default { ...@@ -105,6 +110,18 @@ export default {
}, 5000) }, 5000)
} }
}, },
loginConfirm(){
const cser_user = this.userList.find(item => item.zq_user_id === this.cser_user_id)
this.$confirm(`确认登录上线吗,上线后所有会话都会归属到客服【${cser_user.name}】`, '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.userStartLogin()
}).catch(() => {
this.$message.info('已取消登录')
})
},
// 设置缓存 // 设置缓存
cacheCorp_id(corp_id) { cacheCorp_id(corp_id) {
Cookies.set('corp_id', corp_id, { expires: 7 }) Cookies.set('corp_id', corp_id, { expires: 7 })
...@@ -246,20 +263,17 @@ export default { ...@@ -246,20 +263,17 @@ export default {
}, },
// 7. 钉钉扫码回调页面处理 // 7. 钉钉扫码回调页面处理
async handleDingCallback(res) { async handleDingCallback(token) {
// 在这里处理钉钉扫码成功的回调 // 在这里处理钉钉扫码成功的回调
const corp_id = Cookies.get('corp_id') const corp_id = Cookies.get('corp_id')
if (res.data.token && res.data.token != 'undefined') { if (token && token != 'undefined') {
setToken(res.data.token) setToken(token)
this.set_token(res.data.token) this.set_token(token)
// 获取签名 // 获取签名
await this.getSignature(); await this.getSignature();
} else { } else {
console.log('没有token')
window.location.href = window.location.origin + '/company_app/index.html?corp_id=' + corp_id + '&msg=notoken' window.location.href = window.location.origin + '/company_app/index.html?corp_id=' + corp_id + '&msg=notoken'
} }
}, },
}, },
......
...@@ -22,7 +22,7 @@ import roleInfo from '@/views/roleInfo.vue' ...@@ -22,7 +22,7 @@ import roleInfo from '@/views/roleInfo.vue'
import orderList from '@/views/orderList.vue' import orderList from '@/views/orderList.vue'
import violationRecord from '@/views/ViolationRecord.vue' import violationRecord from '@/views/ViolationRecord.vue'
import { mapState, mapMutations } from 'vuex' import { mapState, mapMutations } from 'vuex'
import Cookies from 'js-cookie'
export default { export default {
name: 'userInfo', name: 'userInfo',
components: { components: {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论