diff --git a/src/api/task.ts b/src/api/task.ts index e69de29..340cd78 100644 --- a/src/api/task.ts +++ b/src/api/task.ts @@ -0,0 +1,27 @@ +import request from "../utils/request"; + + +//城市列表 +export function cityList(data:any) { + return request({ + url: '/sys/city/list', + method: 'get', + params:data + }) +} +//轮播 +export function bannerList(data:any) { + return request({ + url: '/home/banner/list', + method: 'get', + params:data + }) +} +//职位类型 +export function positionTypeList(data:any) { + return request({ + url: '/position/positionTypeApi', + method: 'get', + params:data + }) +} \ No newline at end of file diff --git a/src/assets/img/icon/icon-add.png b/src/assets/img/icon/icon-add.png new file mode 100644 index 0000000..8224883 Binary files /dev/null and b/src/assets/img/icon/icon-add.png differ diff --git a/src/assets/img/icon/icon-code.png b/src/assets/img/icon/icon-code.png new file mode 100644 index 0000000..649e990 Binary files /dev/null and b/src/assets/img/icon/icon-code.png differ diff --git a/src/assets/img/icon/icon-delete.png b/src/assets/img/icon/icon-delete.png new file mode 100644 index 0000000..333c75a Binary files /dev/null and b/src/assets/img/icon/icon-delete.png differ diff --git a/src/assets/img/icon/icon-edit.png b/src/assets/img/icon/icon-edit.png new file mode 100644 index 0000000..604780d Binary files /dev/null and b/src/assets/img/icon/icon-edit.png differ diff --git a/src/components/list/TalentList.vue b/src/components/list/TalentList.vue index e69de29..95a0b25 100644 --- a/src/components/list/TalentList.vue +++ b/src/components/list/TalentList.vue @@ -0,0 +1,128 @@ + + + + \ No newline at end of file diff --git a/src/components/list/message.vue b/src/components/list/message.vue index e69de29..eca9a25 100644 --- a/src/components/list/message.vue +++ b/src/components/list/message.vue @@ -0,0 +1,81 @@ + + + + \ No newline at end of file diff --git a/src/main.ts b/src/main.ts index 186e17e..ea5b93d 100644 --- a/src/main.ts +++ b/src/main.ts @@ -5,15 +5,19 @@ import App from './App.vue' import store from "./store/index.ts"; import router from "./router"; import './utils/rem' -import { Button,NavBar,Tabbar,TabbarItem,Checkbox,Toast,Icon } from "vant"; +import { Button,NavBar,Tabbar,TabbarItem,Checkbox,Toast,Icon ,Popup , Swipe, SwipeItem} from "vant"; const app = createApp(App) app.use(Button) app.use(NavBar) app.use(Tabbar) app.use(TabbarItem) app.use(Checkbox) +app.use(Popup) app.use(Toast) app.use(Icon) +app.use(Swipe) +app.use(SwipeItem) + app.use(store) app.use(router) app.mount('#app') diff --git a/src/router/index.ts b/src/router/index.ts index e0c33d9..c0436c5 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -1,4 +1,7 @@ -import { createRouter, createWebHashHistory, RouteRecordRaw } from "vue-router"; +import { createRouter, createWebHashHistory, RouteRecordRaw } from "vue-router"; +import { userStore } from "../store/user"; +import store from '../store/index'; +import { mapGamepadToXbox360Controller } from "@vueuse/core"; const routes: Array = [ //login { @@ -141,4 +144,18 @@ const router = createRouter({ routes }) +//路由守卫 + +router.beforeEach((to, from, next) => { + const store = userStore() + if (store.token) { + next() + } else { + if (to.path === '/login' || to.path === '/login/serviceAgree' || to.path == '/login/privacyPolicy') { + next() + } else { + next('/login') + } + } +}) export default router \ No newline at end of file diff --git a/src/store/index.ts b/src/store/index.ts index 3298a15..89715ab 100644 --- a/src/store/index.ts +++ b/src/store/index.ts @@ -1,4 +1,4 @@ import { createPinia } from "pinia"; -const store = createPinia +const store = createPinia(); export default store \ No newline at end of file diff --git a/src/store/task.ts b/src/store/task.ts new file mode 100644 index 0000000..683d96f --- /dev/null +++ b/src/store/task.ts @@ -0,0 +1,27 @@ +import { defineStore } from 'pinia' +import { bannerList, positionTypeList } from '../api/task'; + export const taskStore = defineStore({ + id: 'task', + state: () => { + return { + cityList: [], + cityValue: localStorage.getItem('city') || '北京', + bannerList: [], + positionList:[] + } + }, + actions: { + setCityValue(value: string){ + this.cityValue = value + }, + setCityList(data: any){ + this.cityList=data + }, + setBannerList(data: any) { + this.bannerList=data + }, + setPositionList(data: any) { + this.positionList=data + } + } + }) \ No newline at end of file diff --git a/src/store/user.ts b/src/store/user.ts new file mode 100644 index 0000000..6da2942 --- /dev/null +++ b/src/store/user.ts @@ -0,0 +1,23 @@ +import { defineStore } from 'pinia' + export const userStore = defineStore({ + id: 'user', + state: () => { + return { + token: localStorage.getItem('token') || '', + role: localStorage.getItem('role') || '1', + userInfo: {} + } + }, + actions: { + setRole(type: string){ + this.role = type + }, + setUserInfo(data: any){ + this.userInfo = data.user_info + this.token = data.token + this.role = data.user_info.role || '1' + localStorage.setItem('token',this.token) + localStorage.setItem('role',this.role) + }, + } + }) \ No newline at end of file diff --git a/src/utils/request.ts b/src/utils/request.ts index af0caff..73c59af 100644 --- a/src/utils/request.ts +++ b/src/utils/request.ts @@ -1,5 +1,5 @@ import axios from "axios"; -import { showToast } from 'vant'; +import { showToast } from 'vant' let baseURL = "/api" const service = axios.create({ baseURL, @@ -9,8 +9,8 @@ service.interceptors.request.use( config=>{ const token = window.localStorage.getItem('token') if (token) { - config.params = { - 'token':token + config.headers = { + 'x-access-token':token } } return config @@ -25,10 +25,10 @@ service.interceptors.response.use( return Promise.reject(new Error(res.message || 'Error')) } else { if (res.code == 200) { - return res.result + return res.result || res.data } else { - showToast(res.success) - return null + showToast(res.success) + return null } } }, diff --git a/src/view/login/index.vue b/src/view/login/index.vue index 49c968e..7a64428 100644 --- a/src/view/login/index.vue +++ b/src/view/login/index.vue @@ -1,11 +1,171 @@ + - - diff --git a/src/view/login/privacyPolicy.vue b/src/view/login/privacyPolicy.vue index e69de29..ee5e7e9 100644 --- a/src/view/login/privacyPolicy.vue +++ b/src/view/login/privacyPolicy.vue @@ -0,0 +1,37 @@ + + + + \ No newline at end of file diff --git a/src/view/login/serviceAgree.vue b/src/view/login/serviceAgree.vue index e69de29..34189d7 100644 --- a/src/view/login/serviceAgree.vue +++ b/src/view/login/serviceAgree.vue @@ -0,0 +1,37 @@ + + + + \ No newline at end of file diff --git a/src/view/message/index.vue b/src/view/message/index.vue index e69de29..154b63f 100644 --- a/src/view/message/index.vue +++ b/src/view/message/index.vue @@ -0,0 +1,16 @@ + + + \ No newline at end of file diff --git a/src/view/talent/index.vue b/src/view/talent/index.vue index e69de29..fb28bbc 100644 --- a/src/view/talent/index.vue +++ b/src/view/talent/index.vue @@ -0,0 +1,27 @@ + + + + \ No newline at end of file diff --git a/src/view/task/components/Banner.vue b/src/view/task/components/Banner.vue new file mode 100644 index 0000000..fe32951 --- /dev/null +++ b/src/view/task/components/Banner.vue @@ -0,0 +1,45 @@ + + + \ No newline at end of file diff --git a/src/view/task/components/CitySwitch.vue b/src/view/task/components/CitySwitch.vue new file mode 100644 index 0000000..b1205e7 --- /dev/null +++ b/src/view/task/components/CitySwitch.vue @@ -0,0 +1,69 @@ + + + \ No newline at end of file diff --git a/src/view/task/components/PositionType.vue b/src/view/task/components/PositionType.vue new file mode 100644 index 0000000..bb71d0d --- /dev/null +++ b/src/view/task/components/PositionType.vue @@ -0,0 +1,85 @@ + + + \ No newline at end of file diff --git a/src/view/task/components/Screen.vue b/src/view/task/components/Screen.vue new file mode 100644 index 0000000..e69de29 diff --git a/src/view/task/index.vue b/src/view/task/index.vue index 3b7b454..f5a10e4 100644 --- a/src/view/task/index.vue +++ b/src/view/task/index.vue @@ -1,7 +1,12 @@ \ No newline at end of file diff --git a/vite.config.ts b/vite.config.ts index c82f9a1..838c52d 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -5,17 +5,19 @@ import path from "path"; // https://vitejs.dev/config/ export default defineConfig({ plugins: [vue()], - resolve: { - alias: { - '@':path.resolve(__dirname,'./src') - } - }, server: { port: 8002, + host: '0.0.0.0', open:true, proxy: { - '/api': 'https//api.imooc.zcwytd.com' + '/api': 'https://api.imooc.zcwytd.com' }, cors:true - } + }, + resolve: { + alias: { + '@':path.resolve(__dirname,'./src') + } + }, + })