App.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <script>
  2. import config from 'common/js/config.js';
  3. export default {
  4. onLaunch(data) {
  5. if (uni.getStorageSync('baseUrl') != config.baseUrl) {
  6. uni.clearStorageSync();
  7. }
  8. uni.setStorageSync('baseUrl', config.baseUrl);
  9. // #ifdef MP
  10. const updateManager = uni.getUpdateManager();
  11. updateManager.onCheckForUpdate(function(res) {
  12. // 请求完新版本信息的回调
  13. });
  14. updateManager.onUpdateReady(function(res) {
  15. uni.showModal({
  16. title: '更新提示',
  17. content: '新版本已经准备好,是否重启应用?',
  18. success(res) {
  19. if (res.confirm) {
  20. // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
  21. updateManager.applyUpdate();
  22. }
  23. }
  24. });
  25. });
  26. updateManager.onUpdateFailed(function(res) {
  27. // 新的版本下载失败
  28. });
  29. // #endif
  30. // uni.getLocation({
  31. // type: 'gcj02',
  32. // success: res => {
  33. // let obj = uni.getStorageSync('location');
  34. // if (obj) {
  35. // let a = this.$util.getDistance(obj.latitude, obj.longitude, res.latitude, res.longitude);
  36. // if (a > 20) {
  37. // uni.removeStorageSync('store');
  38. // }
  39. // }
  40. // uni.setStorage({
  41. // key: 'location',
  42. // data: {
  43. // latitude: res.latitude,
  44. // longitude: res.longitude
  45. // }
  46. // });
  47. // }
  48. // });
  49. //判断是否支持 获取本地位置
  50. // #ifdef H5
  51. // if (navigator.geolocation) {
  52. // var n = navigator.geolocation.getCurrentPosition(function(res) {
  53. // console.log(res); // 需要的坐标地址就在res中
  54. // });
  55. // } else {
  56. // console.log('该浏览器不支持定位');
  57. // }
  58. // #endif
  59. // #ifdef H5
  60. if (uni.getSystemInfoSync().platform == 'ios') {
  61. uni.setStorageSync('initUrl', location.href);
  62. }
  63. // #endif
  64. uni.onNetworkStatusChange(function(res) {
  65. if (!res.isConnected) {
  66. uni.showModal({
  67. title: '网络失去链接',
  68. content: '请检查网络链接',
  69. showCancel: false
  70. });
  71. }
  72. });
  73. },
  74. onShow: function() {
  75. //全局插件
  76. this.$store.dispatch('getAddonIsexit');
  77. this.$store.dispatch('getDefaultImg');
  78. this.$store.dispatch('getShopInfo');
  79. //判断当前是否为开发状态
  80. // this.$api.sendRequest({
  81. // url: '/api/shop/isshow',
  82. // success: res => {
  83. // this.$store.state.Development = res.data;
  84. // }
  85. // });
  86. },
  87. onHide: function() {},
  88. methods: {}
  89. };
  90. </script>
  91. <style lang="scss">
  92. @import url('/common/css/iconfont.css');
  93. @import './common/css/main.scss';
  94. </style>