123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476 |
- <style lang="scss">
- /* 注意要写在第一行,同时给style标签加入lang="scss"属性 */
- @import "@/uni_modules/uview-ui/index.scss";
- @import 'static/css/common.scss';
- </style>
- <script>
- import region from "@/components/region/data";
- import {
- mapMutations
- } from 'vuex';
- import * as config from '@/config'
- import appUpdate from 'common/appUpdate.js'
- import app_push from './components/APPPush/app_push.js'
- import permision from "@/js_sdk/wa-permission/permission.js"
- export default {
- methods: {
- getLngLat(){
- uni.getLocation({
- type: 'gcj02',
- geocode: true,
- success: res => {
- if (res.latitude) {
- console.log(res)
- if(res.address.city){
- if(res.address.city.indexOf('市')!=-1){
- res.address.city=res.address.city.substring(0,res.address.city.length-1)
- }
- }
- if(res.address.province){
- if(res.address.province.indexOf('省')!=-1){
- res.address.province=res.address.province.substring(0,res.address.province.length-1)
- }
- }
- uni.setStorageSync('fPlaceObj',{
- fchoosearea:'全部',
- fchoosecity:res.address.city,
- fchooseprovince:res.address.province,
- selected:res.address.city
- })
- uni.setStorageSync('sPlaceObj',{
- schoosearea:'请选择区',
- schoosecity:'请选择市',
- schooseprovince:'全国',
- selected:'全国'
- })
- uni.setStorageSync('longitudeAndLatitude',res.longitude+','+res.latitude)
- }
- }
- })
- },
- checkOpenGPSServiceByAndroidIOS() {
- console.log()
- let system = uni.getSystemInfoSync(); // 获取系统信息
- console.log(system);
- if (system.platform === 'android') { // 判断平台
- var context = plus.android.importClass("android.content.Context");
- var locationManager = plus.android.importClass("android.location.LocationManager");
- var main = plus.android.runtimeMainActivity();
- var mainSvr = main.getSystemService(context.LOCATION_SERVICE);
- if (!mainSvr.isProviderEnabled(locationManager.GPS_PROVIDER)) {
- uni.showModal({
- title: '提示',
- content: '请打开定位服务功能',
- // showCancel: false, // 不显示取消按钮
- success(res) {
- if(res.confirm){
- if (!mainSvr.isProviderEnabled(locationManager.GPS_PROVIDER)) {
- var Intent = plus.android.importClass('android.content.Intent');
- var Settings = plus.android.importClass('android.provider.Settings');
- var intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
- main.startActivity(intent); // 打开系统设置GPS服务页面
- this.getLngLat()
- } else {
- uni.setStorageSync('fPlaceObj',{
- fchoosearea:'全部',
- fchoosecity:'市辖区',
- fchooseprovince:'北京',
- selected:res.address.city
- })
- uni.setStorageSync('sPlaceObj',{
- schoosearea:'请选择区',
- schoosecity:'请选择市',
- schooseprovince:'全国',
- selected:'全国'
- })
- uni.setStorageSync('longitudeAndLatitude','116.3972,39.9096')
- }
- }
- }
- });
- }else{
- this.getLngLat()
- }
- } else if (system.platform === 'ios') {
- console.log("苹果");
- var cllocationManger = plus.ios.import("CLLocationManager");
- var enable = cllocationManger.locationServicesEnabled();
- var status = cllocationManger.authorizationStatus();
- plus.ios.deleteObject(cllocationManger);
- if (enable && status != 2) {
- this.getLngLat()
- console.log("手机系统的定位已经打开");
- } else {
- console.log("手机系统的定位没有打开");
- uni.showModal({
- title: '提示',
- content: '请前往设置-隐私-定位服务打开定位服务功能',
- // showCancel: false, // 不显示取消按钮
- success(res) {
- if(res.confirm){
- var UIApplication = plus.ios.import("UIApplication");
- var application2 = UIApplication.sharedApplication();
- var NSURL2 = plus.ios.import("NSURL");
- // var setting2 = NSURL2.URLWithString("prefs:root=LOCATION_SERVICES");
- // var setting2 = NSURL2.URLWithString("App-Prefs:root=LOCATION_SERVICES");
- // var setting2 = NSURL2.URLWithString("app-settings");
- var setting2 = NSURL2.URLWithString("App-Prefs:root=Privacy&path=LOCATION");
- // var setting2 = NSURL2.URLWithString("App-Prefs:root=Privacy&path=LOCATION_SERVICES");
- application2.openURL(setting2);
- plus.ios.deleteObject(setting2);
- plus.ios.deleteObject(NSURL2);
- plus.ios.deleteObject(application2);
- this.getLngLat()
- }
- }
- });
- }
- }
- },
- ...mapMutations(['login']),
- // vue的method里编写如下代码
- // async requestAndroidPermission(permisionID) {
- // var result = await permision.requestAndroidPermission(permisionID)
- // var strStatus
- // if (result == 1) {
- // strStatus = "已获得授权"
- // } else if (result == 0) {
- // strStatus = "未获得授权"
- // // permision.gotoAppPermissionSetting()
- // // 引导设置,判断是否有运输中订单,有订单,必须授权
- // } else {
- // strStatus = "被永久拒绝权限"
- // // permision.gotoAppPermissionSetting()
- // }
-
- // },
- },
-
- onLaunch: function() {
- var that = this
- // #ifdef APP-PLUS
- this.checkOpenGPSServiceByAndroidIOS()
- // uni.getNetworkType({
- // success: function (res) {
- // if(res.networkType=='none'){
- // let options = {
- // title: '提示',
- // info:'当前没有网络中',
- // okText: '连接Wifi',
- // cancelText:'开启流量',
- // infoAlignment:'center',
- // radius:10,
- // // cancelText: '否',
- // // showCancel:false,
- // okButtonColor:'#2772FB'
- // };
- // const native = uni.requireNativePlugin('AJ-Alert');
- // native.showAction(options, result => {
- // // #ifdef APP-PLUS
- // if (uni.getSystemInfoSync().platform == 'ios') {
- // plus.ios.import("UIApplication").sharedApplication().performSelector("exit")
- // } else if (uni.getSystemInfoSync().platform == 'android') {
- // plus.runtime.quit();
- // }
- // // #endif
- // // 点击是的回调, result暂时没有返回内容
- // }, cancel => {
- // // 点击否的回调
- // });
-
- // }
- // console.log(res.networkType);
- // }
- // });
- console.log(uni.getStorageSync('userInfo'))
- if(uni.getStorageSync('userInfo')){
- that.$request.baseRequest('get', '/driverInfo/firstAuthentication', {
- driverPhone:uni.getStorageSync('userInfo').phone,
- }).then(res => {
- if (res.data.authenticationStatus == '已禁用') {
-
- // this.isShowAlert = true
- // this.alertTitle = '账号审核中'
- // this.confirmText = '退出APP'
- // this.showCancelButton = false
- let options = {
- title: '提示',
- info:'账号审核中',
- okText: '退出程序',
- infoAlignment:'center',
- radius:10,
- // cancelText: '否',
- showCancel:false,
- okButtonColor:'#2772FB'
- };
- const native = uni.requireNativePlugin('AJ-Alert');
- native.showAction(options, result => {
- // #ifdef APP-PLUS
- if (uni.getSystemInfoSync().platform == 'ios') {
- plus.ios.import("UIApplication").sharedApplication().performSelector("exit")
- } else if (uni.getSystemInfoSync().platform == 'android') {
- plus.runtime.quit();
- }
- // #endif
- // 点击是的回调, result暂时没有返回内容
- }, cancel => {
- // 点击否的回调
- });
- // uni.showModal({
- // title: '提示',
- // content: '这是一个模态弹窗',
- // showCancel:false,
- // confirmText:'退出app',
- // // confirmColor:'#317AFE',
- // confirmColor:'#F54E40',
- // success: function (res) {
- // if (res.confirm) {
- // // #ifdef APP-PLUS
- // if (uni.getSystemInfoSync().platform == 'ios') {
- // plus.ios.import("UIApplication").sharedApplication().performSelector("exit")
- // } else if (uni.getSystemInfoSync().platform == 'android') {
- // plus.runtime.quit();
- // }
- // // #endif
- // } else if (res.cancel) {
- // console.log('用户点击取消');
- // }
- // }
- // });
-
- } else {
- console.log(1231233212332312312213)
- }
- })
- }
-
-
- // #endif
- uni.setStorageSync("region", region);
- uni.getSystemInfo({
- success:function(e){
- Vue.prototype.statusBar = e.statusBarHeight
- // #ifndef MP
- if(e.platform == 'android') {
- Vue.prototype.customBar = e.statusBarHeight + 50
- }else {
- Vue.prototype.customBar = e.statusBarHeight + 45
- }
- // #endif
-
- // #ifdef MP-WEIXIN
- let custom = wx.getMenuButtonBoundingClientRect()
- Vue.prototype.customBar = custom.bottom + custom.top - e.statusBarHeight
- // #endif
-
- // #ifdef MP-ALIPAY
- Vue.prototype.customBar = e.statusBarHeight + e.titleBarHeight
- // #endif
- }
- })
- // #ifdef APP-PLUS
- var that=this
- //判断该用户是否需要开启持续定位
- if(uni.getStorageSync('userInfo')){
- this.$request.baseRequest('get', '/orderInfo/getData', {
- commonId:uni.getStorageSync('userInfo').id,
- }).then(res1 => {
- if(res1.data.length>0){
- that.$helper.fUN_AmapLocation.start({
- // intervalTime: 1000 * 60,
- intervalTime: 5000,
- // locationCacheEnable:true,
- isReport: false
- // url: 'http://192.168.0.66/fun/open/test_json.do',
- // params: {
- // a: 1,
- // B: '测试',
- // c: true
- // },
- // headers: {
- // a: '123',
- // B: 'abcd'
- // }
- },
- res => {
- // console.log('====确认装车开启连续定位====');
- // console.log(res)
- let _data = {
- orderId: res1.data[0].id,
- longitude: res.longitude,
- latitude: res.latitude,
- province: res.province,
- city: res.city,
- area: res.district
- }
- this.$helper.gjList.push(_data)
- uni.setStorageSync('mapGJ', this.$helper.gjList);
- // console.log('this.$helper.gjList')
- // console.log(this.$helper.gjList)
- // console.log("条数", uni.getStorageSync('mapGJ').length)
- if (uni.getStorageSync('mapGJ').length > 100) {
- console.log(JSON.stringify(uni.getStorageSync('mapGJ')) )
- this.$request.baseRequest('post', '/hyOrderTravelPath/api/addInfo', {
- orderId:"cdae6ec34c2349768c490a9fefa03fb3",
- longitudeLatitude:JSON.stringify(uni.getStorageSync('mapGJ'))
- }).then(res => {
- uni.removeStorageSync('mapGJ');
- this.$helper.gjList = []
- })
- .catch(res => {
- uni.$u.toast(res.message);
- });
- }
- //判断缓存数据条数,超过reportInterval时清空缓存,重新存入缓存
- }
- );
- }
-
- })
- }
- // this.$helper.fUN_AmapLocation.stop({}, result => {
- // console.log('====fUN_AmapLocation定位stop====', JSON.stringify(result));
- // this.$helper.fUN_AmapLocation.start(
- // {
- // intervalTime: 1000*60,
- // isReport: true,
- // reportInterval: 5,
- // url: 'http://192.168.0.66/fun/open/test_json.do',
- // params: { a: 1, B: '测试', c: true },
- // headers: { a: '123', B: 'abcd' }
- // },
- // res => {
- // //见下方定位返回示例
- // console.log('====确认装车开启连续定位====', JSON.stringify(res));
- // //判断缓存数据条数,超过reportInterval时清空缓存,重新存入缓存
- // }
- // );
- // });
-
- // fUN_AmapLocation.permission({}, result => {
- // console.log('====fUN_AmapLocation定位====');
- // });
- // fUN_AmapLocation.hasLocationPermissions(function(result) {
- // console.log('====fUN_AmapLocation定位权限===='+ result)
- // });
- // startLocation与start均可
- // this.$helper.fUN_AmapLocation.start(
- // {
- // intervalTime: 1000*10,
- // isReport: false,
- // },
- // result => {
- // //见下方定位返回示例
- // console.log('====fUN_AmapLocation定位====', JSON.stringify(result));
- // }
- // );
-
- // let isOpenLocation= permision.checkSystemEnableLocation()
- // console.log("isOpenLocation",isOpenLocation)
- // this.requestAndroidPermission('android.permission.ACCESS_FINE_LOCATION')
- let type = uni.getSystemInfoSync().platform
- console.log(type)
- if (type == "android") {
- appUpdate()
- }
- // plus.push.getClientInfoAsync((info) => {
- // var name = 'clientId'
- // var value = info.clientid
- // that.$store.commit('$uStore', {
- // name,
- // value
- // });
- // uni.setStorageSync("clientId", info.clientid)
- // console.log("info.clientid", info.clientid)
- // }, err => {});
- // 监听在线消息事件
- // plus.push.addEventListener("receive", function(msg) {
- // var title = msg.content.split(':')[0]
- // var content = msg.content.split(':')[1]
- // let params = {
- // inApp: true, // app内横幅提醒
- // voice: true, // 声音提醒
- // vibration: true, // 振动提醒
- // messageType: "",
- // messageTitle: title,
- // messageContent: content,
- // messageImage: 'https://taohaoliang.oss-cn-beijing.aliyuncs.com/app/logo.png'
- // }
- // console.log("msg", msg)
- // new app_push({
- // ...params
- // }).show();
- // var userInfo = uni.getStorageSync("userInfo")
- // var that = this
- // that.$request.baseRequest('get', '/notice/query/noticeNumber').then(res => {
- // if (res.data.data) {
- // let name = 'myTip';
- // let value = res.data.data.task;
- // that.$store.commit('$uStore', {
- // name,
- // value
- // });
- // if (value != 0 && value) {
- // uni.setTabBarBadge({
- // index: 4,
- // text: value + ""
- // })
- // }
- // name = 'taskTip';
- // value = res.data.data.task;
- // that.$store.commit('$uStore', {
- // name,
- // value
- // });
- // // name = 'contractTip';
- // // value = res.data.data.contractTip;
- // // that.$store.commit('$uStore', {
- // // name,
- // // value
- // // });
- // }
- // })
- // //其它逻辑
- // }, false);
- // //监听系统通知栏消息点击事件
- // plus.push.addEventListener('click', function(msg) {
- // //处理点击消息的业务逻辑代码
- // if (msg.content && msg.content.contains("任务")) {
- // uni.navigateTo({
- // url: '/pages/task/my_task'
- // })
- // } else if (msg.content && (msg.content.contains("合同") || msg.content.contains("交易"))) {
- // uni.navigateTo({
- // url: '/pageB/contract/contract'
- // })
- // }
- // }, false);
- // #endif
- // this.$socket.initWebIM(this.$ws, true, true)
- let userInfo = uni.getStorageSync('userInfo') || '';
- if (userInfo.id) {
- //更新登陆状态
- uni.getStorage({
- key: 'userInfo',
- success: (res) => {
- this.login(res.data);
- }
- });
- }
- },
- onShow: function() {
- console.log('App Show')
-
- },
- onHide: function() {
- console.log('App Hide')
- },
- }
- </script>
- <style>
- /*每个页面公共css */
- </style>
|