diff --git a/App.vue b/App.vue index 49182bf..f5d59f6 100644 --- a/App.vue +++ b/App.vue @@ -6,25 +6,34 @@ import useUserStore from './stores/useUserStore'; import usePageAnimation from './hook/usePageAnimation'; import useDictStore from './stores/useDictStore'; import { GlobalInactivityManager } from '@/utils/GlobalInactivityManager'; -const { $api, navTo, appendScriptTagElement, aes_Decrypt, sm2_Decrypt, safeReLaunch } = inject('globalFunction'); +const { + $api, + navTo, + appendScriptTagElement, + aes_Decrypt, + sm2_Decrypt, + safeReLaunch, + isY9MachineType, + isAsdMachineType, +} = inject('globalFunction'); import config from '@/config.js'; import baseDB from '@/utils/db.js'; import { $confirm } from '@/utils/modal.js'; import useLocationStore from '@/stores/useLocationStore'; -usePageAnimation(); const appword = 'aKd20dbGdFvmuwrt'; // 固定值 let uQRListen = null; let inactivityManager = null; let inactivityModalTimer = null; +usePageAnimation(); onLaunch((options) => { useDictStore().getDictData(); - if (lightAppJssdk.user) { + if (isAsdMachineType()) { console.warn('爱山东环境'); getUserInfo(); useUserStore().changMiniProgramAppStatus(false); useUserStore().changMachineEnv(false); - useLocationStore().getLocationLoop()//循环获取定位 + useLocationStore().getLocationLoop(); //循环获取定位 return; } if (isY9MachineType()) { @@ -34,17 +43,19 @@ onLaunch((options) => { useUserStore().changMiniProgramAppStatus(true); useUserStore().changMachineEnv(true); (function loop() { - console.log('📍一体机尝试获取定位') - useLocationStore().getLocation().then(({longitude,latitude})=>{ - console.log(`✅一体机获取定位成功:lng:${longitude},lat${latitude}`) - }) - .catch(err=>{ - console.log('❌一体机获取定位失败,30s后尝试重新获取') - setTimeout(() => { - loop() - }, 3000); - }) - })() + console.log('📍一体机尝试获取定位'); + useLocationStore() + .getLocation() + .then(({ longitude, latitude }) => { + console.log(`✅一体机获取定位成功:lng:${longitude},lat${latitude}`); + }) + .catch((err) => { + console.log('❌一体机获取定位失败,30s后尝试重新获取'); + setTimeout(() => { + loop(); + }, 3000); + }); + })(); uQRListen = new IncreaseRevie(); inactivityManager = new GlobalInactivityManager(handleInactivity, 60 * 1000); inactivityManager.start(); @@ -52,7 +63,7 @@ onLaunch((options) => { } // 正式上线去除此方法 console.warn('浏览器环境'); - useLocationStore().getLocationLoop()//循环获取定位 + useLocationStore().getLocationLoop(); //循环获取定位 useUserStore().changMiniProgramAppStatus(true); useUserStore().changMachineEnv(false); useUserStore().initSeesionId(); //更新 @@ -70,7 +81,6 @@ onLaunch((options) => { onMounted(() => {}); - onShow(() => { console.log('App Show'); }); @@ -133,13 +143,6 @@ function performLogout() { inactivityManager?.resume(); // 恢复监听 } -// 一体机环境判断 -function isY9MachineType() { - const ua = navigator.userAgent; - const isY9Machine = /Y9-ZYYH/i.test(ua); // 匹配机器型号 - return isY9Machine; -} - // 爱山东环境登录 function getUserInfo() { lightAppJssdk.user.getUserInfoWithEncryptedParamByAppId({ diff --git a/common/all-in-one-listen.js b/common/all-in-one-listen.js index 2006e3f..1ff93d4 100644 --- a/common/all-in-one-listen.js +++ b/common/all-in-one-listen.js @@ -1,5 +1,6 @@ import { - $api + $api, + safeReLaunch } from "./globalFunction"; import baseDB from '@/utils/db.js'; import useUserStore from '@/stores/useUserStore'; @@ -43,21 +44,23 @@ export class IncreaseRevie { async handleDebouncedCallback(res) { if (res.data) { - const code = res.data.qrQode - console.log('二维码code', code); - // 把code给到后端,后端拿code兑换用户信息,给前端返回token进行登录 - // 一体机用户需要清空indexDB - // useUserStore() - // .loginSetToken(resData.token) - // .then((resume) => { - // if (resume.data.jobTitleId) { - // useUserStore().initSeesionId(); - // safeReLaunch('/pages/index/index'); - // } else { - // safeReLaunch('/pages/login/login'); - // } - // }); - // baseDB.resetAndReinit(); // 清空indexdb + const code = res.data.qrCode + if (/^\d{6}$/.test(String(code))) { + // 把code给到后端,后端拿code兑换用户信息,给前端返回token进行登录 + // 一体机用户需要清空indexDB + $api.createRequest(`/app/qrcodeLogin/${code}`, {}, 'get').then((resData) => { + useUserStore() + .loginSetToken(resData.token) + .then((resume) => { + if (resume.data.jobTitleId) { + useUserStore().initSeesionId(); + safeReLaunch('/pages/index/index'); + } else { + safeReLaunch('/pages/login/login'); + } + }); + }); + } } else { $api.msg('识别失败') } diff --git a/common/globalFunction.js b/common/globalFunction.js index 25e86ad..335aed1 100644 --- a/common/globalFunction.js +++ b/common/globalFunction.js @@ -634,6 +634,20 @@ export function reloadBrowser() { window.location.reload() } +// 一体机环境判断 +export function isY9MachineType() { + const ua = navigator.userAgent; + const isY9Machine = /Y9-ZYYH/i.test(ua); // 匹配机器型号 + return isY9Machine; +} + +// 一体机环境判断 +export function isAsdMachineType() { + const ua = navigator.userAgent; + const isY9Machine = /asd_hanweb/i.test(ua); // 匹配机器型号 + return isY9Machine; +} + export const $api = { msg, @@ -684,5 +698,7 @@ export default { sm2_Decrypt, sm2_Encrypt, safeReLaunch, - reloadBrowser + reloadBrowser, + isAsdMachineType, + isY9MachineType } \ No newline at end of file diff --git a/config.js b/config.js index e4d96e3..19932f8 100644 --- a/config.js +++ b/config.js @@ -4,8 +4,8 @@ export default { // baseUrl: 'http://192.168.3.29:8081', // baseUrl: 'http://10.213.6.207:19010/api', // 语音转文字 - vioceBaseURl: 'wss://qd.zhaopinzao8dian.com/api/app/asr/connect', // 自定义 - // vioceBaseURl: 'wss://fw.rc.qingdao.gov.cn/rgpp-api/api/app/asr/connect', // 内网 + // vioceBaseURl: 'wss://qd.zhaopinzao8dian.com/api/app/asr/connect', // 自定义 + vioceBaseURl: 'wss://fw.rc.qingdao.gov.cn/rgpp-api/api/app/asr/connect', // 内网 // 语音合成 // speechSynthesis: 'wss://qd.zhaopinzao8dian.com/api/speech-synthesis', // speechSynthesis2: 'wss://resource.zhuoson.com/synthesis/', //直接替换即可