切换主题
获取所有用户状态位置数据
提示
使用前提:用户初始化以及登录后
获取所有用户状态位置数据示例
<script setup name="GetLocation">
import { ref } from 'vue'
import {ElMessage} from 'element-plus'
import { checkInstance, getInstanceFCC } from '../../use-fcc'
import { setLog } from '../../use-log'
const loading = ref(false)
const userLocationList = ref([])
const getLocation = async () => {
setLog({
name: '开始获取所有用户状态位置数据'
})
if (loading.value) {
setLog({
name: '获取所有用户状态位置数据结果',
msg: '请先实例化'
})
return
}
if (!await checkInstance()) {
setLog({
name: '获取所有用户状态位置数据',
msg: '请先实例化'
})
ElMessage({
message: '请先实例化',
type: 'warning'
})
return
}
loading.value = true
let result = await getInstanceFCC().getLocation()
if (result.data.code == 200) {
userLocationList.value = result.data.data
}
setLog({
name: '获取所有用户状态位置数据结果',
msg: result
})
loading.value = false
if (result.status == 200) {
ElMessage({
message: '获取所有用户状态位置数据成功',
type: 'success'
})
} else {
ElMessage({
message: result.msg,
type: 'info'
})
}
}
const userSta = (value) => {
if (value === 1) {
return '在线'
} else if (value === 2) {
return '忙碌'
} else {
return '离线'
}
}
</script>
<template>
<el-form>
<div class="info-wrap" v-if="userLocationList.length > 0">
<ul>
<li v-for="item in userLocationList" :key="item.userId">
<span class="user-account">用户账号: {{item.extSysAccount}}</span>
<span>用户状态: {{ userSta(+item.natsStat) }}</span>
</li>
</ul>
</div>
<el-form-item>
<el-button type="primary" @click="getLocation" :loading="loading">获取所有用户状态位置数据</el-button>
</el-form-item>
</el-form>
</template>
<style scoped>
.info-wrap {
margin-bottom: 10px;
}
.user-account {
margin-right: 20px;
}
</style>使用方法
typescript
// 用户初始化以及登录后,调用该接口获取所有用户的状态以及位置数据
fcc.getLocation()1
2
2
入参说明
无
出参说明
| 出参名称 | 数据类型 | 说明 |
|---|---|---|
| status | number | 调用接口返回结果的状态码,其含义参考融合通讯中台通用状态码。 |
| msg | string | 给开发者的文字提示信息 |
| data | array | natsStat: 0-离线,1-在线, 2-忙碌; extSysAccount-是统一账号; longitude-经度,latitude-纬度 |
