From 5a965f2cdf57b9ac4fbba238c77a9bbf94ddc397 Mon Sep 17 00:00:00 2001
From: 13404089107 <puwei@sinata.cn>
Date: 星期四, 30 四月 2026 13:47:43 +0800
Subject: [PATCH] fix
---
traditionalApp/utils/request.js | 2
traditionalApp/pages/login/login.vue | 2
traditionalApp/utils/push.js | 281 ++++++++++++++++
traditionalApp/pages/settings/utils.js | 2
traditionalApp/App.vue | 25 -
traditionalApp/manifest.json | 675 +++++++++++++++++++--------------------
6 files changed, 625 insertions(+), 362 deletions(-)
diff --git a/traditionalApp/App.vue b/traditionalApp/App.vue
index 2fd1ad1..b53ec9b 100644
--- a/traditionalApp/App.vue
+++ b/traditionalApp/App.vue
@@ -7,6 +7,7 @@
extractBindTicket,
extractInviteCode
} from '@/utils/utils.js'
+ import { initJPushLifecycle } from '@/utils/push.js'
let lastHandledBindTicket = ''
@@ -15,27 +16,7 @@
*/
onLaunch(() => {
// #ifdef APP-PLUS
- const jpushModule = uni.requireNativePlugin("JG-JPush")
-
- jpushModule.setLoggerEnable(true);
- jpushModule.initJPushService();
- // 监听是否连接成功
- jpushModule.addConnectEventListener(result => {
- console.log('qweqweqwe', result);
- let connectEnable = result.connectEnable;
- console.log(connectEnable, '极光连接成功');
- if (uni.getStorageSync('token')) {
-
- }
- });
-
- jpushModule.addNotificationListener(result => {
- console.log('qeqwewqe', result);
- // plus.runtime.setBadgeNumber('111111');
- // jpushModule.setBadge('2222222222222')
-
-
- });
+ initJPushLifecycle()
// #endif
})
@@ -82,4 +63,4 @@
/*每个页面公共css */
@import "@/uni_modules/uview-pro/index.scss";
@import "@/static/style/index.scss";
-</style>
\ No newline at end of file
+</style>
diff --git a/traditionalApp/manifest.json b/traditionalApp/manifest.json
index 4995e98..81fab2c 100644
--- a/traditionalApp/manifest.json
+++ b/traditionalApp/manifest.json
@@ -1,342 +1,337 @@
{
- "sassImplementationName": "node-sass",
- "name": "海诊康道",
- "appid": "__UNI__1A90541",
- "description": "",
- "versionName": "1.0.3",
- "versionCode": 103,
- "transformPx": false,
- /* 5+App特有相关 */
- "app-plus": {
- "usingComponents": true,
- "nvueStyleCompiler": "uni-app",
- "compilerVersion": 3,
- "splashscreen": {
- "alwaysShowBeforeRender": true,
- "waiting": true,
- "autoclose": true,
- "delay": 0
- },
- /* 模块配置 */
- "modules": {
- "Barcode": {},
- "VideoPlayer": {},
- "Share": {},
- "OAuth": {},
- "Payment": {},
- "Camera": {}
- },
- /* 应用发布信息 */
- "distribute": {
- /* android打包配置 */
- "android": {
- "permissions": [
- "<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>",
- "<uses-permission android:name=\"android.permission.MOUNT_UNMOUNT_FILESYSTEMS\"/>",
- "<uses-permission android:name=\"android.permission.VIBRATE\"/>",
- "<uses-permission android:name=\"android.permission.READ_LOGS\"/>",
- "<uses-permission android:name=\"android.permission.ACCESS_WIFI_STATE\"/>",
- "<uses-feature android:name=\"android.hardware.camera.autofocus\"/>",
- "<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\"/>",
- "<uses-permission android:name=\"android.permission.CAMERA\"/>",
- "<uses-permission android:name=\"android.permission.GET_ACCOUNTS\"/>",
- "<uses-permission android:name=\"android.permission.READ_PHONE_STATE\"/>",
- "<uses-permission android:name=\"android.permission.CHANGE_WIFI_STATE\"/>",
- "<uses-permission android:name=\"android.permission.WAKE_LOCK\"/>",
- "<uses-permission android:name=\"android.permission.FLASHLIGHT\"/>",
- "<uses-feature android:name=\"android.hardware.camera\"/>",
- "<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>"
- ],
- "minSdkVersion": 28,
- "targetSdkVersion": 30
- },
- /* ios打包配置 */
- "ios": {
- "dSYMs": false,
- "privacyDescription": {
- "NSCameraUsageDescription": "需要使用相机拍摄照片 / 视频,用于扫码自动填充邀请码、拍摄照片作为头像",
- "NSPhotoLibraryUsageDescription": "需要访问手机相册,用于选择图片 / 视频上传、更换个人头像、选择邀请二维码",
- "NSPhotoLibraryAddUsageDescription": "需要访问手机相册,用于选择图片 / 视频上传、更换个人头像、选择邀请二维码"
- },
- "capabilities": {
- "entitlements": {
- "com.apple.developer.associated-domains": [
- "applinks:static-mp-dd6d96de-bdf2-4284-a975-638af4cc8ec8.next.bspapp.com"
- ]
- }
- },
- "idfa": false
- },
- /* SDK配置 */
- "sdkConfigs": {
- "push": {},
- "share": {
- "weixin": {
- "appid": "wx074c1f0cf5a0ecf4",
- "UniversalLinks": "https://static-mp-dd6d96de-bdf2-4284-a975-638af4cc8ec8.next.bspapp.com/uni-universallinks/__UNI__1A90541/"
- }
- },
- "oauth": {
- "weixin": {
- "appid": "wx074c1f0cf5a0ecf4",
- "UniversalLinks": "https://static-mp-dd6d96de-bdf2-4284-a975-638af4cc8ec8.next.bspapp.com/uni-universallinks/__UNI__1A90541/"
- },
- "apple": {}
- },
- "payment": {
- "weixin": {
- "__platform__": ["ios", "android"],
- "appid": "wx074c1f0cf5a0ecf4",
- "UniversalLinks": "https://static-mp-dd6d96de-bdf2-4284-a975-638af4cc8ec8.next.bspapp.com/uni-universallinks/__UNI__1A90541/"
- }
- }
- },
- "icons": {
- "android": {
- "hdpi": "unpackage/res/icons/72x72.png",
- "xhdpi": "unpackage/res/icons/96x96.png",
- "xxhdpi": "unpackage/res/icons/144x144.png",
- "xxxhdpi": "unpackage/res/icons/192x192.png"
- },
- "ios": {
- "appstore": "unpackage/res/icons/1024x1024.png",
- "ipad": {
- "app": "unpackage/res/icons/76x76.png",
- "app@2x": "unpackage/res/icons/152x152.png",
- "notification": "unpackage/res/icons/20x20.png",
- "notification@2x": "unpackage/res/icons/40x40.png",
- "proapp@2x": "unpackage/res/icons/167x167.png",
- "settings": "unpackage/res/icons/29x29.png",
- "settings@2x": "unpackage/res/icons/58x58.png",
- "spotlight": "unpackage/res/icons/40x40.png",
- "spotlight@2x": "unpackage/res/icons/80x80.png"
- },
- "iphone": {
- "app@2x": "unpackage/res/icons/120x120.png",
- "app@3x": "unpackage/res/icons/180x180.png",
- "notification@2x": "unpackage/res/icons/40x40.png",
- "notification@3x": "unpackage/res/icons/60x60.png",
- "settings@2x": "unpackage/res/icons/58x58.png",
- "settings@3x": "unpackage/res/icons/87x87.png",
- "spotlight@2x": "unpackage/res/icons/80x80.png",
- "spotlight@3x": "unpackage/res/icons/120x120.png"
- }
- }
- },
- "splashscreen": {
- "androidStyle": "common",
- "useOriginalMsgbox": true
- }
- },
- "nativePlugins": {
- "JG-JCore": {
- "JPUSH_APPKEY_ANDROID": "b5aed7d076638a0d835786bd",
- "JPUSH_APPKEY_IOS": "b5aed7d076638a0d835786bd",
- "JPUSH_CHANNEL_ANDROID": "default",
- "JPUSH_CHANNEL_IOS": "default",
- "__plugin_info__": {
- "name": "极光推送 JCore 官方 SDK",
- "description": "极光推送 JCore 官方 SDK HBuilder 插件版本",
- "platforms": "Android,iOS",
- "url": "https://ext.dcloud.net.cn/plugin?id=4028",
- "android_package_name": "com.HaiZhenKangDao.hzt",
- "ios_bundle_id": "com.HaiZhenKangDao.hzt",
- "isCloud": true,
- "bought": 1,
- "pid": "4028",
- "parameters": {
- "JPUSH_APPKEY_ANDROID": {
- "des": "[Android]极光portal配置应用信息时分配的AppKey",
- "key": "JPUSH_APPKEY",
- "value": ""
- },
- "JPUSH_APPKEY_IOS": {
- "des": "[iOS]极光portal配置应用信息时分配的AppKey",
- "key": "JCore:APP_KEY",
- "value": ""
- },
- "JPUSH_CHANNEL_ANDROID": {
- "des": "[Android]用于统计分发渠道,不需要可填默认值developer-default",
- "key": "JPUSH_CHANNEL",
- "value": ""
- },
- "JPUSH_CHANNEL_IOS": {
- "des": "[iOS]用于统计分发渠道,不需要可填默认值developer-default",
- "key": "JCore:CHANNEL",
- "value": ""
- }
- }
- }
- },
- "JG-JPush": {
- "JPUSH_ADVERTISINGID_IOS": "",
- "JPUSH_DEFAULTINITJPUSH_IOS": "",
- "JPUSH_GOOGLE_API_KEY": "",
- "JPUSH_GOOGLE_APP_ID": "",
- "JPUSH_GOOGLE_PROJECT_ID": "",
- "JPUSH_GOOGLE_PROJECT_NUMBER": "",
- "JPUSH_GOOGLE_STORAGE_BUCKET": "",
- "JPUSH_HONOR_APPID": "",
- "JPUSH_HUAWEI_APPID": "",
- "JPUSH_ISPRODUCTION_IOS": "",
- "JPUSH_MEIZU_APPID": "",
- "JPUSH_MEIZU_APPKEY": "",
- "JPUSH_OPPO_APPID": "",
- "JPUSH_OPPO_APPKEY": "",
- "JPUSH_OPPO_APPSECRET": "",
- "JPUSH_VIVO_APPID": "",
- "JPUSH_VIVO_APPKEY": "",
- "JPUSH_XIAOMI_APPID": "",
- "JPUSH_XIAOMI_APPKEY": "",
- "__plugin_info__": {
- "name": "极光推送 JPush 官方 SDK",
- "description": "极光推送JPush官方SDK HBuilder插件版本",
- "platforms": "Android,iOS",
- "url": "https://ext.dcloud.net.cn/plugin?id=4035",
- "android_package_name": "com.HaiZhenKangDao.hzt",
- "ios_bundle_id": "com.HaiZhenKangDao.hzt",
- "isCloud": true,
- "bought": 1,
- "pid": "4035",
- "parameters": {
- "JPUSH_ADVERTISINGID_IOS": {
- "des": "[iOS]广告标识符(IDFA)如果不需要使用IDFA,可不填",
- "key": "JPush:ADVERTISINGID",
- "value": ""
- },
- "JPUSH_DEFAULTINITJPUSH_IOS": {
- "des": "[iOS]是否默认初始化,是填true,不是填false或者不填",
- "key": "JPush:DEFAULTINITJPUSH",
- "value": ""
- },
- "JPUSH_GOOGLE_API_KEY": {
- "des": "厂商google api_key,示例:g-12346578",
- "key": "google_api_key",
- "value": ""
- },
- "JPUSH_GOOGLE_APP_ID": {
- "des": "厂商google mobilesdk_app_id,示例:g-12346578",
- "key": "google_app_id",
- "value": ""
- },
- "JPUSH_GOOGLE_PROJECT_ID": {
- "des": "厂商google project_id ,示例:g-12346578",
- "key": "project_id",
- "value": ""
- },
- "JPUSH_GOOGLE_PROJECT_NUMBER": {
- "des": "厂商google project_number,示例:g-12346578",
- "key": "gcm_defaultSenderId",
- "value": ""
- },
- "JPUSH_GOOGLE_STORAGE_BUCKET": {
- "des": "厂商google storage_bucket,示例:g-12346578",
- "key": "google_storage_bucket",
- "value": ""
- },
- "JPUSH_HONOR_APPID": {
- "des": "厂商HONOR-appId,示例:12346578",
- "key": "com.hihonor.push.app_id",
- "value": ""
- },
- "JPUSH_HUAWEI_APPID": {
- "des": "厂商HUAWEI-appId,示例:appid=12346578",
- "key": "com.huawei.hms.client.appid",
- "value": ""
- },
- "JPUSH_ISPRODUCTION_IOS": {
- "des": "[iOS]是否是生产环境,是填true,不是填false或者不填",
- "key": "JPush:ISPRODUCTION",
- "value": ""
- },
- "JPUSH_MEIZU_APPID": {
- "des": "厂商MEIZU-appId,示例:MZ-12345678",
- "key": "MEIZU_APPID",
- "value": ""
- },
- "JPUSH_MEIZU_APPKEY": {
- "des": "厂商MEIZU-appKey,示例:MZ-12345678",
- "key": "MEIZU_APPKEY",
- "value": ""
- },
- "JPUSH_OPPO_APPID": {
- "des": "厂商OPPO-appId,示例:OP-12345678",
- "key": "OPPO_APPID",
- "value": ""
- },
- "JPUSH_OPPO_APPKEY": {
- "des": "厂商OPPO-appkey,示例:OP-12345678",
- "key": "OPPO_APPKEY",
- "value": ""
- },
- "JPUSH_OPPO_APPSECRET": {
- "des": "厂商OPPO-appSecret,示例:OP-12345678",
- "key": "OPPO_APPSECRET",
- "value": ""
- },
- "JPUSH_VIVO_APPID": {
- "des": "厂商VIVO-appId,示例:12345678",
- "key": "com.vivo.push.app_id",
- "value": ""
- },
- "JPUSH_VIVO_APPKEY": {
- "des": "厂商VIVO-appkey,示例:12345678",
- "key": "com.vivo.push.api_key",
- "value": ""
- },
- "JPUSH_XIAOMI_APPID": {
- "des": "厂商XIAOMI-appId,示例:MI-12345678",
- "key": "XIAOMI_APPID",
- "value": ""
- },
- "JPUSH_XIAOMI_APPKEY": {
- "des": "厂商XIAOMI-appKey,示例:MI-12345678",
- "key": "XIAOMI_APPKEY",
- "value": ""
- }
- }
- }
- }
- }
- },
- /* 快应用特有相关 */
- "quickapp": {},
- /* 小程序特有相关 */
- "mp-weixin": {
- "appid": "wxa17e8d1331e50934",
- "setting": {
- "urlCheck": false,
- "minified": true
- },
- "usingComponents": true
- },
- "mp-alipay": {
- "usingComponents": true
- },
- "mp-baidu": {
- "usingComponents": true
- },
- "mp-toutiao": {
- "usingComponents": true
- },
- "uniStatistics": {
- "enable": false
- },
- "vueVersion": "3",
- "permission": {
- "scope.userLocation": {
- "desc": "下载文件"
- }
- },
- "h5": {
- "unipush": {
- "enable": false
- }
- },
- "_spaceID": "mp-dd6d96de-bdf2-4284-a975-638af4cc8ec8",
- "app-harmony": {
- "distribute": {
- "modules": {}
- }
- }
+ "sassImplementationName" : "node-sass",
+ "name" : "海诊康道",
+ "appid" : "__UNI__1A90541",
+ "description" : "",
+ "versionName" : "1.0.5",
+ "versionCode" : 105,
+ "transformPx" : false,
+ /* 5+App特有相关 */
+ "app-plus" : {
+ "usingComponents" : true,
+ "nvueStyleCompiler" : "uni-app",
+ "compilerVersion" : 3,
+ "splashscreen" : {
+ "alwaysShowBeforeRender" : true,
+ "waiting" : true,
+ "autoclose" : true,
+ "delay" : 0
+ },
+ /* 模块配置 */
+ "modules" : {
+ "Barcode" : {},
+ "VideoPlayer" : {},
+ "Share" : {},
+ "OAuth" : {},
+ "Payment" : {},
+ "Camera" : {}
+ },
+ /* 应用发布信息 */
+ "distribute" : {
+ /* android打包配置 */
+ "android" : {
+ "permissions" : [
+ "<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>",
+ "<uses-permission android:name=\"android.permission.MOUNT_UNMOUNT_FILESYSTEMS\"/>",
+ "<uses-permission android:name=\"android.permission.VIBRATE\"/>",
+ "<uses-permission android:name=\"android.permission.READ_LOGS\"/>",
+ "<uses-permission android:name=\"android.permission.ACCESS_WIFI_STATE\"/>",
+ "<uses-feature android:name=\"android.hardware.camera.autofocus\"/>",
+ "<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\"/>",
+ "<uses-permission android:name=\"android.permission.CAMERA\"/>",
+ "<uses-permission android:name=\"android.permission.GET_ACCOUNTS\"/>",
+ "<uses-permission android:name=\"android.permission.READ_PHONE_STATE\"/>",
+ "<uses-permission android:name=\"android.permission.CHANGE_WIFI_STATE\"/>",
+ "<uses-permission android:name=\"android.permission.WAKE_LOCK\"/>",
+ "<uses-permission android:name=\"android.permission.FLASHLIGHT\"/>",
+ "<uses-feature android:name=\"android.hardware.camera\"/>",
+ "<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>"
+ ],
+ "minSdkVersion" : 28,
+ "targetSdkVersion" : 30
+ },
+ /* ios打包配置 */
+ "ios" : {
+ "dSYMs" : false,
+ "capabilities" : {
+ "entitlements" : {
+ "com.apple.developer.associated-domains" : [
+ "applinks:static-mp-dd6d96de-bdf2-4284-a975-638af4cc8ec8.next.bspapp.com"
+ ]
+ }
+ },
+ "idfa" : false
+ },
+ /* SDK配置 */
+ "sdkConfigs" : {
+ "push" : {},
+ "share" : {
+ "weixin" : {
+ "appid" : "wx074c1f0cf5a0ecf4",
+ "UniversalLinks" : "https://static-mp-dd6d96de-bdf2-4284-a975-638af4cc8ec8.next.bspapp.com/uni-universallinks/__UNI__1A90541/"
+ }
+ },
+ "oauth" : {
+ "weixin" : {
+ "appid" : "wx074c1f0cf5a0ecf4",
+ "UniversalLinks" : "https://static-mp-dd6d96de-bdf2-4284-a975-638af4cc8ec8.next.bspapp.com/uni-universallinks/__UNI__1A90541/"
+ },
+ "apple" : {}
+ },
+ "payment" : {
+ "weixin" : {
+ "__platform__" : [ "ios", "android" ],
+ "appid" : "wx074c1f0cf5a0ecf4",
+ "UniversalLinks" : "https://static-mp-dd6d96de-bdf2-4284-a975-638af4cc8ec8.next.bspapp.com/uni-universallinks/__UNI__1A90541/"
+ }
+ }
+ },
+ "icons" : {
+ "android" : {
+ "hdpi" : "unpackage/res/icons/72x72.png",
+ "xhdpi" : "unpackage/res/icons/96x96.png",
+ "xxhdpi" : "unpackage/res/icons/144x144.png",
+ "xxxhdpi" : "unpackage/res/icons/192x192.png"
+ },
+ "ios" : {
+ "appstore" : "unpackage/res/icons/1024x1024.png",
+ "ipad" : {
+ "app" : "unpackage/res/icons/76x76.png",
+ "app@2x" : "unpackage/res/icons/152x152.png",
+ "notification" : "unpackage/res/icons/20x20.png",
+ "notification@2x" : "unpackage/res/icons/40x40.png",
+ "proapp@2x" : "unpackage/res/icons/167x167.png",
+ "settings" : "unpackage/res/icons/29x29.png",
+ "settings@2x" : "unpackage/res/icons/58x58.png",
+ "spotlight" : "unpackage/res/icons/40x40.png",
+ "spotlight@2x" : "unpackage/res/icons/80x80.png"
+ },
+ "iphone" : {
+ "app@2x" : "unpackage/res/icons/120x120.png",
+ "app@3x" : "unpackage/res/icons/180x180.png",
+ "notification@2x" : "unpackage/res/icons/40x40.png",
+ "notification@3x" : "unpackage/res/icons/60x60.png",
+ "settings@2x" : "unpackage/res/icons/58x58.png",
+ "settings@3x" : "unpackage/res/icons/87x87.png",
+ "spotlight@2x" : "unpackage/res/icons/80x80.png",
+ "spotlight@3x" : "unpackage/res/icons/120x120.png"
+ }
+ }
+ },
+ "splashscreen" : {
+ "androidStyle" : "common",
+ "useOriginalMsgbox" : true
+ }
+ },
+ "nativePlugins" : {
+ "JG-JCore" : {
+ "JPUSH_APPKEY_ANDROID" : "b5aed7d076638a0d835786bd",
+ "JPUSH_APPKEY_IOS" : "b5aed7d076638a0d835786bd",
+ "JPUSH_CHANNEL_ANDROID" : "default",
+ "JPUSH_CHANNEL_IOS" : "default",
+ "__plugin_info__" : {
+ "name" : "极光推送 JCore 官方 SDK",
+ "description" : "极光推送 JCore 官方 SDK HBuilder 插件版本",
+ "platforms" : "Android,iOS",
+ "url" : "https://ext.dcloud.net.cn/plugin?id=4028",
+ "android_package_name" : "com.HaiZhenKangDao.hzt",
+ "ios_bundle_id" : "com.HaiZhenKangDao.hzt",
+ "isCloud" : true,
+ "bought" : 1,
+ "pid" : "4028",
+ "parameters" : {
+ "JPUSH_APPKEY_ANDROID" : {
+ "des" : "[Android]极光portal配置应用信息时分配的AppKey",
+ "key" : "JPUSH_APPKEY",
+ "value" : ""
+ },
+ "JPUSH_APPKEY_IOS" : {
+ "des" : "[iOS]极光portal配置应用信息时分配的AppKey",
+ "key" : "JCore:APP_KEY",
+ "value" : ""
+ },
+ "JPUSH_CHANNEL_ANDROID" : {
+ "des" : "[Android]用于统计分发渠道,不需要可填默认值developer-default",
+ "key" : "JPUSH_CHANNEL",
+ "value" : ""
+ },
+ "JPUSH_CHANNEL_IOS" : {
+ "des" : "[iOS]用于统计分发渠道,不需要可填默认值developer-default",
+ "key" : "JCore:CHANNEL",
+ "value" : ""
+ }
+ }
+ }
+ },
+ "JG-JPush" : {
+ "JPUSH_ADVERTISINGID_IOS" : "",
+ "JPUSH_DEFAULTINITJPUSH_IOS" : "",
+ "JPUSH_GOOGLE_API_KEY" : "",
+ "JPUSH_GOOGLE_APP_ID" : "",
+ "JPUSH_GOOGLE_PROJECT_ID" : "",
+ "JPUSH_GOOGLE_PROJECT_NUMBER" : "",
+ "JPUSH_GOOGLE_STORAGE_BUCKET" : "",
+ "JPUSH_HONOR_APPID" : "",
+ "JPUSH_HUAWEI_APPID" : "",
+ "JPUSH_ISPRODUCTION_IOS" : "",
+ "JPUSH_MEIZU_APPID" : "",
+ "JPUSH_MEIZU_APPKEY" : "",
+ "JPUSH_OPPO_APPID" : "",
+ "JPUSH_OPPO_APPKEY" : "",
+ "JPUSH_OPPO_APPSECRET" : "",
+ "JPUSH_VIVO_APPID" : "",
+ "JPUSH_VIVO_APPKEY" : "",
+ "JPUSH_XIAOMI_APPID" : "",
+ "JPUSH_XIAOMI_APPKEY" : "",
+ "__plugin_info__" : {
+ "name" : "极光推送 JPush 官方 SDK",
+ "description" : "极光推送JPush官方SDK HBuilder插件版本",
+ "platforms" : "Android,iOS",
+ "url" : "https://ext.dcloud.net.cn/plugin?id=4035",
+ "android_package_name" : "com.HaiZhenKangDao.hzt",
+ "ios_bundle_id" : "com.HaiZhenKangDao.hzt",
+ "isCloud" : true,
+ "bought" : 1,
+ "pid" : "4035",
+ "parameters" : {
+ "JPUSH_ADVERTISINGID_IOS" : {
+ "des" : "[iOS]广告标识符(IDFA)如果不需要使用IDFA,可不填",
+ "key" : "JPush:ADVERTISINGID",
+ "value" : ""
+ },
+ "JPUSH_DEFAULTINITJPUSH_IOS" : {
+ "des" : "[iOS]是否默认初始化,是填true,不是填false或者不填",
+ "key" : "JPush:DEFAULTINITJPUSH",
+ "value" : ""
+ },
+ "JPUSH_GOOGLE_API_KEY" : {
+ "des" : "厂商google api_key,示例:g-12346578",
+ "key" : "google_api_key",
+ "value" : ""
+ },
+ "JPUSH_GOOGLE_APP_ID" : {
+ "des" : "厂商google mobilesdk_app_id,示例:g-12346578",
+ "key" : "google_app_id",
+ "value" : ""
+ },
+ "JPUSH_GOOGLE_PROJECT_ID" : {
+ "des" : "厂商google project_id ,示例:g-12346578",
+ "key" : "project_id",
+ "value" : ""
+ },
+ "JPUSH_GOOGLE_PROJECT_NUMBER" : {
+ "des" : "厂商google project_number,示例:g-12346578",
+ "key" : "gcm_defaultSenderId",
+ "value" : ""
+ },
+ "JPUSH_GOOGLE_STORAGE_BUCKET" : {
+ "des" : "厂商google storage_bucket,示例:g-12346578",
+ "key" : "google_storage_bucket",
+ "value" : ""
+ },
+ "JPUSH_HONOR_APPID" : {
+ "des" : "厂商HONOR-appId,示例:12346578",
+ "key" : "com.hihonor.push.app_id",
+ "value" : ""
+ },
+ "JPUSH_HUAWEI_APPID" : {
+ "des" : "厂商HUAWEI-appId,示例:appid=12346578",
+ "key" : "com.huawei.hms.client.appid",
+ "value" : ""
+ },
+ "JPUSH_ISPRODUCTION_IOS" : {
+ "des" : "[iOS]是否是生产环境,是填true,不是填false或者不填",
+ "key" : "JPush:ISPRODUCTION",
+ "value" : ""
+ },
+ "JPUSH_MEIZU_APPID" : {
+ "des" : "厂商MEIZU-appId,示例:MZ-12345678",
+ "key" : "MEIZU_APPID",
+ "value" : ""
+ },
+ "JPUSH_MEIZU_APPKEY" : {
+ "des" : "厂商MEIZU-appKey,示例:MZ-12345678",
+ "key" : "MEIZU_APPKEY",
+ "value" : ""
+ },
+ "JPUSH_OPPO_APPID" : {
+ "des" : "厂商OPPO-appId,示例:OP-12345678",
+ "key" : "OPPO_APPID",
+ "value" : ""
+ },
+ "JPUSH_OPPO_APPKEY" : {
+ "des" : "厂商OPPO-appkey,示例:OP-12345678",
+ "key" : "OPPO_APPKEY",
+ "value" : ""
+ },
+ "JPUSH_OPPO_APPSECRET" : {
+ "des" : "厂商OPPO-appSecret,示例:OP-12345678",
+ "key" : "OPPO_APPSECRET",
+ "value" : ""
+ },
+ "JPUSH_VIVO_APPID" : {
+ "des" : "厂商VIVO-appId,示例:12345678",
+ "key" : "com.vivo.push.app_id",
+ "value" : ""
+ },
+ "JPUSH_VIVO_APPKEY" : {
+ "des" : "厂商VIVO-appkey,示例:12345678",
+ "key" : "com.vivo.push.api_key",
+ "value" : ""
+ },
+ "JPUSH_XIAOMI_APPID" : {
+ "des" : "厂商XIAOMI-appId,示例:MI-12345678",
+ "key" : "XIAOMI_APPID",
+ "value" : ""
+ },
+ "JPUSH_XIAOMI_APPKEY" : {
+ "des" : "厂商XIAOMI-appKey,示例:MI-12345678",
+ "key" : "XIAOMI_APPKEY",
+ "value" : ""
+ }
+ }
+ }
+ }
+ }
+ },
+ /* 快应用特有相关 */
+ "quickapp" : {},
+ /* 小程序特有相关 */
+ "mp-weixin" : {
+ "appid" : "wxa17e8d1331e50934",
+ "setting" : {
+ "urlCheck" : false,
+ "minified" : true
+ },
+ "usingComponents" : true
+ },
+ "mp-alipay" : {
+ "usingComponents" : true
+ },
+ "mp-baidu" : {
+ "usingComponents" : true
+ },
+ "mp-toutiao" : {
+ "usingComponents" : true
+ },
+ "uniStatistics" : {
+ "enable" : false
+ },
+ "vueVersion" : "3",
+ "permission" : {
+ "scope.userLocation" : {
+ "desc" : "下载文件"
+ }
+ },
+ "h5" : {
+ "unipush" : {
+ "enable" : false
+ }
+ },
+ "_spaceID" : "mp-dd6d96de-bdf2-4284-a975-638af4cc8ec8",
+ "app-harmony" : {
+ "distribute" : {
+ "modules" : {}
+ }
+ }
}
diff --git a/traditionalApp/pages/login/login.vue b/traditionalApp/pages/login/login.vue
index 1c5e7d9..f11e021 100644
--- a/traditionalApp/pages/login/login.vue
+++ b/traditionalApp/pages/login/login.vue
@@ -61,6 +61,7 @@
import { onLoad } from '@dcloudio/uni-app'
import { computed, onUnmounted, ref } from 'vue'
import { appleLogin, passwordLogin, sendSmsCode, smsLogin, wechatLogin } from './service.js'
+ import { syncJPushAliasWithCurrentUser } from '@/utils/push.js'
const loginType = ref<'code' | 'password'>('code')
const phone = ref('')
@@ -649,6 +650,7 @@
inviteUserId: inviteUserId.value,
inviteType: inviteType.value
})
+ syncJPushAliasWithCurrentUser()
}
/**
diff --git a/traditionalApp/pages/settings/utils.js b/traditionalApp/pages/settings/utils.js
index ffef3a2..4d91d95 100644
--- a/traditionalApp/pages/settings/utils.js
+++ b/traditionalApp/pages/settings/utils.js
@@ -1,4 +1,5 @@
import { normalizeOptionalText } from '@/utils/utils.js'
+import { clearJPushAliasBinding } from '@/utils/push.js'
/**
* 判断接口响应是否成功。
@@ -68,6 +69,7 @@
uni.removeStorageSync('appUserInfo')
uni.removeStorageSync('loginRedirectMeta')
uni.setStorageSync('showLogoutModal', 0)
+ clearJPushAliasBinding()
}
/**
diff --git a/traditionalApp/utils/push.js b/traditionalApp/utils/push.js
new file mode 100644
index 0000000..5a8b1fb
--- /dev/null
+++ b/traditionalApp/utils/push.js
@@ -0,0 +1,281 @@
+import {
+ resolveCurrentAppUserId
+} from './app-user.js'
+
+const PUSH_ALIAS_CACHE_KEY = 'jpushBoundAlias'
+let lastHandledPushMessageId = ''
+
+/**
+ * 读取当前设备上的极光插件实例。
+ */
+function getJPushModule() {
+ // #ifdef APP-PLUS
+ try {
+ return uni.requireNativePlugin('JG-JPush')
+ } catch (error) {
+ return null
+ }
+ // #endif
+ // #ifndef APP-PLUS
+ return null
+ // #endif
+}
+
+/**
+ * 将当前登录用户 ID 归一化为极光 alias。
+ */
+function resolveCurrentPushAlias() {
+ const userId = resolveCurrentAppUserId()
+ if (!userId) {
+ return ''
+ }
+ return String(userId)
+}
+
+/**
+ * 绑定当前登录用户到极光 alias,便于服务端按用户 ID 精准推送。
+ */
+export function syncJPushAliasWithCurrentUser() {
+ const alias = resolveCurrentPushAlias()
+ if (!alias) {
+ return false
+ }
+ const jpushModule = getJPushModule()
+ if (!jpushModule || typeof jpushModule.setAlias !== 'function') {
+ return false
+ }
+ const sequence = Date.now()
+ const invoked = tryInvoke(() => jpushModule.setAlias({
+ sequence,
+ alias
+ })) || tryInvoke(() => jpushModule.setAlias({
+ sequence: String(sequence),
+ alias
+ })) || tryInvoke(() => jpushModule.setAlias(alias)) || tryInvoke(() => jpushModule.setAlias(alias, sequence))
+ if (invoked) {
+ uni.setStorageSync(PUSH_ALIAS_CACHE_KEY, alias)
+ }
+ return invoked
+}
+
+/**
+ * 退出登录后清理本地 alias 缓存,并尽量解除极光别名。
+ */
+export function clearJPushAliasBinding() {
+ uni.removeStorageSync(PUSH_ALIAS_CACHE_KEY)
+ const jpushModule = getJPushModule()
+ if (!jpushModule) {
+ return false
+ }
+ const sequence = Date.now()
+ return tryInvoke(() => {
+ if (typeof jpushModule.deleteAlias === 'function') {
+ jpushModule.deleteAlias({
+ sequence
+ })
+ return
+ }
+ if (typeof jpushModule.setAlias === 'function') {
+ jpushModule.setAlias({
+ sequence,
+ alias: ''
+ })
+ }
+ })
+}
+
+/**
+ * 初始化极光推送,并在连接成功后补一次 alias 同步。
+ */
+export function initJPushLifecycle() {
+ const jpushModule = getJPushModule()
+ if (!jpushModule) {
+ return null
+ }
+ if (typeof jpushModule.setLoggerEnable === 'function') {
+ jpushModule.setLoggerEnable(true)
+ }
+ if (typeof jpushModule.initJPushService === 'function') {
+ jpushModule.initJPushService()
+ }
+ if (typeof jpushModule.addConnectEventListener === 'function') {
+ jpushModule.addConnectEventListener((result) => {
+ const connectEnable = !!(result && result.connectEnable)
+ console.log('极光连接状态', result)
+ if (!connectEnable) {
+ return
+ }
+ syncJPushAliasWithCurrentUser()
+ })
+ }
+ if (typeof jpushModule.addNotificationListener === 'function') {
+ jpushModule.addNotificationListener((result) => {
+ console.log('48948949841weqwe', result);
+ handleJPushNotification(result)
+ })
+ }
+ return jpushModule
+}
+
+/**
+ * 安全执行插件调用,避免因参数签名差异直接中断业务。
+ */
+function tryInvoke(executor) {
+ try {
+ executor()
+ return true
+ } catch (error) {
+ return false
+ }
+}
+
+/**
+ * 根据极光通知内容决定是否执行页面跳转。
+ */
+function handleJPushNotification(result) {
+ const notificationEventType = normalizeOptionalText(result?.notificationEventType)
+ const messageId = normalizeOptionalText(result?.messageID || result?.messageId || result?.android?.msgId)
+ const extras = resolveJPushExtras(result)
+ const targetUrl = resolvePushTargetUrl(extras)
+ if (!targetUrl) {
+ return
+ }
+ if (!shouldHandlePushNavigation(notificationEventType, messageId)) {
+ return
+ }
+ navigateByPush(targetUrl)
+}
+
+/**
+ * 从极光回调中提取扩展参数,优先读取已解析 extras,缺失时兜底解析 Android 原始 JSON。
+ */
+function resolveJPushExtras(result) {
+ const extras = result?.extras
+ if (extras && typeof extras === 'object') {
+ return extras
+ }
+ const notificationExtras = normalizeOptionalText(result?.android?.notificationExtras)
+ if (!notificationExtras) {
+ return {}
+ }
+ try {
+ const parsedExtras = JSON.parse(notificationExtras)
+ return parsedExtras && typeof parsedExtras === 'object' ? parsedExtras : {}
+ } catch (error) {
+ return {}
+ }
+}
+
+/**
+ * 将推送类型映射到应用内页面。
+ */
+function resolvePushTargetUrl(extras) {
+ const noticeTypeCode = normalizeOptionalText(extras?.noticeTypeCode)
+ switch (noticeTypeCode) {
+ case 'MEMBER_EXPIRE_REMIND':
+ return '/pages/vip/vip'
+ case 'LIVE_REMIND':
+ return resolveLiveRemindTargetUrl(extras)
+ case 'ACTIVITY_NOTICE':
+ return resolveActivityNoticeTargetUrl(extras)
+ case 'ORDER_STATUS_UPDATE':
+ return resolveOrderStatusUpdateTargetUrl(extras)
+ case 'HEALTH_COURSE_VIDEO':
+ return resolveHealthCourseVideoTargetUrl(extras)
+ default:
+ return ''
+ }
+}
+
+/**
+ * 解析直播提醒跳转地址,直播详情页当前读取的是 id 参数。
+ */
+function resolveLiveRemindTargetUrl(extras) {
+ const courseId = normalizeOptionalText(extras?.courseId)
+ if (!courseId) {
+ return ''
+ }
+ return `/pages/liveDetail/liveDetail?id=${encodeURIComponent(courseId)}`
+}
+
+/**
+ * 解析活动通知跳转地址,活动详情页当前读取的是 id 参数。
+ */
+function resolveActivityNoticeTargetUrl(extras) {
+ const activityNoticeId = normalizeOptionalText(extras?.activityNoticeId)
+ if (!activityNoticeId) {
+ return ''
+ }
+ return `/pages/activityNotice/activityNoticeDetail?id=${encodeURIComponent(activityNoticeId)}`
+}
+
+/**
+ * 解析兑换订单状态变更跳转地址,明细页当前读取的是 orderId 参数。
+ */
+function resolveOrderStatusUpdateTargetUrl(extras) {
+ const orderId = normalizeOptionalText(extras?.orderId)
+ if (!orderId) {
+ return ''
+ }
+ return `/pages/myPatientExchangeItems/myPatientExchangeItems?orderId=${encodeURIComponent(orderId)}`
+}
+
+/**
+ * 解析养生课程视频更新跳转地址,课程详情页当前读取的是 id 参数。
+ */
+function resolveHealthCourseVideoTargetUrl(extras) {
+ const courseId = normalizeOptionalText(extras?.courseId)
+ if (!courseId) {
+ return ''
+ }
+ return `/pages/courseDetail/courseDetail?id=${encodeURIComponent(courseId)}`
+}
+
+/**
+ * 仅在点击通知或首次收到未处理通知时执行跳转,避免重复打开相同页面。
+ */
+function shouldHandlePushNavigation(notificationEventType, messageId) {
+ const normalizedEventType = normalizeOptionalText(notificationEventType)
+ const canNavigate = normalizedEventType === 'notificationOpened' ||
+ normalizedEventType === 'notificationClicked' ||
+ normalizedEventType === 'notificationArrived'
+ if (!canNavigate) {
+ return false
+ }
+ if (messageId && messageId === lastHandledPushMessageId) {
+ return false
+ }
+ lastHandledPushMessageId = messageId
+ return true
+}
+
+/**
+ * 根据页面栈状态执行推送跳转,避免在当前页重复打开。
+ */
+function navigateByPush(targetUrl) {
+ const currentPages = getCurrentPages()
+ const currentRoute = currentPages && currentPages.length > 0 ? currentPages[currentPages.length - 1].route || '' :
+ ''
+ const normalizedTargetRoute = targetUrl.replace(/^\//, '').split('?')[0]
+ if (currentRoute === normalizedTargetRoute) {
+ return
+ }
+ uni.navigateTo({
+ url: targetUrl,
+ fail: () => {
+ uni.reLaunch({
+ url: targetUrl
+ })
+ }
+ })
+}
+
+/**
+ * 将未知值归一化为可安全使用的文本。
+ */
+function normalizeOptionalText(value) {
+ if (typeof value !== 'string') {
+ return ''
+ }
+ return value.trim()
+}
diff --git a/traditionalApp/utils/request.js b/traditionalApp/utils/request.js
index 4fe0608..9e07861 100644
--- a/traditionalApp/utils/request.js
+++ b/traditionalApp/utils/request.js
@@ -4,6 +4,7 @@
const FORM = 'FORM';
const DELETE = 'DELETE';
import config from '@/config/index.js'
+import { clearJPushAliasBinding } from '@/utils/push.js'
const baseURL = config.BASE_URL;
const waitingList = [] //等待队列
@@ -166,6 +167,7 @@
uni.removeStorageSync('appUserInfo')
uni.removeStorageSync('loginRedirectMeta')
uni.setStorageSync('showLogoutModal', 0)
+ clearJPushAliasBinding()
}
/**
--
Gitblit v1.7.1