Browse Source

genggai

master
yuanshun 1 year ago
parent
commit
ba1ab9d950
  1. 27
      src/api/task.ts
  2. 6
      src/main.ts
  3. 19
      src/router/index.ts
  4. 2
      src/store/index.ts
  5. 27
      src/store/task.ts
  6. 23
      src/store/user.ts
  7. 4
      src/utils/request.ts
  8. 22
      src/view/login/index.vue
  9. 37
      src/view/login/privacyPolicy.vue
  10. 37
      src/view/login/serviceAgree.vue
  11. 45
      src/view/task/components/Banner.vue
  12. 69
      src/view/task/components/CitySwitch.vue
  13. 85
      src/view/task/components/PositionType.vue
  14. 0
      src/view/task/components/Screen.vue

27
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
})
}

6
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')

19
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<RouteRecordRaw> = [
//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

2
src/store/index.ts

@ -1,4 +1,4 @@
import { createPinia } from "pinia";
const store = createPinia
const store = createPinia();
export default store

27
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
}
}
})

23
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)
},
}
})

4
src/utils/request.ts

@ -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

22
src/view/login/index.vue

@ -2,7 +2,10 @@
import { ref,reactive } from "vue";
import {useRoute,useRouter} from 'vue-router'
import { getCode,login } from '@/api/user'
import {userStore} from "@/store/user";
import { showToast } from 'vant'
const store=userStore()
interface Istate{
checked:boolean;
accounts:string;
@ -41,6 +44,7 @@
state.code=res.code
}
}
const router = useRouter()
const loginSubmit=async ()=>{
if(!state.code){
showToast('请输入验证码')
@ -55,15 +59,27 @@
code:state.code
})
if(res.errCode===200){
//dstore
store.setUserInfo(res.data)
if(store.role=='1'){
router.push('/task')
}
if(store.role=='2'){
router.push('/talent')
}
}else{
showToast(res.msg)
}
}
const onClickLeft=()=>{
history.back()
}
</script>
<template>
<div>
<van-icon class="icon-left" name="arrow-left" />
<van-icon class="icon-left" name="arrow-left" @click-left="onClickLeft()"/>
<div class="login-form">
<h3>验证码登录</h3>
<div class="login-form-item">

37
src/view/login/privacyPolicy.vue

@ -0,0 +1,37 @@
<script setup lang="ts">
import { ref,reactive } from "vue";
import { getPolicy} from '@/api/user'
import { showToast } from 'vant'
const state:any=reactive({
htmlText:''
})
const onClickLeft = () => history.back();
const getPolicyChange= async ()=>{
const res:any=await getPolicy({
id:16,
})
if(res){
state.htmlText=res.records[0].content
}else{
showToast(res.msg)
}
}
getPolicyChange()
</script>
<template>
<van-nav-bar
title="隐私政策"
left-text=""
left-arrow
@click-left="onClickLeft"
/>
<div class="text-agree">
<div v-html="state.htmlText"></div>
</div>
</template>
<style scoped>
.text-agree{
padding: 0.5rem 0.7rem;
}
</style>

37
src/view/login/serviceAgree.vue

@ -0,0 +1,37 @@
<script setup lang="ts">
import { ref,reactive } from "vue";
import { getPolicy} from '@/api/user'
import { showToast } from 'vant'
const state:any=reactive({
htmlText:''
})
const onClickLeft = () => history.back();
const getPolicyChange= async ()=>{
const res:any=await getPolicy({
id:17,
})
if(res){
state.htmlText=res.records[0].content
}else{
showToast(res.msg)
}
}
getPolicyChange()
</script>
<template>
<van-nav-bar
title="服务协议"
left-text=""
left-arrow
@click-left="onClickLeft"
/>
<div class="text-agree">
<div v-html="state.htmlText"></div>
</div>
</template>
<style scoped>
.text-agree{
padding: 0.5rem 0.7rem;
}
</style>

45
src/view/task/components/Banner.vue

@ -0,0 +1,45 @@
<script setup lang="ts">
import { inject } from 'vue';
import { bannerList } from "../../../api/task";
import { taskStore } from "../../../store/task";
import { showToast } from 'vant'
const store=taskStore()
const getBannerList=async ()=>{
const res:any =await bannerList({type:2})
console.log('city------',res);
if(res){
store.setBannerList(res.list)
}else{
showToast(res.msg)
}
}
if(store.bannerList.length<=0){
getBannerList()
}
</script>
<template>
<van-swipe :autoplay="3000" lazy-render>
<van-swipe-item v-for="(item,index) in store.bannerList" :key="index" >
<a :href="item.url" target="_blank" v-if="item.url">
<img :src="item.picture" />
</a>
<img v-else ="item.url" :src="item.picture" />
</van-swipe-item>
</van-swipe>
</template>
<style scoped>
>>> .van-swipe__track{
height: 7.47rem;
}
.van-swipe__indicators{
display: none;
}
>>> img{
width: 100%;
height: 7.47rem;
border-radius: 0.5rem;
}
</style>

69
src/view/task/components/CitySwitch.vue

@ -0,0 +1,69 @@
<script setup lang="ts">
import { inject } from 'vue';
import { cityList } from "../../../api/task";
import { taskStore } from "../../../store/task";
import { showToast } from 'vant'
const { closeCitySwitch }:any = inject('popup',)
const store=taskStore()
const leftBack = ()=>{
closeCitySwitch()
}
const getCityList=async ()=>{
const res:any =await cityList({})
console.log('city------',res);
if(res){
store.setCityList(res)
}else{
showToast(res.msg)
}
}
if(store.cityList.length<=0){
getCityList()
}
</script>
<template>
<van-nav-bar title="城市切换" left-arrow @click-left="leftBack"/>
<div class="city-switch">
<h3>当前城市</h3>
<div class="city-switch-text">
<span>{{ store.cityValue }}</span>
</div>
<h3>切换城市</h3>
<div class="city-switch-text">
<span v-for="(item,index) in store.cityList" :key="index" @click="closeCitySwitch(item.name)">{{ item.name }}</span>
</div>
</div>
</template>
<style scoped>
.city-switch{
padding: 0 0.7rem;
}
.city-switch h3{
font-size: 0.8rem;
line-height: 0.8rem;
font-weight: 500;
color: #000000;
margin: 0.7rem 0 0.96rem;
}
.city-switch-text span{
width: 4.01rem;
height: 1.6rem;
line-height: 1.6rem;
background: #FFFFFF;
border: 1px solid #EBEBEB;
border-radius: 0.11rem;
font-size: 0.64rem;
text-align: center;
font-weight: 400;
color: #333333;
margin: 0 0.7rem 0.8rem 0;
display: inline-block;
}
.city-switch-text span:nth-child(4n){
margin-right: 0px;
}
</style>

85
src/view/task/components/PositionType.vue

@ -0,0 +1,85 @@
<script setup lang="ts">
import { inject,reactive } from 'vue';
import { positionTypeList } from "../../../api/task";
import { taskStore } from "../../../store/task";
import { showToast } from 'vant'
const state=reactive({
typeKey:0
})
const { closePositionType }:any = inject('popup')
const store=taskStore()
const leftBack = ()=>{
closePositionType()
}
const getPositionTypeList=async ()=>{
const res:any =await positionTypeList({})
console.log('getPositionTypeList------',res);
if(res){
store.setPositionList(res)
}else{
showToast(res.msg)
}
}
if(store.positionList.length<=0){
getPositionTypeList()
}
</script>
<template>
<van-nav-bar title="职位" left-arrow @click-left="leftBack"/>
<div class="position-type">
<div class="position-type-left">
<h5 :class="state.typeKey==index?'active':''" v-for="(item, index) in store.positionList" :key="index" >{{item.name}}</h5>
</div>
<div class="position-type-right">
<span v-for="(item, index) in store.positionList[state.typeKey] && store.positionList[state.typeKey].children" :key="index">{{item.name}}</span>
</div>
</div>
</template>
<style scoped>
.position-type{
display: flex;
}
.position-type-left{
width: 4.77rem;
height: calc(100vh - 46px);
background: #F6F6F6;
}
.position-type-left h5{
width: 4.77rem;
height: 2.4rem;
line-height: 2.4rem;
background: #F6F6F6;
border-bottom: 1px solid #ffffff;
font-size: 0.75rem;
font-weight: 300;
color: #333333;
text-align: center;
}
.position-type-left h5.active{
background: #EFEFEF;
}
.position-type-right{
padding: 0.8rem 0 0 0.6rem;
}
.position-type-right span{
width: 6.61rem;
height: 2.03rem;
line-height: 2.03rem;
background: #FFFFFF;
border: 1px solid #E9E9E9;
border-radius: 0.11rem;
font-size: 0.75rem;
font-weight: 300;
color: #666666;
text-align: center;
margin-right: 0.59rem;
margin-bottom: 0.64rem;
display: inline-block;
}
.position-type-right span:nth-child(2n){
margin-right: 0px;
}
</style>

0
src/view/task/components/Screen.vue

Loading…
Cancel
Save