| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220 |
- <script lang="uts">
- let firstBackTime = 0
- let timer = 0;
-
- export default {
- onLaunch: function (options: OnLaunchOptions) {
- console.log('App Launch')
- console.log('启动参数:', options)
-
- // 清空之前的缓存
- uni.removeStorageSync('ice_apptoken')
-
- // 如果有启动参数,尝试提取apptoken
- if (options != null) {
- // 1. 从query获取
- const query = options.query
- if (query != null) {
- const apptokenValue = query['apptoken']
- if (apptokenValue != null) {
- const apptoken = apptokenValue as string
- console.log('保存apptoken到缓存:', apptoken)
- uni.setStorageSync('ice_apptoken', apptoken)
- }
- }
-
- // 2. 从appScheme获取
- const appScheme = options.appScheme
- if (appScheme != null) {
- const schemeStr = appScheme as string
- console.log('AppScheme:', schemeStr)
-
- // 简单解析apptoken
- if (schemeStr.includes('apptoken=')) {
- const parts = schemeStr.split('apptoken=')
- if (parts.length > 1) {
- const tokenPart = parts[1]
- const token = tokenPart.split('&')[0] // 去掉可能的后缀
- console.log('从scheme解析apptoken:', token)
- uni.setStorageSync('ice_apptoken', token)
- }
- }
- }
- }
- uni.setStorageSync("notify_key", "0")
- },
- onShow: function (options: OnShowOptions) {
- console.log('App Show')
-
- // 再次检查并保存(确保不会漏掉)
- if (options != null) {
- const query = options.query
- if (query != null) {
- const apptokenValue = query['apptoken']
- if (apptokenValue != null) {
- const apptoken = apptokenValue as string
- console.log('Show时保存apptoken:', apptoken)
- uni.setStorageSync('ice_apptoken', apptoken)
- }
- }
- }
- },
- onHide: function () {
- console.log('App Hide')
- // this.startTimer();
- },
- // #ifdef APP-ANDROID
- onLastPageBackPress: function () {
- console.log('App LastPageBackPress')
- // #ifdef APP-ANDROID
- UTSAndroid.getUniActivity()?.moveTaskToBack(true)
- // #endif
-
- // #ifdef APP-HARMONY
- UTSHarmony.getUIAbilityContext().moveAbilityToBackground()
- // #endif
- },
- // #endif
- onExit: function () {
- console.log('App Exit')
- },
- methods:{
- startTimer() {
- console.log("==========")
- timer = setInterval(() => {
- console.log('定时器运行');
- // 这里写你的定时任务
- }, 10000); // 每1000毫秒运行一次
- },
- stopTimer() {
- if (timer > 0) {
- clearInterval(timer);
- timer = 0;
- }
- }
- }
- }
- </script>
- <style lang="scss">
- @import './static/css/form.scss';
- /*每个页面公共css */
-
- /* 布局 */
- .uni-row {
- flex-direction: row;
- }
- .uni-column {
- flex-direction: column;
- }
-
- /* 文字颜色 */
- .text-primary {
- color: #333333;
- }
-
- .text-secondary {
- color: #666666;
- }
-
- .text-placeholder {
- color: #999999;
- }
-
- /* 背景色 */
- .bg-white {
- background-color: #ffffff;
- }
-
- .bg-gray {
- background-color: #f5f5f5;
- }
-
- /* 间距 */
- .padding-sm {
- padding: 15rpx;
- }
-
- .padding-md {
- padding: 20rpx;
- }
-
- .padding-lg {
- padding: 30rpx;
- }
-
- .margin-sm {
- margin: 15rpx;
- }
-
- .margin-md {
- margin: 20rpx;
- }
-
- .margin-lg {
- margin: 30rpx;
- }
-
- /* 圆角 */
- .radius-sm {
- border-radius: 4rpx;
- }
-
- .radius-md {
- border-radius: 8rpx;
- }
-
- .radius-lg {
- border-radius: 12rpx;
- }
- </style>
- <style>
- /* #ifdef APP-HARMONY */
- /* 鸿蒙平台全局样式 */
- .l-input__placeholder {
- font-weight: 400 !important;
- font-size: 28rpx !important;
- color: #999999 !important;
- }
- .l-textarea__placeholder {
- font-weight: 400 !important;
- font-size: 28rpx !important;
- color: #999999 !important;
- }
- .l-input__control {
- font-weight: 400 !important;
- font-size: 28rpx !important;
- color: #131415 !important;
- }
- .l-textarea__control {
- font-weight: 400 !important;
- font-size: 28rpx !important;
- color: #131415 !important;
- }
- .uni-input-input {
- font-weight: 400 !important;
- font-size: 28rpx !important;
- color: #131415 !important;
- }
- .uni-textarea-textarea {
- font-weight: 400 !important;
- font-size: 28rpx !important;
- color: #131415 !important;
- }
- .uni-input-placeholder,
- .uni-textarea-placeholder {
- font-weight: 400 !important;
- font-size: 28rpx !important;
- color: #999999 !important;
- }
- /* #endif */
- </style>
|