tcwm-uniapp-qsd/main.js

66 lines
1.7 KiB
JavaScript

import Vue from 'vue'
import App from './App'
import HttpRequest from './common/httpRequest'
import HttpCache from './common/cache'
import queue from './common/queue'
import share from './common/share.js'
// 引入全局uView
import uView from "uview-ui";
Vue.use(uView);
// 全局获取位置
Vue.prototype.getLocation = function () {
return new Promise(function (resolve, reject) {
showLoading();
uni.getLocation({
type: "wgs84",
success: function (res) {
hideLoading();
resolve(res);
},
fail: function () {
hideLoading();
uni.showModal({
title: "请求授权当前位置",
content: "我们需要获取地理位置信息,为您推荐附近的订单",
success: (res) => {
if (res.confirm) {
uni.openSetting().then((res) => {
if (res[1].authSetting["scope.userLocation"] === true) {
uni.getLocation({
type: "wgs84",
success: function (res) {
resolve(res);
},
});
} else {
uni.showToast({
title: "您拒绝了授权当前位置",
});
}
});
} else if (res.cancel) {
uni.showToast({
title: "您拒绝了授权当前位置",
});
}
},
});
},
});
});
};
Vue.config.productionTip = false
Vue.prototype.$Request = HttpRequest;
Vue.prototype.$queue = queue;
Vue.prototype.$Sysconf = HttpRequest.config;
Vue.prototype.$SysCache = HttpCache;
Vue.mixin(share)
App.mpType = 'app'
const app = new Vue({
...App
})
app.$mount()