54 lines
1.4 KiB
Vue
54 lines
1.4 KiB
Vue
<script setup>
|
||
import { onLaunch, onShow } from '@dcloudio/uni-app'
|
||
import { captureAppLaunchData, capturePaymentResult } from '/pageSubPack/api/appLaunch.js'
|
||
|
||
onLaunch((options) => {
|
||
console.log('App 启动', JSON.stringify(options))
|
||
// 捕获 App 跳转传入的支付参数(冷启动)
|
||
captureAppLaunchData(options)
|
||
|
||
// #ifdef APP-PLUS
|
||
getPushCID()
|
||
// #endif
|
||
})
|
||
|
||
onShow((options) => {
|
||
console.log('App onShow, options:', JSON.stringify(options))
|
||
// 先判断是否为支付小程序返回:是则本次进入只按支付结果处理,
|
||
// 不能再走 App 跳转参数捕获,否则兜底参数会把上一次的账单写回缓存
|
||
if (capturePaymentResult(options)) return
|
||
// 捕获 App 跳转传入的支付参数(热启动 — options 携带新的 referrerInfo)
|
||
captureAppLaunchData(options)
|
||
})
|
||
|
||
// 获取 uniPush 2.0 CID
|
||
function getPushCID() {
|
||
uni.getPushClientId({
|
||
success: (res) => {
|
||
console.log('推送初始化成功, CID =', res.cid)
|
||
uni.setStorageSync('push_cid', res.cid)
|
||
},
|
||
fail: (err) => {
|
||
console.error('获取推送 CID 失败', err)
|
||
}
|
||
})
|
||
}
|
||
</script>
|
||
|
||
<style lang="scss">
|
||
@import "@/uni_modules/uview-plus/index.scss";
|
||
</style>
|
||
|
||
<style>
|
||
.uni-toast {
|
||
padding: 5px !important;
|
||
min-height: auto !important;
|
||
box-sizing: border-box !important;
|
||
}
|
||
.uni-toast-content {
|
||
padding: 0 !important;
|
||
white-space: normal !important;
|
||
word-break: break-all !important;
|
||
}
|
||
</style>
|