From 7dbaef517bdc2b54878badf46208df9909145e88 Mon Sep 17 00:00:00 2001 From: XiaoXinPro 14 IAH5R <568170040@qq.com> Date: Wed, 9 Aug 2023 15:46:10 +0800 Subject: [PATCH] device --- src/App.vue | 29 +++++++++++++++++++++++++-- src/pages/uploadPhoto/uploadPhoto.vue | 2 +- src/store/modules/userInfo.js | 22 +++++++++++++++++--- 3 files changed, 47 insertions(+), 6 deletions(-) diff --git a/src/App.vue b/src/App.vue index d9ed678..dd071b4 100644 --- a/src/App.vue +++ b/src/App.vue @@ -12,8 +12,33 @@ onLaunch(() => { // 获取平台及系统信息 uni.getSystemInfo({ success: function (res) { - userInfoModulesPinia.equipment = res.uniPlatform; //平台 - userInfoModulesPinia.mySystem = res.osName; //应用 + let uniPlatform = ""; + let osName = ""; + + if (res.uniPlatform == "web") { + uniPlatform = 1; + } else if (res.uniPlatform == "mp-weixin") { + uniPlatform = 2; + } else if (res.uniPlatform == "mp-toutiao") { + uniPlatform = 3; + } + + if (res.osName == "windows") { + osName = 1; + } else if (res.osName == "ios") { + osName = 2; + } else if (res.osName == "android") { + osName = 3; + } else if (res.osName == "mac") { + osName = 4; + } else if (res.osName == "linux") { + osName = 5; + } + + userInfoModulesPinia.platForm = uniPlatform; // 平台 + userInfoModulesPinia.hostSystem = osName; // 系统 + console.log(res.uniPlatform, uniPlatform, "PlatForm"); + console.log(res.osName, osName, "System"); }, }); }); diff --git a/src/pages/uploadPhoto/uploadPhoto.vue b/src/pages/uploadPhoto/uploadPhoto.vue index 2fce832..511d9a5 100644 --- a/src/pages/uploadPhoto/uploadPhoto.vue +++ b/src/pages/uploadPhoto/uploadPhoto.vue @@ -91,7 +91,7 @@ function toCloseStyle() { }); } } -console.log(userInfoModulesPinia.mySystem, "XT"); +console.log(userInfoModulesPinia.hostSystem, "System"); //#endregion --------------------- //#region diff --git a/src/store/modules/userInfo.js b/src/store/modules/userInfo.js index 5ac9f46..5ce6274 100644 --- a/src/store/modules/userInfo.js +++ b/src/store/modules/userInfo.js @@ -3,8 +3,24 @@ import { ref, reactive } from "vue"; export const userInfoModules = defineStore("userInfoStore", () => { // state const userInfo = ref(null) - const equipment = ref(null) //平台 : web、mp-weixin、mp-toutiao - const mySystem = ref(null) //安卓和ios : ios、android、windows、macos + + /** + * @description:依托平台:(web、mp-weixin、mp-toutiao) + * @example 平台名:web-H5,枚举值:1 + * @example 平台名:mp-weixin,枚举值:2 + * @example 平台名:mp-toutiao,枚举值:3 + */ + const platForm = ref(null) + + /** + * @description:宿主系统:(windows、ios、android、mac、linux) + * @example 系统名:windows,值:1 + * @example 系统名:ios,值:2 + * @example 系统名:android,值:3 + * @example 系统名:mac,值:4 + * @example 系统名:linux,值:5 + */ + const hostSystem = ref(null) // 登录获取用户信息 async function getUserInfo() { @@ -14,7 +30,7 @@ export const userInfoModules = defineStore("userInfoStore", () => { function loginOut(params) { } - return { userInfo, equipment, mySystem, getUserInfo, loginOut }; + return { userInfo, platForm, hostSystem, getUserInfo, loginOut }; }, { persist: true,