App.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  1. <script>
  2. import skJGPush from '@/libs/jgPush.js'
  3. import {openMessagePage} from '@/libs/tools.js'
  4. export default {
  5. globalData: {
  6. baseUrl: '',
  7. token: '',
  8. changeOrg:'',
  9. version: '', // 当前版本号
  10. buildType: 'uat', // 打包环境对应类型,pro 生产 uat 预发布 dev 本地开发
  11. envTips: '', // 环境文字提示
  12. theme: 'default', // 主题,default
  13. isIphoneXup: false //是否iphonex以及以上的版本
  14. },
  15. mounted() {
  16. // 非V3模式
  17. if (this.$scope) {
  18. this.$scope.globalData.token = this.$store.state.vuex_token;
  19. this.$scope.globalData.changeOrg = this.$store.state.vuex_changeOrg;
  20. } else {
  21. // V3模式
  22. getApp({ allowDefault: true }).globalData.token = this.$store.state.vuex_token;
  23. getApp({ allowDefault: true }).globalData.changeOrg = this.$store.state.vuex_changeOrg;
  24. }
  25. this.$config('init');
  26. },
  27. onLaunch: function() {
  28. console.log('App launch')
  29. this.$store.state.vuex_tempData = ''
  30. let bgAudioManager = uni.getBackgroundAudioManager();
  31. if(uni.getSystemInfoSync().platform == "ios"){
  32. // 请求定位权限
  33. let locationServicesEnabled = skJGPush.locationServicesEnabled()
  34. let locationAuthorizationStatus = skJGPush.getLocationAuthorizationStatus()
  35. console.log('locationAuthorizationStatus',locationAuthorizationStatus)
  36. if (locationServicesEnabled == true && locationAuthorizationStatus < 3) {
  37. skJGPush.requestLocationAuthorization((result)=>{
  38. console.log('定位权限',result.status)
  39. })
  40. }
  41. skJGPush.requestNotificationAuthorization((result)=>{
  42. let status = result.status
  43. if (status < 2) {
  44. uni.showModal({
  45. title: '提示',
  46. content: '您还没有打开通知权限',
  47. success: function (res) {
  48. if (res.confirm) {
  49. skJGPush.openSettingsForNotification()
  50. } else if (res.cancel) {
  51. console.log('用户点击取消');
  52. }
  53. }
  54. });
  55. }
  56. })
  57. }else{
  58. // 极光推送-init
  59. skJGPush.initJPushService()
  60. }
  61. // 极光推送-打开debug
  62. skJGPush.openDebug()
  63. skJGPush.initCrashHandler()
  64. // 极光推送-获取rid
  65. skJGPush.getRegistrationID(result => {
  66. console.log('【业务getRegistrationID】', result)
  67. })
  68. // 极光推送-通知事件回调
  69. skJGPush.addNotificationListener(result => {
  70. console.log('【业务addNotificationListener】', result)
  71. // 点击通知
  72. if(result.notificationEventType == 'notificationOpened'){
  73. this.setRead(result)
  74. }else if(result.notificationEventType == 'notificationArrived'){
  75. if(bgAudioManager){
  76. bgAudioManager.src = '/static/notes.mp3';
  77. bgAudioManager.play()
  78. }
  79. }else{
  80. }
  81. })
  82. // 极光推送-标签别名事件回调
  83. skJGPush.addTagAliasListener(result => {
  84. console.log('【业务addTagAliasListener】', result)
  85. })
  86. // 连接状态
  87. skJGPush.addConnectEventListener(result => {
  88. console.log('【连接状态】', result)
  89. })
  90. },
  91. onShow: function() {
  92. console.log('App Show')
  93. },
  94. onHide: function() {
  95. console.log('App Hide')
  96. },
  97. methods:{
  98. setRead(item){
  99. const api = require("@/api/user.js")
  100. const token = getApp().globalData.token
  101. if(token){
  102. api.setReadNotice({'noticeId': item.extras.noticeId}).then(res => {
  103. console.log(res,'setRead')
  104. openMessagePage(item)
  105. })
  106. }else{
  107. uni.$emit("openMessage",item)
  108. }
  109. },
  110. }
  111. }
  112. </script>
  113. <style lang="scss">
  114. @import "./static/iconfont/iconfont.css";
  115. @import "uview-ui/index.scss";
  116. /*每个页面公共css */
  117. page {
  118. width: 100%;
  119. min-height: 100%;
  120. display: flex;
  121. background-color: #F8F8F8;
  122. }
  123. /* 登录页是否记住密码多选框样式 */
  124. uni-checkbox.login-form-checkbox .uni-checkbox-input{
  125. width: 24upx !important;
  126. height: 24upx !important;
  127. }
  128. .status_bar {
  129. height: var(--status-bar-height);
  130. width: 100%;
  131. }
  132. .isIPXup{
  133. padding-bottom: 64rpx !important;
  134. }
  135. /* form表单样式 */
  136. .form-box{
  137. background-color: #fff;
  138. padding: 0 30rpx;
  139. }
  140. .form-input {
  141. font-size: 28rpx;
  142. color: #333;
  143. text-align: right;
  144. width: 95%;
  145. box-sizing: border-box;
  146. height: 60rpx;
  147. line-height: 60rpx;
  148. &.textarea{
  149. height: 240rpx;
  150. padding: 24rpx 0;
  151. text-align: left;
  152. }
  153. }
  154. .form-input-placeholder {
  155. font-size: 28rpx;
  156. color: #999;
  157. }
  158. .form-textarea{
  159. height: 240rpx;
  160. padding: 24rpx 0;
  161. text-align: left;
  162. }
  163. .form-number-input{
  164. margin: 0 auto;
  165. }
  166. .u-required{
  167. position: relative;
  168. }
  169. .u-required:before{
  170. content: '*';
  171. position: absolute;
  172. left: -8px;
  173. top: 10upx;
  174. font-size: 14px;
  175. color: #fa3534;
  176. height: 9px;
  177. line-height: 1;
  178. }
  179. /* 元素宽度 百分比 */
  180. .uni-col-1{
  181. box-sizing: border-box;
  182. width: 10%;
  183. }
  184. .uni-col-2{
  185. box-sizing: border-box;
  186. width: 20%;
  187. }
  188. .uni-col-3{
  189. box-sizing: border-box;
  190. width: 30%;
  191. }
  192. .uni-col-4{
  193. box-sizing: border-box;
  194. width: 40%;
  195. }
  196. .uni-col-5{
  197. box-sizing: border-box;
  198. width: 50%;
  199. }
  200. .uni-col-6{
  201. box-sizing: border-box;
  202. width: 60%;
  203. }
  204. .uni-col-7{
  205. box-sizing: border-box;
  206. width: 70%;
  207. }
  208. .uni-col-8{
  209. box-sizing: border-box;
  210. width: 80%;
  211. }
  212. .uni-col-9{
  213. box-sizing: border-box;
  214. width: 90%;
  215. }
  216. .uni-col-10{
  217. box-sizing: border-box;
  218. width: 100%;
  219. }
  220. /* felx布局 */
  221. .flex{
  222. display: -webkit-flex; /* Chrome 21+, Safari 6.1+, iOS Safari 7+, Opera 15/16 */
  223. display: -moz-flex; /* Firefox 18+ */
  224. display: -ms-flexbox; /* IE 10 */
  225. display: flex; /* Chrome 29+, Firefox 22+, IE 11+, Opera 12.1/17/18, Android 4.4+ */
  226. }
  227. /*伸缩流方向*/
  228. .flex_column{
  229. -webkit-box-orient: vertical;
  230. -ms-flex-direction: column;
  231. -webkit-flex-direction: column;
  232. flex-direction: column;
  233. }
  234. /*主轴对齐*/
  235. .justify_center{
  236. -webkit-box-pack: center;
  237. -ms-flex-pack: center;
  238. -webkit-justify-content: center;
  239. justify-content: center;
  240. }
  241. .justify_end{
  242. -webkit-box-pack: end;
  243. -ms-flex-pack: end;
  244. -webkit-justify-content: flex-end;
  245. justify-content: flex-end;
  246. }
  247. .justify_between{
  248. -webkit-box-pack: justify;
  249. -ms-flex-pack: justify;
  250. -webkit-justify-content: space-between;
  251. justify-content: space-between;
  252. }
  253. /*侧轴对齐*/
  254. .align_start{
  255. -webkit-box-align: start;
  256. -ms-flex-align: start;
  257. -webkit-align-items: flex-start;
  258. align-items: flex-start;
  259. }
  260. .align_end{
  261. -webkit-box-align: end;
  262. -ms-flex-align: end;
  263. -webkit-align-items: flex-end;
  264. align-items: flex-end;
  265. }
  266. .align_center{
  267. -webkit-box-align: center;
  268. -ms-flex-align: center;
  269. -webkit-align-items: center;
  270. align-items: center;
  271. }
  272. .align_baseline{
  273. -webkit-box-align: baseline;
  274. -ms-flex-align: baseline;
  275. -webkit-align-items: baseline;
  276. align-items: baseline;
  277. }
  278. /*伸缩性*/
  279. .flex_auto{
  280. -webkit-box-flex: 1;
  281. -ms-flex: auto;
  282. -webkit-flex: auto;
  283. flex: auto;
  284. }
  285. .flex_1{
  286. -webkit-box-flex: 1;
  287. -ms-flex: 1;
  288. -webkit-flex: 1;
  289. flex: 1;
  290. }
  291. // ios15原生input的type=search时会默认自带搜索图标。
  292. // 在全局的公共样式隐藏ios自带搜索图标即可
  293. [type="search"]::-webkit-search-decoration {
  294. display: none;
  295. }
  296. uni-toast {
  297. z-index: 1000000;
  298. }
  299. </style>