App.vue 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <script>
  2. //#ifdef APP-PLUS
  3. var alog = uni.requireNativePlugin("AndroidLog")
  4. // var device = uni.requireNativePlugin("DeviceInfo")
  5. import update from '@/utils/update.js';
  6. import deviceUt from '@/utils/deviceUtils.js';
  7. import pushreg from '@/utils/pushUtils.js';
  8. //#endif
  9. export default {
  10. onLaunch: function() {
  11. //#ifdef APP-PLUS
  12. update(this); //软件更新
  13. deviceUt.devicereg(this); //设备注册
  14. pushreg(); //推送注册
  15. //#endif
  16. //#ifdef H5
  17. this.$u.api.deviceReg({
  18. deviceNo: '123456789',
  19. pushCid: '123456789'
  20. })
  21. .then(res => {
  22. if (res.code == 200) {
  23. uni.showToast({
  24. title: '设备注册成功',
  25. duration: 2000
  26. });
  27. } else {
  28. uni.showToast({
  29. title: '设备注册失败',
  30. duration: 2000
  31. });
  32. }
  33. }).catch(err => {
  34. uni.showToast({
  35. title: '设备注册失败',
  36. duration: 2000
  37. });
  38. });
  39. //#endif
  40. },
  41. onShow: function() {
  42. // console.log('App Show')
  43. },
  44. onHide: function() {
  45. // console.log('App Hide')
  46. }
  47. }
  48. </script>
  49. <style lang="scss">
  50. @import "uview-ui/index.scss";
  51. /*每个页面公共css */
  52. </style>