diff --git a/.env b/.env new file mode 100644 index 0000000..bdfefc5 --- /dev/null +++ b/.env @@ -0,0 +1 @@ +VITE_WX_REDIRECT_URI=https://mailbox.biutag.com/ \ No newline at end of file diff --git a/.env.dev b/.env.dev new file mode 100644 index 0000000..bdfefc5 --- /dev/null +++ b/.env.dev @@ -0,0 +1 @@ +VITE_WX_REDIRECT_URI=https://mailbox.biutag.com/ \ No newline at end of file diff --git a/.env.prod b/.env.prod new file mode 100644 index 0000000..8d83f4c --- /dev/null +++ b/.env.prod @@ -0,0 +1 @@ +VITE_WX_REDIRECT_URI=https://jzxx.biutag.com/ \ No newline at end of file diff --git a/.gitignore b/.gitignore index e728804..5a737cb 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,5 @@ node_modules dist .history + +*.zip diff --git a/nginx.conf b/nginx.conf deleted file mode 100644 index 5d07518..0000000 --- a/nginx.conf +++ /dev/null @@ -1,19 +0,0 @@ - - -client_max_body_size 10M; - -server { - listen 80; - server_name mailbox.biutag.com; - - location / { - root /usr/share/nginx/html/mailbox; - index index.html; - try_files $uri $uri/ /index.html; - } - - location /api/ { - proxy_pass http://172.31.217.20:30784/; - } - -} diff --git a/package.json b/package.json index 6fdf560..c3d9547 100644 --- a/package.json +++ b/package.json @@ -6,19 +6,25 @@ "scripts": { "dev": "vite", "build": "vite build", + "build:prod": "vite build --mode prod", "preview": "vite preview" }, "dependencies": { "crypto-js": "^4.2.0", + "install": "^0.13.0", + "npm": "^10.5.0", "pinia": "^2.1.7", "vant": "^4.8.2", "vue": "^3.3.11", - "vue-router": "^4.2.5" + "vue-router": "^4.2.5", + "vue-touch": "^2.0.0-beta.4", + "vue3-touch-events": "^4.1.8" }, "devDependencies": { "@vitejs/plugin-vue": "^4.5.2", "sass": "^1.69.7", "unplugin-auto-import": "^0.17.3", + "vconsole": "^3.15.1", "vite": "^5.0.8", "vite-svg-loader": "^5.1.0" } diff --git a/src/assets/style/style.scss b/src/assets/style/style.scss index d974308..f79158a 100644 --- a/src/assets/style/style.scss +++ b/src/assets/style/style.scss @@ -79,7 +79,7 @@ svg+span { } .flex.gap-10 { - gap: 0 10px; + gap: 10px; } .flex.gap-16 { @@ -187,6 +187,11 @@ svg+span { margin-top: 16px; font-size: 17px; font-weight: bold; + .state { + font-size: 14px; + font-weight: 500; + color: var(--primary-color); + } } .content { diff --git a/src/components/FileList.vue b/src/components/FileList.vue new file mode 100644 index 0000000..0c67186 --- /dev/null +++ b/src/components/FileList.vue @@ -0,0 +1,116 @@ + + + \ No newline at end of file diff --git a/src/components/ImgPreview.vue b/src/components/ImgPreview.vue deleted file mode 100644 index 86f9181..0000000 --- a/src/components/ImgPreview.vue +++ /dev/null @@ -1,44 +0,0 @@ - - - \ No newline at end of file diff --git a/src/main.js b/src/main.js index 5db88b9..dc4478d 100644 --- a/src/main.js +++ b/src/main.js @@ -7,6 +7,7 @@ import App from './App.vue' import { Button, Tab, Tabs, Form, Field, CellGroup, Cell, RadioGroup, Radio, Uploader, Icon, Popup, Loading, Overlay, Empty, List, Picker } from 'vant'; import IconComponent from '@/components/Icon.vue' import LoadingComponent from '@/components/Loading.vue' +import Vue3TouchEvents from "vue3-touch-events"; import './permission' // 权限控制 @@ -15,7 +16,7 @@ import './assets/style/style.scss' import './assets/style/vant.scss' // import VConsole from 'vconsole'; -// + // const vConsole = new VConsole(); const app = createApp(App) @@ -38,6 +39,7 @@ const app = createApp(App) .use(Empty) .use(List) .use(Picker) + .use(Vue3TouchEvents) .component('Icon', IconComponent) .component('Loading', LoadingComponent); -app.mount('#app') +app.mount('#app') \ No newline at end of file diff --git a/src/permission.js b/src/permission.js index 8478e06..3952e7c 100644 --- a/src/permission.js +++ b/src/permission.js @@ -2,10 +2,17 @@ import router from './router' import UserStore from "@/store/user" import { showToast } from 'vant'; import { getToken } from '@/util/cookie' +import { showLoadingToast } from "vant"; // 白名单 const whiteList = ['/']; +let toast; router.beforeEach((to, from, next) => { + toast = showLoadingToast({ + message: "加载中...", + forbidClick: true, + duration: 0, + }); const whiteFlag = whiteList.indexOf(to.path) !== -1; const userStore = UserStore(); const token = getToken(); @@ -21,33 +28,26 @@ router.beforeEach((to, from, next) => { } // 已有用户信息 if (userStore.user.id) { - // 判断用户是否进行了人脸认证 - if (userStore.user.idCard || to.path === '/realName/auth') { - // 判断是否是从信件页面回退到人脸认证界面的,如果是则返回首页 - if (to.path === '/realName/auth' && from.path === '/mail') { - next('/'); - return - } - next(); - return - } - next('/realName/auth'); + if (to.path === '/realName/auth' || userStore.user.faceAuth) { + next() + } else { + next('/realName/auth') + } return } // 获取用户信息 userStore.getUser().then(() => { - // 判断用户是否进行了人脸认证 - if (userStore.user.idCard || to.path === '/realName/auth') { - // 判断是否是从信件页面回退到人脸认证界面的,如果是则返回首页 - if (to.path === '/realName/auth' && from.path === '/mail') { - next('/'); - return - } - next(); - return - } - next('/realName/auth'); - }).catch((res) => { + // 解决人脸认证页面回退空白页 + if (to.path === '/realName/auth' || userStore.user.faceAuth) { + next() + } else { + next('/realName/auth') + } + }).catch(() => { next('/') }) +}) + +router.afterEach(() => { + toast.close() }) \ No newline at end of file diff --git a/src/store/wx.js b/src/store/wx.js index af74260..ba62088 100644 --- a/src/store/wx.js +++ b/src/store/wx.js @@ -20,7 +20,7 @@ const WxStore = defineStore( nonceStr: data.nonceStr, // 必填,生成签名的随机串 signature: data.signature, // 必填,签名 jsApiList: ["chooseImage", 'getLocalImgData', 'previewImage'], // 必填,需要使用的JS接口列表 - openTagList: ["wx-open-launch-weapp"], + openTagList: ["wx-open-launch-weapp"] }); wx.ready(function () { _this.signInitFlag = true @@ -31,7 +31,13 @@ const WxStore = defineStore( console.log('签名失败') reject(res) }); - resolve() + setTimeout(() => { + if (_this.signInitFlag) { + resolve() + } else { + reject('签名加载失败') + } + }, 1000) }).catch((res) => { reject(res) }); diff --git a/src/views/Home.vue b/src/views/Home.vue index 260db00..720677d 100644 --- a/src/views/Home.vue +++ b/src/views/Home.vue @@ -1,45 +1,45 @@ diff --git a/src/views/RealNameAuth.vue b/src/views/RealNameAuth.vue index f8b09fd..586ed5a 100644 --- a/src/views/RealNameAuth.vue +++ b/src/views/RealNameAuth.vue @@ -55,7 +55,7 @@ import { validatorIdCard } from "@/util/validator"; import { realUserInfo } from "@/api/auth"; import UserStore from "@/store/user"; import WxStore from "@/store/wx"; -import { showToast } from "vant"; +import { nextTick } from "vue"; const router = useRouter(); const userStore = UserStore(); @@ -63,47 +63,44 @@ const wxStore = WxStore(); const showForm = ref(false); const formRef = ref(null); -const form = ref({}); +const form = ref({ + realName: userStore.user.realName, + idCard: userStore.user.idCard, +}); const disabled = ref(true); // 判断微信签名是否初始化 -if (!wxStore.signInitFlag) { // 未初始化 +if (!wxStore.signInitFlag) { + // 未初始化 // 初始化签名 - wxStore.initSign() + wxStore.initSign(); +} else { + if (form.value.realName && validatorIdCard(form.value.idCard) === true) { + nextTick(() => { + onFinish(); + }); + } } +watch( + () => wxStore.signInitFlag, + (val) => { + if (val) { + if ( + form.value.realName && + validatorIdCard(form.value.idCard) === true + ) { + nextTick(() => { + onFinish(); + }); + } + } + } +); + function onInput() { if (form.value.realName && validatorIdCard(form.value.idCard) === true) { - disabled.value = false; - const extraData = JSON.stringify(form.value); - const pathParam = `name=${form.value.realName}&idCard=${form.value.idCard}&userId=${userStore.user.id}`; - const script = document.createElement("script"); - script.type = "text/wxtag-template"; - script.text = `
`; - // env-version="trial" - const html = `${script.outerHTML}`; - //const html = `${script.outerHTML}`; - - document.querySelector("#launch-btn").innerHTML = html; - const launchEl = document.querySelector( - "#launch-btn wx-open-launch-weapp" - ); - launchEl.addEventListener("launch", function (e) { - console.log("launch"); - let timer = setInterval(() => { - realUserInfo(userStore.user.id).then((data) => { - if (data.idCard) { - userStore.user = data; - clearInterval(timer); - // 跳转到写信界面 - router.push("/mail"); - } - }); - }, 1000); - }); - launchEl.addEventListener("error", function (e) { - - }); + onFinish(); } else { disabled.value = true; if ( @@ -115,6 +112,36 @@ function onInput() { } } } + +function onFinish() { + console.log("onFinish"); + disabled.value = false; + const extraData = JSON.stringify(form.value); + const pathParam = `name=${form.value.realName}&idCard=${form.value.idCard}&userId=${userStore.user.id}`; + const script = document.createElement("script"); + script.type = "text/wxtag-template"; + script.text = `
`; + // env-version="trial" + //const html = `${script.outerHTML}`; + const html = `${script.outerHTML}`; + + document.querySelector("#launch-btn").innerHTML = html; + const launchEl = document.querySelector("#launch-btn wx-open-launch-weapp"); + launchEl.addEventListener("launch", function (e) { + console.log("launch"); + let timer = setInterval(() => { + realUserInfo(userStore.user.id).then((data) => { + if (data.faceAuth) { + userStore.user = data; + clearInterval(timer); + // 跳转到写信界面 + router.push("/mail"); + } + }); + }, 1000); + }); + launchEl.addEventListener("error", function (e) {}); +} \ No newline at end of file diff --git a/src/views/mail/MailEvaluate.vue b/src/views/mail/MailEvaluate.vue index 15d1124..ad40e6c 100644 --- a/src/views/mail/MailEvaluate.vue +++ b/src/views/mail/MailEvaluate.vue @@ -29,9 +29,12 @@ import { showSuccessToast } from "vant"; const route = useRoute(); const router = useRouter(); -const satisfaction = ref(route.query.satisfaction || "SATISFIED"); +const satisfaction = ref(route.query.satisfaction && route.query.satisfaction !== 'null' ? route.query.satisfaction : "satisfied"); function sumbit() { + if (!satisfaction.value) { + return + } updateEvaluate({ mailId: route.params.id, satisfaction: satisfaction.value diff --git a/src/views/mail/components/MyMail.vue b/src/views/mail/components/MyMail.vue index 235da07..49cf232 100644 --- a/src/views/mail/components/MyMail.vue +++ b/src/views/mail/components/MyMail.vue @@ -7,14 +7,23 @@ > @@ -45,9 +55,9 @@ const pageStore = PageStore(); const router = useRouter(); const satisfactions = { - NOT_SATISFIED: "不满意", - BASICALLY_SATISFIED: "基本满意", - SATISFIED: "满意", + not_satisfied: "不满意", + basically_satisfied: "基本满意", + satisfied: "满意", }; const params = ref({ size: 6, @@ -62,8 +72,8 @@ function onLoad() { listMail(params.value).then((data) => { loading.value = false; if (!data.records.length) { - finished.value = true - return + finished.value = true; + return; } mails.value = mails.value.concat(data.records); }); @@ -74,26 +84,32 @@ onLoad(); watch(loading, (val) => { if (val) { params.value.current += 1; - onLoad() + onLoad(); } }); function refresh() { mails.value = []; params.value.current = 1; - finished.value = false - onLoad() + finished.value = false; + onLoad(); } -watch(() => pageStore.myMailRefresh, (val) => { - if (val) { - refresh(); - pageStore.myMailRefresh = false; +watch( + () => pageStore.myMailRefresh, + (val) => { + if (val) { + refresh(); + pageStore.myMailRefresh = false; + } } -}) +); +const MAIL_STATES = { + processing: "办理中", + terminated: "已终止", + completion: "已办结", +}; \ No newline at end of file diff --git a/src/views/mail/components/Write.vue b/src/views/mail/components/Write.vue index 6079b87..f8cb1ce 100644 --- a/src/views/mail/components/Write.vue +++ b/src/views/mail/components/Write.vue @@ -1,379 +1,366 @@ diff --git a/vite.config.js b/vite.config.js index 212a009..258794e 100644 --- a/vite.config.js +++ b/vite.config.js @@ -1,55 +1,60 @@ -import { defineConfig } from 'vite' +import { defineConfig, loadEnv } from 'vite' import vue from '@vitejs/plugin-vue' import AutoImport from 'unplugin-auto-import/vite' import svgLoader from 'vite-svg-loader' import path from 'path' // https://vitejs.dev/config/ -export default defineConfig({ - - plugins: [ - vue(), - svgLoader(), - AutoImport({ - imports: [ - 'vue' - ] - }), - ], - resolve: { - // https://cn.vitejs.dev/config/#resolve-alias - alias: { - // 设置路径 - '~': path.resolve(__dirname, './'), - // 设置别名 - '@': path.resolve(__dirname, './src/') +export default ({ mode }) => { + const env = loadEnv(mode, process.cwd()); + return defineConfig({ + define: { + 'process.env': env + }, + plugins: [ + vue(), + svgLoader(), + AutoImport({ + imports: [ + 'vue' + ] + }), + ], + resolve: { + // https://cn.vitejs.dev/config/#resolve-alias + alias: { + // 设置路径 + '~': path.resolve(__dirname, './'), + // 设置别名 + '@': path.resolve(__dirname, './src/') + }, + // https://cn.vitejs.dev/config/#resolve-extensions + extensions: ['.js'] }, - // https://cn.vitejs.dev/config/#resolve-extensions - extensions: ['.js'] - }, - server: { - host: '0.0.0.0', - proxy: { - '/api': { - // https://mailbox.biutag.com/api - // http://127.0.0.1:8080 - target: 'https://mailbox.biutag.com/api', - changeOrigin: true, - rewrite: (p) => p.replace(/^\/api/, '') + server: { + host: '0.0.0.0', + proxy: { + '/api': { + // https://mailbox.biutag.com/api + // http://127.0.0.1:8080 + target: 'https://jzxx.biutag.com/api', + changeOrigin: true, + rewrite: (p) => p.replace(/^\/api/, '') + } } - } - }, - build: { - rollupOptions: { - output: { - entryFileNames: `assets/[name].${new Date().getTime()}.js`, - chunkFileNames: `assets/[name].${new Date().getTime()}.js`, - assetFileNames: `assets/[name].${new Date().getTime()}.[ext]`, - compact: true, - manualChunks: { - vue: ['vue'] - }, + }, + build: { + rollupOptions: { + output: { + entryFileNames: `assets/[name].${new Date().getTime()}.js`, + chunkFileNames: `assets/[name].${new Date().getTime()}.js`, + assetFileNames: `assets/[name].${new Date().getTime()}.[ext]`, + compact: true, + manualChunks: { + vue: ['vue'] + }, + } } } - } -}) + }) +}