App.vue 7.4 KB

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