App.vue 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <script>
  2. import Vue from 'vue'
  3. import store from './store/index.js'
  4. import updateCustomBarInfo from './tuniao-ui/libs/function/updateCustomBarInfo.js'
  5. export default {
  6. onLaunch: function() {
  7. if (!wx.cloud) {
  8. console.error('请使用 2.2.3 或以上的基础库以使用云能力');
  9. } else {
  10. wx.cloud.init({
  11. env: 'cloud1-6g83nk504b196aa9'
  12. });
  13. }
  14. uni.getSystemInfo({
  15. success: function(e) {
  16. // #ifndef H5
  17. // 获取手机系统版本
  18. const system = e.system.toLowerCase()
  19. const platform = e.platform.toLowerCase()
  20. // 判断是否为ios设备
  21. if (platform.indexOf('ios') != -1 && (system.indexOf('ios') != -1 || system.indexOf('macos') != -1)) {
  22. Vue.prototype.SystemPlatform = 'apple'
  23. } else if (platform.indexOf('android') != -1 && (system.indexOf('android') != -1)) {
  24. Vue.prototype.SystemPlatform = 'android'
  25. } else {
  26. Vue.prototype.SystemPlatform = 'devtools'
  27. }
  28. // #endif
  29. }
  30. })
  31. // 获取设备的状态栏信息和自定义顶栏信息
  32. // store.dispatch('updateCustomBarInfo')
  33. updateCustomBarInfo().then((res) => {
  34. store.commit('$tStore', {
  35. name: 'vuex_status_bar_height',
  36. value: res.statusBarHeight
  37. })
  38. store.commit('$tStore', {
  39. name: 'vuex_custom_bar_height',
  40. value: res.customBarHeight
  41. })
  42. })
  43. // #ifdef MP-WEIXIN
  44. //更新检测
  45. if (wx.canIUse('getUpdateManager')) {
  46. const updateManager = wx.getUpdateManager();
  47. updateManager && updateManager.onCheckForUpdate((res) => {
  48. if (res.hasUpdate) {
  49. updateManager.onUpdateReady(() => {
  50. uni.showModal({
  51. title: '更新提示',
  52. content: '新版本已经准备好,是否重启应用?',
  53. success: (res) => {
  54. if (res.confirm) {
  55. uni.clearStorageSync() // 更新完成后刷新storage的数据
  56. updateManager.applyUpdate()
  57. }
  58. }
  59. })
  60. })
  61. updateManager.onUpdateFailed(() => {
  62. uni.showModal({
  63. title: '已有新版本上线',
  64. content: '小程序自动更新失败,请删除该小程序后重新搜索打开哟~~~',
  65. showCancel: false
  66. })
  67. })
  68. } else {
  69. //没有更新
  70. }
  71. })
  72. } else {
  73. uni.showModal({
  74. title: '提示',
  75. content: '当前微信版本过低,无法使用该功能,请更新到最新的微信后再重试。',
  76. showCancel: false
  77. })
  78. }
  79. // #endif
  80. },
  81. onShow: function() {
  82. // console.log('App Show')
  83. },
  84. onHide: function() {
  85. // console.log('App Hide')
  86. }
  87. }
  88. </script>
  89. <style lang="scss">
  90. /* 注意要写在第一行,同时给style标签加入lang="scss"属性 */
  91. @import './tuniao-ui/index.scss';
  92. @import './tuniao-ui/iconfont.css';
  93. </style>