| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200 |
- <script lang="uts">
- export default {
- onLaunch: function (options: OnLaunchOptions) {
- console.log('App Launch')
- console.log('启动参数:', options)
- uni.onPushMessage((res) => {
- console.log("收到推送消息:",res) //监听推送消息
- if(res.type =='receive'){
- uni.setAppBadgeNumber(0);
- // 安全取出推送数据并强转类型
- const pushData = res.data as UTSJSONObject
- const title = pushData["title"] as string
- const content = pushData["content"] as string
- if (title!=null && content!=null) {
- uni.createPushMessage({
- title: title,
- content: content,
- when: Date.now() + 10000,
- icon: "/static/login/2.png",
- sound: "system",
- success: (res) => {
- console.log('创建推送消息成功', res);
- },
- fail: (err) => {
- console.error('创建推送消息失败', err);
- }
- });
- }
- }
- })
-
- // 清空之前的缓存
- uni.removeStorageSync('emcs_ticket')
-
- // 如果有启动参数,尝试提取apptoken
- if (options != null) {
- // 1. 从query获取
- const query = options.query
- if (query != null) {
- const ticketValue = query['ticket']
- if (ticketValue != null) {
- const ticket = ticketValue as string
- console.log('保存ticket到缓存:', ticket)
- uni.setStorageSync('emcs_ticket', ticket)
- }
- }
- }
-
- uni.setStorageSync("notify_key", "0")
- },
- onShow: function (options: OnShowOptions) {
- console.log('App Show')
- },
- 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:{
-
- }
- }
- </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>
|