123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317 |
- <script>
- import skJGPush from '@/libs/jgPush.js'
- import {openMessagePage} from '@/libs/tools.js'
- export default {
- globalData: {
- baseUrl: '',
- token: '',
- changeOrg:'',
- version: '', // 当前版本号
- buildType: 'dev', // 打包环境对应类型,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>
|