895 lines
18 KiB
TypeScript
895 lines
18 KiB
TypeScript
import router from '@/router';
|
|
import store from '@/store';
|
|
import { LiveList, LivelistInfo, LoginData, UserInfo } from '@/types';
|
|
import { saveValue } from '@/utils/common';
|
|
import { message } from 'ant-design-vue';
|
|
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={}
|
|
if(type==1){
|
|
newdata={type:type?type:2,username: phone, smscode: smscode}
|
|
}else{
|
|
newdata={type:type?type:2,username: phone, password: password}
|
|
}
|
|
|
|
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);
|
|
store.dispatch("setUserInfo");
|
|
router.push("/mine/archives")
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 用户头像和用户名字
|
|
*/
|
|
export async function userinfo(){
|
|
const user = await get<UserInfo>('personalInfo');
|
|
// console.log(user.data.img)
|
|
if(user.code == 1001){
|
|
router.push("/")
|
|
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)
|
|
}
|
|
|
|
/**
|
|
* 发布视频
|
|
*/
|
|
export async function videoadd( form: any,data: any) {
|
|
const res=await post<Liveaddrule>('video',data)
|
|
if(res.code==0){
|
|
message.success("发布成功")
|
|
form.value = {
|
|
title: "",
|
|
img: "",
|
|
fileid: "",
|
|
fileurl: "",
|
|
fileduration: "",
|
|
desc: "",
|
|
video: [""],
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 视频详情
|
|
*/
|
|
|
|
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;
|
|
}
|
|
|
|
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
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
* 删除视频
|
|
*/
|
|
export async function videodel(data: any) {
|
|
const res = await del<Liveaddrule>('video/'+data);
|
|
if(res.code==0){
|
|
message.success("删除成功")
|
|
}
|
|
|
|
console.log(res)
|
|
}
|
|
|
|
/**
|
|
* 新增账户
|
|
*/
|
|
export async function accountadd(data?: any) {
|
|
const res = await post<Liveaddrule>('wallect',data);
|
|
if(res.code==0){
|
|
message.success("新增成功")
|
|
}
|
|
|
|
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
|
|
console.log(data)
|
|
const res = await post<Liveaddrule>('withdrawal',data);
|
|
if(res.code==0){
|
|
message.success(res.msg)
|
|
// userinfo()
|
|
store.dispatch("setUserInfo");
|
|
}else{
|
|
message.error(res.msg)
|
|
}
|
|
}
|
|
/**
|
|
* 账户详情
|
|
*/
|
|
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(data?: any){
|
|
const res=await put<Liveaddrule>('wallect/'+data);
|
|
if(res.code==0){
|
|
message.success("修改成功")
|
|
}
|
|
}
|
|
/**
|
|
* 删除账户
|
|
*/
|
|
export async function deleteaccount(data: any) {
|
|
|
|
const res = await del<Liveaddrule>('wallect/' + data);
|
|
if(res.code==0){
|
|
message.success("删除成功")
|
|
}
|
|
|
|
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={
|
|
memberid:0,
|
|
password: "",
|
|
topassword: ""
|
|
}
|
|
newdata.memberid=data.memberid
|
|
newdata.password=data.password
|
|
newdata.topassword=data.repassword
|
|
console.log(newdata)
|
|
const res = await post<Liveaddrule>('resetPassword',newdata)
|
|
if(res.code==0){
|
|
message.success("修改成功")
|
|
|
|
}
|
|
return res
|
|
}
|
|
|
|
/**
|
|
* 提现记录 列表
|
|
*/
|
|
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("发布成功")
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 删除评论
|
|
*/
|
|
|
|
export async function delreply(data?: any) {
|
|
const res = await del<Liveaddrule>('comments/'+data);
|
|
if(res.code==0){
|
|
message.success("删除成功")
|
|
}
|
|
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)
|
|
return {
|
|
code: res.code,
|
|
msg: res.msg,
|
|
data: {
|
|
memberid: res.data.memberid,
|
|
name: res.data.name,
|
|
mobile: res.data.mobile,
|
|
email: res.data.email,
|
|
code: res.data.code
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 获取区号列表
|
|
*/
|
|
export async function getquhaolist() {
|
|
const res=await get("phonecodes")
|
|
// console.log(res)
|
|
return res.data
|
|
}
|
|
|
|
/**
|
|
* 获取时区列表
|
|
*/
|
|
export async function getzonelist(): Promise<any>{
|
|
const res=await get("timezones")
|
|
// console.log(res)
|
|
return res.data
|
|
}
|
|
|
|
/**
|
|
* 修改时区 货币 语言
|
|
*/
|
|
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("修改成功")
|
|
store.dispatch("setUserInfo");
|
|
return true;
|
|
}else{
|
|
message.error(res.msg);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 货币列表
|
|
*/
|
|
export async function getcurrencys(){
|
|
const res=await get("currencys")
|
|
return res.data
|
|
}
|
|
|
|
/**
|
|
* 发送验证码
|
|
* @param phone 手机号
|
|
* @param type 国外1 国内0
|
|
*/
|
|
interface SendSms{
|
|
code: number;
|
|
msg: string;
|
|
}
|
|
|
|
export async function sendsms(phone: string, type: number): Promise<boolean>{
|
|
const res = await post<SendSms>("SendSms", {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 async function getarchives(): Promise<[Countries[],Willsay[]]>{
|
|
return [(await get<Countries[]>("countries")).data, (await get<Willsay[]>("willsay")).data];
|
|
}
|
|
|
|
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 async function getlanguages(): Promise<Language[]>{
|
|
|
|
return (await get<Language[]>("languages")).data;
|
|
}
|
|
|
|
/**
|
|
* 修改我的档案
|
|
*/
|
|
|
|
// 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.willsayValue),
|
|
birthday: data.birthday,
|
|
zoneid: data.zoneid,
|
|
currency: data.currencyValue,
|
|
language: data.languageValue,
|
|
tlanguage: data.tlanguageValue,
|
|
video: data.video,
|
|
desc: data.desc
|
|
}
|
|
console.log(newdata)
|
|
const res = await put<Liveaddrule>(`member/${store.state.userinfo.memberid}`, newdata)
|
|
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;
|
|
}
|
|
|
|
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(e: string) {
|
|
const res = await put(`member/${store.state.userinfo.memberid}`,{mobile:e});
|
|
console.log(res)
|
|
if(res.code == 0){
|
|
message.success("修改成功")
|
|
return true;
|
|
}else{
|
|
message.error(res.msg);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
* 验证验证码
|
|
*/
|
|
|
|
export async function checksmscode(phone: string, smscode: string){
|
|
const res = await get("checkSmscode",{phone, smscode});
|
|
if(res.code == 0){
|
|
return true;
|
|
}else{
|
|
message.error(res.msg);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
export async function register(data: any){
|
|
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
|
|
})
|
|
if(res.code == 0){
|
|
message.success(res.msg)
|
|
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;
|
|
} |