hookehuyr

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

...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
2 * @Author: hookehuyr hookehuyr@gmail.com 2 * @Author: hookehuyr hookehuyr@gmail.com
3 * @Date: 2022-06-09 02:25:31 3 * @Date: 2022-06-09 02:25:31
4 * @LastEditors: hookehuyr hookehuyr@gmail.com 4 * @LastEditors: hookehuyr hookehuyr@gmail.com
5 - * @LastEditTime: 2022-06-09 02:26:54 5 + * @LastEditTime: 2022-06-17 22:32:59
6 * @FilePath: /tswj/src/api/B/kg.js 6 * @FilePath: /tswj/src/api/B/kg.js
7 * @Description: 幼儿园主页接口 7 * @Description: 幼儿园主页接口
8 */ 8 */
...@@ -10,6 +10,7 @@ import { fn, fetch } from '@/api/fn'; ...@@ -10,6 +10,7 @@ import { fn, fetch } from '@/api/fn';
10 10
11 const Api = { 11 const Api = {
12 KG_INFO: '/srv/?a=kg_info', 12 KG_INFO: '/srv/?a=kg_info',
13 + MY_KG: '/srv/?a=my_kg',
13 } 14 }
14 15
15 /** 16 /**
...@@ -17,3 +18,9 @@ const Api = { ...@@ -17,3 +18,9 @@ const Api = {
17 * @returns {*} data 18 * @returns {*} data
18 */ 19 */
19 export const kgInfoAPI = (params) => fn(fetch.get(Api.KG_INFO, params)); 20 export const kgInfoAPI = (params) => fn(fetch.get(Api.KG_INFO, params));
21 +
22 +/**
23 + * @description 我的幼儿园详情
24 + * @returns {*} data
25 + */
26 +export const myKgAPI = (params) => fn(fetch.get(Api.MY_KG, params));
......
1 /* 1 /*
2 * @Date: 2022-06-17 15:03:03 2 * @Date: 2022-06-17 15:03:03
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2022-06-17 15:05:04 4 + * @LastEditTime: 2022-06-17 22:44:30
5 * @FilePath: /tswj/src/api/B/login.js 5 * @FilePath: /tswj/src/api/B/login.js
6 * @Description: 文件描述 6 * @Description: 文件描述
7 */ 7 */
...@@ -9,6 +9,7 @@ import { fn, fetch } from '@/api/fn'; ...@@ -9,6 +9,7 @@ import { fn, fetch } from '@/api/fn';
9 9
10 const Api = { 10 const Api = {
11 B_LOGIN: '/srv/?a=b_login', 11 B_LOGIN: '/srv/?a=b_login',
12 + B_LOGOUT: '/srv/?a=b_logout',
12 } 13 }
13 14
14 /** 15 /**
...@@ -16,4 +17,9 @@ const Api = { ...@@ -16,4 +17,9 @@ const Api = {
16 * @param {*} phone 手机号 17 * @param {*} phone 手机号
17 * @param {*} pin 验证码 18 * @param {*} pin 验证码
18 */ 19 */
19 -export const b_LoginAPI = (params) => fn(fetch.get(Api.B_LOGIN, params)); 20 +export const bLoginAPI = (params) => fn(fetch.get(Api.B_LOGIN, params));
21 +
22 +/**
23 + * @description 登出接口
24 + */
25 +export const bLogoutAPI = (params) => fn(fetch.post(Api.B_LOGOUT, params));
......
...@@ -53,7 +53,7 @@ import { wxInfo } from '@/utils/tools'; ...@@ -53,7 +53,7 @@ import { wxInfo } from '@/utils/tools';
53 import { useCountDown } from '@vant/use'; 53 import { useCountDown } from '@vant/use';
54 54
55 import { smsAPI } from '@/api/common' 55 import { smsAPI } from '@/api/common'
56 -import { b_LoginAPI } from '@/api/B/login' 56 +import { bLoginAPI } from '@/api/B/login'
57 57
58 const $router = useRouter(); 58 const $router = useRouter();
59 59
...@@ -177,7 +177,7 @@ const formatter = (value) => value.substring(0, 4); ...@@ -177,7 +177,7 @@ const formatter = (value) => value.substring(0, 4);
177 */ 177 */
178 178
179 const onSubmit = async (values) => { 179 const onSubmit = async (values) => {
180 - const { code } = await b_LoginAPI({ phone: values.phone, pin: values.code }) 180 + const { code } = await bLoginAPI({ phone: values.phone, pin: values.code })
181 if (code === 1) { 181 if (code === 1) {
182 $router.push({ 182 $router.push({
183 path: '/business/index' 183 path: '/business/index'
......
...@@ -28,46 +28,36 @@ ...@@ -28,46 +28,36 @@
28 import ShortcutFixed from '@/components/ShortcutFixed/index.vue' 28 import ShortcutFixed from '@/components/ShortcutFixed/index.vue'
29 import { icon_logo } from '@/utils/generateIcons'; 29 import { icon_logo } from '@/utils/generateIcons';
30 import { USER_ROLE } from '@/constant' 30 import { USER_ROLE } from '@/constant'
31 -import { ref} from 'vue' 31 +import { onMounted, ref} from 'vue'
32 import { useRouter } from 'vue-router' 32 import { useRouter } from 'vue-router'
33 -import axios from '@/utils/axios'; 33 +import { myKgAPI } from '@/api/B/kg'
34 -import { Toast } from 'vant'; 34 +import { bLogoutAPI } from '@/api/B/login'
35 +
35 const $router = useRouter(); 36 const $router = useRouter();
36 37
37 const myKgInfo = ref({}); 38 const myKgInfo = ref({});
38 -let itemList = ref([]) 39 +let itemList = ref([]);
39 -axios.get('/srv/?a=my_kg') 40 +
40 -.then(res => { 41 +onMounted(async () => {
41 - if (res.data.code === 1) { 42 + const { data } = await myKgAPI();
42 - myKgInfo.value = res.data.data; 43 + myKgInfo.value = data;
43 - // 有空格分割name 44 + // 有空格分割name
44 - if (myKgInfo.value.name.indexOf(' ') > -1) { 45 + if (myKgInfo.value.name.indexOf(' ') > -1) {
45 - myKgInfo.value.multi_name = myKgInfo.value.name.split(' '); 46 + myKgInfo.value.multi_name = myKgInfo.value.name.split(' ');
46 - }
47 - itemList.value = [
48 - {
49 - name: '幼儿园上传视频',
50 - sum: res.data.data.mission_num,
51 - to: '/business/myVideo'
52 - },
53 - {
54 - name: '家长上传视频',
55 - sum: res.data.data.prod_num,
56 - tag: true,
57 - to: '/business/auditVideo'
58 - },
59 - ]
60 - } else {
61 - console.warn(res);
62 - if (!res.data.show) return false;
63 - Toast({
64 - icon: 'close',
65 - message: res.data.msg
66 - });
67 } 47 }
68 -}) 48 + itemList.value = [
69 -.catch(err => { 49 + {
70 - console.error(err); 50 + name: '幼儿园上传视频',
51 + sum: data.mission_num,
52 + to: '/business/myVideo'
53 + },
54 + {
55 + name: '家长上传视频',
56 + sum: data.prod_num,
57 + tag: true,
58 + to: '/business/auditVideo'
59 + },
60 + ]
71 }) 61 })
72 62
73 const goTo = (path) => { // 跳转作品详情页 63 const goTo = (path) => { // 跳转作品详情页
...@@ -77,25 +67,13 @@ const goTo = (path) => { // 跳转作品详情页 ...@@ -77,25 +67,13 @@ const goTo = (path) => { // 跳转作品详情页
77 } 67 }
78 68
79 // 退出登录 69 // 退出登录
80 -const exitLogin = () => { 70 +const exitLogin = async () => {
81 - axios.post('/srv/?a=b_logout') 71 + const { code } = await bLogoutAPI()
82 - .then(res => { 72 + if (code === 1) {
83 - if (res.data.code === 1) { 73 + $router.replace({
84 - $router.replace({ 74 + path: '/business/login'
85 - path: '/business/login' 75 + });
86 - }); 76 + }
87 - } else {
88 - console.warn(res);
89 - if (!res.data.show) return false;
90 - Toast({
91 - icon: 'close',
92 - message: res.data.msg
93 - });
94 - }
95 - })
96 - .catch(err => {
97 - console.error(err);
98 - })
99 } 77 }
100 </script> 78 </script>
101 79
......