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