App.vue 7.4 KB

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