App.vue 7.2 KB

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