提交 a5c080fc 编写于 作者: 刘英杰's avatar 刘英杰

博物馆H5扫码

上级 6d479e6d
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*
node_modules
dist
dist-ssr
*.local
# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
{
"recommendations": ["Vue.volar", "Vue.vscode-typescript-vue-plugin"]
}
# Vue 3 + Vite
This template should help get you started developing with Vue 3 in Vite. The template uses Vue 3 `<script setup>` SFCs, check out the [script setup docs](https://v3.vuejs.org/api/sfc-script-setup.html#sfc-script-setup) to learn more.
## Recommended IDE Setup
- [VS Code](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (and disable Vetur) + [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.vscode-typescript-vue-plugin).
文件已添加
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8"/>
<link rel="icon" type="image/svg+xml" href="/vite.svg"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>琼台博物馆预约</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.js"></script>
</body>
</html>
此差异已折叠。
{
"name": "wxlezduty",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview"
},
"dependencies": {
"animate.css": "^4.1.1",
"axios": "^1.5.0",
"dayjs": "^1.11.9",
"js-cookie": "^3.0.5",
"lodash": "^4.17.21",
"vant": "^4.6.6",
"vconsole": "^3.15.1",
"vue": "^3.3.4",
"vue-cookies": "^1.8.3",
"vue-router": "^4.2.4",
"weixin-js-sdk": "^1.6.0"
},
"devDependencies": {
"@vitejs/plugin-vue": "^4.2.3",
"unplugin-vue-components": "^0.25.1",
"vite": "^4.4.5"
}
}
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
\ No newline at end of file
<script setup>
</script>
<template>
<router-view></router-view>
</template>
<style scoped>
@import "style.css";
body {
margin: 0;
}
</style>
import {requestGet, requestPost} from '../util/request.js'
import axios from 'axios'
/**
* 单点
* **/
export function GetWxConfig(data) {
return requestGet(
`${window.location.protocol + "//" + window.location.host}/wx/eicrs/api/GetJSSDK/GetWxConfig?url=${data.url}`,
data
);
}
export function QRCodeVerify(data) {
return requestGet(
`/api/AccessRecord/QRCodeVerify?id=${data.id}`,
data
);
}
export function SSOPCNew(data) {
//单点
return requestGet(`/api/Login/SSOPCNew?token=${data.token}`, data)
// axios.get(`/api/Login/api/Login/SSOPC`,data)
}
export function SSOPC(data) {
//单点
return requestGet(`/api/Login/api/Login/SSOPC?token=${data.token}`, data)
// axios.get(`/api/Login/api/Login/SSOPC`,data)
}
export function GetTokenInfo(data) {
//获取用户信息
return requestGet(`/api/Login/api/Login/GetTokenInfo`, data)
}
export function RefreshToken(data) {
//刷新token
return requestGet(`/api/Login/api/Login/RefreshToken`, data)
}
export function SSOPCWX(data) {
//刷新token
return requestGet(`/api/Login/api/Login/SSOPCWX?&code=${data.code}&sign=${data.sign}&timestamp=${data.timestamp}`, data)
}
/**
* 值班列表
*
* */
export function GetWatchList(data) {
//获取值班列表
return requestPost('/api/Watch/api/Watch/GetWatchList', data)
}
export function GetWatchHourTime(data) {
//获取值班时段
return requestGet(`/api/Watch/api/Watch/GetWatchHourTime`, data)
}
export function GetWatchTypeSelect(data) {
//获取值班类型
return requestGet(`/api/Watch/api/Watch/GetWatchTypeSelect`, data)
}
export function GetWatchDepSelect(data) {
//获取值班部门
return requestGet(`/api/Watch/api/Watch/GetWatchDepSelect`, data)
}
export function GetWatchCampusSelect(data) {
//获取校区
return requestGet(`/api/Watch/api/Watch/GetWatchCampusSelect`, data)
}
export function GetWatchInfo(data) {
//获取值班详情
return requestGet(`/api/Watch/api/Watch/GetWatchInfo?id${data.id}`, data)
}
/***
*
* 签到列表
*
*
* */
export function GetSignRecordList(data) {
//获取签到列表
return requestPost(`/api/SignRecord/api/SignRecord/GetSignRecordList`, data)
}
export function SignInOrOut(data) {
//批量签到签退
return requestPost(`/api/SignRecord/api/SignRecord/SignInOrOut`, data)
}
export function SignLogSave(data) {
//填写日志
return requestGet(`/api/SignRecord/api/SignRecord/SignLogSave?signId=${data.signId}&content=${data.content}`, data)
}
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="37.07" height="36" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 198"><path fill="#41B883" d="M204.8 0H256L128 220.8L0 0h97.92L128 51.2L157.44 0h47.36Z"></path><path fill="#41B883" d="m0 0l128 220.8L256 0h-51.2L128 132.48L50.56 0H0Z"></path><path fill="#35495E" d="M50.56 0L128 133.12L204.8 0h-47.36L128 51.2L97.92 0H50.56Z"></path></svg>
\ No newline at end of file
<template>
<van-button type="primary">主要按钮</van-button>
<van-button type="success">成功按钮</van-button>
<van-button type="default">默认按钮</van-button>
<van-button type="warning">警告按钮</van-button>
<van-button type="danger">危险按钮</van-button>
</template>
<script setup>
</script>
import {createApp} from 'vue'
import './style.css'
import App from './App.vue'
import router from "./router/index.js";
import 'animate.css' //引入
import VueCookies from 'vue-cookies'
import Vconsole from 'vconsole'
import 'vant/lib/index.css';
let vConsole = new Vconsole()
const app = createApp(App)
app.config.globalProperties.$cookies = VueCookies
app.use(router)
// app.use(vConsole)
app.mount('#app')
<template>
<van-nav-bar
left-text="返回"
left-arrow
@click-left="onClickLeft"
></van-nav-bar>
<van-empty style="width: 100%;height: 100%" image="error" description="异常" />
<!-- <van-button primary='success' @click="onClickLeft">返回</van-button>-->
</template>
<script setup>
import {useRouter} from "vue-router";
const router = useRouter()
const onClickLeft = () => router.replace({name:'welcome'});
</script>
<template>
<div style="display: flex; justify-content: center; margin-top: 50%">
<van-loading size="38px" color="#1989fa" vertical> 登录中</van-loading>
</div>
<!-- {{router.currentRoute.value.query.token}}-->
</template>
<script setup>
// import router from "../router/index.js";
import Cookies from 'js-cookie'
import {useRouter} from 'vue-router'
import {onMounted} from 'vue'
import * as api from '../api/index.js'
import {SSOPCNew} from "../api/index.js";
const router = useRouter()
const getTokenAction = async (date) => {
const res = await api.SSOPCNew(date)
if (res.code !== 1) {
await router.replace({
name: '403'
})
} else if (res.response.access_token.token_content !== '') {
// access_token.token_content
Cookies.set('admin-token', res.response.access_token.token_content)
Cookies.set('time', res.response.access_token.expires)
const user = await api.GetTokenInfo()
Cookies.set('user-card_number', user.response.card_number)
Cookies.set('user-name', user.response.name)
await router.replace({
name: 'welcome'
})
}
}
const getTokenActionWx = async (date) => {
const res = await api.SSOPCWX(date)
if (res.code !== 1) {
await router.replace({
name: '403'
})
} else if (res.response.access_token.token_content !== '') {
Cookies.set('admin-token', res.response.access_token.token_content)
Cookies.set('time', res.response.access_token.expires)
const user = await api.GetTokenInfo()
Cookies.set('user-info', user.response.role)
localStorage.setItem('user-info', user.response.role)
await router.replace({
name: 'welcome'
})
}
}
const getToken = async () => {
if (Number(router.currentRoute.value.query.type) === 2) {
Cookies.set('token', router.currentRoute.value.query.token)
// localStorage.setItem('token', router.currentRoute.value.query.token)
let date = {
token: Cookies.get('token')
}
await getTokenAction(date)
} else if (Number(router.currentRoute.value.query.type) === 1) {
// Cookies.set('sign', router.currentRoute.value.query.sign)
// Cookies.set('code', router.currentRoute.value.query.code)
// Cookies.set('timestamp', router.currentRoute.value.query.timestamp)
let date = {
sign: router.currentRoute.value.query.sign,
code: router.currentRoute.value.query.code,
timestamp: router.currentRoute.value.query.timestamp,
}
// Cookies.set('sign', router.currentRoute.value.query.sign,)
// Cookies.set('code', router.currentRoute.value.query.code,)
// Cookies.set('timestamp', router.currentRoute.value.query.timestamp,)
await getTokenActionWx(date)
}
}
onMounted(() => {
getToken()
})
</script>
<template>
<van-nav-bar
left-text="返回"
left-arrow
@click-left="onClickLeft"
></van-nav-bar>
<van-empty style="width: 100%;height: 100%" image="error" description="暂无权限!" />
<!-- <van-button primary='success' @click="onClickLeft">返回</van-button>-->
</template>
<script setup>
import {useRouter} from "vue-router";
const router = useRouter()
const onClickLeft = () => router.replace({name:'welcome'});
</script>
<template>
<van-nav-bar
title="值班信息"
left-text="返回"
left-arrow
@click-left="onClickLeft"
/>
<div class="container">
<!-- v-for="(item,index) in dutyObject.data" :key="index"-->
<van-cell-group class="cardContainer" inset v-for="(item,index) in dutyObject.data" :key="index">
<van-cell class="cardContent" :title="item.username">
<template #extra>
<van-tag type="primary" plain><span>{{ item.card_name }}</span></van-tag>
<van-tag color="#7232dd" type="primary" plain style="margin-left: 10px">{{
['值班教师', '值班领导'][item.is_lead]
}}
</van-tag>
<!-- <van-tag :color="['','#7232dd'][item.is_lead]" type="primary" plain style="margin-left: 10px">-->
<!-- <span>{{ ['值班教师', '值班领导'][item.is_lead] }}</span></van-tag>-->
</template>
</van-cell>
<van-cell class="cardContent" title="手机号">
<template #extra>
<van-tag type="primary" plain><span>{{ item.mobile }}</span></van-tag>
</template>
</van-cell>
<van-cell class="cardContent" title="日期">
<template #extra>
<van-tag type="primary" plain><span>{{ item.watch_date }}</span></van-tag>
</template>
</van-cell>
<van-cell class="cardContent" title="时段">
<template #extra>
<van-tag type="primary" plain style="margin-left: 10px"><span>{{ item.watch_hour_time }}</span>
</van-tag>
</template>
</van-cell>
<van-cell class="cardContent" title="类型">
<template #extra>
<van-tag type="primary" plain>
<span>{{ item.watchtypename + '-' + item.dept_name + '-' + item.campusname }}</span>
</van-tag>
</template>
</van-cell>
</van-cell-group>
</div>
</template>
<script setup>
import dayjs from 'dayjs';
import * as api from '../../api/index.js';
import {ref, reactive, onMounted, watch} from 'vue';
import {useRouter} from "vue-router";
import {showToast} from "vant";
const router = useRouter()
let dutyObject = reactive({
data: []
})
const getDutyMessage = async () => {
let data = {
id: router.currentRoute.value.query.id
}
const res = await api.GetWatchInfo(data)
dutyObject.data = res.response
}
onMounted(() => {
getDutyMessage()
})
const onClickLeft = () => history.back();
</script>
<style>
.container {
.cardContainer {
margin-top: 10px;
width: 95%;
background-color: #ffffff;
height: 20%;
.cardContent {
//height: 150px;
}
}
}
</style>
<template>
<van-pull-refresh v-model="myDuty.loading" @refresh="onRefresh">
<div style="position: fixed;z-index: 2;width: 100%">
<!-- &lt;!&ndash; 圆角弹窗(居中) &ndash;&gt;-->
<van-popup v-model:show="myDuty.showCenter" round style="width: 100%; padding: 10px;">
<template v-slot:default>
<van-field
v-model="myDuty.message"
rows="2"
autosize
clearable
type="textarea"
maxlength="100"
placeholder="请输入日志"
show-word-limit
/>
<div style="float: right">
<van-button icon="close" size="small" style="margin-right: 10px" @click="myDuty.showCenter = false">取消
</van-button>
<van-button type="primary" icon="passed" size="small" style="margin-right: 10px">提交</van-button>
</div>
</template>
</van-popup>
<van-nav-bar
title="我的值班"
left-text="返回"
left-arrow
@click-left="onClickLeft"
></van-nav-bar>
<van-search
v-model="searchValue"
shape="round"
placeholder="请输入搜索关键词"
/>
<van-dropdown-menu :overlay="false">
<van-dropdown-item @close="closeMenu" :key="myDuty.menuKey" @open="openMenu" title="日期">
<template #default>
<van-calendar v-model:show="myDuty.show" type="range" @confirm="dateRange"/>
</template>
</van-dropdown-item>
<van-dropdown-item v-model="myDuty[item[2]]" v-for="(item,index) in myDuty.addDutySelectList" :key="index"
:title="item[1]" :options="item[0]"/>
</van-dropdown-menu>
</div>
<van-list
class="container"
@load="onLoad"
direction="down"
:finished="finished"
offset="600"
>
<div style="width: 100%;height: 150px"></div>
<!-- <van-cell/>-->
<van-cell-group inset class="cardContainer" v-for="(item,index) in list" :key="index">
<van-cell class="cardContent" :title="item.username">
<template #extra>
<van-tag type="primary" plain><span>{{ item.card_name }}</span></van-tag>
<van-tag :color="['','#7232dd'][item.is_lead]" type="primary" plain style="margin-left: 10px">
<span>{{ ['值班教师', '值班领导'][item.is_lead] }}</span></van-tag>
</template>
</van-cell>
<van-cell class="cardContent" title="日期">
<template #extra>
<van-tag type="primary" plain><span>{{ item.watch_date }}</span></van-tag>
<van-tag type="primary" plain style="margin-left: 10px"><span>{{ item.watch_hour_time }}</span></van-tag>
</template>
</van-cell>
<van-cell class="cardContent" title="类型">
<template #extra>
<van-tag type="primary" plain>
<span>{{ item.watchtypename + '-' + item.dept_name + '-' + item.campusname }}</span></van-tag>
</template>
</van-cell>
<!-- <van-cell class="cardContent">-->
<!-- <template #value>-->
<!-- <van-button @click="dutyLog(item)" type="primary" icon="edit" size="small" style="margin-right: 10px">日志</van-button>-->
<!-- </template>-->
<!-- </van-cell>-->
</van-cell-group>
<div style="width: 100%;height: 100px"></div>
</van-list>
</van-pull-refresh>
</template>
<style>
.container {
//box-sizing: border-box; //background-color: #706c6c; //width: 100%; //height: 100%; //min-height: 896px; //display: flex; //flex-wrap: wrap; //justify-content: center; //align-content: flex-start;
.cardContainer {
margin-top: 10px;
width: 95%;
background-color: #ffffff;
height: 20%;
.cardContent {
//height: 150px;
}
}
.cardContainer:nth-last-child(1) {
background-color: red;
}
}
</style>
<script setup>
import _ from 'lodash';
import * as api from '../../api/index.js';
import {ref, reactive, onMounted, watch} from 'vue';
import dayjs from 'dayjs';
import {showToast} from "vant";
const onClickLeft = () => history.back();
let myDuty = reactive({
addDutySelectList: [],
DatePickerKey: 1,
showCenter: false,
message: '',
show: false,
startTime: dayjs().startOf('day').format('YYYY-MM-DD'),
endTime: dayjs().startOf('day').format('YYYY-MM-DD'),
page_index: 1,
page_size: 5,
total: '',
deleteSetTimeOut: '',
menuKey: 1,
loading: false
})
const list = ref([]);
const loading = ref(false);
const finished = ref(false);
let searchValue = ref('')
watch([searchValue, () => myDuty.watchtypeid, () => myDuty.watch_hour_id, () => myDuty.campusid, () => myDuty.dept_id], (newValue, oldValue) => {
console.log("🚀🚀🚀,", newValue[0], newValue[1])
if (newValue[0] || newValue[1] || newValue[2] || newValue[3] || newValue[4]) {
clearTimeout(myDuty.deleteSetTimeOut)
myDuty.deleteSetTimeOut = setTimeout(async () => {
await search()
showToast('操作成功!')
}, 500)
}
}, {deep: true})
const onRefresh = async () => {
myDuty.loading = true
myDuty.startTime = dayjs().format('YYYY-MM-DD')
myDuty.endTime = dayjs().format('YYYY-MM-DD')
await onLoad()
myDuty.loading = false
//初始化刷新
// myDuty.loading = true
// let data = {
// "dep_id": "",
// "key_name": "",
// "start_time": myDuty.startTime,
// "end_time": myDuty.endTime,
// "type_id": "",
// "watchhour_time": "",
// "is_lead": 3,
// "campus_id": "",
// "page_index": myDuty.page_index,
// "page_size": myDuty.page_size,
// }
// const res = await api.GetWatchList(data)
// list.value = res.response.data
// myDuty.total = res.response.data_count
}
const dutyLog = (e) => {
console.log("🚀🚀🚀,", e)
myDuty.showCenter = true
}
const search = async () => {
let data = {
"dep_id": myDuty.dept_id,
"key_name": searchValue.value,
"start_time": myDuty.startTime,
"end_time": myDuty.endTime,
"type_id": myDuty.watchtypeid,
"watchhour_time": myDuty.watch_hour_id,
"is_lead": 3,
"campus_id": myDuty.campusid,
"page_index": myDuty.page_index,
"page_size": myDuty.page_size,
}
const res = await api.GetWatchList(data)
list.value = res.response.data
myDuty.total = res.response.data_count
}
const onLoad = async () => {
clearTimeout(myDuty.deleteSetTimeOut)
myDuty.deleteSetTimeOut = setTimeout(async () => {
let data = {
"dep_id": "",
"key_name": "",
"start_time": myDuty.startTime,
"end_time": myDuty.endTime,
"type_id": "",
"watchhour_time": "",
"is_lead": 3,
"campus_id": "",
"page_index": myDuty.page_index,
"page_size": myDuty.page_size,
}
const res = await api.GetWatchList(data)
list.value = res.response.data
myDuty.total = res.response.data_count
// 异步更新数据
// setTimeout 仅做示例,真实场景中一般为 ajax 请求
// for (let i = 0; i < 10; i++) {
// list.value.push(list.value.length + 1);
// }
// 数据全部加载完成
if (list.value.length >= Number(myDuty.total)) {
finished.value = true;
showToast('加载完成!')
} else if (list.value.length < Number(myDuty.total)) {
myDuty.page_size = myDuty.page_size + 10
}
}, 100)
}
const dateRange = async (e) => {
myDuty.startTime = dayjs(e[0]).format('YYYY-MM-DD')
myDuty.endTime = dayjs(e[1]).format('YYYY-MM-DD')
await search()
myDuty.menuKey++
closeMenu()
}
const closeMenu = () => {
myDuty.show = false
}
const openMenu = () => {
myDuty.show = true
}
const addDutySearchSelectList = () => {
Promise.all([
getSearchSelectListPromiseAllAction("dutyType", '类型', "watchtypeid", api.GetWatchTypeSelect),
getSearchSelectListPromiseAllAction("dutyHourTime", '时段', "watch_hour_id", api.GetWatchHourTime),
getSearchSelectListPromiseAllAction("campusname", '校区', "campusid", api.GetWatchCampusSelect),
getSearchSelectListPromiseAllAction("dept_name", '部门', "dept_id", api.GetWatchDepSelect),
])
.then(res => {
myDuty.addDutySelectList = res
myDuty.DatePickerKey++
})
}
const getSearchSelectListPromiseAllAction = (publicName, title, objectAttribute, apiFunction) => {
return new Promise(async (resolve, reject) => {
const publicName = await apiFunction()
const list = []
publicName.response.map((cur, index) => {
list.push({text: cur.name, value: cur.id})
})
let array = [list, title, objectAttribute]
resolve(array)
})
}
onMounted(() => {
addDutySearchSelectList()
})
</script>
此差异已折叠。
<template>
<div class="container">
<div class="header">
<van-nav-bar
title="琼台博物馆预约入馆扫码"
left-text="返回"
left-arrow
@click-left="onClickLeft"
/>
<!-- <van-cell-group inset style="width: 100%;">-->
<!-- <van-cell>-->
<!-- <template #title>-->
<!-- <div style="display: flex;justify-content: center;align-items: center">琼台博物馆预约入馆扫码</div>-->
<!-- </template>-->
<!-- &lt;!&ndash; title="博物馆预约入馆扫码"&ndash;&gt;-->
<!-- </van-cell>-->
<!-- </van-cell-group>-->
</div>
<div class="content">
<div class="cardContainer">
<div class="cardContent" @click="handleScanQR">
<img src="./sys.png" style="width: 100px;height: 100px">
<!-- <van-button>扫一扫</van-button>-->
</div>
<div class="cardFooter"><span>
点击“按钮”,进行二维码扫描
</span></div>
</div>
</div>
<!-- <div class="clock-card">-->
<!-- <van-skeleton title round :row="5" :loading="loading">-->
<!-- <van-button @click="handleScanQR">扫一扫</van-button>-->
<!-- <div class="btn-wrap">-->
<!-- <div :class="['clock-btn', 'can-back']" @click="handleScanQR">-->
<!-- &lt;!&ndash; <img class="saomaIcon" src="../../image/3f258fbafe311489c415a1cdea7e11f.png"/>&ndash;&gt;-->
<!-- &lt;!&ndash; <p>扫一扫</p>&ndash;&gt;-->
<!-- </div>-->
<!-- </div>-->
<!-- &lt;!&ndash; <div class="clock-address">点击"扫一扫"扫码或点击上方搜索框搜索</div>&ndash;&gt;-->
<!-- </van-skeleton>-->
<!-- </div>-->
</div>
</template>
<script>
import * as api from '../../api/index.js';
// import {GetWxConfig} from "@/common/api/common";
import wx from "weixin-js-sdk";
import {QRCodeVerify} from "../../api/index.js";
import {showDialog, showSuccessToast} from "vant";
// import utils from "@/common/util";
export default {
data() {
return {
searchValue: "",
loading: false,
timer: '',
};
},
mounted() {
this.wxScanCode();
},
methods: {
onClickLeft() {
history.back()
},
getData() {
},
// 微信初始化配置
wxScanCode() {
const params = {
url: window.location.href.replace(window.location.hash, ""),
};
console.log("🚀🚀🚀,", params)
api.GetWxConfig(params).then((result) => {
let data = result;
wx.config({
debug: false,
appId: data.appId, // 必填,公众号的唯一标识
timestamp: data.timeStamp, // 必填,生成签名的时间戳
nonceStr: data.nonceStr, // 必填,生成签名的随机串
signature: data.signature, // 必填,签名,见附录1
jsApiList: ["scanQRCode", "checkJsApi"],
// jsApiList: [
// "checkJsApi",
// "onMenushareTimeline",
// "onMenushareAppMessage",
// "scanQRCode"
// ]
});
wx.ready(() => {
console.log("设备已经可以使用");
// setTimeout(() => {
// wx.checkJsApi({
// jsApiList: ["scanQRCode"],
// success: (res) => {
// console.log(res);
// },
// });
// });
});
wx.error(function (res) {
console.log("设备已经无法使用");
});
});
},
// 扫码
async handleScanQR() {
clearTimeout(this.timer)
this.timer = setTimeout(() => {
wx.scanQRCode({
needResult: 1, // 默认为0,扫描结果由微信处理,1则直接返回扫描结果,
scanType: ["qrCode"], // 可以指定扫二维码
success: async (res) => {
const value = await api.QRCodeVerify({id: res.resultStr})
if (value.code !== 1) {
// showSuccessToast(value.msg_detail);
showDialog({
title: '提示',
message: value.msg_detail,
theme: 'round-button',
}).then(() => {
setTimeout(() => {
this.handleScanQR()
}, 1000)
});
} else {
// showSuccessToast(value.msg);
showSuccessToast(value.msg);
setTimeout(() => {
this.handleScanQR()
}, 3000)
}
},
fail: (err) => {
alert(JSON.stringify(err))
this.handleScanQR()
}
});
}, 500)
},
// 搜索框输入
// doSearch() {
// this.$router.push({
// path: '/scanList',
// });
// }
},
};
</script>
<style>
.container {
width: 100vw;
height: 100vh;
position: absolute;
.header {
width: 100%;
height: 10%;
}
.content {
width: 100%;
height: 80%;
padding: 30px 10px 10px 10px;
.cardContainer {
width: 100%;
height: 60%;
box-sizing: border-box;
border-radius: 2%;
background-color: #ffffff;
display: flex;
justify-content: center;
align-content: center;
flex-wrap: wrap;
.cardContent {
width: 150px;
height: 150px;
border-radius: 50%;
display: flex;
justify-content: center;
align-items: center;
background-color: #2aa9ff;
}
.cardFooter {
width: 100%;
height: 10%;
display: flex;
justify-content: center;
align-items: flex-end;
}
.cardContent:active {
background-color: #006cbb;
transform: scale(1.05);
}
}
}
}
</style>
<!--.cardFooter {-->
<!--width: 100%;-->
<!--height: 10%;-->
<!--margin-top: auto;-->
<!--background-color: #706c6c;-->
<!--}-->
<!--.clock-card {-->
<!-- position: relative;-->
<!-- height: 400px;-->
<!-- background: #fff;-->
<!-- border-radius: 12px;-->
<!-- margin-bottom: 30px;-->
<!-- margin: 20px;-->
<!--}-->
<!--.btn-wrap {-->
<!-- position: absolute;-->
<!-- height: 230px;-->
<!-- width: 180px;-->
<!-- top: 0;-->
<!-- bottom: 0;-->
<!-- left: 0;-->
<!-- right: 0;-->
<!-- margin: auto;-->
<!-- text-align: center;-->
<!--}-->
<!--.clock-address {-->
<!-- font-size: 14px;-->
<!-- color: #9e9e9e;-->
<!-- line-height: 20px;-->
<!-- position: absolute;-->
<!-- bottom: 50px;-->
<!-- text-align: center;-->
<!-- width: 100%;-->
<!--}-->
<!--.clock-btn {-->
<!-- display: flex;-->
<!-- flex-direction: column;-->
<!-- justify-content: center;-->
<!-- align-items: center;-->
<!-- text-align: center;-->
<!-- width: 180px;-->
<!-- height: 180px;-->
<!-- // line-height: 180px; border-radius: 100%; // color: #fff; font-weight: 500; font-size: 18px;-->
<!--}-->
<!--.can-back {-->
<!-- background: linear-gradient(to bottom, #1cbfff, #1989fa);-->
<!-- box-shadow: 0 0 20px rgba(149, 156, 172, 0.3);-->
<!--}-->
<!--.saomaIcon {-->
<!-- width: 60px;-->
<!-- margin-top: 30px;-->
<!--}-->
<!--.searchStyle {-->
<!-- border-radius: 12px;-->
<!--}-->
import {createRouter, createWebHashHistory} from 'vue-router'
import routes from "./routes.js";
import * as api from '../api/index.js'
import Cookies from 'js-cookie'
const router = new createRouter({
history: createWebHashHistory(),
routes: routes,
})
// 全局守卫:登录拦截 本地没有存token,请重新登录
router.beforeEach(async (to, from, next) => {
if (to.meta.isAuth && to.meta.admin) {
if (Cookies.get('user-info')) {
next()
// Cookies.get('user-info').split('"').indexOf('值班领导') === -1 ? next({name: 'undefinedAuthorization'}) : next()
} else {
const res = await api.GetTokenInfo()
Cookies.set('user-info', res.response.name)
if (Cookies.get('user-info')) next()
else {
next({name: '403'})
}
}
} else if (to.meta.isAuth) {
if (Cookies.get('user-info')) {
next()
} else {
const res = await api.GetTokenInfo()
Cookies.set('user-info', res.response.name)
if (Cookies.get('user-info')) next()
else {
next({name: '403'})
}
}
} else if (!to.meta.isAuth) {
next()
}
});
export default router
const routes = [
{
name: '403',
path: '/403',
component: () => import('../pages/403/index.vue'),
},
{
name: 'undefinedAuthorization',
path: '/undefinedAuthorization',
component: () => import('../pages/authPage/index.vue'),
},
{
name: 'et',
path: '/et',
component: () => import('../pages/SSO.vue')
},
{
name: 'welcome',
path: '/welcome',
component: () => import('../pages/welcome/index.vue'),
meta: {isAuth: true},
},
{
name: 'signList',
path: '/signList',
component: () => import('../pages/signList/index.vue'),
meta: {isAuth: true, admin: true}
},
{
name: 'myDuty',
path: '/myDuty',
component: () => import('../pages/myDuty/index.vue'),
meta: {isAuth: true}
},
{
name: 'messageDetails',
path: '/messageDetails',
component: () => import('../pages/messageDetails/index.vue'),
}
]
export default routes
.container{
box-sizing: border-box;
background-color: #e8e5e5;
width: 100%;
height: 100%;
min-height: 812px;
/*max-width: 600px;*/
display: flex;
flex-wrap: wrap;
justify-content: center;
align-content: flex-start;
}
/*:root {*/
/* font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;*/
/* line-height: 1.5;*/
/* font-weight: 400;*/
/* color-scheme: light dark;*/
/* color: rgba(255, 255, 255, 0.87);*/
/* !*background-color: #242424;*!*/
/* font-synthesis: none;*/
/* text-rendering: optimizeLegibility;*/
/* -webkit-font-smoothing: antialiased;*/
/* -moz-osx-font-smoothing: grayscale;*/
/* -webkit-text-size-adjust: 100%;*/
/*}*/
/*a {*/
/* font-weight: 500;*/
/* color: #646cff;*/
/* text-decoration: inherit;*/
/*}*/
/*a:hover {*/
/* color: #535bf2;*/
/*}*/
/*a {*/
/* font-weight: 500;*/
/* color: #646cff;*/
/* text-decoration: inherit;*/
/*}*/
/*a:hover {*/
/* color: #535bf2;*/
/*}*/
/*body {*/
/* margin: 0;*/
/* display: flex;*/
/* place-items: center;*/
/* min-width: 320px;*/
/* min-height: 100vh;*/
/*}*/
/*h1 {*/
/* font-size: 3.2em;*/
/* line-height: 1.1;*/
/*}*/
/*button {*/
/* border-radius: 8px;*/
/* border: 1px solid transparent;*/
/* padding: 0.6em 1.2em;*/
/* font-size: 1em;*/
/* font-weight: 500;*/
/* font-family: inherit;*/
/* background-color: #1a1a1a;*/
/* cursor: pointer;*/
/* transition: border-color 0.25s;*/
/*}*/
/*button:hover {*/
/* border-color: #646cff;*/
/*}*/
/*button:focus,*/
/*button:focus-visible {*/
/* outline: 4px auto -webkit-focus-ring-color;*/
/*}*/
/*.card {*/
/* padding: 2em;*/
/*}*/
/*#app {*/
/* max-width: 1280px;*/
/* margin: 0 auto;*/
/* padding: 2rem;*/
/* text-align: center;*/
/*}*/
/*@media (prefers-color-scheme: light) {*/
/* :root {*/
/* color: #213547;*/
/* background-color: #ffffff;*/
/* }*/
/* a:hover {*/
/* color: #747bff;*/
/* }*/
/* button {*/
/* background-color: #f9f9f9;*/
/* }*/
/*}*/
import axios from 'axios';
import Cookies from 'js-cookie'
import {showToast} from 'vant';
import 'vant/es/toast/style';
import dayjs from 'dayjs';
import * as api from '../api/index.js'
// import {BASE_URL} from './publicURL.js'
// const BASE_URL = BASE_URL // 替换成你的API的基本URL
const axiosInstance = axios.create({
// baseURL: 'https://asc.hnasct.cn/DutyManagement',
baseURL: '/museumAppointment', // 默认地址代理转换为··域名·· 请求地址为 域名 + baseURL + 动态传入URL
timeout: 10000, // 设置请求超时时间,单位为毫秒
headers: {
'Content-Type': 'application/json',
// 可以在这里添加其他请求头信息
},
});
// const refreshTokenAction = () => {
// let flag = 1
// let currentTime = dayjs(dayjs().valueOf())
// // let refreshTime = dayjs(dayjs('2023-09-06T16:07:31.230Z').valueOf())
// let refreshTime = dayjs(dayjs(Cookies.get('time')).valueOf())
// console.log("🚀🚀🚀,")
// if (currentTime.diff(refreshTime) <= 2 * 60 * 60 * 1000 && flag === 1) {
// flag = 2
// api.RefreshToken()
// .then(res => {
// console.log('asdasd', res)
// Cookies.set('admin-token', res.response.access_token.token_content)
// Cookies.set('time', res.response.access_token.expires)
// flag = 1
// })
//
//
// }
//
//
// // console.log("🚀🚀🚀,", currentTime.diff(refreshTime))
// // console.log("🚀🚀🚀 dayjs().valueOf(),",currentTime,refreshTime,currentTime.diff(refreshTime) <= 15 * 60 * 1000)
// }
// 添加请求拦截器
let flag = 1; // 将 flag 移出函数,以便在多次调用之间保持不变
const refreshTokenAction = async () => {
if (flag === 1) {
flag = 2;
let currentTime = dayjs(dayjs().valueOf());
let refreshTime = dayjs(dayjs(Cookies.get('time')).valueOf());
if (refreshTime.diff(currentTime) <= 2 * 60 * 60 * 1000) {
try {
const res = await api.RefreshToken();
// console.log('asdasd', res.response.token_content, currentTime.format('YYYY-MM-DD HH:mm:ss'), refreshTime.format('YYYY-MM-DD HH:mm:ss'), refreshTime.diff(currentTime),);
Cookies.set('admin-token', res.response.token_content);
Cookies.set('time', res.response.expires);
} catch (error) {
console.error('刷新 Token 失败', error);
} finally {
flag = 1; // 无论成功或失败,都将 flag 重置为 1
}
}
}
};
axiosInstance.interceptors.request.use(
(config) => {
// 在发送请求之前可以进行一些处理,例如添加认证信息、日志等
let token = Cookies.get('admin-token')
config.headers['Authorization'] = 'Bearer ' + token
refreshTokenAction()
return config;
},
(error) => {
// 处理请求错误
return Promise.reject(error);
}
);
// 添加响应拦截器
axiosInstance.interceptors.response.use(
(response) => {
// 在这里可以对响应数据进行处理,例如解析JSON、错误处理等
return response.data;
},
(error) => {
// 处理响应错误
if (error && error.response) {
let msg = ''
switch (error.response.status) {
case 400:
msg = '请求错误';
break;
case 401:
msg = '未授权,请登录';
break;
case 403:
msg = '拒绝访问';
break;
case 404:
msg = `请求地址出错: ${error.response.config.url}`;
break;
case 408:
msg = '请求超时';
break;
case 500:
msg = '服务器内部错误';
break;
case 501:
msg = '服务未实现';
break;
case 502:
msg = '网关错误';
break;
case 503:
msg = '服务不可用';
break;
case 504:
msg = '网关超时';
break;
case 505:
msg = 'HTTP版本不受支持';
break;
default:
msg = '网络出了小差~';
break;
}
showToast(msg);
}
return Promise.reject(error);
}
);
export default axiosInstance
// export const BASE_URL = 'https://asc.hnasct.cn/DutyManagement/'; // 替换成你的API的基本URL
import axiosInstance from './axios.js'
export let requestGet = (url, data) => {
return new Promise((resolve, reject) => {
console.log("🚀🚀🚀GetWxConfigGetWxConfig,", data)
axiosInstance.get(url, data)
.then(res => {
resolve(res)
})
.catch(err => {
reject(err)
})
})
}
export const requestPost = (url, data) => {
return new Promise((resolve, reject) => {
axiosInstance.post(url, data)
.then(res => {
resolve(res)
})
.catch(err => {
reject(err)
})
})
}
import {defineConfig} from 'vite'
import vue from '@vitejs/plugin-vue'
import Components from 'unplugin-vue-components/vite';
import {VantResolver} from 'unplugin-vue-components/resolvers';
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
vue(),
Components({
resolvers: [VantResolver()],
}),
],
base: './',
server: {
// host: "127.0.0.1",
// cors: true,
// port: 8991,
// open: true, //自动打开
proxy: {
// 这里的ccc可乱写, 是拼接在url后面的地址 如果接口中没有统一的后缀可自定义
// 如果有统一后缀, 如api, 直接写api即可, 也不用rewrite了
"/museumAppointment": {
target: "https://asc.hnasct.cn/", // 真实接口地址, 后端给的基地址
changeOrigin: true, // 允许跨域
// rewrite: (path) => path.replace(/^\/DutyManagement/, ""), // 将ccc替换为空
},
},
}
})
Markdown 格式
0% or
您添加了 0 人 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册 或