Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Hooke
/
tswj
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
hookehuyr
2022-05-18 23:04:20 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
0df3f4f20e6181b4f7d3aa36681ee9afa28b6992
0df3f4f2
1 parent
618db7d2
API请求接口封装
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
49 additions
and
22 deletions
src/api/C/kg.js
src/api/C/me.js
src/api/fn.js
src/views/client/chooseSchool.vue
src/views/me/index.vue
src/api/C/kg.js
0 → 100644
View file @
0df3f4f
import
axios
from
'@/utils/axios'
;
import
{
fn
}
from
'@/api/fn'
;
const
Api
=
{
KG_LIST
:
'/srv/?a=kg_list'
,
// 幼儿园列表页
}
export
const
kgListAPI
=
(
params
)
=>
fn
(
axios
.
get
(
Api
.
KG_LIST
,
{
params
}))
src/api/C/me.js
0 → 100644
View file @
0df3f4f
import
axios
from
'@/utils/axios'
;
const
Api
=
{
CHANGE_PERFORMER
:
'/srv/?a=change_performer'
,
// 切换儿童角色
}
export
const
changePerformerAPI
=
(
params
)
=>
axios
.
post
(
Api
.
CHANGE_PERFORMER
,
params
)
src/api/fn.js
0 → 100644
View file @
0df3f4f
import
{
Toast
}
from
'vant'
;
/**
* 网络请求功能函数
* @param {*} api 请求axios接口
* @returns 请求成功后,获取数据
*/
export
const
fn
=
(
api
)
=>
{
return
api
.
then
(
res
=>
{
if
(
res
.
data
.
code
===
1
)
{
return
res
.
data
.
data
;
}
else
{
console
.
warn
(
res
);
if
(
!
res
.
data
.
show
)
return
false
;
Toast
({
icon
:
'close'
,
message
:
res
.
data
.
msg
});
}
})
.
catch
(
err
=>
{
console
.
error
(
err
);
})
}
src/views/client/chooseSchool.vue
View file @
0df3f4f
...
...
@@ -14,10 +14,7 @@ import { mainStore } from '@/store'
import RightSideList from '@/components/RightSideList/index.vue'
import { ref } from 'vue';
import axios from '@/utils/axios';
import { useRouter } from 'vue-router'
import { Toast } from 'vant';
const $router = useRouter();
...
...
@@ -39,27 +36,14 @@ const onClick = (item) => {
<script>
import mixin from 'common/mixin'
import { kgListAPI } from '@/api/C/kg.js'
export default {
beforeRouteEnter (to, from, next) {
// 幼儿园列表页
axios.get('/srv/?a=kg_list')
.then(res => {
if (res.data.code === 1) {
to.params.schoolList = res.data.data;
next();
} else {
console.warn(res);
if (!res.data.show) return false;
Toast({
icon: 'close',
message: res.data.msg
});
}
})
.catch(err => {
console.error(err);
})
(async () => {
to.params.schoolList = await kgListAPI();
next();
})()
},
mixins: [mixin.init],
data () {
...
...
src/views/me/index.vue
View file @
0df3f4f
...
...
@@ -91,6 +91,9 @@ import axios from '@/utils/axios';
import $ from 'jquery'
import _ from 'lodash'
import { Toast } from 'vant';
import { changePerformerAPI } from '@/api/C/me.js'
const $route = useRoute();
const $router = useRouter();
...
...
@@ -134,7 +137,7 @@ const onSelect = (item) => {
// 可以通过 close-on-click-action 属性开启自动收起
show.value = false;
// 切换当前角色
axios.post('/srv/?a=change_performer',
{
changePerformerAPI(
{
perf_id: item.id
})
.then(res => {
...
...
Please
register
or
login
to post a comment