import router from '@/router'; import store from '@/store'; import { LoginData, UserInfo } from '@/types'; import { saveValue } from '@/utils/common'; import { message } from 'ant-design-vue'; import { get, post, setToken } from './base' /** * 用户名密码登录 * @param phone 手机号 * @param password 密码 */ export async function loginpass(phone: string, password: string){ const res = await post("login",{type: 2,username: phone, password: password}); 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"); store.dispatch("setUserInfo"); router.push("/mine/archives") } } } /** * 用户头像和用户名字 */ export async function userinfo(){ const user = await get('personalInfo'); // console.log(user.data?.img) if(user.code == 1001){ router.push("/") return '未登录'; } return { head: user.data?.img, username: user.data?.name, language: user.data?.language, currency: user.data?.currency, zoneStr: user.data?.zoneStr, memberid: user.data?.memberid, country: user.data?.country, live: user.data?.live, mtongue: user.data?.mtongue, tlanguage: user.data?.tlanguage, willsay: user.data?.willsay, interest: user.data?.interest, mobile: user.data?.mobile, email: user.data?.email, birthday: user.data?.birthday, video: user.data?.video, desc: user.data?.desc, money: user.data?.money } } /** * 获取用户绑定银行卡列表 */ 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>('wallect') console.log(res) } /** * 订阅者列表 */ interface Teacherliked { memberid: number; name: string; img: string; live: string; birthday: string; mtongue: string; interest: string; } export async function getteacherliked(){ const res = await get>('teacherliked'); console.log(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; } export async function getvideolist() { const res = await get>('video') console.log(res) } /** * 直播列表 */ interface LiveList { liveid: number; memberid: number; title: string; img: string; fileid: string; fileurl: string; fileduration: string; vodurl: string; vodid: string; vodduration: string; dateline: string; livetime: number; livenumber: number; status: number; livestatus: number; students: string; desc: string; deleted_at: null; created_at: string; updated_at: string; statusname: string; starttime: string; begin: number; } export async function getlivelist() { const res = await get>('live'); console.log(res); }