131 lines
3.7 KiB
TypeScript
131 lines
3.7 KiB
TypeScript
import { action, makeObservable, observable } from "mobx";
|
|
// 档案文件夹
|
|
import baseHttp from "@/service/base";
|
|
import BaseStore from "./baseStore";
|
|
import { TagDataType } from "@/model/userModel";
|
|
import MapUtl from "@/components/map/mapUtil";
|
|
import Config from "@/util/config";
|
|
|
|
class HomeConfig {
|
|
static os: string = "public/os"
|
|
static tr: string = "public/tr"
|
|
static af: string = "public/af"
|
|
static mm: string = "public/mm"
|
|
static rm: string = "public/rm"
|
|
static ae: string = "public/ae"
|
|
static newTask: string = "user/newTask"
|
|
static taskulist: string = "public/taskInUser"
|
|
static deviceList: string = "api/v1/devicesconfig" //设备列表
|
|
static channerList: string = "api/v1/channelsconfig" //设备列表
|
|
static channelstream: string = "api/v1/channelstream" //设备包活
|
|
|
|
}
|
|
class HomeStore extends BaseStore<TagDataType> {
|
|
constructor() {
|
|
super(HomeConfig)
|
|
makeObservable(this, {
|
|
getOgCount: action,
|
|
ogMap: observable,
|
|
alist: observable,
|
|
showVideo: observable,
|
|
ulist: observable,
|
|
showVideoHandler: action,
|
|
getTaskUserList: action,
|
|
})
|
|
}
|
|
|
|
async getOgCount() {
|
|
let res = await baseHttp.get(HomeConfig.os, {});
|
|
this.ogMap = res.data.record
|
|
}
|
|
async getTr() {
|
|
return await baseHttp.get(HomeConfig.tr, {});
|
|
}
|
|
|
|
async getAf() {
|
|
return await baseHttp.get(HomeConfig.af, {});
|
|
}
|
|
async getMm() {
|
|
return await baseHttp.get(HomeConfig.mm, {});
|
|
}
|
|
async getRm() {
|
|
return await baseHttp.get(HomeConfig.rm, {});
|
|
}
|
|
async getAe() {
|
|
return await baseHttp.get(HomeConfig.ae, {});
|
|
}
|
|
|
|
// 获取视频推流连接
|
|
async getVideoUrlList() {
|
|
try {
|
|
let data = await baseHttp.gets(Config.videoApi + HomeConfig.deviceList, {
|
|
start: 0,
|
|
limit: 30
|
|
})
|
|
return data
|
|
} catch (error) {
|
|
console.log(error)
|
|
return false
|
|
}
|
|
}
|
|
// 通道列表
|
|
async getChannerUrlList(deviceId) {
|
|
try {
|
|
let data = await baseHttp.gets(Config.videoApi + HomeConfig.channerList, {
|
|
start: 0,
|
|
limit: 30,
|
|
device:deviceId
|
|
})
|
|
return data;
|
|
} catch (error) {
|
|
console.log(error)
|
|
return false
|
|
}
|
|
}
|
|
// 获取通道流
|
|
async getChannerStrem(deviceId,channel) {
|
|
try {
|
|
let data = await baseHttp.gets(Config.videoApi + HomeConfig.channelstream, {
|
|
device:deviceId,
|
|
channel:channel,
|
|
protocol:"HLS"
|
|
})
|
|
console.log(data)
|
|
return true
|
|
} catch (error) {
|
|
console.log(error)
|
|
return false
|
|
}
|
|
}
|
|
async getNewTask() {
|
|
let res = await baseHttp.get(HomeConfig.newTask, {});
|
|
if (res.data?.record) {
|
|
this.getTaskUserList()
|
|
this.showVideoHandler(true)
|
|
}
|
|
}
|
|
async getTaskUserList() {
|
|
let res = await baseHttp.get(HomeConfig.taskulist, {});
|
|
if (res.data?.record?.ulist && res.data?.record.ulist.length > 0) {
|
|
res.data?.record?.ulist.forEach(element => {
|
|
MapUtl.addMaker({
|
|
lng: element.long,
|
|
lat: element.lat,
|
|
title: element.user_name,
|
|
users: element
|
|
})
|
|
});
|
|
}
|
|
}
|
|
showVideoHandler(status) {
|
|
this.showVideo = status
|
|
}
|
|
ogMap!: Object;
|
|
showVideo!: boolean;
|
|
alist!: Array<any>;
|
|
ulist!: Array<any>;
|
|
}
|
|
const homeStore = new HomeStore()
|
|
export default homeStore;
|
|
|