Showing
5 changed files
with
49 additions
and
22 deletions
src/api/C/kg.js
0 → 100644
src/api/C/me.js
0 → 100644
src/api/fn.js
0 → 100644
| 1 | +import { Toast } from 'vant'; | ||
| 2 | + | ||
| 3 | +/** | ||
| 4 | + * 网络请求功能函数 | ||
| 5 | + * @param {*} api 请求axios接口 | ||
| 6 | + * @returns 请求成功后,获取数据 | ||
| 7 | + */ | ||
| 8 | +export const fn = (api) => { | ||
| 9 | + return api | ||
| 10 | + .then(res => { | ||
| 11 | + if (res.data.code === 1) { | ||
| 12 | + return res.data.data; | ||
| 13 | + } else { | ||
| 14 | + console.warn(res); | ||
| 15 | + if (!res.data.show) return false; | ||
| 16 | + Toast({ | ||
| 17 | + icon: 'close', | ||
| 18 | + message: res.data.msg | ||
| 19 | + }); | ||
| 20 | + } | ||
| 21 | + }) | ||
| 22 | + .catch(err => { | ||
| 23 | + console.error(err); | ||
| 24 | + }) | ||
| 25 | +} |
| ... | @@ -14,10 +14,7 @@ import { mainStore } from '@/store' | ... | @@ -14,10 +14,7 @@ import { mainStore } from '@/store' |
| 14 | 14 | ||
| 15 | import RightSideList from '@/components/RightSideList/index.vue' | 15 | import RightSideList from '@/components/RightSideList/index.vue' |
| 16 | 16 | ||
| 17 | -import { ref } from 'vue'; | ||
| 18 | -import axios from '@/utils/axios'; | ||
| 19 | import { useRouter } from 'vue-router' | 17 | import { useRouter } from 'vue-router' |
| 20 | -import { Toast } from 'vant'; | ||
| 21 | 18 | ||
| 22 | const $router = useRouter(); | 19 | const $router = useRouter(); |
| 23 | 20 | ||
| ... | @@ -39,27 +36,14 @@ const onClick = (item) => { | ... | @@ -39,27 +36,14 @@ const onClick = (item) => { |
| 39 | 36 | ||
| 40 | <script> | 37 | <script> |
| 41 | import mixin from 'common/mixin' | 38 | import mixin from 'common/mixin' |
| 39 | +import { kgListAPI } from '@/api/C/kg.js' | ||
| 42 | 40 | ||
| 43 | export default { | 41 | export default { |
| 44 | beforeRouteEnter (to, from, next) { | 42 | beforeRouteEnter (to, from, next) { |
| 45 | - // 幼儿园列表页 | 43 | + (async () => { |
| 46 | - axios.get('/srv/?a=kg_list') | 44 | + to.params.schoolList = await kgListAPI(); |
| 47 | - .then(res => { | 45 | + next(); |
| 48 | - if (res.data.code === 1) { | 46 | + })() |
| 49 | - to.params.schoolList = res.data.data; | ||
| 50 | - next(); | ||
| 51 | - } else { | ||
| 52 | - console.warn(res); | ||
| 53 | - if (!res.data.show) return false; | ||
| 54 | - Toast({ | ||
| 55 | - icon: 'close', | ||
| 56 | - message: res.data.msg | ||
| 57 | - }); | ||
| 58 | - } | ||
| 59 | - }) | ||
| 60 | - .catch(err => { | ||
| 61 | - console.error(err); | ||
| 62 | - }) | ||
| 63 | }, | 47 | }, |
| 64 | mixins: [mixin.init], | 48 | mixins: [mixin.init], |
| 65 | data () { | 49 | data () { | ... | ... |
| ... | @@ -91,6 +91,9 @@ import axios from '@/utils/axios'; | ... | @@ -91,6 +91,9 @@ import axios from '@/utils/axios'; |
| 91 | import $ from 'jquery' | 91 | import $ from 'jquery' |
| 92 | import _ from 'lodash' | 92 | import _ from 'lodash' |
| 93 | import { Toast } from 'vant'; | 93 | import { Toast } from 'vant'; |
| 94 | + | ||
| 95 | +import { changePerformerAPI } from '@/api/C/me.js' | ||
| 96 | + | ||
| 94 | const $route = useRoute(); | 97 | const $route = useRoute(); |
| 95 | const $router = useRouter(); | 98 | const $router = useRouter(); |
| 96 | 99 | ||
| ... | @@ -134,7 +137,7 @@ const onSelect = (item) => { | ... | @@ -134,7 +137,7 @@ const onSelect = (item) => { |
| 134 | // 可以通过 close-on-click-action 属性开启自动收起 | 137 | // 可以通过 close-on-click-action 属性开启自动收起 |
| 135 | show.value = false; | 138 | show.value = false; |
| 136 | // 切换当前角色 | 139 | // 切换当前角色 |
| 137 | - axios.post('/srv/?a=change_performer', { | 140 | + changePerformerAPI({ |
| 138 | perf_id: item.id | 141 | perf_id: item.id |
| 139 | }) | 142 | }) |
| 140 | .then(res => { | 143 | .then(res => { | ... | ... |
-
Please register or login to post a comment