123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329 |
- <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: {
- ...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() {
- // #ifdef APP-PLUS
- console.log(uni.getStorageSync('userInfo'))
- if(uni.getStorageSync('userInfo')){
- that.$request.baseRequest('get', '/cargoOwnerInfo/firstAuthentication', {
- phone: 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>
|