177 lines
5.3 KiB
TypeScript
177 lines
5.3 KiB
TypeScript
import { action, makeObservable, observable } from "mobx";
|
|
// 档案文件夹
|
|
import baseHttp from "@/service/base";
|
|
import BaseStore from "./baseStore";
|
|
import { TagDataType } from "@/model/userModel";
|
|
import Config from "@/util/config";
|
|
|
|
class HomeConfig {
|
|
static os: string = "/v1/public/os"
|
|
static tr: string = "/v1/public/tr"
|
|
static af: string = "/v1/public/af"
|
|
static mm: string = "/v1/public/mm"
|
|
static mmb: string = "/v1/public/mmb"
|
|
static rm: string = "/v1/public/rm"
|
|
static ae: string = "/v1/public/ae"
|
|
static todo: string = "/v1/public/todo"
|
|
static con: string = "/v1/user/mapMakerUser"
|
|
|
|
static newTask: string = "/v1/user/newTask"
|
|
static taskulist: string = "/v1/public/taskInUser"
|
|
static deviceList: string = "/api/v1/devicesconfig" //设备列表
|
|
static channerList: string = "/api/v1/channelsconfig" //设备列表
|
|
static channelstream: string = "/api/v1/devices/channelstream" //设备包活
|
|
static scores: string = "/v1/user/scores"
|
|
static times: string = "/v1/archives/times"
|
|
static folderall: string = "/v1/archives/folder/all"
|
|
static folderalls: string = "/v1/archives/list"
|
|
}
|
|
class HomeStore extends BaseStore<TagDataType> {
|
|
scoreData = {}
|
|
constructor() {
|
|
super(HomeConfig)
|
|
makeObservable(this, {
|
|
getOgCount: action,
|
|
scoreData: observable,
|
|
ogMap: observable,
|
|
alist: observable,
|
|
showVideo: observable,
|
|
ulist: observable,
|
|
showVideoHandler: action,
|
|
getTaskUserList: action,
|
|
getScores: action,
|
|
})
|
|
}
|
|
async getScores(id) {
|
|
let data = await baseHttp.get(HomeConfig.scores + "/" + id, null)
|
|
this.scoreData = data.data.record
|
|
|
|
}
|
|
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 getmmb() {
|
|
return await baseHttp.get(HomeConfig.mmb, {});
|
|
}
|
|
async getAe() {
|
|
return await baseHttp.get(HomeConfig.ae, {});
|
|
}
|
|
// 获取联系人
|
|
async getContact(params) {
|
|
return await baseHttp.get(HomeConfig.con, params);
|
|
}
|
|
async getTodo(params) {
|
|
return await baseHttp.get(HomeConfig.todo, params);
|
|
}
|
|
|
|
// 获取档案时间
|
|
async getTimes() {
|
|
return await baseHttp.get(HomeConfig.times, {});
|
|
}
|
|
|
|
// 获取档案列表
|
|
async getFolders(year: string) {
|
|
return await baseHttp.get(HomeConfig.folderall, { "year": year });
|
|
}
|
|
|
|
async getFolderss(identity: string) {
|
|
return await baseHttp.get(HomeConfig.folderalls+"/"+identity, { });
|
|
}
|
|
|
|
// folderDetail
|
|
|
|
// 获取视频推流连接
|
|
async getVideoUrlList() {
|
|
try {
|
|
let data = await baseHttp.gets(HomeConfig.deviceList, {
|
|
start: 0,
|
|
limit: 100
|
|
})
|
|
return data
|
|
} catch (error) {
|
|
return false
|
|
}
|
|
}
|
|
// 通道列表
|
|
async getChannerUrlList(deviceId) {
|
|
try {
|
|
let data = await baseHttp.gets(HomeConfig.channerList, {
|
|
start: 0,
|
|
limit: 30,
|
|
device: deviceId
|
|
})
|
|
return data;
|
|
} catch (error) {
|
|
return false
|
|
}
|
|
}
|
|
// 获取通道流
|
|
async getChannerStrem(deviceId, channel) {
|
|
try {
|
|
let data = await baseHttp.gets(HomeConfig.channelstream, {
|
|
device: deviceId,
|
|
channel: channel,
|
|
protocol: "flv"
|
|
})
|
|
return data;
|
|
} catch (error) {
|
|
console.log(error)
|
|
return false
|
|
}
|
|
}
|
|
async getNewTask() {
|
|
let urls: any = []
|
|
try {
|
|
let res = await baseHttp.get(HomeConfig.newTask, {});
|
|
if (res.data?.record) {
|
|
for await (const element of res.data?.record.videos) {
|
|
let res = await this.getChannerStrem(element.device, element.channel)
|
|
urls.push(Config.videoApis + res.EasyDarwin?.Body.URL)
|
|
}
|
|
// this.getTaskUserList()
|
|
this.showVideoHandler(true)
|
|
}
|
|
return urls;
|
|
} catch (error) {
|
|
return []
|
|
}
|
|
}
|
|
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 ?? 116.478935,
|
|
// lat: element.lat ?? 39.997761,
|
|
// 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;
|
|
|