From 691eddb7c6556bbffc7313b0d0df2e9385cc091a Mon Sep 17 00:00:00 2001
From: chenhaozhe <cgz@hz-kingdee.com>
Date: 星期一, 19 一月 2026 09:25:22 +0800
Subject: [PATCH] 个推 测试环境 切换分支开发
---
utils/getuiUtils.js | 16 +++++
utils/WebSocketServices.js | 29 +++++++--
manifest.json | 38 +++++++++++-
pages/index/login.vue | 46 ++++++++------
App.vue | 45 +++++++++++++++
5 files changed, 143 insertions(+), 31 deletions(-)
diff --git a/App.vue b/App.vue
index 16c947d..129c3f5 100644
--- a/App.vue
+++ b/App.vue
@@ -7,6 +7,7 @@
getToken,
getUserInfo
} from "./utils/auth";
+ import getuiUtils from "./utils/getuiUtils";
export default {
onLaunch: function() {
console.log('App Launch')
@@ -38,6 +39,27 @@
// });
// }
// #endif
+
+ // #ifdef APP-PLUS || APP
+ // 鐩戝惉 App 鍚姩鏃剁殑鎺ㄩ�佸弬鏁帮紙鍐峰惎鍔細App 鍏抽棴鍚庣偣鍑婚�氱煡鍚姩锛�
+ const launchOpts = plus.runtime.launchArguments;
+ if (launchOpts && launchOpts.payload) {
+ this.handlePushJump(launchOpts.payload); // 澶勭悊璺宠浆
+ }
+
+ // 鐩戝惉閫氱煡鐐瑰嚮浜嬩欢锛堢儹鍚姩锛欰pp 鍚庡彴杩愯鏃剁偣鍑婚�氱煡锛�
+ plus.push.addEventListener("click", (msg) => {
+ let payload = {};
+ console.log('payload: ', msg.payload);
+ // 鍏煎涓嶅悓鏍煎紡鐨� payload锛堟湰鍦版帹閫� vs 杩滅▼鎺ㄩ�侊級
+ if (typeof msg.payload === "string") {
+ payload = JSON.parse(msg.payload); // 杩滅▼鎺ㄩ�佸彲鑳芥槸瀛楃涓诧紝闇�瑙f瀽
+ } else {
+ payload = msg.payload; // 鏈湴鎺ㄩ�佹槸瀵硅薄
+ }
+ this.handlePushJump(payload); // 澶勭悊璺宠浆
+ });
+ // #endif
},
onShow: function() {
console.log('App Show')
@@ -45,6 +67,29 @@
},
onHide: function() {
console.log('App Hide')
+ },
+ methods: {
+ // 澶勭悊閫氱煡璺宠浆閫昏緫
+ handlePushJump(payload) {
+ console.log('payload-enter: ', payload);
+ if (!payload || !payload.pagePath) return;
+
+ // 纭繚 App 澶勪簬鍓嶅彴
+ // plus.runtime.foreground();
+
+ // 璺宠浆鍒版寚瀹氶〉闈�
+ setTimeout(() => {
+ uni.navigateTo({
+ url: `${payload.pagePath}?itemId=${payload.itemId}`, // 鎼哄甫鍙傛暟
+ fail: (err) => {
+ // 鑻ラ〉闈㈡爤婊★紙鏈�澶�10灞傦級锛屼娇鐢� redirectTo 鏇挎崲褰撳墠椤甸潰
+ uni.redirectTo({
+ url: `${payload.pagePath}?itemId=${payload.itemId}`,
+ });
+ }
+ });
+ }, 300)
+ }
}
}
</script>
diff --git a/manifest.json b/manifest.json
index 2a2de20..c128efa 100644
--- a/manifest.json
+++ b/manifest.json
@@ -52,10 +52,24 @@
"<uses-permission android:name=\"android.permission.WRITE_CONTACTS\"/>",
"<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>",
"<uses-permission android:name=\"android.permission.READ_EXTERNAL_STORAGE\"/>",
- "<uses-permission android:name=\"android.permission.WRITE_EXTERNAL_STORAGE\"/>"
+ "<uses-permission android:name=\"android.permission.WRITE_EXTERNAL_STORAGE\"/>",
+ "<uses-permission android:name=\"android.permission.INTERNET\"/>",
+ "<uses-permission android:name=\"android.permission.RECEIVE_BOOT_COMPLETED\"/>",
+ "<uses-permission android:name=\"android.permission.GET_TASKS\"/>",
+ "<uses-permission android:name=\"android.permission.BLUETOOTH\"/>",
+ "<uses-permission android:name=\"android.permission.BLUETOOTH_ADMIN\"/>",
+ "<uses-permission android:name=\"android.permission.ACCESS_FINE_LOCATION\"/>",
+ "<uses-permission android:name=\"android.permission.ACCESS_COARSE_LOCATION\"/>",
+ "<uses-permission android:name=\"android.permission.BROADCAST_PACKAGE_ADDED\"/>",
+ "<uses-permission android:name=\"android.permission.BROADCAST_PACKAGE_CHANGED\"/>",
+ "<uses-permission android:name=\"android.permission.BROADCAST_PACKAGE_INSTALL\"/>",
+ "<uses-permission android:name=\"android.permission.BROADCAST_PACKAGE_REPLACED\"/>",
+ "<uses-permission android:name=\"android.permission.RESTART_PACKAGES\"/>",
+ "<uses-permission android:name=\"android.permission.REQUEST_INSTALL_PACKAGES\"/>"
],
"abiFilters" : [ "armeabi-v7a", "arm64-v8a", "x86" ],
- "minSdkVersion" : 23
+ "minSdkVersion" : 23,
+ "excludePermissions" : []
},
/* ios鎵撳寘閰嶇疆 */
"ios" : {
@@ -63,7 +77,20 @@
},
/* SDK閰嶇疆 */
"sdkConfigs" : {
- "ad" : {}
+ "ad" : {},
+ "push" : {
+ "unipush" : {
+ "icons" : {
+ "small" : {
+ "ldpi" : "static/logo_icon.png",
+ "mdpi" : "static/logo_icon.png",
+ "hdpi" : "static/logo_icon.png",
+ "xhdpi" : "static/logo_icon.png",
+ "xxhdpi" : "static/logo_icon.png"
+ }
+ }
+ }
+ }
},
"icons" : {
"android" : {
@@ -132,7 +159,7 @@
}
}
}
- }
+ }
},
/* 蹇簲鐢ㄧ壒鏈夌浉鍏� */
"quickapp" : {},
@@ -160,3 +187,6 @@
"locale" : "zh-Hans",
"fallbackLocale" : "zh-Hans"
}
+//docs.getui.com/getui/question/sdk/ -->
+/* ios鎵撳寘閰嶇疆 *//* SDK閰嶇疆 */
+
diff --git a/pages/index/login.vue b/pages/index/login.vue
index e5484ab..5065984 100644
--- a/pages/index/login.vue
+++ b/pages/index/login.vue
@@ -81,8 +81,11 @@
import {
CommonUtils
} from "../../utils/common";
- import { getLanguagePackJson } from "../../utils/i18n";
+ import {
+ getLanguagePackJson
+ } from "../../utils/i18n";
import WebSocketServices from "@/utils/WebSocketServices";
+ import getuiUtils from "../../utils/getuiUtils";
export default {
components: {
hFormAlert
@@ -107,7 +110,7 @@
"鏉窞鍑礉濂堢壒澶栫綉": 'http://erp.hzcabinet.cn:9090/API/',
"缈佹稕娑涙湰鍦版祴璇�": 'http://localhost:81/API/',
"闄堥晲鍝叉湰鍦版祴璇�": 'http://192.168.0.121:81/API/',
- "闄堥晲鍝叉湰鍦版祴璇�2": 'http://192.168.255.35:81/API/',
+ "闄堥晲鍝叉湰鍦版祴璇�2": 'http://192.168.0.102:81/API/',
"寮犵憺骞挎湰鍦版祴璇�": 'http://localhost:8082/API/',
"浣欐�濇澃鏈湴娴嬭瘯": 'http://localhost:8082/LuBaoAPI/',
// 灏忓崼鍐呭缃�
@@ -119,12 +122,12 @@
// 閿﹂殕
"閿﹂殕-鏅鸿兘瀹跺眳": "http://192.168.1.11/API/",
"閿﹂殕-鏅鸿兘瀹跺眳-澶栫綉": "http://61.174.29.234:8880/API/",
- // 鍗庤垷鍖呰
- "瀹佹尝鍗庤垷鍖呰1": "http://192.168.110.222:8082/API_NW/",
+ // 鍗庤垷鍖呰
+ "瀹佹尝鍗庤垷鍖呰1": "http://192.168.110.222:8082/API_NW/",
"瀹佹尝鍗庤垷鍖呰2": "http://192.168.88.167:8082/API_NW/",
- "瀹佹尝鍗庤垷鍖呰": "http://61.164.64.222:8082/API_WW/",
+ "瀹佹尝鍗庤垷鍖呰": "http://61.164.64.222:8082/API_WW/",
},
- serverUrlName:uni.getStorageSync('serverUrlName') || '娴欐睙鏅轰簯杩堟��',
+ serverUrlName: uni.getStorageSync('serverUrlName') || '娴欐睙鏅轰簯杩堟��',
arrayOrganization: [],
Organization: '',
@@ -197,7 +200,7 @@
let url = this.serverUrlandName[this.serverUrlName];
if (url != undefined) {
uni.setStorageSync('serverUrl', url)
- uni.setStorageSync('serverUrlName', this.serverUrlName)
+ uni.setStorageSync('serverUrlName', this.serverUrlName)
this.serverUrl = url
this.changeApi = false
this.getOrganization()
@@ -322,21 +325,24 @@
uni.setStorageSync('login', "login");
uni.setStorageSync('Organization', this.Organization);
uni.setStorageSync('OrganizationID', this.HOrgName);
- //瀛樺偍閮ㄩ棬 鑱屽憳 浠撳簱 绛変俊鎭�
- uni.setStorageSync('HDeptID', res.data.data[0].HDeptID); //閮ㄩ棬
- uni.setStorageSync('HDeptName', res.data.data[0].HDeptName);
- uni.setStorageSync('HEmpID', res.data.data[0].HEmpID); //鑱屽憳
- uni.setStorageSync('HEmpName', res.data.data[0].HEmpName);
- uni.setStorageSync('HSCWHID', res.data.data[0].HSCWHID); //璋冨叆浠撳簱
- uni.setStorageSync('HSCWHName', res.data.data[0].HSCWHName);
- uni.setStorageSync('HWhID', res.data.data[0].HWhID);//瀵瑰簲浠撳簱
- uni.setStorageSync('HWhName', res.data.data[0].HWhName);
- uni.setStorageSync('HWorkCenterID', res.data.data[0].HWorkCenterID);//宸ヤ綔涓績
- uni.setStorageSync('HWorkCenterName', res.data.data[0].HWorkCenterName);
- uni.setStorageSync('HSecManagerID', res.data.data[0].HSecManagerID); //瀵瑰簲楠屾敹
- uni.setStorageSync('HSecManagerName', res.data.data[0].HSecManagerName);
+ //瀛樺偍閮ㄩ棬 鑱屽憳 浠撳簱 绛変俊鎭�
+ uni.setStorageSync('HDeptID', res.data.data[0].HDeptID); //閮ㄩ棬
+ uni.setStorageSync('HDeptName', res.data.data[0].HDeptName);
+ uni.setStorageSync('HEmpID', res.data.data[0].HEmpID); //鑱屽憳
+ uni.setStorageSync('HEmpName', res.data.data[0].HEmpName);
+ uni.setStorageSync('HSCWHID', res.data.data[0].HSCWHID); //璋冨叆浠撳簱
+ uni.setStorageSync('HSCWHName', res.data.data[0].HSCWHName);
+ uni.setStorageSync('HWhID', res.data.data[0].HWhID); //瀵瑰簲浠撳簱
+ uni.setStorageSync('HWhName', res.data.data[0].HWhName);
+ uni.setStorageSync('HWorkCenterID', res.data.data[0].HWorkCenterID); //宸ヤ綔涓績
+ uni.setStorageSync('HWorkCenterName', res.data.data[0].HWorkCenterName);
+ uni.setStorageSync('HSecManagerID', res.data.data[0].HSecManagerID); //瀵瑰簲楠屾敹
+ uni.setStorageSync('HSecManagerName', res.data.data[0].HSecManagerName);
this.CommonUtils.setServerUrl(this.serverUrl)
// this.WebSocketServices.createConnect(res.data.data[0].Czybm,res.data.data[0].Czymc);
+ // getuiUtils.getClientID()
+ var clientInfo = plus.push.getClientInfo();
+ console.log('clientInfo: ', clientInfo);
uni.reLaunch({
url: '/pages/index/index'
})
diff --git a/utils/WebSocketServices.js b/utils/WebSocketServices.js
index 7115a50..c1a0526 100644
--- a/utils/WebSocketServices.js
+++ b/utils/WebSocketServices.js
@@ -11,7 +11,7 @@
this.wsUrl = CommonUtils.httpFormatWs(); // WebSocket 鍩虹鍦板潃
// 瓒呮椂鏍¢獙閰嶇疆
- this.businessMessageInterval = 5 * 60 * 1000;
+ this.businessMessageInterval = 5 * 60 * 1000;
this.noMessageTimeout = this.businessMessageInterval + 2 * 60 * 1000;
this.noMessageTimer = null; // 鏃犳秷鎭秴鏃跺畾鏃跺櫒
@@ -96,10 +96,22 @@
this.resetNoMessageTimer();
// 澶勭悊涓氬姟娑堟伅
- if (message.Type === "Message") {
+ if (message.Type === "MessageUnRead") { // 鏈娑堟伅
+ let payload = {
+ pagePath: "/pages/ZLGL/OA_WorkLink/OA_WorkLinkBillList",
+ itemId: 0
+ }
const content = JSON.parse(message.Content);
- this.showTaskTip(`鎮ㄦ湁${content.length}鏉℃秷鎭渶瑕佸鐞�!`);
+ this.showTaskTip(`鎮ㄦ湁${content.length}鏉℃秷鎭渶瑕佸鐞�!`, payload);
// this.emit("message", content); // 鏀寔澶栭儴鐩戝惉
+ } else if (message.Type === "Message") {
+ const content = JSON.parse(message.Content)
+ let payload = {
+ pagePath: "/pages/ZLGL/OA_WorkLink/OA_WorkLinkBillList",
+ itemId: 0
+ }
+ this.showTaskTip(content[0]["鍐呭"], payload, content[0]["涓婚"]);
+
}
} catch (error) {
console.error("[WebSocket] 娑堟伅瑙f瀽澶辫触", error, res.data);
@@ -213,16 +225,19 @@
}
- showTaskTip(Content) {
+ showTaskTip(Content, payloads, Title = "閲嶈閫氱煡") {
// #ifdef APP-PLUS || APP
let content = Content;
let options = {
- title: "閲嶈閫氱煡",
+ title: Title,
cover: true, // 鏄惁瑕嗙洊涓婁竴娆$殑閫氱煡
- when: new Date() // 閫氱煡鏄剧ず鏃堕棿
+ when: new Date(), // 閫氱煡鏄剧ず鏃堕棿
+ icon: "../static/logo.png",
+ largeIcon: "../static/logo.png"
};
// TODO 璺宠浆鍒版寚瀹氶〉
- let payload = JSON.stringify({});
+ let payload = JSON.stringify(payloads);
+ console.log('payload: ', payload);
plus.push.createMessage(content, payload, options);
// #endif
diff --git a/utils/getuiUtils.js b/utils/getuiUtils.js
new file mode 100644
index 0000000..5268ada
--- /dev/null
+++ b/utils/getuiUtils.js
@@ -0,0 +1,16 @@
+class getuiInstance {
+ constructor() {
+ this.cid = ""
+ }
+
+ getClientID() {
+ // #ifdef APP-PLUS
+ plus.push.getClientInfoAsync((info) => {
+ this.cid = info["clientid"]
+ console.log('cid: ', this.cid);
+ });
+ // #endif
+ }
+}
+
+export default new getuiInstance()
\ No newline at end of file
--
Gitblit v1.9.1