From 7de1396e315896dbc72a9d54e44f77434ea90f18 Mon Sep 17 00:00:00 2001
From: wlzboy <66905212@qq.com>
Date: 星期日, 14 十二月 2025 23:47:34 +0800
Subject: [PATCH] feat:增加企业微信自动登录
---
app/utils/common.js | 86 +++++++++++++++++++++++++++++++++++++++++++
1 files changed, 86 insertions(+), 0 deletions(-)
diff --git a/app/utils/common.js b/app/utils/common.js
index 00d4137..4f095b9 100644
--- a/app/utils/common.js
+++ b/app/utils/common.js
@@ -51,4 +51,90 @@
}
}
return result
+}
+
+/**
+ * 鏍煎紡鍖栨棩鏈熸椂闂达紙鍏煎iOS锛�
+ * @param dateTime 鏃ユ湡鏃堕棿瀛楃涓叉垨Date瀵硅薄
+ * @param format 鏍煎紡鍖栨ā鏉匡紝榛樿涓� 'YYYY-MM-DD HH:mm:ss'
+ * @returns {string} 鏍煎紡鍖栧悗鐨勬棩鏈熸椂闂村瓧绗︿覆
+ */
+export function formatDateTime(dateTime, format = 'YYYY-MM-DD HH:mm:ss') {
+ if (!dateTime) return ''
+
+ let date
+ if (typeof dateTime === 'string') {
+ // iOS鍏煎鎬у鐞嗭細灏� "yyyy-MM-dd HH:mm:ss" 鏍煎紡杞崲涓� "yyyy/MM/dd HH:mm:ss"
+ const iosCompatibleDate = dateTime.replace(/-/g, '/')
+ date = new Date(iosCompatibleDate)
+ } else {
+ date = new Date(dateTime)
+ }
+
+ // 妫�鏌ユ棩鏈熸槸鍚︽湁鏁�
+ if (isNaN(date.getTime())) {
+ console.warn('Invalid date:', dateTime)
+ return ''
+ }
+
+ const year = date.getFullYear()
+ const month = String(date.getMonth() + 1).padStart(2, '0')
+ const day = String(date.getDate()).padStart(2, '0')
+ const hours = String(date.getHours()).padStart(2, '0')
+ const minutes = String(date.getMinutes()).padStart(2, '0')
+ const seconds = String(date.getSeconds()).padStart(2, '0')
+
+ // 鏍规嵁format妯℃澘杩斿洖鏍煎紡鍖栫粨鏋�
+ if (format === 'YYYY-MM-DD') {
+ return `${year}-${month}-${day}`
+ } else if (format === 'YYYY-MM-DD HH:mm') {
+ return `${year}-${month}-${day} ${hours}:${minutes}`
+ } else if (format === 'MM-DD HH:mm') {
+ return `${month}-${day} ${hours}:${minutes}`
+ } else {
+ return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`
+ }
+}
+
+/**
+ * 鑾峰彇绯荤粺淇℃伅锛堝吋瀹规柊鏃PI锛�
+ * 鏇夸唬宸插簾寮冪殑uni.getSystemInfoSync()
+ * @returns {Object} 绯荤粺淇℃伅瀵硅薄
+ */
+export function getSystemInfo() {
+ // #ifdef MP-WEIXIN
+ // 寰俊灏忕▼搴忎娇鐢ㄦ柊API
+ try {
+ const windowInfo = uni.getWindowInfo()
+ const deviceInfo = uni.getDeviceInfo()
+ const appBaseInfo = uni.getAppBaseInfo()
+
+ return {
+ ...windowInfo,
+ ...deviceInfo,
+ ...appBaseInfo,
+ // 鍏煎鏃у瓧娈靛悕
+ windowHeight: windowInfo.windowHeight,
+ windowWidth: windowInfo.windowWidth,
+ screenHeight: windowInfo.screenHeight,
+ screenWidth: windowInfo.screenWidth,
+ statusBarHeight: windowInfo.statusBarHeight,
+ platform: deviceInfo.platform,
+ system: deviceInfo.system,
+ model: deviceInfo.model,
+ brand: deviceInfo.brand,
+ SDKVersion: appBaseInfo.SDKVersion,
+ version: appBaseInfo.version
+ }
+ } catch (e) {
+ // 闄嶇骇浣跨敤鏃PI
+ console.warn('鏂癆PI璋冪敤澶辫触锛岄檷绾т娇鐢ㄦ棫API', e)
+ return uni.getSystemInfoSync()
+ }
+ // #endif
+
+ // #ifndef MP-WEIXIN
+ // 鍏朵粬骞冲彴缁х画浣跨敤鏃PI
+ return uni.getSystemInfoSync()
+ // #endif
}
\ No newline at end of file
--
Gitblit v1.9.1