<script> import skJGPush from '@/libs/jgPush.js' import {openMessagePage} from '@/libs/tools.js' export default { globalData: { baseUrl: '', token: '', changeOrg:'', version: '', // 当前版本号 buildType: 'uat', // 打包环境对应类型,pro 生产 uat 预发布 dev 本地开发 envTips: '', // 环境文字提示 theme: 'default', // 主题,default isIphoneXup: false //是否iphonex以及以上的版本 }, mounted() { // 非V3模式 if (this.$scope) { this.$scope.globalData.token = this.$store.state.vuex_token; this.$scope.globalData.changeOrg = this.$store.state.vuex_changeOrg; } else { // V3模式 getApp({ allowDefault: true }).globalData.token = this.$store.state.vuex_token; getApp({ allowDefault: true }).globalData.changeOrg = this.$store.state.vuex_changeOrg; } this.$config('init'); }, onLaunch: function() { console.log('App launch') this.$store.state.vuex_tempData = '' let bgAudioManager = uni.getBackgroundAudioManager(); if(uni.getSystemInfoSync().platform == "ios"){ // 请求定位权限 let locationServicesEnabled = skJGPush.locationServicesEnabled() let locationAuthorizationStatus = skJGPush.getLocationAuthorizationStatus() console.log('locationAuthorizationStatus',locationAuthorizationStatus) if (locationServicesEnabled == true && locationAuthorizationStatus < 3) { skJGPush.requestLocationAuthorization((result)=>{ console.log('定位权限',result.status) }) } skJGPush.requestNotificationAuthorization((result)=>{ let status = result.status console.log(result,'通知权限') if (status < 2) { uni.showModal({ title: '提示', content: '您未打开通知权限,应用将无法收到消息通知,确定开启通知权限吗?', success: function (res) { if (res.confirm) { skJGPush.openSettingsForNotification() } else if (res.cancel) { console.log('用户点击取消'); } } }); } }) }else{ // 极光推送-init skJGPush.initJPushService() } // 极光推送-打开debug skJGPush.openDebug() skJGPush.initCrashHandler() // 极光推送-获取rid skJGPush.getRegistrationID(result => { console.log('【业务getRegistrationID】', result) }) // 极光推送-通知事件回调 skJGPush.addNotificationListener(result => { console.log('【业务addNotificationListener】', result) // 点击通知 if(result.notificationEventType == 'notificationOpened'){ this.setRead(result) }else if(result.notificationEventType == 'notificationArrived'){ // 安卓铃声 if(bgAudioManager&&uni.getSystemInfoSync().platform != "ios"){ bgAudioManager.src = '/static/notes.mp3'; bgAudioManager.play() }else{ uni.vibrateLong({ success: function () { console.log('vibrateLong success'); } }); } }else{ // 清空角标 skJGPush.setBadge(0) } }) // 极光推送-标签别名事件回调 skJGPush.addTagAliasListener(result => { console.log('【业务addTagAliasListener】', result) }) // 连接状态 skJGPush.addConnectEventListener(result => { console.log('【连接状态】', result) }) }, onShow: function() { console.log('App Show') }, onHide: function() { console.log('App Hide') }, methods:{ setRead(item){ const api = require("@/api/user.js") const token = getApp().globalData.token if(token){ api.setReadNotice({'noticeId': item.extras.noticeId}).then(res => { console.log(res,'setRead') openMessagePage(item) }) }else{ uni.$emit("openMessage",item) } }, } } </script> <style lang="scss"> @import "./static/iconfont/iconfont.css"; @import "uview-ui/index.scss"; /*每个页面公共css */ page { width: 100%; min-height: 100%; display: flex; background-color: #F8F8F8; } /* 登录页是否记住密码多选框样式 */ uni-checkbox.login-form-checkbox .uni-checkbox-input{ width: 24upx !important; height: 24upx !important; } .status_bar { height: var(--status-bar-height); width: 100%; } .isIPXup{ padding-bottom: 64rpx !important; } /* form表单样式 */ .form-box{ background-color: #fff; padding: 0 30rpx; } .form-input { font-size: 28rpx; color: #333; text-align: right; width: 95%; box-sizing: border-box; height: 60rpx; line-height: 60rpx; &.textarea{ height: 240rpx; padding: 24rpx 0; text-align: left; } } .form-input-placeholder { font-size: 28rpx; color: #999; } .form-textarea{ height: 240rpx; padding: 24rpx 0; text-align: left; } .form-number-input{ margin: 0 auto; } .u-required{ position: relative; } .u-required:before{ content: '*'; position: absolute; left: -8px; top: 10upx; font-size: 14px; color: #fa3534; height: 9px; line-height: 1; } /* 元素宽度 百分比 */ .uni-col-1{ box-sizing: border-box; width: 10%; } .uni-col-2{ box-sizing: border-box; width: 20%; } .uni-col-3{ box-sizing: border-box; width: 30%; } .uni-col-4{ box-sizing: border-box; width: 40%; } .uni-col-5{ box-sizing: border-box; width: 50%; } .uni-col-6{ box-sizing: border-box; width: 60%; } .uni-col-7{ box-sizing: border-box; width: 70%; } .uni-col-8{ box-sizing: border-box; width: 80%; } .uni-col-9{ box-sizing: border-box; width: 90%; } .uni-col-10{ box-sizing: border-box; width: 100%; } /* felx布局 */ .flex{ display: -webkit-flex; /* Chrome 21+, Safari 6.1+, iOS Safari 7+, Opera 15/16 */ display: -moz-flex; /* Firefox 18+ */ display: -ms-flexbox; /* IE 10 */ display: flex; /* Chrome 29+, Firefox 22+, IE 11+, Opera 12.1/17/18, Android 4.4+ */ } /*伸缩流方向*/ .flex_column{ -webkit-box-orient: vertical; -ms-flex-direction: column; -webkit-flex-direction: column; flex-direction: column; } /*主轴对齐*/ .justify_center{ -webkit-box-pack: center; -ms-flex-pack: center; -webkit-justify-content: center; justify-content: center; } .justify_end{ -webkit-box-pack: end; -ms-flex-pack: end; -webkit-justify-content: flex-end; justify-content: flex-end; } .justify_between{ -webkit-box-pack: justify; -ms-flex-pack: justify; -webkit-justify-content: space-between; justify-content: space-between; } /*侧轴对齐*/ .align_start{ -webkit-box-align: start; -ms-flex-align: start; -webkit-align-items: flex-start; align-items: flex-start; } .align_end{ -webkit-box-align: end; -ms-flex-align: end; -webkit-align-items: flex-end; align-items: flex-end; } .align_center{ -webkit-box-align: center; -ms-flex-align: center; -webkit-align-items: center; align-items: center; } .align_baseline{ -webkit-box-align: baseline; -ms-flex-align: baseline; -webkit-align-items: baseline; align-items: baseline; } /*伸缩性*/ .flex_auto{ -webkit-box-flex: 1; -ms-flex: auto; -webkit-flex: auto; flex: auto; } .flex_1{ -webkit-box-flex: 1; -ms-flex: 1; -webkit-flex: 1; flex: 1; } // ios15原生input的type=search时会默认自带搜索图标。 // 在全局的公共样式隐藏ios自带搜索图标即可 [type="search"]::-webkit-search-decoration { display: none; } uni-toast { z-index: 1000000; } </style>