App.vue 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <script>
  2. export default {
  3. globalData: {
  4. // 用户信息
  5. userInfo: {},
  6. // 状态栏
  7. statusBarHeight: 20,
  8. // 设备信息
  9. deviceInfo: {},
  10. // 是否在App内部H5
  11. inside: false
  12. },
  13. onLaunch() {
  14. try {
  15. // 获取App方法
  16. getUserInfo.postMessage('获取用户信息')
  17. getDeviceInfo.postMessage('获取设备信息')
  18. getMWDeviceInfo.postMessage('获取音响信息')
  19. // 在App内部H5
  20. this.globalData.inside = true
  21. // 暴露setUserInfo方法给APP
  22. window['setUserInfo'] = res => {
  23. this.globalData.userInfo = JSON.parse(res)
  24. }
  25. window['setDeviceInfo'] = res => {
  26. this.globalData.statusBarHeight = JSON.parse(res).statusHeight
  27. }
  28. window['setMWDeviceInfo'] = res => {
  29. this.globalData.deviceInfo = JSON.parse(res)
  30. }
  31. } catch {
  32. // 在浏览器H5
  33. this.globalData.inside = false
  34. }
  35. }
  36. }
  37. </script>
  38. <style>
  39. /*每个页面公共css */
  40. @import url('@/common/main.scss');
  41. @import url('@/common/button.scss');
  42. </style>