This commit is contained in:
liuxi 2025-02-24 17:21:10 +08:00
commit dc8b2b9d6b
3 changed files with 41 additions and 2 deletions

View File

@ -117,6 +117,7 @@ export default {
voiceCall.webCalling().then(res => { voiceCall.webCalling().then(res => {
const {agent, token, sdkAppId, agentId, sdkURL} = res; const {agent, token, sdkAppId, agentId, sdkURL} = res;
// console.log(res, '---res') // console.log(res, '---res')
this.$store.commit('setAgent', agent)
if (agent){ if (agent){
let userId = agentId; let userId = agentId;
let sdkUrl = sdkURL; let sdkUrl = sdkURL;

View File

@ -22,7 +22,7 @@
<el-avatar size="medium" :src="userInfo.headUrl?userInfo.headUrl:defaultHeadUrl" ></el-avatar> <el-avatar size="medium" :src="userInfo.headUrl?userInfo.headUrl:defaultHeadUrl" ></el-avatar>
<span class="f16 color-fff ml-16">{{ userInfo.realName || userInfo.showName || '-' }}</span> <span class="f16 color-fff ml-16">{{ userInfo.realName || userInfo.showName || '-' }}</span>
</div> </div>
<div class="cursor-pointer border-radius-8 p-8-16" style="background-color:#00000010 ;"> <div v-if="agent" class="cursor-pointer border-radius-8 p-8-16" style="background-color:#00000010 ;">
<el-dropdown @command="handleCommand"> <el-dropdown @command="handleCommand">
<div class="flex-row align-items-center"> <div class="flex-row align-items-center">
<img :src="require(`@/assets/image/${agentStatus}.png`)" alt="" class="mr-8"> <img :src="require(`@/assets/image/${agentStatus}.png`)" alt="" class="mr-8">
@ -241,7 +241,7 @@
</template> </template>
<script> <script>
import api from "@/services/systemManage"; import api from "@/services/systemManage";
import {mapState} from 'vuex'
export default { export default {
components: { components: {
SideMenu: () => import('./SideMenu'), SideMenu: () => import('./SideMenu'),
@ -319,12 +319,23 @@ export default {
agentStatusName: '空闲', agentStatusName: '空闲',
} }
}, },
computed: {
...mapState({
agent: state => state.agent
}),
},
mounted() { mounted() {
if (JSON.parse(sessionStorage.getItem('userInfo'))) { if (JSON.parse(sessionStorage.getItem('userInfo'))) {
this.userInfo = JSON.parse(sessionStorage.getItem('userInfo')) this.userInfo = JSON.parse(sessionStorage.getItem('userInfo'))
} }
// console.log('',this.userInfo) // console.log('',this.userInfo)
// console.log(this.userInfo.showName) // console.log(this.userInfo.showName)
console.log('判断是否绑定坐席agent',this.agent)
// if (this.agent) {
// setTimeout(() => {
// this.getStatus()
// }, 2000)
// }
}, },
methods: { methods: {
// //
@ -414,6 +425,7 @@ export default {
} else if (command === 'rest') { } else if (command === 'rest') {
this.agentStatusName = '小休' this.agentStatusName = '小休'
} }
this.setStatus()
}, },
// //
handleClose() { handleClose() {
@ -437,6 +449,27 @@ export default {
}) })
}, },
//
async getStatus() {
console.log('进入获取座席状态')
try {
let res = await window.tccc.Agent.getStatus()
console.log('获取座席状态:', res)
} catch (error) {
this.$message.error('获取座席状态失败' + error.message)
console.log('获取座席状态失败',error.message)
}
},
//
async setStatus() {
try {
let res = await window.tccc.Agent.setStatus({status: this.agentStatus})
console.log('设置座席状态:', res)
} catch (err) {
this.$message.error('设置座席状态失败' + err.message)
console.log('设置座席状态失败',err.message)
}
}
} }
} }
</script> </script>

View File

@ -11,6 +11,7 @@ const vuexPersisted = new CreatePersistedState({
token: state.token, //需要持久化的数据 token: state.token, //需要持久化的数据
routes: state.routes, routes: state.routes,
userinfo: state.userinfo, userinfo: state.userinfo,
agent: state.agent
}) })
}) })
@ -26,6 +27,7 @@ const store = new Vuex.Store({
routes: [], // 从后端获取的路由菜单 routes: [], // 从后端获取的路由菜单
brokerEndpoint: '', brokerEndpoint: '',
videoReminder: '', videoReminder: '',
agent: false, // 是否绑定坐席
}, },
plugins: [vuexPersisted], plugins: [vuexPersisted],
// 全局同步方法, 调用方法,this.$store.commit("xxx",'赋值数据') // 全局同步方法, 调用方法,this.$store.commit("xxx",'赋值数据')
@ -47,6 +49,9 @@ const store = new Vuex.Store({
}, },
setVideoReminder(state, data) { setVideoReminder(state, data) {
state.videoReminder = data; state.videoReminder = data;
},
setAgent(state, data) {
state.agent = data;
} }
}, },