12312
This commit is contained in:
parent
923e167623
commit
5d74c80121
@ -11,6 +11,7 @@
|
||||
"serve": "vite preview"
|
||||
},
|
||||
"dependencies": {
|
||||
"@fingerprintjs/fingerprintjs": "^4.4.3",
|
||||
"@unocss/reset": "^0.61.9",
|
||||
"@vueuse/core": "^10.11.0",
|
||||
"axios": "^1.7.3",
|
||||
|
@ -8,6 +8,9 @@ importers:
|
||||
|
||||
.:
|
||||
dependencies:
|
||||
'@fingerprintjs/fingerprintjs':
|
||||
specifier: ^4.4.3
|
||||
version: 4.4.3
|
||||
'@unocss/reset':
|
||||
specifier: ^0.61.9
|
||||
version: 0.61.9
|
||||
@ -1099,6 +1102,9 @@ packages:
|
||||
cpu: [x64]
|
||||
os: [win32]
|
||||
|
||||
'@fingerprintjs/fingerprintjs@4.4.3':
|
||||
resolution: {integrity: sha512-sm0ZmDp5Oeq8hQTf+bAHKsuuteVAYme/YOY9UPP/GrUBrR5Fzl1P5oOv6F5LvyBrO7qLjU5HQkfU0MmFte/8xA==}
|
||||
|
||||
'@iconify/types@2.0.0':
|
||||
resolution: {integrity: sha512-+wluvCrRhXrhyOmRDJ3q8mux9JkKy5SJ/v8ol2tu4FVjyYvtEzkc/3pK15ET6RKg4b4w4BmTk1+gsCUhf21Ykg==}
|
||||
|
||||
@ -2392,6 +2398,9 @@ packages:
|
||||
treemate@0.3.11:
|
||||
resolution: {integrity: sha512-M8RGFoKtZ8dF+iwJfAJTOH/SM4KluKOKRJpjCMhI8bG3qB74zrFoArKZ62ll0Fr3mqkMJiQOmWYkdYgDeITYQg==}
|
||||
|
||||
tslib@2.6.3:
|
||||
resolution: {integrity: sha512-xNvxJEOUiWPGhUuUdQgAJPKOOJfGnIyKySOc09XkKsgdUV/3E2zvwZYdejjmRgPCgcym1juLH3226yA7sEFJKQ==}
|
||||
|
||||
tsx@4.16.5:
|
||||
resolution: {integrity: sha512-ArsiAQHEW2iGaqZ8fTA1nX0a+lN5mNTyuGRRO6OW3H/Yno1y9/t1f9YOI1Cfoqz63VAthn++ZYcbDP7jPflc+A==}
|
||||
engines: {node: '>=18.0.0'}
|
||||
@ -3739,6 +3748,10 @@ snapshots:
|
||||
'@esbuild/win32-x64@0.21.5':
|
||||
optional: true
|
||||
|
||||
'@fingerprintjs/fingerprintjs@4.4.3':
|
||||
dependencies:
|
||||
tslib: 2.6.3
|
||||
|
||||
'@iconify/types@2.0.0': {}
|
||||
|
||||
'@iconify/utils@2.1.30':
|
||||
@ -5172,6 +5185,8 @@ snapshots:
|
||||
|
||||
treemate@0.3.11: {}
|
||||
|
||||
tslib@2.6.3: {}
|
||||
|
||||
tsx@4.16.5:
|
||||
dependencies:
|
||||
esbuild: 0.21.5
|
||||
|
@ -1,4 +1,6 @@
|
||||
import request from '@/service/index.js'
|
||||
import {useAuth} from "@/store/auth/index.js";
|
||||
|
||||
export const sendCode = (data) => {
|
||||
return request({
|
||||
url: '/api/children/competition/sendCode',
|
||||
@ -69,8 +71,21 @@ export const voteStatus = (data) => {
|
||||
export const cWxApi = (data) => {
|
||||
return request({
|
||||
url: '/api/children/competition/wx',
|
||||
maxRedirects: 0,
|
||||
method: 'GET',
|
||||
data,
|
||||
})
|
||||
}
|
||||
export const GToken = (data) => {
|
||||
return request({
|
||||
url: '/api/children/competition/view/login',
|
||||
method: 'POST',
|
||||
data,
|
||||
})
|
||||
}
|
||||
export const viewOpenId = (data) => {
|
||||
return request({
|
||||
url: '/api/children/competition/view/openId',
|
||||
method: 'POST',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
// router/index.js
|
||||
import { createRouter, createWebHistory } from 'vue-router';
|
||||
import {deadlineAPI} from "@/api/auth/index.js";
|
||||
const routes = [
|
||||
{
|
||||
path: '/',
|
||||
|
@ -1,4 +1,5 @@
|
||||
import { useRouter } from 'vue-router';
|
||||
|
||||
import Request from '@/service/request/index.js'
|
||||
import {message} from "@/utils/message.js";
|
||||
const request = new Request({
|
||||
@ -8,14 +9,17 @@ const request = new Request({
|
||||
//实例的请求拦截器
|
||||
requestInterceptors: (config) => {
|
||||
const token=localStorage.getItem('token')
|
||||
|
||||
config.headers['Content-Type'] = config.method === 'get' ?
|
||||
'application/x-www-form-urlencoded' :
|
||||
'application/json'
|
||||
if (config.isFormData) {
|
||||
config.headers['Content-Type'] = 'multipart/form-data';
|
||||
config.headers['Authorization'] = token
|
||||
config.headers['Authorization2'] ='1234567'
|
||||
} else {
|
||||
config.headers['Authorization'] = token
|
||||
config.headers['Authorization2'] ='1234567'
|
||||
}
|
||||
return config;
|
||||
},
|
||||
|
@ -1,8 +1,9 @@
|
||||
import {ref,computed} from 'vue'
|
||||
import {computed, ref} from 'vue'
|
||||
import {createGlobalState, useStorage} from '@vueuse/core'
|
||||
import {
|
||||
competitionApply,
|
||||
competitionWorks, deadlineAPI,
|
||||
competitionWorks,
|
||||
GToken,
|
||||
loginRegister,
|
||||
sendCode,
|
||||
uploadFile,
|
||||
@ -13,13 +14,18 @@ import {message} from "@/utils/message.js"
|
||||
import {useRouter} from 'vue-router';
|
||||
import {showImagePreview} from 'vant';
|
||||
import useImgModalPopup from "@/components/imgModal/imgModal.js";
|
||||
export const useAuth=createGlobalState(()=>{
|
||||
|
||||
export const useAuth=createGlobalState(()=>{
|
||||
console.log('useRouter',useRouter)
|
||||
const router = useRouter()
|
||||
const token = useStorage('token', '', localStorage)
|
||||
const workUid = useStorage('workUid', '', localStorage)
|
||||
const telNum =useStorage('telNum', '', localStorage)
|
||||
const code=ref('')
|
||||
const voteToken=useStorage('voteToken', {
|
||||
authorization: '',
|
||||
expireTime: ''
|
||||
}, localStorage)
|
||||
const workData=useStorage('workData', {}, localStorage)
|
||||
const countdown = ref(0)
|
||||
const isCountingDown = ref(false)
|
||||
@ -27,6 +33,18 @@ export const useAuth=createGlobalState(()=>{
|
||||
return isCountingDown.value ? `${countdown.value}s` : '获取验证码'
|
||||
})
|
||||
const resultType=useStorage('resultType', '', localStorage)
|
||||
|
||||
const getVoteToken=async ()=>{
|
||||
const res=await GToken()
|
||||
if (res.status===0){
|
||||
const currentTimestamp = Date.now();
|
||||
const millisecondsIn48Hours = 48 * 60 * 60 * 1000;
|
||||
voteToken.value.expireTime=currentTimestamp + millisecondsIn48Hours
|
||||
voteToken.value.authorization=res.data?.authorization
|
||||
console.log('voteToken',voteToken.value)
|
||||
}
|
||||
|
||||
}
|
||||
const sendVote=async ()=>{
|
||||
|
||||
const res= await voteAPI({workUid:workUid.value})
|
||||
@ -40,6 +58,14 @@ export const useAuth=createGlobalState(()=>{
|
||||
})
|
||||
}
|
||||
}
|
||||
const isWechat=()=>{
|
||||
const os = window.navigator.userAgent.toLowerCase();
|
||||
if(os.match(/micromessenger/i) == 'micromessenger'){
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
const getWorkInfo=async ()=>{
|
||||
const res=await workInfo({workUid:workUid.value})
|
||||
if (res.status===0){
|
||||
@ -139,7 +165,9 @@ export const useAuth=createGlobalState(()=>{
|
||||
}
|
||||
const viewDetails=async ()=>{
|
||||
await getDetail()
|
||||
router.push('/details')
|
||||
router.push({
|
||||
path: '/details',
|
||||
})
|
||||
}
|
||||
const clickApply=async ()=>{
|
||||
const isValid = validateFormData();
|
||||
@ -191,11 +219,15 @@ export const useAuth=createGlobalState(()=>{
|
||||
if (res.data.status===1){
|
||||
message.warning('您已经报名')
|
||||
await getDetail()
|
||||
router.push('/details')
|
||||
console.log('router',router)
|
||||
router.push({
|
||||
path: '/details',
|
||||
})
|
||||
}else {
|
||||
message.success('登录成功')
|
||||
|
||||
router.push('/signup')
|
||||
router.push({
|
||||
path: '/signup',
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
@ -249,6 +281,9 @@ export const useAuth=createGlobalState(()=>{
|
||||
}
|
||||
};
|
||||
return {
|
||||
voteToken,
|
||||
isWechat,
|
||||
getVoteToken,
|
||||
beforeUploadImage,
|
||||
showText,
|
||||
resultType,
|
||||
|
@ -1,19 +1,32 @@
|
||||
<script setup>
|
||||
import {useAuth} from "@/store/auth/index.js";
|
||||
import {useRoute, useRouter} from 'vue-router';
|
||||
import {cWxApi, voteStatus} from "@/api/auth/index.js";
|
||||
const {detailData,workUid,getWorkInfo,workData,openMask,sendVote} =useAuth()
|
||||
import {cWxApi, viewOpenId, voteStatus} from "@/api/auth/index.js";
|
||||
const {detailData,workUid,getWorkInfo,workData,openMask,sendVote,getVoteToken,isWechat} =useAuth()
|
||||
const route = useRoute()
|
||||
|
||||
const router = useRouter()
|
||||
const initLoad=async ()=>{
|
||||
await getVoteToken()
|
||||
if (route.query.state && route.query.code){
|
||||
const res= await viewOpenId({code: Array.isArray(route.query.code)?route.query.code[0]:route.query.code, state: Array.isArray(route.query.state)?route.query.state[0]:route.query.state})
|
||||
console.log('openid',res)
|
||||
if (res.status===0){
|
||||
|
||||
}
|
||||
}
|
||||
window.location.href = `https://appointteam.szjixun.cn/api/appointment/auth/wx?time=${Date.now()}¬ifyUrl=${encodeURIComponent(window.location.href)}`
|
||||
|
||||
}
|
||||
if (route.query.uid){
|
||||
workUid.value = route.query.uid;
|
||||
getWorkInfo()
|
||||
}
|
||||
const isW=isWechat()
|
||||
console.log('isW',isW)
|
||||
voteStatus().then((res)=>{
|
||||
setTimeout(() => {
|
||||
|
||||
}, 2000);
|
||||
}, 2000)
|
||||
if(res.data.status===2){
|
||||
router.push({
|
||||
path: '/result',
|
||||
@ -23,12 +36,12 @@ if(res.data.status===2){
|
||||
})
|
||||
}
|
||||
if(res.status===401){
|
||||
if (!document.cookie){
|
||||
/* if (!document.cookie){
|
||||
window.location.href = `https://appointteam.szjixun.cn/api/appointment/wx?notifyUrl=${encodeURIComponent(window.location.href)}`
|
||||
}
|
||||
}*/
|
||||
|
||||
/*cWxApi()*/
|
||||
|
||||
initLoad()
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
Loading…
Reference in New Issue
Block a user