|
|
@@ -1,6 +1,6 @@
|
|
|
<script>
|
|
|
export default {
|
|
|
- onLaunch: function () {
|
|
|
+ onLaunch: function () {
|
|
|
uni.removeStorageSync('web_config')
|
|
|
// #ifdef APP-PLUS
|
|
|
// 初始化极光推送
|
|
|
@@ -626,39 +626,73 @@ export default {
|
|
|
if (res.notificationEventType == 'notificationOpened' && res.extras && res.extras.page) {
|
|
|
// tab页面
|
|
|
// /pages/index/index
|
|
|
- // /pages/talentSearch/index
|
|
|
+ // /pages/talentSearch/index
|
|
|
// /pages/index/game/gameList
|
|
|
// /pages/msg/index
|
|
|
- // /pages/my/index
|
|
|
- const tabPages = [
|
|
|
- '/pages/index/index',
|
|
|
- '/pages/talentSearch/index',
|
|
|
- '/pages/index/game/gameList',
|
|
|
- '/pages/msg/index',
|
|
|
- '/pages/my/index'
|
|
|
+ // /pages/my/index
|
|
|
+ const tabPages = [
|
|
|
+ '/pages/index/index',
|
|
|
+ '/pages/talentSearch/index',
|
|
|
+ '/pages/index/game/gameList',
|
|
|
+ '/pages/msg/index',
|
|
|
+ '/pages/my/index'
|
|
|
]
|
|
|
- setTimeout(() => {
|
|
|
- if (tabPages.includes(res.extras?.page)) {
|
|
|
- uni.switchTab({
|
|
|
- url: res.extras.page // 例如:/pages/detail/detail?id=123
|
|
|
- })
|
|
|
- } else {
|
|
|
- uni.navigateTo({
|
|
|
- url: res.extras.page
|
|
|
- })
|
|
|
+ setTimeout(() => {
|
|
|
+ if (tabPages.includes(res.extras?.page)) {
|
|
|
+ uni.switchTab({
|
|
|
+ url: res.extras.page // 例如:/pages/detail/detail?id=123
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ uni.navigateTo({
|
|
|
+ url: res.extras.page
|
|
|
+ })
|
|
|
}
|
|
|
}, 500)
|
|
|
}
|
|
|
})
|
|
|
+
|
|
|
+ const saveRid = (rid) => {
|
|
|
+ if (!rid) return false
|
|
|
+ this.$queue.setData('registerID', rid)
|
|
|
+ console.log('jpushModule registerID:', rid)
|
|
|
+ return true
|
|
|
+ }
|
|
|
+ const tryGetRid = (maxTry = 12) => {
|
|
|
+ let n = 0
|
|
|
+ const run = () => {
|
|
|
+ jpushModule.getRegistrationID((res) => {
|
|
|
+ console.log('获取设备ID', res)
|
|
|
+ // 不同版本字段名可能不同,这里做兼容
|
|
|
+ const rid = res?.registerID || res?.registrationID || res?.registrationId
|
|
|
+ if (res?.code === 0 && saveRid(rid)) return
|
|
|
+ n++
|
|
|
+ if (n >= maxTry) {
|
|
|
+ console.warn('jpushModule registerID empty after retry:', res)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ setTimeout(run, 400 * n) // 递增重试
|
|
|
+ })
|
|
|
+ }
|
|
|
+ run()
|
|
|
+ }
|
|
|
+
|
|
|
+ jpushModule.addConnectEventListener && jpushModule.addConnectEventListener((result) => {
|
|
|
+ console.log('jpushModule connect:', result)
|
|
|
+ if (result.connectEnable) {
|
|
|
+ tryGetRid(12)
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ tryGetRid(12)
|
|
|
|
|
|
- jpushModule.getRegistrationID((res) => {
|
|
|
- if (res.code === 0) {
|
|
|
- console.log('获取设备ID', res)
|
|
|
- this.$queue.setData('registerID', res?.registerID || '')
|
|
|
- } else {
|
|
|
- console.error('获取RegistrationID失败:', res)
|
|
|
- }
|
|
|
- })
|
|
|
+ // jpushModule.getRegistrationID((res) => {
|
|
|
+ // if (res.code === 0) {
|
|
|
+ // console.log('获取设备ID', res)
|
|
|
+ // this.$queue.setData('registerID', res?.registerID || '')
|
|
|
+ // } else {
|
|
|
+ // console.error('获取RegistrationID失败:', res)
|
|
|
+ // }
|
|
|
+ // })
|
|
|
}
|
|
|
},
|
|
|
}
|