App.vue 7.3 KB

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