beelink/src/api/index.ts
2020-12-17 14:10:49 +08:00

1321 lines
31 KiB
TypeScript

import router from '@/router';
import store from '@/store';
import { LiveList, LivelistInfo, LoginData, UserInfo } from '@/types';
import { getValue, saveValue, toindex } from '@/utils/common';
import { geti18n } from '@/utils/i18n';
import { message } from 'ant-design-vue';
import dayjs from 'dayjs';
import { del, get, post, put, setToken } from './base'
/**
* 用户名密码登录
* @param phone 手机号
* @param password 密码
*/
export async function loginpass(phone: string, password: string,type?: number,smscode?: string){
let newdata: any = {}
if(type==1){
newdata={type:type?type:2,username: phone, smscode: smscode}
}else{
newdata={type:type?type:2,username: phone, password: password}
}
newdata.logintype = 1;
const res = await post<LoginData>("login",newdata);
console.log(res.code)
if(res.code == 1){
message.error(res.msg)
}else{
console.log(res.data)
if(!saveValue("token", res.data.api_token) && !saveValue("memberid", res.data.memberid) ){
message.error("存储错误, 请允许网页使用本地存储!")
}else{
setToken();
store.commit("login", true);
await store.dispatch("setUserInfo");
await router.push("/mine/archives")
location.reload();
}
}
}
/**
* 用户头像和用户名字
*/
export async function userinfo(){
const user = await get<UserInfo>('personalInfo');
// console.log(user.data.img)
if(user.code == 1001){
saveValue("token","")
toindex()
return '未登录';
}
return user.data;
}
/**
* 获取用户绑定银行卡列表
*/
interface Wallect {
wallectid: number;
memberid: number;
type: number;
account: string;
mname: string;
bankcode: string;
bankname: string;
deleted_at: null;
created_at: string;
updated_at: string;
typeName: string;
}
export async function getwallect(){
const res = await get<Array<Wallect>>('wallect')
console.log(res)
return res.data
}
/**
* 订阅者列表
*/
interface Teacherliked {
memberid: number;
name: string;
img: string;
live: string;
birthday: string;
mtongue: string;
interest: string;
}
export async function getteacherliked(data?: any){
const res = await get<Array<Teacherliked>>('teacherliked',data);
// console.log(res)
return res;
}
/**
* 视频列表
*/
interface VideoList{
videoid: number;
memberid: number;
title: string;
img: string;
fileid: string;
fileurl: string;
fileduration: string;
status: number;
desc: string;
deleted_at: null;
created_at: string;
updated_at: string;
statusname: string;
}
interface VideoListInfo {
data: VideoList[];
code: number;
msg: string;
total: number;
}
export async function getvideolist(data?: any): Promise<VideoListInfo>{
const res = await get<Array<VideoList>>('video',data)
console.log(res)
return res
}
/**
* 直播列表
*/
export async function getlivelist(data?: any): Promise<LivelistInfo> {
const res = await get<Array<LiveList>>('live',data);
console.log(res);
return res;
}
/**
* 列表统计
*/
interface StatisticList{
liveInfo: any;
videoInfo: any;
studentInfo: any;
}
export async function getstatisticlist() {
const res = await get<StatisticList>('statistics');
// console.log(res)
return {
liveInfo: res.data.liveInfo,
videoInfo: res.data.videoInfo,
studentInfo: res.data.studentInfo
}
}
/**
* 发布直播
*/
interface Liveaddrule{
code: number;
msg: string;
}
export async function liveadd(data: any) {
const res = await post<Liveaddrule>('live',data);
console.log(res)
if(res.code==0){
message.success(res.msg)
router.push("/regime/live")
}else{
message.error(res.msg)
}
}
/**
* 发布视频
*/
export async function videoadd( form: any,data: any) {
const res=await post<Liveaddrule>('video',data)
if(res.code==0){
message.success(geti18n().$t('shipinshangchuanchenggong'))
form.value = {
title: "",
img: "",
fileid: "",
fileurl: "",
fileduration: "",
desc: "",
video: [""],
}
router.push("/regime/video")
}else{
message.error(res.msg)
}
}
/**
* 编辑视频
*/
export async function setvideo(data?: any) {
console.log(data,11110)
const res=await put<Liveaddrule>('video/'+data.id,data)
if(res.code==0){
message.success(res.msg)
router.push("/regime/video")
}else{
message.error(res.msg)
}
}
/**
* 视频详情
*/
interface VideoDetail{
videoid: number;
memberid: number;
title: string;
img: string;
fileid: string;
fileurl: string;
fileduration: string;
status: number;
desc: string;
deleted_at: string;
created_at: string;
updated_at: string;
share: number;
watch: number;
score: string;
statusdesc: string;
}
export async function videodetail(data?: any,ifupdate?: number) {
const res=await get<VideoDetail>('video/'+data)
if(ifupdate){
console.log(111)
return{
title: res.data.title,
img: res.data.img,
fileid: res.data.fileid,
fileurl: res.data.fileurl,
fileduration: res.data.fileduration,
desc: res.data.desc,
video: [res.data.fileurl],
}
}else{
return {
videoid: res.data.videoid,
memberid: res.data.memberid,
title: res.data.title,
img: res.data.img,
fileid: res.data.fileid,
fileurl: res.data.fileurl,
fileduration: res.data.fileduration,
status: res.data.status,
desc: res.data.desc,
deletedAt: res.data.deleted_at,
createdAt: res.data.created_at,
updatedAt: res.data.updated_at,
watch: res.data.watch,
share: res.data.share,
score: res.data.score,
statusdesc: res.data.statusdesc
}
}
}
/**
* 删除视频
*/
export async function videodel(data: any) {
const res = await del<Liveaddrule>('video/'+data);
if(res.code==0){
message.success(res.msg)
}
console.log(res)
}
/**
* 新增账户
*/
export async function accountadd(data?: any) {
const res = await post<Liveaddrule>('wallect',data);
if(res.code==0){
message.success(res.msg)
router.push("/mine/wallet")
}
console.log(res)
}
interface SaleInfo{
total: number;
accountid: number;
memberid: number;
sn: string;
type: number;
typename: string;
money: string;
source: number;
remark: string;
deleted_at: string;
created_at: string;
updated_at: string;
basemoney: string;
}
interface SaleInfolData{
data: SaleInfo[];
code: number;
msg: string;
total: number;
}
/**
* 交易明细
* @param data
*/
export async function saleinfo(data?: any){
const res=await get<SaleInfolData>('account',data)
console.log(res)
return res
}
/**
* 申请提现
*/
export async function cashout(data?: any,accountinfo?: any){
// data.type=data.typeid?data.typeid:0
// if(data.type!=0){
// delete data.typeid
// }
data.type=accountinfo.type
console.log(data,'tixian')
console.log(accountinfo)
// data.account=accountinfo.account
// data.bankcode=accountinfo.bankcode
// data.bankname=accountinfo.bankname
// data.mname=accountinfo.mname
data.wallectid=accountinfo.wallectid
console.log(data)
const res = await post<Liveaddrule>('withdrawal',data);
if(res.code==0){
message.success(res.msg)
// userinfo()
store.dispatch("setUserInfo");
return true;
}else{
message.error(res.msg)
return false;
}
}
/**
* 账户详情
*/
interface AccountInfo{
wallectid: number;
typeid: number;
type: number;
account: number;
mname: string;
bankcode: string;
bankname: string;
}
export async function getaccountinfo(data?: any){
const res=await get<AccountInfo>('wallect/'+data)
console.log(res,2333)
return {
accountid: res.data.wallectid,
type: res.data.type,
account: res.data.account,
mname: res.data.mname,
bankcode: res.data.bankcode,
bankname: res.data.bankname
}
}
/**
* 账户编辑
*/
export async function editaccount( id: any,data?: any){
const res=await put<Liveaddrule>('wallect/' +id ,data);
if(res.code==0){
message.success(res.msg)
router.push("/mine/wallet")
}else{
message.error(res.msg)
}
}
/**
* 删除账户
*/
export async function deleteaccount(data: any) {
const res = await del<Liveaddrule>('wallect/' + data);
if(res.code==0){
message.success(res.msg)
router.push("/mine/wallet")
}
console.log(res)
}
/**
*
* 交易明细 详情
*/
interface TransactionInfo{
accountid: number;
memberid: number;
sn: string;
type: number;
typename: string;
money: number;
source: number;
remark: string;
deleted_at: any;
created_at: string;
updated_at: string;
}
export async function transactioninfo(data?: any){
const res = await get<TransactionInfo>('account/'+data)
// console.log(res)
return res.data
}
/**
* 修改密码
*/
export async function editpassword(data?: any): Promise<any> {
console.log(data,111)
const newdata={
password:"",
newpassword: "",
topassword: ""
}
newdata.password = data.original
newdata.newpassword=data.password
newdata.topassword=data.topassword
console.log(newdata)
const res = await put<Liveaddrule>('/member/' + data.memberid,newdata)
if(res.code==0){
message.success(res.msg)
return false
}else{
message.error(res.msg)
return true
}
}
/**
* 提现记录 列表
*/
interface WithDrawal{
withdrawalid: number;
memberid: number;
sn: string;
status: number;
statusname: string;
type: number;
typename: string;
money: number;
sxf: number;
international: number;
account: string;
mname: string;
bankcode: string;
bankname: string;
remark: string;
deleted_at: string;
created_at: string;
updated_at: string;
}
interface WithdrawlData{
data: WithDrawal[];
code: number;
msg: string;
total: number;
}
export async function withdrawal(data?: any) {
console.log(data)
const res=await get<WithdrawlData>('withdrawal',data)
// console.log(res)
return res
}
/**
* 提现记录 详情
*/
export async function withdrawlxq(data?: any){
const res=await get<WithDrawal>('withdrawal/'+data)
return res.data
}
/**
* 评论(视频?)
*/
interface CommentList{
commentid: number;
memberid: number;
cid: number;
type: number;
score: number;
content: string;
deleted_at: null;
created_at: string;
updated_at: string;
name: string;
img: string;
}
interface CommentlData{
data: CommentList[];
code: number;
msg: string;
total: number;
}
interface ReplylistData{
data: CommentList[];
code: number;
msg: string;
score?: string;
total: number;
}
export async function getcommentlist(data?: any) {
console.log(data.type==2)
if(data.type==2){
const res=await get<CommentlData>('comments',data)
return res
}else{
const res=await get<ReplylistData>('comments',data)
console.log(res)
return res
}
// if(data.type==2){
// return res
// }
}
/**
* 发布评论
*/
interface SendData{
type?: number;
cid?: number;
teacherid?: number;
score?: number;
content?: string;
}
export async function addcomment(data?: any): Promise<void> {
const res=await post<SendData>('comments',data)
if(res.code==0){
message.success(res.msg)
}
}
/**
* 删除评论
*/
export async function delreply(data?: any) {
const res = await del<Liveaddrule>('comments/'+data);
if(res.code==0){
message.success(res.msg)
}
return res
}
/**
* 验证用户是否存在
*/
interface CheckuserRule{
memberid: number;
name: string;
mobile: string;
email: string;
code: string;
}
interface CheckData{
data: {
memberid: any;
name: string;
mobile: string;
email: string;
code: string;
};
code: number;
msg: string;
}
export async function checkuser(data?: any){
const newdata={number: ""}
newdata.number=data.phone
const res = await get<CheckuserRule>('checkUser',newdata);
// console.log(res)
// if(res.code == 1){
// return {
// code: res.code,
// msg: res.msg,
// }
// }
return {
code: res.code,
msg: res.msg,
data: res.data
}
}
/**
* 获取区号列表
*/
export function getquhaolist() {
// const res=await get("phonecodes")
// console.log(res)
// return res.data
return new Promise((res)=>{
const time = setInterval(()=>{
if(JSON.stringify(store.state.indexarr.phonecodes) != "{}"){
console.log(JSON.stringify(store.state.indexarr.phonecodes),"quhao")
res(store.state.indexarr.phonecodes)
clearInterval(time)
}
console.log("dengdaiquhao")
}, 500)
})
}
/**
* 获取时区列表
*/
export function getzonelist(): Promise<any>{
// console.log(res)
// const res=await get("timezones")
// console.log(res)
// return res.data
return new Promise((res)=>{
const time = setInterval(()=>{
if(JSON.stringify(store.state.indexarr.timezones) != "{}"){
res(store.state.indexarr.timezones)
clearInterval(time)
}
console.log("dengdai")
}, 500)
})
}
/**
* 修改时区 货币 语言
*/
export async function editsystemsetting(e?: any): Promise<boolean> {
let newdata={}
newdata=e
const res = await put(`member/${store.state.userinfo.memberid}`,newdata);
console.log(res)
if(res.code == 0){
message.success(res.msg)
store.dispatch("setUserInfo");
location.reload();
return true;
}else{
message.error(res.msg);
return false;
}
}
/**
* 货币列表
*/
export function getcurrencys(){
// const res=await get("currencys")
// return res.data
return new Promise((res)=>{
const time = setInterval(()=>{
if(JSON.stringify(store.state.indexarr.currencys) != "{}"){
res(store.state.indexarr.currencys)
clearInterval(time)
}
console.log("dengdai")
}, 500)
})
}
/**
* 登录右侧 视频列表
*/
export async function getwebvideolist() {
const res=await get("webvideos")
console.log(res)
return res.data
}
/**
* 发送验证码
* @param phone 手机号
* @param type 国外1 国内0
*/
interface SendSms{
code: number;
msg: string;
}
export async function sendsms(code: string ,phone: string): Promise<boolean>{
const type = code == '86' ? 0 : 1;
const res = await post<SendSms>("SendSms", {phone: code + phone, type});
console.log(res);
if(res.code == 0){
message.success(res.msg);
return true;
}else{
message.error(res.msg);
return false;
}
}
/**
* 获取国家与语言数据
*/
interface Countries{
id: number;
name: string;
country_code: string;
}
interface Willsay{
languageid: number;
name: string;
}
export function getarchives(): Promise<[any,any]>{
// return [(await get<Countries[]>("countries")).data, (await get<Willsay[]>("willsay")).data];
return new Promise((res)=>{
const time = setInterval(()=>{
if(JSON.stringify(store.state.indexarr.countries) != "{}" && JSON.stringify(store.state.indexarr.willsay) != "{}"){
res([store.state.indexarr.countries, store.state.indexarr.willsay])
clearInterval(time)
}
console.log("dengdai")
}, 500)
})
}
export async function getwillsay(): Promise<Willsay[]>{
return (await get<Willsay[]>("willsay")).data;
}
/**
* 客户端语言
*/
interface Language {
dictionaryid: number;
name: string;
alias: string;
code: string;
position: number;
publish: number;
value: string;
deleted_at: null;
created_at: string;
updated_at: string;
}
export function getlanguages(): Promise<any>{
// return (await get<Language[]>("languages")).data;
return new Promise((res)=>{
const time = setInterval(()=>{
if(JSON.stringify(store.state.indexarr.language) != "{}"){
res(store.state.indexarr.language)
clearInterval(time)
}
console.log("dengdai")
}, 500)
})
}
/**
* 修改我的档案
*/
// export async function putmember(data: unknown): Promise<Liveaddrule>{
export async function putmember(data: any): Promise<any>{
data.interest={}
console.log(data)
for(let i=0;i<data.willsayValue.length;i++){
data.willsayValue[i].level=data.willsayValue[i].level+''
}
const newdata={
name: data.name,
mobile: data.mobile,
img: data.img,
country: data.countryValue,
live: data.live,
mtongue: data.mtongue,
email: data.email,
interest: JSON.stringify(data.interest),
willsay: JSON.stringify(data.willsay),
birthday: data.birthday,
zoneid: data.zoneid,
currency: data.currencyValue,
language: data.languageValue,
tlanguage: data.tlanguageValue,
video: data.video,
desc: data.desc,
videoid: data.videoid
}
console.log(newdata)
const res = await put<Liveaddrule>(`member/${store.state.userinfo.memberid}`, newdata)
if(res.code == 0){
message.success(res.msg)
}else {
message.error(res.msg)
}
store.dispatch("setUserInfo");
return res;
}
/**
* 直播详情
*
*/
interface LiveInfo {
liveid: number;
title: string;
img: string;
fileid: string;
fileurl: string;
fileduration: string;
vodid: string;
vodurl: string;
vodduration: string;
dateline: string;
livetime: number;
livenumber: number;
status: number;
desc: string;
deleted_at: null;
created_at: string;
updated_at: string;
livestatus: number;
overdue: number;
}
interface StudentList {
memberid: number;
name: string;
img: string;
}
export async function getliveinfo(id: number){
const liveinfo = (await get<LiveInfo>(`live/${id}`)).data;
const studentlist = (await get<StudentList[]>("studentLive",{id})).data;
return {...liveinfo,studentlist}
}
/**
* 参与直播的学生列表
*/
export async function getstudentlist(data?: any) {
const studentlist = (await get<StudentList[]>("studentLive",data)).data;
return studentlist
}
/**
* 直播日历
*/
export async function getdatelist(start: string, end: string, teacherid: number) {
return (await get("teacherCalendar",{start, end, teacherid})).data
}
/**
* 取消直播
*/
export async function cancellive(id: number, status: number){
const res = await post("cancelLive",{id, status})
if(res.code == 0){
message.success(res.msg);
return true;
}else{
message.error(res.msg);
return false;
}
}
/**
* 修改手机号
*/
export async function changetel(code: string,e: string) {
const res = await put(`member/${store.state.userinfo.memberid}`,{code: code, mobile:e});
console.log(res)
if(res.code == 0){
message.success(res.msg)
return true;
}else{
message.error(res.msg);
return false;
}
}
/**
* 验证验证码
*/
export async function checksmscode(phone: string, smscode: string){
const res = await get<any>("checkSmscode",{phone, smscode,memberid: sessionStorage.getItem("mid")});
if(res.code == 0){
if(!res.data){
return true;
}else{
sessionStorage.removeItem("mid")
if(!saveValue("token", res.data.api_token) && !saveValue("memberid", res.data.memberid) ){
message.error("存储错误, 请允许网页使用本地存储!")
return false;
}else{
setToken();
store.commit("login", true);
store.dispatch("setUserInfo");
router.push("/mine/archives")
}
}
// retuzrn true;
}else{
message.error(res.msg);
return false;
}
}
export async function register(data: any){
/* eslint-disable */
const utc = require('dayjs/plugin/utc') // dependent on utc plugin
/* eslint-disable */
const timezone = require('dayjs/plugin/timezone')
const days: any = dayjs;
dayjs.extend(utc)
dayjs.extend(timezone)
const res = await post<any>("register",{
mobile: data.phone,
code: data.quhao,
password: data.pass,
topassword: data.passtow,
name: data.name,
email: data.emil,
mtongue: data.muyu,
tlanguage: data.jiaoshou,
language: getValue("Lanvuage") || 'zh',
zoneid: days.tz.guess(),
memberid: sessionStorage.getItem('mid')
})
if(res.code == 0){
message.success(res.msg)
sessionStorage.removeItem("mid")
if(!saveValue("token", res.data.api_token) && !saveValue("memberid", res.data.memberid) ){
message.error("存储错误, 请允许网页使用本地存储!")
return false;
}else{
setToken();
store.commit("login", true);
store.dispatch("setUserInfo");
// router.push("/mine/archives")
}
return true;
}else{
message.error(res.msg)
return false;
}
}
/**
* 拒绝学生直播
*
*/
export async function refusedtolive(signupid: number, msg: string){
const res = await get<any>("refusedToLive",{signupid, msg})
if(res.code == 0){
message.success(res.msg)
return true;
}else{
message.error(res.msg)
return false;
}
}
/**
* 获取直播签名
*/
export async function usersig(userid: number) {
const res = await get<string>("userSig",{userid});
if(res.code != 0){
message.error(res.msg)
return '';
}
return res.data;
}
export async function liveinfo(id: number): Promise<any>{
const liveinfo = (await get<LiveInfo>(`live/${id}`)).data;
return {
liveid: liveinfo.liveid,
title: liveinfo.title,
img: liveinfo.img,
fileid: liveinfo.fileid,
fileurl: liveinfo.fileurl,
fileduration: liveinfo.fileduration,
dateline: liveinfo.dateline,
livetime: liveinfo.livetime,
livenumber: liveinfo.livenumber,
desc: liveinfo.desc,
status: liveinfo.status
}
}
export async function setlive(data: any){
// data.status = data.livestatus;
console.log(data)
delete data.status;
const info = await put("live/" + data.id, data)
console.log(info.data)
if(info.code==0){
message.success(info.msg)
router.push("/regime/live")
}else{
message.error(info.msg)
}
}
export async function getlivest() {
const res = await get<any>("checkReleaseLive");
if(res.data.status != 0) {
return res.data;
} else {
return false;
}
}
export async function feedback(text: string) {
const res = await post<any>("feedback",{desc:text})
// todo 返回参数错误
if(res.code == 0){
message.success(res.msg)
}else{
message.error(res.msg)
}
}
export async function livestart(id: string) {
const res = await put("live/" + id, {status : 1})
if(res.code == 0){
message.success(res.msg)
}else{
message.error(res.msg)
}
}
export async function livestop(id: string, roomid: string) {
const res = await put("live/" + id, {status : 2})
if(res.code == 0){
message.success(res.msg)
}else{
message.error(res.msg)
}
// const luzhi = await get('StopMCUMixTranscode', {roomid});
// console.log(luzhi)
}
export async function luzhi(roomid: string){
const res = await get('StartMCUMixTranscode', {roomid});
console.log(res)
}
export function getaddr() {
return new Promise(async (r)=>{
// console.log("开始定位")
const lan = getValue("Lanvuage");
// if ("geolocation" in navigator) {
// /* 地理位置服务可用 */
// navigator.geolocation.getCurrentPosition(async (res) => {
// console.log(res, 'res')
// const qh = await get<any>('countryCode', {
// longitude: res.coords.longitude,
// latitude: res.coords.latitude
// });
// console.log(qh)
// if(lan != null && lan){
// if(qh.data.ename == "China"){
// r({hb: '人民币¥', qh});
// }else {
// r({hb: '美元$', qh})
// }
// }else{
// if(qh.data.ename == "China"){
// r({yy: "zh", yyx: "中文", hb: '人民币¥', qh});
// }else {
// r({yy: 'en', yyx: 'English', hb: '美元$', qh})
// }
// }
// },async () => {
// const qh = await get<any>('countryCode', {
// });
// console.log(qh)
// if(lan != null && lan){
// if(qh.data.ename == "China"){
// r({hb: '人民币¥', qh});
// }else {
// r({hb: '美元$', qh})
// }
// }else{
// if(qh.data.ename == "China"){
// r({yy: "zh", yyx: "中文", hb: '人民币¥', qh});
// }else {
// r({yy: 'en', yyx: 'English', hb: '美元$', qh})
// }
// }
// // message.error(err.message)
// // console.log(err, 'err')
// })
// } else {
// const qh = await get<any>('countryCode', {
// });
// console.log(qh)
// if(lan != null && lan){
// if(qh.data.ename == "China"){
// r({hb: '人民币¥', qh});
// }else {
// r({hb: '美元$', qh})
// }
// }else{
// if(qh.data.ename == "China"){
// r({yy: "zh", yyx: "中文", hb: '人民币¥', qh});
// }else {
// r({yy: 'en', yyx: 'English', hb: '美元$', qh})
// }
// }
// /* 地理位置服务不可用 */
// console.log("无法定位")
// }
const qh = await get<any>('countryCode', {
});
console.log(qh)
if(lan != null && lan){
if(qh.data.ename == "China"){
r({hb: '人民币¥', qh});
}else {
r({hb: '美元$', qh})
}
}else{
if(qh.data.ename == "China"){
r({yy: "zh", yyx: "中国(CN)", hb: '人民币¥', qh});
}else {
r({yy: 'en', yyx: 'EN', hb: '美元$', qh})
}
}
})
// const res = await get<any>('ip');
// const gj = res.data.address.split("|")[0];
// const lan = getValue("Lanvuage");
// const qh = await get<any>('countryCode', {
// longitude: res.data.content.point.x,
// latitude: res.data.content.point.y
// });
// console.log(qh)
// if(lan != null && lan){
// if(gj == "CN"){
// return {hb: '人民币¥', qh};
// }else {
// return {hb: '美元$'}
// }
// }else{
// if(gj == "CN"){
// return {yy: "zh", yyx: "中文", hb: '人民币¥', qh};
// }else {
// return {yy: 'en', yyx: 'English', hb: '美元$', qh}
// }
// }
}
// export async function StopMCUMixTranscode(roomid: number) {
// const res = await get('StopMCUMixTranscode', {roomid});
// console.log(res)
// }
export function interests() {
// const res = await get('interests');
// return res.data;
return new Promise((res)=>{
const time = setInterval(()=>{
if(JSON.stringify(store.state.indexarr.interests) != "{}"){
res(store.state.indexarr.interests)
clearInterval(time)
}
console.log("dengdai")
}, 500)
})
}
export async function getset() {
const res = await get('getset');
return res.data;
}
export async function setheadimg(src: string){
const res = await put(`member/${store.state.userinfo.memberid}`,{img: src});
if(res.code == 0){
message.success(res.msg)
}else{
message.error(res.msg);
}
console.log(res)
}
export async function setusername(src: string){
const res = await put(`member/${store.state.userinfo.memberid}`,{name: src});
if(res.code == 0){
message.success(res.msg)
}else{
message.error(res.msg);
}
console.log(res)
}
export async function logoutapi() {
await get("logout");
}
export async function authLogin(id:number, type: number, img: string = "") {
const res = await post("authLogin",{
uid: id,
type: 1,
login_type: type,
img: img
})
if(res.code == 0){
return res.data
}else{
message.error(res.msg);
}
}
export async function accessToken(code:string,type: number) {
const res = await get("accessToken", {code, type})
if(res.code == 0){
return res.data
}else{
message.error(res.msg);
router.push("/")
}
}
export async function getarticle() {
const res1 = await get("article", {navigationid: 1})
const res2 = await get("article", {navigationid: 2})
return [
res1.data,
res2.data
]
}
export async function share() {
const res = await get("share")
if(res.code == 0){
return res.data
}else{
message.error(res.msg);
}
}
export async function addshareClick(videoid:number) {
await get("addshareClick",{videoid})
}
export async function personalCenterData() {
return (await get<any>('personalCenterData')).data
}