main.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. import Vue from 'vue'
  2. import App from './App'
  3. import HttpRequest from './common/httpRequest'
  4. import HttpCache from './common/cache'
  5. import queue from './common/queue'
  6. import share from './common/share.js'
  7. import cuProgress from './components/cu-progress/cu-progress.vue'
  8. Vue.component('cu-progress', cuProgress)
  9. // 引入全局uView
  10. import uView from "uview-ui";
  11. Vue.use(uView);
  12. // 全局获取位置
  13. Vue.prototype.getLocation = function() {
  14. return new Promise(function(resolve, reject) {
  15. showLoading();
  16. uni.getLocation({
  17. // #ifdef APP
  18. type: 'wgs84',
  19. // #endif
  20. // #ifndef APP
  21. type: 'gcj02', //wgs84 gcj02
  22. // #endif
  23. success: function(res) {
  24. hideLoading();
  25. resolve(res);
  26. },
  27. fail: function() {
  28. hideLoading();
  29. uni.showModal({
  30. title: "请求授权当前位置",
  31. content: "我们需要获取地理位置信息,为您推荐附近的订单",
  32. success: (res) => {
  33. if (res.confirm) {
  34. uni.openSetting().then((res) => {
  35. if (res[1].authSetting[
  36. "scope.userLocation"] === true) {
  37. uni.getLocation({
  38. // #ifdef APP
  39. type: 'wgs84',
  40. // #endif
  41. // #ifndef APP
  42. type: 'gcj02', //wgs84 gcj02
  43. // #endif
  44. success: function(res) {
  45. resolve(res);
  46. },
  47. });
  48. } else {
  49. uni.showToast({
  50. title: "您拒绝了授权当前位置",
  51. });
  52. }
  53. });
  54. } else if (res.cancel) {
  55. uni.showToast({
  56. title: "您拒绝了授权当前位置",
  57. });
  58. }
  59. },
  60. });
  61. },
  62. });
  63. });
  64. };
  65. Vue.config.productionTip = false
  66. Vue.prototype.$Request = HttpRequest;
  67. Vue.prototype.$queue = queue;
  68. Vue.prototype.$Sysconf = HttpRequest.config;
  69. Vue.prototype.$SysCache = HttpCache;
  70. Vue.mixin(share)
  71. App.mpType = 'app'
  72. const app = new Vue({
  73. ...App
  74. })
  75. app.$mount()