ball_admin/src/store/home.ts

83 lines
2.3 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";
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"
}
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 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;