App.vue 7.7 KB

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