hookehuyr

✨ feat(B端页面): 登录模块和我的模块API形式调整

......@@ -2,7 +2,7 @@
* @Author: hookehuyr hookehuyr@gmail.com
* @Date: 2022-06-09 02:25:31
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2022-06-09 02:26:54
* @LastEditTime: 2022-06-17 22:32:59
* @FilePath: /tswj/src/api/B/kg.js
* @Description: 幼儿园主页接口
*/
......@@ -10,6 +10,7 @@ import { fn, fetch } from '@/api/fn';
const Api = {
KG_INFO: '/srv/?a=kg_info',
MY_KG: '/srv/?a=my_kg',
}
/**
......@@ -17,3 +18,9 @@ const Api = {
* @returns {*} data
*/
export const kgInfoAPI = (params) => fn(fetch.get(Api.KG_INFO, params));
/**
* @description 我的幼儿园详情
* @returns {*} data
*/
export const myKgAPI = (params) => fn(fetch.get(Api.MY_KG, params));
......
/*
* @Date: 2022-06-17 15:03:03
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2022-06-17 15:05:04
* @LastEditTime: 2022-06-17 22:44:30
* @FilePath: /tswj/src/api/B/login.js
* @Description: 文件描述
*/
......@@ -9,6 +9,7 @@ import { fn, fetch } from '@/api/fn';
const Api = {
B_LOGIN: '/srv/?a=b_login',
B_LOGOUT: '/srv/?a=b_logout',
}
/**
......@@ -16,4 +17,9 @@ const Api = {
* @param {*} phone 手机号
* @param {*} pin 验证码
*/
export const b_LoginAPI = (params) => fn(fetch.get(Api.B_LOGIN, params));
export const bLoginAPI = (params) => fn(fetch.get(Api.B_LOGIN, params));
/**
* @description 登出接口
*/
export const bLogoutAPI = (params) => fn(fetch.post(Api.B_LOGOUT, params));
......
......@@ -53,7 +53,7 @@ import { wxInfo } from '@/utils/tools';
import { useCountDown } from '@vant/use';
import { smsAPI } from '@/api/common'
import { b_LoginAPI } from '@/api/B/login'
import { bLoginAPI } from '@/api/B/login'
const $router = useRouter();
......@@ -177,7 +177,7 @@ const formatter = (value) => value.substring(0, 4);
*/
const onSubmit = async (values) => {
const { code } = await b_LoginAPI({ phone: values.phone, pin: values.code })
const { code } = await bLoginAPI({ phone: values.phone, pin: values.code })
if (code === 1) {
$router.push({
path: '/business/index'
......
......@@ -28,46 +28,36 @@
import ShortcutFixed from '@/components/ShortcutFixed/index.vue'
import { icon_logo } from '@/utils/generateIcons';
import { USER_ROLE } from '@/constant'
import { ref} from 'vue'
import { onMounted, ref} from 'vue'
import { useRouter } from 'vue-router'
import axios from '@/utils/axios';
import { Toast } from 'vant';
import { myKgAPI } from '@/api/B/kg'
import { bLogoutAPI } from '@/api/B/login'
const $router = useRouter();
const myKgInfo = ref({});
let itemList = ref([])
axios.get('/srv/?a=my_kg')
.then(res => {
if (res.data.code === 1) {
myKgInfo.value = res.data.data;
// 有空格分割name
if (myKgInfo.value.name.indexOf(' ') > -1) {
myKgInfo.value.multi_name = myKgInfo.value.name.split(' ');
}
itemList.value = [
{
name: '幼儿园上传视频',
sum: res.data.data.mission_num,
to: '/business/myVideo'
},
{
name: '家长上传视频',
sum: res.data.data.prod_num,
tag: true,
to: '/business/auditVideo'
},
]
} else {
console.warn(res);
if (!res.data.show) return false;
Toast({
icon: 'close',
message: res.data.msg
});
let itemList = ref([]);
onMounted(async () => {
const { data } = await myKgAPI();
myKgInfo.value = data;
// 有空格分割name
if (myKgInfo.value.name.indexOf(' ') > -1) {
myKgInfo.value.multi_name = myKgInfo.value.name.split(' ');
}
})
.catch(err => {
console.error(err);
itemList.value = [
{
name: '幼儿园上传视频',
sum: data.mission_num,
to: '/business/myVideo'
},
{
name: '家长上传视频',
sum: data.prod_num,
tag: true,
to: '/business/auditVideo'
},
]
})
const goTo = (path) => { // 跳转作品详情页
......@@ -77,25 +67,13 @@ const goTo = (path) => { // 跳转作品详情页
}
// 退出登录
const exitLogin = () => {
axios.post('/srv/?a=b_logout')
.then(res => {
if (res.data.code === 1) {
$router.replace({
path: '/business/login'
});
} else {
console.warn(res);
if (!res.data.show) return false;
Toast({
icon: 'close',
message: res.data.msg
});
}
})
.catch(err => {
console.error(err);
})
const exitLogin = async () => {
const { code } = await bLogoutAPI()
if (code === 1) {
$router.replace({
path: '/business/login'
});
}
}
</script>
......