diff --git a/common/http.interceptor.js b/common/http.interceptor.js index e380dc0..711e537 100644 --- a/common/http.interceptor.js +++ b/common/http.interceptor.js @@ -1,7 +1,7 @@ const install = (Vue, vm) => { uni.setStorageSync('deptId', 100); Vue.prototype.$u.http.setConfig({ - // baseUrl: 'http://192.168.2.19:4101', //键辉本地 + // baseUrl: 'http://192.168.2.124:4101', //键辉本地 // baseUrl: 'http://192.168.0.102:4101', //景森本地 baseUrl: 'https://ele.ccttiot.com/prod-api', //线上 // baseUrl: 'https://cc.ccttiot.com/prod-api', //叉车线上 diff --git a/components/tab-bar/tab-bar.vue b/components/tab-bar/tab-bar.vue index 23c14ff..24bea2a 100644 --- a/components/tab-bar/tab-bar.vue +++ b/components/tab-bar/tab-bar.vue @@ -157,7 +157,7 @@ let sceneValue = res.result let decodedValue = decodeURIComponent(sceneValue) this.sn = getQueryParam(decodedValue, 's') - this.$u.get("/app/orderDevice/mineUsing").then(res =>{ + this.$u.get("/app/order/mineProcessing").then(res =>{ if(res.code == 200){ if(res.data){ uni.switchTab({ diff --git a/page_fenbao/index.vue b/page_fenbao/index.vue index 1f2da35..36adaaa 100644 --- a/page_fenbao/index.vue +++ b/page_fenbao/index.vue @@ -36,7 +36,7 @@ methods: { // 确认开锁 btnkaisuo(){ - this.$u.get("/app/orderDevice/mineUsing").then(res =>{ + this.$u.get("/app/order/mineProcessing").then(res =>{ if(res.code == 200){ if(res.data){ uni.switchTab({ diff --git a/page_fenbao/storedlist/trueorder.vue b/page_fenbao/storedlist/trueorder.vue index 07d47c0..9b71cc5 100644 --- a/page_fenbao/storedlist/trueorder.vue +++ b/page_fenbao/storedlist/trueorder.vue @@ -446,6 +446,75 @@ + + + + + + + + + {{item.name == null ? '--' : item.name}}:{{item.contact == null ? '--' : item.contact}} + + + + 拨打 + + + + + + 在线客服 + + + + 温馨提示 + + + 客服电话高峰期可能遇忙,请耐心等待 + + + + + + + + + + {{wenbentxt}} + + + + + + + + + × + + + + 蓝牙连接失败 + + + 请检查手机或微信蓝牙授权是否打开 + + + 还是不行查看教程 + + + + + + 联系客服 + + + 点击重试 + + + + @@ -470,7 +539,7 @@ yucun: '', suitId: '', yucobj: {}, - ggobj:{}, + ggobj:null, channelId: '', sn: '', tit: '', @@ -502,7 +571,14 @@ videoUrl:'', videoPath:'', token:'', - areaNeedCheckVideo:false + areaNeedCheckVideo:false, + jiance:false, + shibainum:0, + wenbentxt:'', + wenbentxtflag:false, + ljsbflag:false, + kefuflag: false, + kefulist: [], } }, onLoad(option) { @@ -511,18 +587,24 @@ 'isStart': true }) xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent) - this.$u.get("/app/orderDevice/mineUsing").then((res) => { + uni.getLocation({ + type: 'gcj02', + success: function (lb) { + }, + fail: function (error) { + console.log('未获取定位'); + // 在这里处理获取位置信息失败的情况 + } + }) + this.$u.get("/app/order/mineProcessing").then((res) => { if (res.code == 200) { if (res.data) { uni.switchTab({ - url:'/pages/myorder/returned/index' + url:'/pages/index/index' }) - } else { - - } + } } }) - this.getQiniuToken() console.log(option) if (option.modelId) { uni.showLoading({ @@ -530,11 +612,11 @@ mask: true }) setTimeout(()=>{ - this.$u.get("/app/orderDevice/mineUsing").then(res =>{ + this.$u.get("/app/order/mineProcessing").then(res =>{ if(res.code == 200){ if(res.data){ uni.switchTab({ - url:'/pages/nearbystores/index' + url:'/pages/index/index' }) this.zhezhaoflag = false uni.hideLoading() @@ -544,9 +626,15 @@ uni.hideLoading() this.modelId = option.modelId this.chesn = option.sn + this.getQiniuToken() this.gettaocan() this.getcheliang() } + }else if(res.code == 401){ + this.modelId = option.modelId + this.chesn = option.sn + this.zhezhaoflag = false + this.logoflag = true } }) },1000) @@ -556,11 +644,11 @@ mask: true }) setTimeout(()=>{ - this.$u.get("/app/orderDevice/mineUsing").then((res) => { + this.$u.get("/app/order/mineProcessing").then((res) => { if (res.code == 200) { if (res.data) { uni.switchTab({ - url:'/pages/nearbystores/index' + url:'/pages/index/index' }) this.zhezhaoflag = false uni.hideLoading() @@ -584,29 +672,26 @@ this.bikeobj = res.data this.modelId = res.data.modelId this.areaNeedCheckVideo = res.data.areaNeedCheckVideo - if(res.data.onlineStatus == 0){ - this.mac = res.data.mac - console.log(this.mac) - this.findDevice() - } + this.mac = res.data.mac this.gettaocan() this.getcheliang() + this.getQiniuToken() } else { - uni.showModal({ - title: '提示', - content:'当前车辆不可以', - showCancel: false, - confirmText: '知道了' - }) - setTimeout(() => { - if (this.chesn == '') { //判断是直接从微信扫码进来的点击返回回到首页 - uni.switchTab({ - url: '/pages/nearbystores/index' - }) - } else { //不是则返回上一级 - uni.navigateBack() - } - }, 2000) + // uni.showModal({ + // title: '提示', + // content:'当前车辆不可用', + // showCancel: false, + // confirmText: '知道了' + // }) + // setTimeout(() => { + // if (this.chesn == '') { //判断是直接从微信扫码进来的点击返回回到首页 + // uni.switchTab({ + // url: '/pages/index/index' + // }) + // } else { //不是则返回上一级 + // uni.navigateBack() + // } + // }, 2000) } }else{ uni.showModal({ @@ -618,6 +703,9 @@ } }) } + }else if(res.code == 401){ + this.zhezhaoflag = false + this.logoflag = true }else{ this.tit= '确认订单页' this.zhezhaoflag = false @@ -636,31 +724,28 @@ if (res.data) { console.log(res.data); this.bikeobj = res.data + this.mac = res.data.mac this.areaNeedCheckVideo = res.data.areaNeedCheckVideo this.modelId = res.data.modelId - if(res.data.onlineStatus == 0){ - this.mac = res.data.mac - console.log(this.mac); - this.findDevice() - } this.gettaocan() this.getcheliang() + this.getQiniuToken() } else { - uni.showModal({ - title: '提示', - content: '当前车辆不可用', - showCancel: false, - confirmText: '知道了' - }) - setTimeout(() => { - if (this.chesn == '') { //判断是直接从微信扫码进来的点击返回回到首页 - uni.switchTab({ - url: '/pages/nearbystores/index' - }) - } else { //不是则返回上一级 - uni.navigateBack() - } - }, 1500) + // uni.showModal({ + // title: '提示', + // content: '当前车辆不可用', + // showCancel: false, + // confirmText: '知道了' + // }) + // setTimeout(() => { + // if (this.chesn == '') { //判断是直接从微信扫码进来的点击返回回到首页 + // uni.switchTab({ + // url: '/pages/index/index' + // }) + // } else { //不是则返回上一级 + // uni.navigateBack() + // } + // }, 1500) } }else{ uni.showModal({ @@ -679,25 +764,135 @@ this.getgg() this.gethuiyuan() },1500) + console.log(this.sn,'03333333303333333'); }, onShow() { }, onHide() { - xBlufi.notifyStartDiscoverBle({ - 'isStart': false - }) - xBlufi.listenDeviceMsgEvent(false, this.funListenDeviceMsgEvent) - console.log('likai00'); + }, onUnload() { - xBlufi.notifyStartDiscoverBle({ - 'isStart': false - }) - xBlufi.listenDeviceMsgEvent(false, this.funListenDeviceMsgEvent) - console.log('likai11'); + }, methods: { + // 点击查看教程 + btnjc(){ + uni.navigateTo({ + url:'/page_user/yongche/index?type=2' + }) + }, + // 点击重试 + btnchongshi(){ + this.ljsbflag = false + this.wenbentxtflag = true + this.wenbentxt = '开锁中...' + let xllat = null + let xllng = null + uni.getLocation({ + type: 'wgs84', + success: (res) => { + xllat = res.latitude + xllng = res.longitude + }, + fail: (err) => { + console.error('获取位置失败:', err) + } + }) + this.$u.put(`/app/order/openDevice?orderId=${this.bstId}&requiredIot=true&lon=${xllng}&lat=${xllat}`).then(res =>{ + if(res.code == 200){ + uni.switchTab({ + url: '/pages/index/index?orderid=' + this.bstId + }) + }else if(res.code == 20001){ + this.wenbentxtflag = true + this.wenbentxt = '蓝牙开锁中...' + let that = this + const findDevice = () =>{ + that.ver_dataflag = 2 + const matchedDevice = that.devicesarr.find(device => { + return device.name.slice(-12) == that.mac.slice(-12) + }) + if (matchedDevice) { + xBlufi.notifyStartDiscoverBle({ + 'isStart': false + }) + xBlufi.notifyConnectBle({ + isStart: true, + deviceId: matchedDevice.deviceId, + name: matchedDevice.name + }) + that.deviceid = matchedDevice.deviceId + that.devicename = matchedDevice.name + setTimeout(()=>{ + if(that.ver_dataflag == 3){ + xBlufi.notifySendCustomData({ + customData: "11opensub5@" + }) + that.wenbentxt = '' + that.wenbentxtflag = false + let flag = false + that.zhezhaoflag = true + that.$u.put(`/app/order/openDevice?orderId=${that.bstId}&requiredIot=false&lon=${xllng}&lat=${xllat}`).then((res) =>{}) + setTimeout(()=>{ + uni.switchTab({ + url: '/pages/index/index?orderid=' + that.bstId + }) + },2000) + }else{ + that.ver_dataflag = 1 + that.shibainum = 0 + that.wenbentxt = '' + that.wenbentxtflag = false + that.ljsbflag = true + } + },4000) + } else { + if(that.shibainum < 3){ + that.shibainum++ + that.findDeviceTimer = setTimeout(findDevice.bind(that), 1000) // 使用 bind 保持 this 上下文 + }else{ + that.ver_dataflag = 1 + that.shibainum = 0 + that.wenbentxt = '' + that.wenbentxtflag = false + that.ljsbflag = true + } + } + } + findDevice() + }else{ + uni.showToast({ + title: res.msg, + icon: 'none', + duration: 2000 + }) + } + }) + }, + // 点击咨询客服 + btnkefu(){ + this.$u.get(`/app/customerService/list?pageNum=1&pageSize=999&areaId=${this.bikeobj.areaId}`).then(res => { + if(res.code == 200){ + if(res.rows.length > 0){ + this.kefulist = res.rows + this.kefuflag = true + }else{ + uni.showToast({ + title: '当前运营区暂无客服', + icon: 'none', + duration: 2000 + }) + } + }else{ + uni.showToast({ + title: res.msg, + icon: 'none', + duration: 2000 + }) + } + }) + }, getQiniuToken() { console.log('diaou'); this.$u.get("/common/qiniuToken").then((res) => { @@ -885,41 +1080,15 @@ url:'/page_fenbao/huiyuan/index?areaId=' + this.bikeobj.areaId }) }, - - // 判断离线连接蓝牙 - findDevice() { - // 使用 find 方法查找匹配的设备 - // console.log(this.devicesarr); - const matchedDevice = this.devicesarr.find(device => { - // console.log(device.name, this.mac, '111') - return device.name.slice(-12) == this.mac.slice(-12) - }) - if (matchedDevice) { - // 找到匹配的设备 - xBlufi.notifyStartDiscoverBle({ - 'isStart': false - }) - xBlufi.notifyConnectBle({ - isStart: true, - deviceId: matchedDevice.deviceId, - name: matchedDevice.name - }) - this.deviceid = matchedDevice.deviceId - this.devicename = matchedDevice.name - console.log(this.deviceid, '11221') - } else { - this.findDeviceTimer = setTimeout(this.findDevice.bind(this), 1000) // 使用 bind 保持 this 上下文 - } - }, // 获取附近蓝牙设备列表 funListenDeviceMsgEvent: function(options) { switch (options.type) { case xBlufi.XBLUFI_TYPE.TYPE_STATUS_CONNECTED: if (!options.result) { - console.log('断开'); this.ver_dataflag = 1 console.log(this.ver_dataflag,'断开断开'); - this.findDevice() + clearTimeout(this.uploadTimer) //清除每十秒传一次的定时 + this.jiance = true } break; case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS: @@ -932,7 +1101,6 @@ if (options.result == true) { setTimeout(() => { this.ver_dataflag = 3 - uni.hideLoading() }, 2000) xBlufi.notifyInitBleEsp32({ deviceId: this.deviceid @@ -940,20 +1108,18 @@ this.deviceid = options.data.deviceId this.name = this.name }else{ - uni.hideLoading() - this.findDevice() + this.ver_dataflag = 1 } break; - // case xBlufi.XBLUFI_TYPE.TYPE_RECIEVE_CUSTON_DATA: - // console.log("1收到设备发来的自定义数据结果:", options.data) - // break; + case xBlufi.XBLUFI_TYPE.TYPE_RECIEVE_CUSTON_DATA: + console.log("1收到设备发来的自定义数据结果:", options.data) + break; case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS_START: if (!options.result) { console.log('蓝牙未开启') + this.jiance = true return - } else { - this.lanyaflag = false - } + } break; } }, @@ -1002,38 +1168,15 @@ }, // 点击进行支付 btnzhifu() { + if(this.jiance == true){ + xBlufi.initXBlufi(1) + xBlufi.notifyStartDiscoverBle({ + 'isStart': true + }) + xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent) + } if(this.jieliuflag == true){ this.jieliuflag = false - if(this.bikeobj.onlineStatus == 0){ - if(this.ver_dataflag == 3){ - this.getlyzf() - }else{ - uni.showLoading({ - title: '车辆连接中...', - mask: true - }) - setTimeout(()=>{ - if(this.ver_dataflag == 3){ - uni.hideLoading() - }else{ - uni.hideLoading() - let that = this - uni.showModal({ - title: '提示', - content: '连接失败,是否重新连接?', - showCancel: true, - success: function(res) { - if (res.confirm) { - that.btnzhifu() - } else if (res.cancel) { - - } - } - }) - } - },10000) - } - }else{ if (this.bikeobj.areaAuthentication == true) { //判断是否需要实名认证 this.$u.get("/getInfo").then(res => { if (res.code == 200) { @@ -1111,235 +1254,12 @@ }) this.getzf() } - } setTimeout(()=>{ this.jieliuflag = true },5000) } }, - // 蓝牙支付 - getlyzf(){ - if (this.bikeobj.areaAuthentication == true) { //判断是否需要实名认证 - this.$u.get("/getInfo").then(res => { - if (res.code == 200) { - if (res.user.isReal == false) { //未实名需要去实名才能进行下单 - uni.showModal({ - title: '提示', - content: '您当前还未实名认证,是否前去实名认证?', - showCancel: true, - success: function(res) { - if (res.confirm) { - uni.navigateTo({ - url: '/page_user/shiming' - }) - } else if (res.cancel) { - - } - } - }) - }else{ - if (this.checked == false) { - let that = this - uni.showModal({ - title: '提示', - content: '您是否已经阅读完,并且同意此《电动车租赁协议》?', - showCancel: true, - success: function(res) { - if (res.confirm) { - that.checked = true - uni.showLoading({ - title: '加载中...', - mask: true - }) - that.getlyxd() - } else if (res.cancel) { - console.log('取消') // 用户点击取消 - } - } - }) - } else { - uni.showLoading({ - title: '加载中...', - mask: true - }) - this.getlyxd() - } - } - }else if(res.code == 401){ - this.logoflag = true - } - }) - } else if (this.checked == false) { - let that = this - uni.showModal({ - title: '提示', - content: '您是否已经阅读完,并且同意此《电动车租赁协议》?', - showCancel: true, - success: function(res) { - if (res.confirm) { - that.checked = true - uni.showLoading({ - title: '加载中...', - mask: true - }) - that.getlyxd() - } else if (res.cancel) { - console.log('取消') // 用户点击取消 - } - } - }) - } else { - uni.showLoading({ - title: '加载中...', - mask: true - }) - this.getlyxd() - } - }, - // 蓝牙下单 - getlyxd(){ - uni.getLocation({ - type: 'gcj02', // 国内地图更兼容 - isHighAccuracy: true, - accuracy:'best', - success: (res) => { - console.log('精确坐标:', res); - this.lat = res.latitude; - this.lon = res.longitude; - }, - fail: (err) => { - console.error('获取位置失败:', err); - this.lat = null - this.lon = null - } - }); - if(this.ver_dataflag == 3){ - let data = { - deviceId: this.bikeobj.id, - suitId: this.suitId, - price: this.yucobj, - appId: this.$store.state.appid, - channelId: this.channelId, - creditUserId:this.selectedSubPayment, - checkVideo:this.videoUrl - } - uni.showLoading({ - title: '加载中...', - mask: true - }) - this.$u.post(`/app/order`, data).then((resp) => { - if (resp.code == 200) { - console.log(resp.data.needPay,'resp.data.needPayresp.data.needPay'); - if(resp.data.needPay == true){ - uni.requestPayment({ - provider: 'wxpay', - timeStamp: resp.data.payParams.timeStamp, - nonceStr: resp.data.payParams.nonceStr, - package: resp.data.payParams.packageVal, - signType: resp.data.payParams.signType, - paySign: resp.data.payParams.paySign, - success: (respc) => { - xBlufi.notifySendCustomData({ - customData: "11open@" - }) - console.log(respc, '支付成功') - uni.showLoading({ - title: '加载中...', - mask: true - }) - this.zhezhaoflag = true - let data = { - mac:this.mac, - reason:'还车', - command:'open', - longitude:this.lon, - latitude:this.lat, - result:'成功' - } - this.$u.post(`/app/commandLog/bluetooth`,data).then(res => { - console.log(res,'蓝牙'); - }) - setTimeout(()=>{ - this.$u.put(`/app/pay/refreshPayResult?no=${resp.data.pay.no}`).then((res) => { - uni.switchTab({ - url: '/pages/myorder/returned/index?orderid=' + resp.data.pay.bstId + '&vate=' + this.devicesarr - }) - uni.hideLoading() - }) //刷新支付结果 - },2000) - }, - fail(err) { - setTimeout(() => { - uni.hideLoading() - }, 1000) - console.log('取消或者支付失败') - } - }) - }else{ - console.log('111'); - setTimeout(()=>{ - uni.switchTab({ - url: '/pages/myorder/returned/index?orderid=' + resp.data.pay.bstId + '&vate=' + this.devicesarr - }) - uni.hideLoading() - },2000) - } - }else if(resp.code == 10001){ - uni.showModal({ - title: '提示', - content: '您当前还未实名认证,是否前去实名认证?', - showCancel: true, - success: function(res) { - if (res.confirm) { - uni.navigateTo({ - url: '/page_user/shiming' - }) - } else if (res.cancel) { - - } - } - }) - }else if(resp.code == 10002){ - uni.showModal({ - title: '提示', - content: '您当前驾驶证未认证,是否前去认证?', - showCancel: true, - success: function(res) { - if (res.confirm) { - uni.navigateTo({ - url: 'page_user/renzheng/jiashizheng' - }) - } else if (res.cancel) { - - } - } - }) - } else { - uni.hideLoading() - uni.showToast({ - title: resp.msg, - icon: 'none', - duration: 2000 - }) - } - }).catch(e => { - uni.hideLoading() - }) - }else{ - uni.showModal({ - title: '提示', - content: '设备未连接,请靠近车辆等待连接', - showCancel: false, - success: function(res) { - if (res.confirm) { - - } else if (res.cancel) { - - } - } - }) - } - }, + // 下单 getzf() { let data = { @@ -1367,19 +1287,99 @@ paySign: resp.data.payParams.paySign, success: (respc) => { console.log(respc, '支付成功') - uni.showLoading({ - title: '加载中...', - mask: true + this.bstId = resp.data.pay.bstId + this.wenbentxtflag = true + this.wenbentxt = '开锁中...' + let xllat = null + let xllng = null + uni.getLocation({ + type: 'wgs84', + success: (res) => { + xllat = res.latitude + xllng = res.longitude + }, + fail: (err) => { + console.error('获取位置失败:', err) + } }) - this.zhezhaoflag = true - this.$u.put(`/app/pay/refreshPayResult?no=${resp.data.pay.no}`).then((res) => { - setTimeout(() => { - uni.switchTab({ - url: '/pages/myorder/returned/index?orderid=' + resp.data.pay.bstId + this.$u.put(`/app/order/openDevice?orderId=${this.bstId}&requiredIot=true&lon=${xllng}&lat=${xllat}`).then(res =>{ + if(res.code == 200){ + this.$u.put(`/app/pay/refreshPayResult?no=${resp.data.pay.no}`).then((res) => { + setTimeout(() => { + uni.switchTab({ + url: '/pages/index/index?orderid=' + this.bstId + }) + }, 2000) + }) //刷新支付结果 + }else if(res.code == 20001){ + this.wenbentxtflag = true + this.wenbentxt = '蓝牙开锁中...' + let that = this + const findDevice = () =>{ + that.ver_dataflag = 2 + const matchedDevice = that.devicesarr.find(device => { + return device.name.slice(-12) == that.mac.slice(-12) + }) + if (matchedDevice) { + xBlufi.notifyStartDiscoverBle({ + 'isStart': false + }) + xBlufi.notifyConnectBle({ + isStart: true, + deviceId: matchedDevice.deviceId, + name: matchedDevice.name + }) + that.deviceid = matchedDevice.deviceId + that.devicename = matchedDevice.name + setTimeout(()=>{ + if(that.ver_dataflag == 3){ + xBlufi.notifySendCustomData({ + customData: "11opensub5@" + }) + that.wenbentxt = '' + that.wenbentxtflag = false + let flag = false + that.zhezhaoflag = true + that.$u.put(`/app/order/openDevice?orderId=${that.bstId}&requiredIot=false&lon=${xllng}&lat=${xllat}`).then(res =>{}) + that.$u.put(`/app/pay/refreshPayResult?no=${resp.data.pay.bstId}`).then((res) => { + setTimeout(() => { + uni.switchTab({ + url: '/pages/index/index?orderid=' + resp.data.pay.bstId + }) + }, 2000) + }) //刷新支付结果 + }else{ + that.ver_dataflag = 1 + that.shibainum = 0 + that.wenbentxt = '' + that.wenbentxtflag = false + that.ljsbflag = true + } + },4000) + } else { + if(that.shibainum < 3){ + that.shibainum++ + that.findDeviceTimer = setTimeout(findDevice.bind(that), 1000) // 使用 bind 保持 this 上下文 + }else{ + that.ver_dataflag = 1 + that.shibainum = 0 + that.wenbentxt = '' + that.wenbentxtflag = false + that.ljsbflag = true + } + } + } + findDevice() + }else{ + this.wenbentxt = '' + this.wenbentxtflag = false + uni.showToast({ + title: res.msg, + icon: 'none', + duration: 3000 }) - uni.hideLoading() - }, 2000) - }) //刷新支付结果 + } + }) }, fail(err) { setTimeout(() => { @@ -1392,7 +1392,7 @@ this.zhezhaoflag = true setTimeout(() => { uni.switchTab({ - url: '/pages/myorder/returned/index?orderid=' + resp.data.pay.bstId + url: '/pages/index/index?orderid=' + resp.data.pay.bstId }) uni.hideLoading() }, 2000) @@ -1450,10 +1450,11 @@ if (res.code == 200) { this.bikeobj = res.data this.areaNeedCheckVideo = res.data.areaNeedCheckVideo - if(res.data.onlineStatus == 0){ - this.mac = res.data.mac - this.findDevice() - } + this.mac = res.data.mac + // if(res.data.onlineStatus == 0){ + // this.mac = res.data.mac + // this.findDevice() + // } console.log(res.data,'020202'); this.$u.put(`/app/user/bindArea?areaId=${res.data.areaId}`).then(resp =>{}) } @@ -1462,10 +1463,11 @@ this.$u.get(`/app/device/availableDetail?sn=${this.chesn}`).then((res) => { if (res.code == 200) { this.areaNeedCheckVideo = res.data.areaNeedCheckVideo - if(res.data.onlineStatus == 0){ - this.mac = res.data.mac - this.findDevice() - } + this.mac = res.data.mac + // if(res.data.onlineStatus == 0){ + // this.mac = res.data.mac + // this.findDevice() + // } this.bikeobj = res.data } }) @@ -1562,10 +1564,42 @@ } this.$u.post("/wxLogin", datas).then((res) => { if (res.code == 200) { - wx.setStorageSync('token', res.token) - this.gettaocan() - this.getQiniuToken() - // this.fanganindex = 0 + wx.setStorageSync('token', res.token); + this.$u.get(`/app/device/availableDetail?sn=${this.sn == '' ? this.chesn : this.sn}`).then((res) => { + if (res.code == 200) { + if (res.data) { + this.bikeobj = res.data + this.mac = res.data.mac + this.areaNeedCheckVideo = res.data.areaNeedCheckVideo + this.modelId = res.data.modelId + this.gettaocan() + this.getcheliang() + } else { + // uni.showModal({ + // title: '提示', + // content: '当前车辆不可用', + // showCancel: false, + // confirmText: '知道了' + // }) + // setTimeout(() => { + // if (this.chesn == '') { //判断是直接从微信扫码进来的点击返回回到首页 + // uni.switchTab({ + // url: '/pages/index/index' + // }) + // } else { //不是则返回上一级 + // uni.navigateBack() + // } + // }, 1500) + } + }else{ + uni.showModal({ + title: '提示', + content: res.msg, + showCancel: false, + confirmText: '知道了' + }) + } + }) this.tit = '确认订单页' this.logoflag = false } else { @@ -1595,6 +1629,152 @@ /deep/ .u-checkbox { width: 40rpx; } + .kefutc { + animation: fadeIn 0.5s ease-in-out forwards; + position: fixed; + top: 660rpx; + left: 50%; + transform: translateX(-50%); + z-index: 1001; + + .bot { + margin-top: 30rpx; + + .wz { + margin-top: 10rpx; + font-weight: 600; + font-size: 28rpx; + color: #3D3D3D; + } + + .wzs { + margin-top: 10rpx; + font-size: 24rpx; + color: #7C7C7C; + } + } + + .top { + width: 538rpx; + height: 122rpx; + background: #FFFFFF; + box-shadow: 0rpx 0rpx 10rpx 0rpx rgba(0, 0, 0, 0.1); + border-radius: 14rpx 14rpx 14rpx 14rpx; + display: flex; + justify-content: space-between; + align-items: center; + padding-right: 14rpx; + box-sizing: border-box; + margin-top: 20rpx; + + .dianhua { + font-weight: 600; + font-size: 28rpx; + color: #3D3D3D; + padding-left: 26rpx; + box-sizing: border-box; + } + + .boda { + width: 94rpx; + height: 94rpx; + background: #DCEDFF; + border-radius: 8rpx 8rpx 8rpx 8rpx; + text-align: center; + padding-top: 8rpx; + box-sizing: border-box; + + text { + display: block; + } + } + } + + image { + position: absolute; + top: -280rpx; + z-index: -1; + left: 50%; + transform: translateX(-50%); + width: 614rpx; + height: 748rpx; + } + } + @keyframes rotate360 { + 0% { + transform: rotate(0deg); + } + 100% { + transform: rotate(360deg); + } + } + .tongyi{ + width: 100%; + height: 580rpx; + background: #FFFFFF; + border-radius: 3rpx 3rpx 0rpx 0rpx; + position: fixed; + bottom: 0; + left: 50%; + transform: translateX(-50%); + z-index: 999; + border-radius: 30rpx 30rpx 0 0; + text-align: center; + .anniu{ + width: 100%; + display: flex; + justify-content: space-between; + margin-top: 30rpx; + .lx{ + width: 338rpx; + height: 90rpx; + border-radius: 10rpx; + border: 2rpx solid #808080; + text-align: center; + line-height: 90rpx; + font-size: 40rpx; + color: #808080; + } + .zx{ + width: 338rpx; + height: 90rpx; + background: #4C97E7; + border-radius: 10rpx; + text-align: center; + line-height: 90rpx; + font-size: 40rpx; + color: #FFFFFF; + } + } + .top{ + display: flex; + justify-content: center; + align-items: center; + margin-top: 30rpx; + image{ + width: 50rpx; + height: 50rpx; + margin-right: 8rpx; + animation: rotate360 1.2s linear infinite; + } + font-weight: 600; + font-size: 32rpx; + color: #3D3D3D; + } + .tops{ + margin-top: 30rpx; + image{ + width: 50rpx; + height: 50rpx; + margin-right: 8rpx; + } + } + .ddc{ + width: 610rpx; + height: 314rpx; + margin-top: 40rpx; + } + } .cont { width: 100%; padding: 0 39rpx; diff --git a/page_shanghu/guanli/device_detail.vue b/page_shanghu/guanli/device_detail.vue index 3039013..d84c8ad 100644 --- a/page_shanghu/guanli/device_detail.vue +++ b/page_shanghu/guanli/device_detail.vue @@ -54,7 +54,7 @@ + mode="aspectFit" /> @@ -226,7 +226,7 @@ 二维码 - + @@ -502,7 +502,9 @@ isVisible: true, glowInterval: null, lat:'', - lon:'' + lon:'', + shibainum:0, + jiance:false } }, onLoad(e) { @@ -511,6 +513,11 @@ this.deptId = uni.getStorageSync('deptId') }, onShow() { + xBlufi.initXBlufi(1) + xBlufi.notifyStartDiscoverBle({ + 'isStart': true + }) + xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent) this.getyunying() uni.getLocation({ type: 'gcj02', // 国内地图更兼容 @@ -738,9 +745,7 @@ duration: 2000 }) } - setTimeout(() => { this.jieliuflag = true - }, 3000) } }, getlanya() { @@ -797,6 +802,7 @@ if (options.result == true) { setTimeout(() => { this.ver_dataflag = 3 + this.jiance = false }, 2000) xBlufi.notifyInitBleEsp32({ deviceId: this.deviceid @@ -815,6 +821,7 @@ case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS_START: if (!options.result) { console.log('蓝牙未开启') + this.jiance = true return } else { this.lanyaflag = false @@ -1143,15 +1150,21 @@ this.showvehicle = false }, btn(num) { + if(this.jiance == true){ + xBlufi.initXBlufi(1) + xBlufi.notifyStartDiscoverBle({ + 'isStart': true + }) + xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent) + } if (this.jieliuflag == true) { this.jieliuflag = false this.showbtntip = false let data = [this.sn] if (num == 0) { uni.showLoading({ - title: '加载中...' + title: '车辆开锁中...' }) - console.log('点击了....1') if (this.ver_dataflag == 3) { xBlufi.notifySendCustomData({ customData: "11opensub5@" @@ -1173,9 +1186,7 @@ result:'成功' } this.$u.post(`/app/commandLog/bluetooth`,data).then(res => {}) - setTimeout(() => { this.jieliuflag = true - }, 2000) } else { uni.hideLoading() uni.showToast({ @@ -1183,35 +1194,125 @@ icon: 'none', duration: 2000 }) - setTimeout(() => { this.jieliuflag = true - }, 2000) } }) } else { this.$u.put(`/bst/device/iot/unlock?id=${this.sn}&requiredIot=true`).then((res) => { if (res.code == 200) { - this.deviceInfo() - uni.showToast({ - title: '操作成功', - icon: 'success', - duration: 3000 - }) - setTimeout(() => { - this.jieliuflag = true - }, 2000) - }else if(res.code == 20001){ - uni.hideLoading() - uni.showModal({ - title: '提示', - content: '设备离线,请进行连接蓝牙开锁', - showCancel: false, - success: function(res) { - if (res.confirm) { - + if(res.data.db == 1 && res.data.iot == false){ + uni.hideLoading() + uni.showLoading({ + title: '蓝牙开锁中...', + mask: true + }) + const findDevice = () =>{ + this.ver_dataflag = 2 + const matchedDevice = this.devicesarr.find(device => { + return device.name.slice(-12) == this.mac.slice(-12) + }) + if (matchedDevice) { + xBlufi.notifyStartDiscoverBle({ + 'isStart': false + }) + xBlufi.notifyConnectBle({ + isStart: true, + deviceId: matchedDevice.deviceId, + name: matchedDevice.name + }) + this.deviceid = matchedDevice.deviceId + this.devicename = matchedDevice.name + setTimeout(()=>{ + if(this.ver_dataflag == 3){ + uni.hideLoading() + xBlufi.notifySendCustomData({ + customData: "11opensub5@" + }) + this.$u.put(`/bst/device/iot/unlock?id=${this.sn}&requiredIot=false`).then((res) => { + if (res.code == 200) { + this.deviceInfo() + uni.showToast({ + title: '操作成功', + icon: 'success', + duration: 3000 + }) + let data = { + mac:this.mac, + reason:'商户开锁', + command:'11opensub5@', + longitude:this.lon, + latitude:this.lat, + result:'成功' + } + this.$u.post(`/app/commandLog/bluetooth`,data).then(res => {}) + + this.jieliuflag = true + + } else { + uni.hideLoading() + uni.showToast({ + title: res.msg, + icon: 'none', + duration: 2000 + }) + + this.jieliuflag = true + + } + }) + }else{ + this.ver_dataflag = 1 + this.shibainum = 0 + this.jieliuflag = true + uni.hideLoading() + uni.showModal({ + title: '提示', + content: '车辆开锁失败,请检查手机蓝牙是否打开或微信蓝牙是否授权,开启手机定位', + showCancel: false, + success: function(res) { + if (res.confirm) { + + } else if (res.cancel) { + + } + } + }) + } + },4000) + } else { + if(this.shibainum < 3){ + this.shibainum++ + this.findDeviceTimer = setTimeout(findDevice.bind(this), 1000) // 使用 bind 保持 this 上下文 + }else{ + this.jieliuflag = true + this.ver_dataflag = 1 + this.shibainum = 0 + uni.hideLoading() + uni.showModal({ + title: '提示', + content: '车辆开启失败,可让用户在车辆旁边点击解锁骑行', + showCancel: false, + success: function(res) { + if (res.confirm) { + + } else if (res.cancel) { + + } + } + }) + } } } - }) + findDevice() + }else{ + this.deviceInfo() + uni.showToast({ + title: '操作成功', + icon: 'success', + duration: 3000 + }) + } + this.jieliuflag = true } else { uni.hideLoading() uni.showToast({ @@ -1219,20 +1320,25 @@ icon: 'none', duration: 2000 }) - setTimeout(() => { + this.jieliuflag = true - }, 2000) + } }) } } else if (num == 1) { uni.showLoading({ - title: '加载中...' + title: '锁车中...' }) if (this.ver_dataflag == 3) { xBlufi.notifySendCustomData({ customData: "11closesub200@" }) + setTimeout(()=>{ + xBlufi.notifySendCustomData({ + customData: "11reboot@" + }) + },2000) this.$u.put(`/bst/device/iot/lock?id=${this.sn}&requiredIot=false`).then((res) => { if (res.code == 200) { this.deviceInfo() @@ -1244,38 +1350,21 @@ let data = { mac:this.mac, reason:'商户关锁', - command:'11', + command:'11closesub200@', result:'成功' } this.$u.post(`/app/commandLog/bluetooth`,data).then(res => {}) - setTimeout(() => { - // closesub200@', - // longitude:this.lon, - // latitude:this.lat, this.jieliuflag = true - }, 2000) - }else if(res.code == 20001){ - uni.hideLoading() - uni.showModal({ - title: '提示', - content: '设备离线,请进行连接蓝牙关锁', - showCancel: false, - success: function(res) { - if (res.confirm) { - - } - } - }) - } else{ + }else{ uni.hideLoading() uni.showToast({ title: res.msg, icon: 'none', duration: 2000 }) - setTimeout(() => { + this.jieliuflag = true - }, 2000) + } }) } else { @@ -1287,9 +1376,112 @@ icon: 'success', duration: 3000 }) - setTimeout(() => { + this.jieliuflag = true - }, 2000) + + }else if(res.code == 20001){ + uni.showLoading({ + title: '蓝牙关锁中...', + mask: true + }) + const findDevice = () =>{ + this.ver_dataflag = 2 + const matchedDevice = this.devicesarr.find(device => { + return device.name.slice(-12) == this.mac.slice(-12) + }) + if (matchedDevice) { + xBlufi.notifyStartDiscoverBle({ + 'isStart': false + }) + xBlufi.notifyConnectBle({ + isStart: true, + deviceId: matchedDevice.deviceId, + name: matchedDevice.name + }) + this.deviceid = matchedDevice.deviceId + this.devicename = matchedDevice.name + setTimeout(()=>{ + if(this.ver_dataflag == 3){ + uni.hideLoading() + xBlufi.notifySendCustomData({ + customData: "11closesub200@" + }) + this.$u.put(`/bst/device/iot/lock?id=${this.sn}&requiredIot=false`).then((res) => { + if (res.code == 200) { + this.deviceInfo() + uni.showToast({ + title: '操作成功', + icon: 'success', + duration: 3000 + }) + let data = { + mac:this.mac, + reason:'商户关锁', + command:'11closesub200@', + longitude:this.lon, + latitude:this.lat, + result:'成功' + } + this.$u.post(`/app/commandLog/bluetooth`,data).then(res => {}) + + this.jieliuflag = true + + } else { + uni.hideLoading() + uni.showToast({ + title: res.msg, + icon: 'none', + duration: 2000 + }) + + this.jieliuflag = true + + } + }) + }else{ + this.jieliuflag = true + this.ver_dataflag = 1 + this.shibainum = 0 + uni.hideLoading() + uni.showModal({ + title: '提示', + content: '车辆开锁失败,请检查手机蓝牙是否打开或微信蓝牙是否授权,开启手机定位', + showCancel: false, + success: function(res) { + if (res.confirm) { + + } else if (res.cancel) { + + } + } + }) + } + },4000) + } else { + if(this.shibainum < 3){ + this.shibainum++ + this.findDeviceTimer = setTimeout(findDevice.bind(this), 1000) // 使用 bind 保持 this 上下文 + }else{ + this.jieliuflag = true + this.ver_dataflag = 1 + this.shibainum = 0 + uni.hideLoading() + uni.showModal({ + title: '提示', + content: '车辆解锁失败,请检查手机蓝牙是否打开或微信蓝牙是否授权,开启手机定位', + showCancel: false, + success: function(res) { + if (res.confirm) { + + } else if (res.cancel) { + + } + } + }) + } + } + } + findDevice() } else{ uni.hideLoading() uni.showToast({ @@ -1297,9 +1489,9 @@ icon: 'none', duration: 2000 }) - setTimeout(() => { + this.jieliuflag = true - }, 2000) + } }) } @@ -1316,18 +1508,16 @@ }); // 处理接口返回的数据,将边界数据转换为地图组件需要的折线结构 this.deviceInfo() - setTimeout(() => { + this.jieliuflag = true - }, 2000) + } else { uni.showToast({ title: res.msg, icon: 'none', duration: 2000 }) - setTimeout(() => { this.jieliuflag = true - }, 2000) } }) } else if (num == 3) { @@ -1343,9 +1533,7 @@ duration: 2000 }) this.deviceInfo() - setTimeout(() => { this.jieliuflag = true - }, 2000) } else { uni.showToast({ @@ -1353,14 +1541,12 @@ icon: 'none', duration: 2000 }) - setTimeout(() => { this.jieliuflag = true - }, 2000) } }) } else if (num == 4) { uni.showLoading({ - title: '加载中...' + title: '响铃中...' }) this.$u.put('/bst/device/iot/ring?id=' + this.sn).then((res) => { if (res.code == 200) { @@ -1370,11 +1556,79 @@ icon: 'success', duration: 2000 }) - setTimeout(() => { this.jieliuflag = true - }, 2000) - } else if (res.code == 200001) { - + } else if (res.code == 20001) { + uni.showLoading({ + title: '响铃中...', + mask: true + }) + const findDevice = () =>{ + this.ver_dataflag = 2 + const matchedDevice = this.devicesarr.find(device => { + return device.name.slice(-12) == this.mac.slice(-12) + }) + if (matchedDevice) { + xBlufi.notifyStartDiscoverBle({ + 'isStart': false + }) + xBlufi.notifyConnectBle({ + isStart: true, + deviceId: matchedDevice.deviceId, + name: matchedDevice.name + }) + this.deviceid = matchedDevice.deviceId + this.devicename = matchedDevice.name + setTimeout(()=>{ + if(this.ver_dataflag == 3){ + xBlufi.notifySendCustomData({ + customData: "11play1@" + }) + this.jieliuflag = true + uni.hideLoading() + }else{ + this.jieliuflag = true + this.ver_dataflag = 1 + this.shibainum = 0 + uni.hideLoading() + uni.showModal({ + title: '提示', + content: '响铃失败,请检查手机蓝牙是否打开或微信蓝牙是否授权,开启手机定位', + showCancel: false, + success: function(res) { + if (res.confirm) { + + } else if (res.cancel) { + + } + } + }) + } + },4000) + } else { + if(this.shibainum < 3){ + this.shibainum++ + this.findDeviceTimer = setTimeout(findDevice.bind(this), 1000) // 使用 bind 保持 this 上下文 + }else{ + this.jieliuflag = true + this.ver_dataflag = 1 + this.shibainum = 0 + uni.hideLoading() + uni.showModal({ + title: '提示', + content: '响铃失败,请检查手机蓝牙是否打开或微信蓝牙是否授权,开启手机定位', + showCancel: false, + success: function(res) { + if (res.confirm) { + + } else if (res.cancel) { + + } + } + }) + } + } + } + findDevice() } else { uni.hideLoading() uni.showToast({ @@ -1382,9 +1636,7 @@ icon: 'none', duration: 2000 }) - setTimeout(() => { this.jieliuflag = true - }, 2000) } }) } else if (num == 5) { @@ -1399,18 +1651,14 @@ duration: 2000 }); this.deviceInfo() - setTimeout(() => { this.jieliuflag = true - }, 2000) } else { uni.showToast({ title: res.msg, icon: 'none', duration: 2000 }) - setTimeout(() => { this.jieliuflag = true - }, 2000) } }) } else if (num == 6) { @@ -1425,25 +1673,21 @@ icon: 'success', duration: 2000 }) - setTimeout(() => { this.jieliuflag = true - }, 2000) } else { uni.showToast({ title: res.msg, icon: 'none', duration: 2000 }) - setTimeout(() => { this.jieliuflag = true - }, 2000) } }) } else if (num == 7) { this.showvehicle = true } else if (num == 8) { uni.showLoading({ - title: '加载中...' + title: '重启中...' }) this.$u.put('/bst/device/iot/reboot?id=' + this.sn).then((res) => { if (res.code == 200) { @@ -1453,18 +1697,88 @@ icon: 'success', duration: 2000 }) - setTimeout(() => { this.jieliuflag = true - }, 2000) + }else if(res.code == 20001){ + this.jieliuflag = true + uni.showLoading({ + title: '重启中...', + mask: true + }) + const findDevice = () =>{ + this.ver_dataflag = 2 + const matchedDevice = this.devicesarr.find(device => { + return device.name.slice(-12) == this.mac.slice(-12) + }) + if (matchedDevice) { + xBlufi.notifyStartDiscoverBle({ + 'isStart': false + }) + xBlufi.notifyConnectBle({ + isStart: true, + deviceId: matchedDevice.deviceId, + name: matchedDevice.name + }) + this.deviceid = matchedDevice.deviceId + this.devicename = matchedDevice.name + setTimeout(()=>{ + if(this.ver_dataflag == 3){ + xBlufi.notifySendCustomData({ + customData: "11reboot@" + }) + this.jieliuflag = true + uni.hideLoading() + }else{ + this.jieliuflag = true + this.ver_dataflag = 1 + this.shibainum = 0 + uni.hideLoading() + uni.showModal({ + title: '提示', + content: '重启失败,请检查手机蓝牙是否打开或微信蓝牙是否授权,开启手机定位', + showCancel: false, + success: function(res) { + if (res.confirm) { + + } else if (res.cancel) { + + } + } + }) + } + },4000) + } else { + if(this.shibainum < 3){ + this.shibainum++ + this.findDeviceTimer = setTimeout(findDevice.bind(this), 1000) // 使用 bind 保持 this 上下文 + }else{ + this.jieliuflag = true + this.ver_dataflag = 1 + this.shibainum = 0 + uni.hideLoading() + uni.showModal({ + title: '提示', + content: '重启失败,请检查手机蓝牙是否打开或微信蓝牙是否授权,开启手机定位', + showCancel: false, + success: function(res) { + if (res.confirm) { + + } else if (res.cancel) { + + } + } + }) + } + } + } + findDevice() + } else { uni.showToast({ title: res.msg, icon: 'none', duration: 3000 }) - setTimeout(() => { this.jieliuflag = true - }, 2000) } }) } else if (num == 9) { @@ -1479,18 +1793,14 @@ icon: 'success', duration: 2000 }) - setTimeout(() => { this.jieliuflag = true - }, 2000) } else { uni.showToast({ title: res.msg, icon: 'none', duration: 2000 }) - setTimeout(() => { this.jieliuflag = true - }, 2000) } }) } else if (num == 10) { @@ -1505,21 +1815,30 @@ icon: 'success', duration: 2000 }) - setTimeout(() => { this.jieliuflag = true - }, 2000) } else { uni.showToast({ title: res.msg, icon: 'none', duration: 2000 }) - setTimeout(() => { this.jieliuflag = true - }, 2000) } }) } + }else{ + this.jieliuflag = true + uni.hideLoading() + uni.showModal({ + title: '提示', + content: '请不要频繁点击', + showCancel: false, + success: function(res) { + if (res.confirm) { + + } + } + }) } }, btnyc() { @@ -1544,7 +1863,7 @@ this.deviceInfos = res.data this.mac = res.data.mac if (this.ver_dataflag != 3) { - this.getlanya() + // this.getlanya() } if (this.getnum == 0) { this.getArea() @@ -1943,7 +2262,6 @@ .page { padding-bottom: 400rpx; width: 750rpx; - .new_infocard { width: 750rpx; max-height: 100vh; diff --git a/page_user/guzhang/index.vue b/page_user/guzhang/index.vue index d020037..2d120a7 100644 --- a/page_user/guzhang/index.vue +++ b/page_user/guzhang/index.vue @@ -74,7 +74,9 @@ this.getQiniuToken() }, onLoad(e) { - + if(e.sn){ + this.sn = e.sn + } }, computed: { appointmentServiceFee() { diff --git a/page_user/hcshenhe.vue b/page_user/hcshenhe.vue index f34063b..fbfcee4 100644 --- a/page_user/hcshenhe.vue +++ b/page_user/hcshenhe.vue @@ -146,6 +146,10 @@ }) }, gethc(){ + uni.showLoading({ + title: '还车中...', + mask: true + }) if(this.flag == true){ let data = { orderId:this.orderId, @@ -198,12 +202,6 @@ this.$u.put(`/app/order/end`,data).then(res =>{ if (res.code == 200) { this.fjflag = false - uni.hideLoading() - setTimeout(()=>{ - uni.redirectTo({ - url:'/page_user/yongche/orderxq?id=' + this.orderId - }) - },1000) let data = { mac:this.mac, reason:'还车', @@ -215,9 +213,18 @@ this.$u.post(`/app/commandLog/bluetooth`,data).then(res => { console.log(res,'蓝牙') }) - xBlufi.notifySendCustomData({ - customData: "11reboot@" - }) + setTimeout(()=>{ + xBlufi.notifySendCustomData({ + customData: "11reboot@" + }) + setTimeout(()=>{ + uni.hideLoading() + uni.redirectTo({ + url:'/page_user/yongche/orderxq?id=' + this.orderId + }) + },1000) + },2000) + }else if(res.msg == null) { uni.hideLoading() uni.showToast({ diff --git a/page_user/luru/bind_mac.vue b/page_user/luru/bind_mac.vue index ad241c1..ed67d18 100644 --- a/page_user/luru/bind_mac.vue +++ b/page_user/luru/bind_mac.vue @@ -1,7 +1,7 @@ @@ -19,7 +22,7 @@ backgroundColor: "#fff", }, type:'', - obj:{}, + obj:'', tit:'' } }, @@ -27,7 +30,9 @@ this.type = option.type if(option.type == 0){ this.tit = '租车指南' - }else{ + }else if(option.type == 2){ + this.tit = '查看教程' + } else{ this.tit = '用车指南' } this.getqingqiu() diff --git a/page_user/yongche/orderxq.vue b/page_user/yongche/orderxq.vue index 318fd77..d19931c 100644 --- a/page_user/yongche/orderxq.vue +++ b/page_user/yongche/orderxq.vue @@ -336,8 +336,9 @@ channelobj:{} } }, - onLoad(e) { - this.id = e.id + onLoad(option) { + this.id = option.id + console.log(option,this.id,'020202020'); this.getyouhui() this.updateTrackData() this.orderInfo() @@ -579,7 +580,7 @@ const refunded = parseFloat(payRefunded) || 0; const refunding = parseFloat(payRefunding) || 0; const actualAmount = amount - (refunded + refunding); - return `${actualAmount.toFixed(2)}`; + return `${actualAmount}`; }, // 点击隐藏客服 btnkefu(){ diff --git a/pages.json b/pages.json index d049217..0ffe1e9 100644 --- a/pages.json +++ b/pages.json @@ -4,6 +4,13 @@ }, "lazyCodeLoading": "requiredComponents", "pages": [{ + "path": "pages/nearbystores/index", + "style": { + "navigationBarTitleText": "", + "enablePullDownRefresh": false, + "navigationStyle": "custom" + } + },{ "path": "pages/index/index", "style": { "navigationBarTitleText": "首页", @@ -12,13 +19,6 @@ "navigationBarTextStyle": "#FFFFFF", "navigationStyle": "custom" } - },{ - "path": "pages/nearbystores/index", - "style": { - "navigationBarTitleText": "", - "enablePullDownRefresh": false, - "navigationStyle": "custom" - } },{ "path": "pages/login/login", "style": { diff --git a/pages/index/index.vue b/pages/index/index.vue index c70ad7e..f00a1e9 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -1,168 +1,163 @@ @@ -219,238 +260,874 @@ export default { data() { return { - bgc: { - backgroundColor: "#F4FCFF", - }, - latitude:'', - longitude:'', - covers:[], - kefuflag:false, - gonggaoxq:{}, - gonggaoflag:false, - announcements: {}, - kefulist:[], - lists: [], - info:{}, - tiaozhuanlist:[], - jinweidu:'', - kefuarr:[], - fjflag: false, - orderflag: false, - iconobj:this.$store.state.iconobj, - orderobj: {}, - orderAreaReturnVerify:'', - latsc:'', - lngsc:'', - fajinobj:{} + iconobj:this.$store.state.iconobj, + bgc: { + backgroundColor: "", + }, + latitude: '', + longitude: '', + lat: '', + lng: '', + latsc: '', + lngsc: '', + rtindex: 2, + covers: [], + shoptcflag: false, + iconPath: '', + tcindex: 0, + taocanflag: false, + kefuflag: false, + iconflag: false, + cheobj: {}, + jingweidu: '', + taocaolist: [], + polyline: [], + kefulist: [], + orderAreaId: '', + areaId: '', + orderobj: {}, + orderAreaReturnVerify: '', + fajinobj: {}, + fjflag: false, + showIconAndCallout: false, + orderflag: false, + hei: { + height: '64vh' + }, + sockedata: {}, + socketTask: null, + messages: [], + reconnectAttempts: 0, + maxReconnectAttempts: 5, + reconnectInterval: 3000, + isPageActive: true, + deviceMac: '', + newMarkers: '', + count: 0, + timer: null, + user: {}, + xllat: '', + xllng: '', + circles: [], + nearbyMarkers: [], + listData: [], + yyid: '', + cachedPolyline: [], // 缓存多边形数据 + cachedParkingData: {}, // 缓存停车区域数据 + isFirstLoad: true ,// 是否是首次加载 + parkingList:[], + shibainum:0, + jiance:false, + ver_dataflag: 1, + mac: '', + deviceid: '', + devicename: '', + name:'', + devicesarr: [], + findDeviceTimer: null, + uploadTimer: null, // 定时器ID + lastUploadTime: 0, // 上次上传时间戳 + isUploading: false,// 上传状态锁 + isRefreshing: false, + bluetoothData:{}, + lslat:'', + lslon:'', + orderDeviceTimer: null, // 订单设备定时器 + wenbentxt:'', + wenbentxtflag:false, + ljsbflag:false, + chongshinum:'', } - }, + }, onLoad() { - uni.getLocation({ - type: 'gcj02', // 国内地图更兼容 - isHighAccuracy: true, - success: (res) => { - console.log('精确坐标:', res) - }, - fail: (err) => { - console.error('获取位置失败:', err) - } - }) - }, - // 分享到好友(会话) - onShareAppMessage: function() { - return { - title: '小鹿骑行', - path: '/pages/index/index' - } - }, - // 分享到朋友圈 - onShareTimeline: function() { - return { - title: '小鹿骑行', - query: '', - path: '/pages/index/index' - } + }, onShow() { - this.getinfo() - this.getlunbo() this.getorderdevice() + xBlufi.initXBlufi(1) + xBlufi.notifyStartDiscoverBle({ + 'isStart': true + }) + xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent) + uni.getLocation({ + type: 'wgs84', + success: (res) => { + this.xllat = res.latitude + this.xllng = res.longitude + }, + fail: (err) => { + console.error('获取位置失败:', err) + } + }) + this.getAone() + this.covers = [] + this.sockedata = '' + setTimeout(()=>{ + this.setMapScale() + },500) + this.getkefu() + this.polyline = [] + this.isFirstLoad = true // 重置首次加载标志 + setTimeout(()=>{ + this.toggleIconAndCallout() + },3000) + }, + onUnload() { + this.clearTimer() + this.stopOrderDeviceTimer() // 停止订单设备定时器 + this.isPageActive = false + this.closeWebSocket() + if (this.findDeviceTimer) { + clearTimeout(this.findDeviceTimer) + this.findDeviceTimer = null + } + }, + onHide() { + if (this.findDeviceTimer) { + clearTimeout(this.findDeviceTimer) + this.findDeviceTimer = null + } + this.clearTimer() + this.stopOrderDeviceTimer() // 停止订单设备定时器 + // 页面隐藏时关闭连接 + this.isPageActive = false + this.closeWebSocket() + }, + // 组件销毁时清除定时器 + beforeDestroy() { + clearTimeout(this.uploadTimer) + this.stopOrderDeviceTimer() // 停止订单设备定时器 }, methods: { - // 请求查询是否有未支付订单 - getzhifu(){ - this.$u.get("/app/order/unpaid").then((res) => { - if (res.code == 200) { - if(res.data){ - let id = res.data.id - uni.showModal({ - title: '提示', - content: '您当前还有未支付订单,是否前去支付?', - showCancel: true, - success: function (res) { - if (res.confirm) { - uni.navigateTo({ - url:'/page_user/yongche/orderxq?id=' + id - }) - } else if (res.cancel) { - console.log('取消'); // 用户点击取消 - } - } + // 点击查看教程 + btnjc(){ + uni.navigateTo({ + url:'/page_user/yongche/index?type=2' + }) + }, + // 点击重试 + btnchongshi(){ + this.ljsbflag = false + if(this.chongshinum == '解锁' || this.chongshinum == '锁车'){ + this.btnqd() + }else if(this.chongshinum == '还车'){ + this.btnjsdd() + }else if(this.chongshinum == '换车'){ + this.btnghbike() + }else if(this.chongshinum == '响铃'){ + this.btnxl() + } + }, + // 点击咨询客服 + btnkefu(){ + this.$u.get(`/app/customerService/list?pageNum=1&pageSize=999&areaId=${this.orderobj.orderAreaId}`).then(res => { + if(res.code == 200){ + if(res.rows.length > 0){ + this.kefulist = res.rows + this.kefuflag = true + }else{ + uni.showToast({ + title: '当前运营区暂无客服', + icon: 'none', + duration: 2000 }) } + }else{ + uni.showToast({ + title: res.msg, + icon: 'none', + duration: 2000 + }) } }) }, - - // 点击跳转到车辆 - btntz() { - uni.switchTab({ - url: '/pages/myorder/returned/index' + // 点击响铃 + btnxl(){ + if(this.jiance == true){ + xBlufi.initXBlufi(1) + xBlufi.notifyStartDiscoverBle({ + 'isStart': true + }) + xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent) + } + this.wenbentxt = '车辆响铃中...' + this.wenbentxtflag = true + this.$u.put(`/app/device/iot/ring?id=${this.orderobj.deviceId}`).then((res) => { + if (res.code == 200) { + this.wenbentxt = '' + this.wenbentxtflag = false + uni.showToast({ + title: '操作成功', + icon: 'success', + duration: 2000 + }) + } else if (res.code == 20001) { + this.wenbentxt = '蓝牙响铃中...' + let that = this + const findDevice = () =>{ + that.ver_dataflag = 2 + const matchedDevice = that.devicesarr.find(device => { + return device.name.slice(-12) == that.mac.slice(-12) + }) + if (matchedDevice) { + xBlufi.notifyStartDiscoverBle({ + 'isStart': false + }) + xBlufi.notifyConnectBle({ + isStart: true, + deviceId: matchedDevice.deviceId, + name: matchedDevice.name + }) + that.deviceid = matchedDevice.deviceId + that.devicename = matchedDevice.name + setTimeout(()=>{ + if(that.ver_dataflag == 3){ + that.wenbentxt = '' + that.wenbentxtflag = false + xBlufi.notifySendCustomData({ + customData: "11play1@" + }) + }else{ + that.chongshinum = '响铃' + that.ver_dataflag = 1 + that.shibainum = 0 + that.wenbentxt = '' + that.wenbentxtflag = false + that.ljsbflag = true + } + },4000) + } else { + if(that.shibainum < 3){ + that.shibainum++ + that.findDeviceTimer = setTimeout(findDevice.bind(that), 1000) // 使用 bind 保持 this 上下文 + }else{ + that.chongshinum = '响铃' + that.ver_dataflag = 1 + that.shibainum = 0 + that.wenbentxt = '' + that.wenbentxtflag = false + that.ljsbflag = true + let lanya = '' + if(that.jiance == true){ + lanya = '蓝牙未开启' + }else{ + lanya = '蓝牙已开启' + } + let data = { + mac:that.mac, + orderId: that.orderobj.orderId, + reason:'用户蓝牙响铃失败' + lanya, + command:'11play1@', + lat: that.lat, + lon: that.lon, + result:'失败' + } + that.$u.post(`/app/commandLog/bluetooth`,data).then(res => {}) + } + } + } + findDevice() + } else { + this.wenbentxt = '' + this.wenbentxtflag = false + uni.showToast({ + title: res.msg, + icon: 'none', + duration: 2000 + }) + } }) }, - // 点击继续骑行 + // 获取附近蓝牙设备列表 + funListenDeviceMsgEvent: function(options) { + switch (options.type) { + case xBlufi.XBLUFI_TYPE.TYPE_STATUS_CONNECTED: + if (!options.result) { + this.ver_dataflag = 1 + console.log(this.ver_dataflag,'断开断开'); + clearTimeout(this.uploadTimer) //清除每十秒传一次的定时 + this.jiance = true + } + break; + case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS: + if (options.result) { + this.devicesarr = options.data + } + break; + case xBlufi.XBLUFI_TYPE.TYPE_CONNECTED: + console.log("连接回调:" + JSON.stringify(options)) + if (options.result == true) { + setTimeout(() => { + this.ver_dataflag = 3 + }, 2000) + xBlufi.notifyInitBleEsp32({ + deviceId: this.deviceid + }) + this.deviceid = options.data.deviceId + this.name = this.name + }else{ + this.ver_dataflag = 1 + } + break; + case xBlufi.XBLUFI_TYPE.TYPE_RECIEVE_CUSTON_DATA: + console.log("1收到设备发来的自定义数据结果:", options.data) + this.getlysj(options.data) + break; + case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS_START: + if (!options.result) { + console.log('蓝牙未开启') + this.jiance = true + return + } + break; + } + }, + getlysj(data) { + if (!data) return; + // 1. 更健壮的数据解析 + const dataStr = data.toString(); + // console.log('原始数据:', dataStr); + const dataObj = {}; + // 判断数据格式:检查是否包含@或,分隔符 + let separator = ','; + if (dataStr.includes('@')) { + separator = '@'; + } + dataStr.split(separator).forEach(part => { + if (!part) return; // 忽略空字符串 + let key, value; + // 如果使用@分隔符,数据格式为 key-value 对,例如: status0@csq0@bat125@... + if (separator === '@') { + // 使用正则表达式分离键(字母)和值(数字) + const match = part.match(/^([a-zA-Z]+)(.*)$/); + if (!match) return; + key = match[1]; + value = match[2]; + } else { + // 如果使用,分隔符,数据格式为 key:value 对,例如: status:0,csq:0,bat:125,... + const [keyPart, valuePart] = part.split(':').map(item => item.trim()); + if (!keyPart || valuePart === undefined) return; + key = keyPart; + value = valuePart; + } + if (key && value !== undefined) { + switch (key) { + case 'status': + dataObj.status = value; + break; + case 'bat': + dataObj.bat = parseFloat(value); + break; + case 'csq': + dataObj.csq = parseInt(value, 10); + break; + case 'lat': + dataObj.lat = parseFloat(value); + break; + case 'lon': + dataObj.lon = parseFloat(value); + break; + case 'q': + dataObj.q = parseInt(value, 10); + break; + case 's': + dataObj.s = parseInt(value, 10); + break; + } + } + }); + // 2. 获取定位 + uni.getLocation({ + type: 'gcj02', + isHighAccuracy: true, + success: (res) => { + this.submitData({ + ...dataObj, + lon: res.longitude, + lat: res.latitude + }) + }, + fail: () => { + this.submitData({ + ...dataObj, + lon: dataObj.lon || 0, + lat: dataObj.lat || 0 + }) + } + }) + }, + // 3. 单独封装数据提交 + submitData(data) { + const payload = { + mac: this.mac, + sys: { + bat: data.bat !== undefined && data.bat !== null ? Number(data.bat) : 0, + csq: data.csq !== undefined && data.csq !== null ? Number(data.csq) : 0, + s: data.s !== undefined && data.s !== null ? Number(data.s) : null, + q: data.q !== undefined && data.q !== null ? Number(data.q) : null, + status: String(data.status || '0'), + lon: data.lon !== undefined && data.lon !== null ? Number(data.lon) : 0, + lat: data.lat !== undefined && data.lat !== null ? Number(data.lat) : 0 + } + } + this.bluetoothData = payload + this.throttledUpload() + }, + // 节流上传控制 + throttledUpload() { + const now = Date.now() + const throttleInterval = 10000 // 10秒 + clearTimeout(this.uploadTimer) + // 如果距离上次上传超过10秒且没有正在上传的请求 + if (now - this.lastUploadTime >= throttleInterval && !this.isUploading) { + this.doUpload() + } else { + const remainingTime = throttleInterval - (now - this.lastUploadTime) + this.uploadTimer = setTimeout(() => { + this.doUpload() + }, remainingTime) + } + }, + // 实际执行上传 + doUpload() { + if (!this.bluetoothData || this.isUploading) return + this.isUploading = true + this.lastUploadTime = Date.now() + this.$u.put(`/app/device/iot/bltUpload`, this.bluetoothData).then(res => { + if(res.code == 200) { + console.log('上传蓝牙数据成功',this.bluetoothData, new Date().toLocaleTimeString()) + } else { + console.log('上传蓝牙数据失败', res.msg) + } + }).catch(err => { + console.error('上传异常:', err) + }).finally(() => { + this.isUploading = false + }) + }, + // 开坐垫锁 + btnkzds(){ + uni.getLocation({ + type: 'gcj02', // 国内地图更兼容 + isHighAccuracy: true, + accuracy:'best', + success: (res) => { + // console.log('精确坐标:', res) + this.lslat = res.latitude + this.lslon = res.longitude + }, + fail: (err) => { + console.error('获取位置失败:', err) + this.lslat = null + this.lslat = null + } + }) + let that = this + uni.showModal({ + title: '提示', + content: '您是否要开启坐垫锁?', + showCancel: true, + success: function(res) { + if (res.confirm) { + uni.showLoading({ + title: '加载中...', + mask: true + }) + let data = { + orderId:that.orderobj.orderId, + lon:that.lslon, + lat:that.lslat, + requiredIot:true + } + that.$u.put("/app/order/seat",data).then((res) => { + if (res.code == 200) { + uni.showToast({ + title: '打开成功', + icon: 'success', + duration: 2000 + }) + } else if(res.code == 20001){ + uni.hideLoading() + if(that.ver_dataflag != 3){ + uni.showLoading({ + title: '坐垫锁开启中...', + mask: true + }) + this.ver_dataflag = 2 + const matchedDevice = this.devicesarr.find(device => { + return device.name.slice(-12) == this.mac.slice(-12) + }) + if (matchedDevice) { + xBlufi.notifyStartDiscoverBle({ + 'isStart': false + }) + xBlufi.notifyConnectBle({ + isStart: true, + deviceId: matchedDevice.deviceId, + name: matchedDevice.name + }) + this.deviceid = matchedDevice.deviceId + this.devicename = matchedDevice.name + setTimeout(()=>{ + uni.hideLoading() + xBlufi.notifySendCustomData({ + customData: "11hpen@" + }) + },4000) + } else { + if(this.shibainum < 3){ + this.shibainum++ + this.findDeviceTimer = setTimeout(this.findDevice.bind(this), 1000) // 使用 bind 保持 this 上下文 + }else{ + this.ver_dataflag = 1 + this.shibainum = 0 + uni.showModal({ + title: '提示', + content: '开启坐垫锁失败,请重试', + showCancel: false, + success: function(res) { + if (res.confirm) { + + } else if (res.cancel) { + + } + } + }) + } + } + } + } else { + uni.hideLoading() + uni.showToast({ + title: res.msg, + icon: 'none', + duration: 2000 + }) + } + }) + } + } + }) + }, + // 点击自定义返回 + btnfh(){ + uni.reLaunch({ + url:'/pages/nearbystores/index?qbtype=1' + }) + }, + // 拖动查询中心点的数据 + regionchange(e) { + // this.iconflag = true + // if (e.type == 'end') { + // if (this.rtindex == 2) { + // this.jingweidu = e.detail.centerLocation.longitude + ',' + e.detail.centerLocation.latitude + // this.getAone() + // this.iconflag = false + // } + // } + }, + debounceUpdate() { + if (this.updateTimer) { + clearTimeout(this.updateTimer) + } + this.updateTimer = setTimeout(() => { + this.getAone() + }, 300) // 延迟300ms执行更新 + }, + getNearbyMarkers(clickedLat, clickedLon) { + const nearbyMarkers = this.listData.filter(item => { + if (item.latitude && item.longitude) { + const distance = this.haversineDistance( + parseFloat(clickedLat), + parseFloat(clickedLon), + parseFloat(item.latitude), + parseFloat(item.longitude) + ); + return distance <= 100 + } + return false + }); + // 更新 circles 数组来绘制淡灰色的圆形区域 + this.circles = [{ + latitude: clickedLat, + longitude: clickedLon, + color: '#fff', // 圆形边框颜色(淡灰色) + fillColor: '#00000010', // 圆形填充颜色(淡灰色) + radius: 100, // 圆的半径(单位:米) + strokeWidth: 1 + }] + this.nearbyMarkers = nearbyMarkers + }, + haversineDistance(lat1, lon1, lat2, lon2) { + const R = 6371e3 // Earth radius in meters + const toRad = angle => angle * Math.PI / 180 + const dLat = toRad(lat2 - lat1) + const dLon = toRad(lon2 - lon1) + const a = Math.sin(dLat / 2) * Math.sin(dLat / 2) + Math.cos(toRad(lat1)) * Math.cos(toRad(lat2)) * Math.sin(dLon / 2) * Math.sin(dLon / 2) + const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)) + return R * c + }, + status(item) { + if (item.status == 0) { + return '仓库中' + } else if (item.status == 1) { + return '待租' + } else if (item.status == 2) { + return '预约中' + } else if (item.status == 3) { + return '骑行中' + } else if (item.status == 4) { + return '临时锁车中' + } else if (item.status == 6) { + return '调度中' + } else if (item.status == 7) { + return '未绑定' + } else if (item.status == 8) { + return '禁用中' + } + }, + startTimer() { + this.timer = setInterval(() => { + this.count++ + // 这里替换为你的实际逻辑 + this.setMapScale() + }, 5000) + }, + + // 清除定时器 + clearTimer() { + if (this.timer) { + clearInterval(this.timer) + this.timer = null + console.log("定时器已清除") + } + }, btnjjqx(){ this.orderflag = true this.fjflag = false }, - // 点击跳转导航 - danghang() { - if (this.orderobj.deviceLatitude && this.orderobj.deviceLongitude) { - uni.openLocation({ - latitude: this.orderobj.deviceLatitude, //纬度-目的地/坐标点 - longitude: this.orderobj.deviceLongitude, //经度-目的地/坐标点 - name: '', //地点名称 - address: '' //详细地点名称 + //WebSocket 自动重连实现 + initWebSocket() { + if (!this.isPageActive || !this.deviceMac) return + let token = uni.getStorageSync('token') + // 关闭已有连接 + if (this.socketTask) { + this.socketTask.close() + this.socketTask = null + } + // 创建新连接 + this.socketTask = uni.connectSocket({ + url: `wss://ele.ccttiot.com/prod-api/ws/device?token=${token}&mac=${this.deviceMac}`, + success: () => { + console.log('WebSocket连接建立中...') + }, + fail: (err) => { + console.error('WebSocket连接失败:', err) + this.scheduleReconnect() + } + }); + // 监听连接打开 + this.socketTask.onOpen(() => { + console.log('WebSocket连接已打开') + this.reconnectAttempts = 0; // 重置重连计数器 + // 发送订阅消息(如果需要) + this.socketTask.send({ + data: JSON.stringify({ + action: 'subscribe' + }), + success: () => console.log('订阅消息发送成功'), + fail: (err) => console.error('订阅消息发送失败:', err) }) - } else { - uni.showToast({ - title: '车辆暂无法导航', - icon: 'none', - duration: 2000 + }) + // 监听消息接收 + this.socketTask.onMessage((res) => { + console.log('收到实时消息:', res.data) + this.messages.push(res.data) // 存储消息 + try { + const data = JSON.parse(res.data) + console.log('解析后的JSON数据:', data) + // 这里可以处理具体的业务逻辑 + this.sockedata = data + this.covers = [] + const newMarkers = [] + this.parkingList.forEach(item => { + newMarkers.push({ + id: parseFloat(item.id), + latitude: parseFloat(item.latitude), + longitude: parseFloat(item.longitude), + width: 40, + height: 60, + iconPath: item.type == 1 ? + 'https://lxnapi.ccttiot.com/bike/img/static/up2xXqAgwCX5iER600k3' : + item.type == 2 ? + 'https://lxnapi.ccttiot.com/bike/img/static/uDNY5Q4zOiZTCBTA2Jdq' : + 'https://lxnapi.ccttiot.com/bike/img/static/u53BAQcFIX3vxsCzEZ7t', + callout: { + content: item.name, + color: '#ffffff', + fontSize: 14, + borderRadius: 10, + bgColor: item.type == 1 ? '#3A7EDB' : item.type == 2 ? '#FF473E' : + '#FFC107', + padding: 6, + display: 'ALWAYS' + }, + isCalloutVisible: true // 添加标记 + }) + }) + this.newMarkers = newMarkers + this.$set(this, 'covers', [...this.covers, ...newMarkers]) + if(this.sockedata.latitude){ + this.covers.push({ + latitude: this.sockedata.latitude, + longitude: this.sockedata.longitude, + width: 8, + height: 8, + iconPath: 'https://api.ccttiot.com/smartmeter/img/static/uow9Zq3edTUYCVHI9H60', + }) + } + this.covers.push({ + latitude: data.latitude, + longitude: data.longitude, + width: 8, + height: 8, + iconPath: 'https://api.ccttiot.com/smartmeter/img/static/uow9Zq3edTUYCVHI9H60', + }) + } catch (e) { + console.log('原始消息内容:', res.data) + } + }); + // 监听错误 + this.socketTask.onError((err) => { + console.error('WebSocket错误:', err) + this.scheduleReconnect() + }); + // 监听连接关闭 + this.socketTask.onClose((res) => { + console.log('WebSocket连接已关闭', res) + if (this.isPageActive) { + this.scheduleReconnect() + } + }) + }, + // 关闭WebSocket连接 + closeWebSocket() { + if (this.socketTask) { + this.socketTask.close({ + success: () => { + console.log('WebSocket已主动关闭') + this.socketTask = null + }, + fail: (err) => { + console.error('WebSocket关闭失败:', err) + this.socketTask = null + } }) } }, - // 点击启动and关闭 - btnqd() { - if (this.orderobj.deviceLockStatus == 0) { - let that = this - uni.showModal({ - title: '提示', - content: '您是否要解锁车辆?', - showCancel: true, - success: function(res) { - if (res.confirm) { - that.$u.put(`/app/order/openDevice?orderId=${that.orderobj.orderId}`).then(( - res) => { - if (res.code == 200) { - uni.showToast({ - title: '解锁成功', - icon: 'success', - duration: 2000 - }) - that.getorderdevice() - } else { - uni.showModal({ - title: '提示', - content: '设备离线,请前往车辆详情连接车辆操作', - showCancel: false, - success: function(res) { - if (res.confirm) { - uni.switchTab({ - url:'/pages/myorder/returned/index' - }) - } else if (res.cancel) { - - } - } - }) - } - }) - } else if (res.cancel) { - console.log('取消') - } - } - }) - } else if (this.orderobj.deviceLockStatus == 1) { - uni.getLocation({ - type: 'wgs84', - success: (res) => { - this.latsc = res.latitude - this.lngsc = res.longitude - }, - fail: (err) => { - console.error('获取位置失败:', err) - this.latsc = null - this.lngsc = null - } - }) - let that = this - uni.showModal({ - title: '提示', - content: '您是否要临时锁车?', - showCancel: true, - success: function(res) { - if (res.confirm) { - let query = { - orderId: that.orderobj.orderId, - lat: that.latsc, - lon: that.lngsc, - } - let url = '/app/order/closeDevice?' + that.$tansParams(query) - that.$u.put(url).then((res) => { - if (res.code == 200) { - uni.showToast({ - title: '临时锁车成功', - icon: 'success', - duration: 2000 - }) - that.getorderdevice() - } else { - uni.showModal({ - title: '提示', - content: '设备离线,请前往车辆详情连接车辆操作', - showCancel: false, - success: function(res) { - if (res.confirm) { - uni.switchTab({ - url:'/pages/myorder/returned/index' - }) - } else if (res.cancel) { - - } - } - }) - } - }) - } else if (res.cancel) { - console.log('取消') - } - } - }) + // 安排重连 + scheduleReconnect() { + if (!this.isPageActive || this.reconnectAttempts >= this.maxReconnectAttempts) { + console.log('已达到最大重连次数或页面已关闭,停止重连') + return } + this.reconnectAttempts++; + console.log(`尝试第 ${this.reconnectAttempts} 次重连,等待 ${this.reconnectInterval/1000} 秒...`) + setTimeout(() => { + this.initWebSocket() + }, this.reconnectInterval) + // 指数退避策略,增加重连间隔 + this.reconnectInterval = Math.min(this.reconnectInterval * 2, 30000) // 最大不超过30秒 }, // 点击结束订单 btnjsdd() { - if (this.orderAreaReturnVerify == true) { - uni.navigateTo({ - url: '/page_user/hcshenhe?sn=' + this.orderobj.deviceSn + '&orderid=' + this.orderobj.orderId + '&orderAreaId=' + this.orderobj.orderAreaId - }) - } else { - uni.getLocation({ - type: 'gcj02', // 国内地图更兼容 - isHighAccuracy: true, - success: (res) => { - this.latsc = res.latitude - this.lonsc = res.longitude - this.getfeiyong() - }, - fail: (err) => { - console.error('获取位置失败:', err) - this.getfeiyong() + this.$u.get("/app/order/mineProcessing").then((res) => { + if (res.code == 200) { + if(res.data){ + if (this.orderAreaReturnVerify == true) { + if(this.orderobj.deviceOnlineStatus == 0){ + this.wenbentxtflag = true + this.wenbentxt = '蓝牙连接中...' + let that = this + const findDevice = () =>{ + that.ver_dataflag = 2 + const matchedDevice = that.devicesarr.find(device => { + return device.name.slice(-12) == that.mac.slice(-12) + }) + if (matchedDevice) { + xBlufi.notifyStartDiscoverBle({ + 'isStart': false + }) + xBlufi.notifyConnectBle({ + isStart: true, + deviceId: matchedDevice.deviceId, + name: matchedDevice.name + }) + that.deviceid = matchedDevice.deviceId + that.devicename = matchedDevice.name + setTimeout(()=>{ + if(that.ver_dataflag == 3){ + that.wenbentxt = '' + that.wenbentxtflag = false + let flag = false + uni.navigateTo({ + url: '/page_user/hcshenhe?sn=' + that.orderobj.deviceSn + '&orderid=' + that.orderobj.orderId + '&orderAreaId=' + that.orderobj.orderAreaId + '&flag=' + flag + '&mac=' + that.mac + }) + }else{ + that.ver_dataflag = 1 + that.shibainum = 0 + that.wenbentxt = '' + that.wenbentxtflag = false + that.ljsbflag = true + that.chongshinum = '还车' + } + },4000) + } else { + if(that.shibainum < 3){ + that.shibainum++ + that.findDeviceTimer = setTimeout(findDevice.bind(that), 1000) // 使用 bind 保持 this 上下文 + }else{ + that.ver_dataflag = 1 + that.shibainum = 0 + that.wenbentxt = '' + that.wenbentxtflag = false + that.ljsbflag = true + that.chongshinum = '还车' + } + } + } + findDevice() + }else{ + uni.navigateTo({ + url: '/page_user/hcshenhe?sn=' + this.orderobj.deviceSn + '&orderid=' + this.orderobj.orderId + '&orderAreaId=' + this.orderobj.orderAreaId + '&flag=' + false + }) + } + } else { + uni.getLocation({ + type: 'gcj02', // 国内地图更兼容 + isHighAccuracy: true, + accuracy:'best', + success: (res) => { + console.log('精确坐标:', res) + this.lat = res.latitude + this.lon = res.longitude + this.getfeiyong() + }, + fail: (err) => { + console.error('获取位置失败:', err) + this.lat = null + this.lon = null + this.getfeiyong() // 降级处理 + } + }); + } + }else{ + uni.navigateTo({ + url:'/page_user/yongche/orderxq?id=' + this.orderobj.orderId + }) } - }) - } + } + }) }, // 点击还车判断是否需要另外缴费 getfeiyong() { @@ -464,6 +1141,8 @@ if (res.code == 200) { this.fajinobj = res.data if (res.data.manageFee > 0 || res.data.dispatchFee > 0) { + this.wenbentxt = '' + this.wenbentxtflag = false this.fjflag = true this.orderflag = false } else { @@ -487,6 +1166,12 @@ icon: 'none', duration: 5000 }) + }else{ + uni.showToast({ + title: res.msg, + icon: 'none', + duration: 5000 + }) } }) }, @@ -498,43 +1183,227 @@ gethuan() { let that = this uni.showModal({ - title: '提示', + title: '提示', content: '您确定要还车吗?', showCancel: true, success: function(res) { if (res.confirm) { + that.fjflag = false + that.wenbentxt = '车辆还车中...' + that.wenbentxtflag = true let data = { orderId: that.orderobj.orderId, picture: that.imgs, lon: that.lonsc, - lat: that.latsc + lat: that.latsc, + requiredIot: true } that.$u.put(`/app/order/end`, data).then(res => { if (res.code == 200) { + that.cheflag = true + that.fjflag = false + that.wenbentxt = '' + that.wenbentxtflag = false uni.showToast({ title: '还车成功', icon: 'success', duration: 2000 }) setTimeout(()=>{ - that.fjflag = false - that.orderflag = false - setTimeout(()=>{ - uni.navigateTo({ - url:'/page_user/yongche/orderxq?id=' + that.orderobj.orderId - }) - },1000) + uni.navigateTo({ + url:'/page_user/yongche/orderxq?id=' + that.orderobj.orderId + }) },1000) + }else if(res.code == 20001){ + if(that.ver_dataflag == 3){ + that.wenbentxt = '蓝牙还车中...' + xBlufi.notifySendCustomData({ + customData: "11llosesub300@" + }) + setTimeout(()=>{ + xBlufi.notifySendCustomData({ + customData: "11reboot@" + }) + },2000) + that.fjflag = false + let data = { + orderId: that.orderobj.orderId, + picture: that.imgs, + lon: that.lon, + lat: that.lat, + requiredIot: false + } + that.$u.put(`/app/order/end`, data).then(res => { + if (res.code == 200) { + setTimeout(()=>{ + that.wenbentxt = '' + that.wenbentxtflag = false + setTimeout(()=>{ + uni.navigateTo({ + url:'/page_user/yongche/orderxq?id=' + that.orderobj.orderId + }) + },1000) + },2000) + }else if(res.msg == null) { + that.wenbentxt = '' + that.wenbentxtflag = false + uni.showToast({ + title: '未知错误', + icon: 'none', + duration: 2000 + }) + } else { + that.wenbentxt = '' + that.wenbentxtflag = false + uni.showModal({ + title: '提示', + content: res.msg, + showCancel: false, + success: function(res) { + if (res.confirm) { + + } else if (res.cancel) { + + } + } + }) + } + }) + }else{ + that.wenbentxt = '蓝牙还车中...' + const findDevice = () =>{ + that.ver_dataflag = 2 + const matchedDevice = that.devicesarr.find(device => { + return device.name.slice(-12) == that.mac.slice(-12) + }) + if (matchedDevice) { + xBlufi.notifyStartDiscoverBle({ + 'isStart': false + }) + xBlufi.notifyConnectBle({ + isStart: true, + deviceId: matchedDevice.deviceId, + name: matchedDevice.name + }) + that.deviceid = matchedDevice.deviceId + that.devicename = matchedDevice.name + setTimeout(()=>{ + if(that.ver_dataflag == 3){ + that.fjflag = false + let data = { + orderId: that.orderobj.orderId, + picture: that.imgs, + lon: that.lon, + lat: that.lat, + requiredIot: false + } + that.$u.put(`/app/order/end`, data).then(res => { + if (res.code == 200) { + xBlufi.notifySendCustomData({ + customData: "11close@" + }) + setTimeout(()=>{ + xBlufi.notifySendCustomData({ + customData: "11reboot@" + }) + that.wenbentxt = '' + that.wenbentxtflag = false + setTimeout(()=>{ + uni.navigateTo({ + url:'/page_user/yongche/orderxq?id=' + that.orderobj.orderId + }) + },1000) + },2000) + } else if(res.msg == null) { + that.wenbentxt = '' + that.wenbentxtflag = false + that.orderflag = true + uni.showToast({ + title: '未知错误', + icon: 'none', + duration: 2000 + }) + } else { + that.wenbentxt = '' + that.wenbentxtflag = false + that.orderflag = true + uni.showModal({ + title: '提示', + content: res.msg, + showCancel: false, + success: function(res) { + if (res.confirm) { + + } else if (res.cancel) { + + } + } + }) + } + }) + }else{ + that.ver_dataflag = 1 + that.shibainum = 0 + that.wenbentxt = '' + that.wenbentxtflag = false + that.orderflag = true + that.ljsbflag = true + that.chongshinum = '还车' + } + },4000) + } else { + if(that.shibainum < 3){ + that.shibainum++ + that.findDeviceTimer = setTimeout(findDevice.bind(that), 1000) // 使用 bind 保持 this 上下文 + }else{ + that.ver_dataflag = 1 + that.shibainum = 0 + that.wenbentxt = '' + that.wenbentxtflag = false + that.orderflag = true + that.ljsbflag = true + that.chongshinum = '还车' + let lanya = '' + if(that.jiance == true){ + lanya = '蓝牙未开启' + }else{ + lanya = '蓝牙已开启' + } + let data = { + mac:that.mac, + orderId: that.orderobj.orderId, + reason:'用户蓝牙还车失败' + lanya, + command:'11close@', + lat: that.lat, + lon: that.lon, + result:'失败' + } + that.$u.post(`/app/commandLog/bluetooth`,data).then(res => {}) + } + } + } + findDevice() + } + } else if(res.msg == null) { + that.wenbentxt = '' + that.wenbentxtflag = false + that.orderflag = true + uni.showToast({ + title: '未知错误', + icon: 'none', + duration: 2000 + }) } else { + that.wenbentxt = '' + that.wenbentxtflag = false + that.orderflag = true uni.showModal({ - title: '提示', - content: '设备离线,请前往车辆详情连接车辆操作', + title: '提示', + content: res.msg, showCancel: false, success: function(res) { if (res.confirm) { - uni.switchTab({ - url:'/pages/myorder/returned/index' - }) + } else if (res.cancel) { } @@ -543,7 +1412,8 @@ } }) } else if (res.cancel) { - + that.wenbentxtflag = false + that.wenbentxt = '' } } }) @@ -554,6 +1424,557 @@ url: '/pages/myorder/returned/tingche?areaId=' + this.orderobj.orderAreaId }) }, + // 点击故障上报 + btnguzhang(){ + uni.navigateTo({ + url:'/page_user/guzhang/index?sn=' + this.orderobj.deviceSn + }) + }, + // 点击去进行换车 + btnghbike() { + if(this.jiance == true){ + xBlufi.initXBlufi(1) + xBlufi.notifyStartDiscoverBle({ + 'isStart': true + }) + xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent) + } + uni.getLocation({ + type: 'gcj02', // 国内地图更兼容 + isHighAccuracy: true, + accuracy:'best', + success: (res) => { + console.log('精确坐标:', res) + this.lslat = res.latitude + this.lslon = res.longitude + }, + fail: (err) => { + console.error('获取位置失败:', err) + this.lslat = null + this.lslon = null + } + }) + let that = this + that.wenbentxt = '车辆连接中...' + that.wenbentxtflag = true + let query = { + orderId: that.orderobj.orderId, + lat: that.lslat, + lon: that.lslon, + requiredIot: true + } + let url = '/app/order/closeDevice?' + that.$tansParams(query) + that.$u.put(url).then((res) => { + if (res.code == 200) { + that.wenbentxt = '' + that.wenbentxtflag = false + uni.showToast({ + title: '临时锁车成功', + icon: 'success', + duration: 2000 + }) + that.orderobj.deviceLockStatus = 0 + setTimeout(()=>{ + uni.navigateTo({ + url: '/page_user/huanbike?sn=' + that.orderobj.deviceSn + '&orderid=' + that.orderobj.orderId + '&deviceid=' + that.deviceid + '&devicename=' + that.devicename + }) + },1000) + } else if(res.code == 20001){ + if(that.ver_dataflag == 3){ + that.orderobj.deviceLockStatus = 0 + xBlufi.notifySendCustomData({ + customData: "11llosesub300@", + }) + setTimeout(()=>{ + // xBlufi.notifySendCustomData({ + // customData: "11reboot@" + // }) + that.wenbentxt = '' + that.wenbentxtflag = false + },2000) + let lanya = '' + if(that.jiance == true){ + lanya = '蓝牙未开启' + }else{ + lanya = '蓝牙已开启' + } + let data = { + mac:that.mac, + reason:'临时锁车' + lanya, + command:'11llosesub300@', + longitude:that.lslon, + latitude:that.lslat, + result:'失败' + } + that.$u.post(`/app/commandLog/bluetooth`,data).then(res => { + console.log(res,'蓝牙') + }) + let query = { + orderId: that.orderobj.orderId, + lat: that.lslat, + lon: that.lslon, + requiredIot: false + } + let url = '/app/order/closeDevice?' + that.$tansParams(query) + that.$u.put(url).then((res) =>{}) + uni.navigateTo({ + url: '/page_user/huanbike?sn=' + that.orderobj.deviceSn + '&orderid=' + that.orderobj.orderId + '&deviceid=' + that.deviceid + '&devicename=' + that.devicename + }) + }else{ + that.wenbentxt = '蓝牙连接中...' + const findDevice = () =>{ + that.ver_dataflag = 2 + const matchedDevice = that.devicesarr.find(device => { + return device.name.slice(-12) == that.mac.slice(-12) + }) + if (matchedDevice) { + xBlufi.notifyStartDiscoverBle({ + 'isStart': false + }) + xBlufi.notifyConnectBle({ + isStart: true, + deviceId: matchedDevice.deviceId, + name: matchedDevice.name + }) + that.deviceid = matchedDevice.deviceId + that.devicename = matchedDevice.name + setTimeout(()=>{ + if(that.ver_dataflag == 3){ + that.orderobj.deviceLockStatus = 0 + xBlufi.notifySendCustomData({ + customData: "11llosesub300@", + }) + setTimeout(()=>{ + xBlufi.notifySendCustomData({ + customData: "11reboot@" + }) + that.wenbentxt = '' + that.wenbentxtflag = false + },2000) + let lanya = '' + if(that.jiance == true){ + lanya = '蓝牙未开启' + }else{ + lanya = '蓝牙已开启' + } + let data = { + mac:that.mac, + reason:'临时锁车' + lanya, + command:'11llosesub300@', + longitude:that.lslon, + latitude:that.lslat, + result:'失败' + } + that.$u.post(`/app/commandLog/bluetooth`,data).then(res => { + console.log(res,'蓝牙') + }) + let query = { + orderId: that.orderobj.orderId, + lat: that.lslat, + lon: that.lslon, + requiredIot: false + } + let url = '/app/order/closeDevice?' + that.$tansParams(query) + that.$u.put(url).then((res) =>{}) + uni.navigateTo({ + url: '/page_user/huanbike?sn=' + that.orderobj.deviceSn + '&orderid=' + that.orderobj.orderId + '&deviceid=' + that.deviceid + '&devicename=' + that.devicename + }) + }else{ + that.ver_dataflag = 1 + that.shibainum = 0 + that.wenbentxt = '' + that.wenbentxtflag = false + that.ljsbflag = true + that.chongshinum = '换车' + } + },4000) + } else { + if(that.shibainum < 3){ + that.shibainum++ + that.findDeviceTimer = setTimeout(findDevice.bind(that), 1000) // 使用 bind 保持 this 上下文 + }else{ + that.ver_dataflag = 1 + that.shibainum = 0 + that.wenbentxt = '' + that.wenbentxtflag = false + that.ljsbflag = true + that.chongshinum = '换车' + let lanya = '' + if(that.jiance == true){ + lanya = '蓝牙未开启' + }else{ + lanya = '蓝牙已开启' + } + let data = { + mac:that.mac, + orderId: that.orderobj.orderId, + reason:'用户蓝牙临时锁车失败' + lanya, + command:'11llosesub300@', + lat: that.lslat, + lon: that.lslon, + result:'失败' + } + that.$u.post(`/app/commandLog/bluetooth`,data).then(res => {}) + } + } + } + findDevice() + } + } else { + that.wenbentxt = '' + that.wenbentxtflag = false + uni.showToast({ + title: res.msg, + icon: 'none', + duration: 2000 + }) + } + }) + }, + // 点击跳转到车辆 + btntz() { + // uni.switchTab({ + // url: '/pages/myorder/returned/index' + // }) + }, + // 点击跳转导航 + danghang() { + if (this.orderobj.deviceLatitude && this.orderobj.deviceLongitude) { + uni.openLocation({ + latitude: this.orderobj.deviceLatitude, //纬度-目的地/坐标点 + longitude: this.orderobj.deviceLongitude, //经度-目的地/坐标点 + name: '', //地点名称 + address: '' //详细地点名称 + }) + } else { + uni.showToast({ + title: '车辆暂无法导航', + icon: 'none', + duration: 2000 + }) + } + }, + // 点击启动and关闭 + btnqd() { + if(this.jiance == true){ + xBlufi.initXBlufi(1) + xBlufi.notifyStartDiscoverBle({ + 'isStart': true + }) + xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent) + } + this.$u.get("/app/orderDevice/mineUsing").then((res) => { + if (res.code == 200) { + if(res.data){ + if(res.data.deviceStatus == 9){ + uni.showModal({ + title: '提示', + content: '车辆已被强制锁车,请联系客服', + showCancel: false, + success: function(res) { + if (res.confirm) { + + } + } + }) + }else{ + if (res.data.deviceLockStatus == 0) { + uni.getLocation({ + type: 'gcj02', // 国内地图更兼容 + isHighAccuracy: true, + accuracy:'best', + success: (res) => { + console.log('精确坐标:', res) + this.lslat = res.latitude + this.lslon = res.longitude + }, + fail: (err) => { + console.error('获取位置失败:', err) + this.lslat = null + this.lslon = null + } + }) + let that = this + uni.showModal({ + title: '提示', + content: '您是否要解锁车辆?', + showCancel: true, + success: function(res) { + if (res.confirm) { + that.wenbentxt = '车辆解锁中...' + that.wenbentxtflag = true + let query = { + orderId: that.orderobj.orderId, + lat: that.lslat, + lon: that.lslon, + requiredIot: true + } + let url = '/app/order/openDevice?' + that.$tansParams(query) + that.$u.put(url).then((res) => { + if (res.code == 200) { + that.wenbentxt = '' + that.wenbentxtflag = false + uni.showToast({ + title: '解锁成功', + icon: 'success', + duration: 2000 + }) + that.orderobj.deviceLockStatus = 1 + } else if(res.code == 20001){ + that.wenbentxt = '蓝牙解锁中...' + const findDevice = () =>{ + that.ver_dataflag = 2 + const matchedDevice = that.devicesarr.find(device => { + return device.name.slice(-12) == that.mac.slice(-12) + }) + if (matchedDevice) { + xBlufi.notifyStartDiscoverBle({ + 'isStart': false + }) + xBlufi.notifyConnectBle({ + isStart: true, + deviceId: matchedDevice.deviceId, + name: matchedDevice.name + }) + that.deviceid = matchedDevice.deviceId + that.devicename = matchedDevice.name + setTimeout(()=>{ + if(that.ver_dataflag == 3){ + xBlufi.notifySendCustomData({ + customData: "11opensub5@" + }) + that.wenbentxt = '' + that.wenbentxtflag = false + that.orderobj.deviceLockStatus = 1 + let query = { + orderId: that.orderobj.orderId, + lat: that.lslat, + lon: that.lslon, + requiredIot: false + } + let url = '/app/order/openDevice?' + that.$tansParams(query) + that.$u.put(url).then((res) =>{}) + }else{ + that.ver_dataflag = 1 + that.shibainum = 0 + that.wenbentxt = '' + that.wenbentxtflag = false + uni.hideLoading() + that.ljsbflag = true + that.chongshinum = '解锁' + } + },4000) + } else { + if(that.shibainum < 3){ + that.shibainum++ + that.findDeviceTimer = setTimeout(findDevice.bind(that), 1000) // 使用 bind 保持 this 上下文 + }else{ + that.ver_dataflag = 1 + that.shibainum = 0 + that.wenbentxt = '' + that.wenbentxtflag = false + uni.hideLoading() + that.ljsbflag = true + that.chongshinum = '解锁' + let lanya = '' + if(that.jiance == true){ + lanya = '蓝牙未开启' + }else{ + lanya = '蓝牙已开启' + } + let data = { + mac:that.mac, + orderId: that.orderobj.orderId, + reason:'用户蓝牙解锁失败' + lanya, + command:'11opensub5@', + lat: that.lslat, + lon: that.lslon, + result:'失败', + } + that.$u.post(`/app/commandLog/bluetooth`,data).then(res => {}) + } + } + } + findDevice() + } else { + uni.hideLoading() + uni.showToast({ + title: res.msg, + icon: 'none', + duration: 2000 + }) + } + }) + } + } + }) + } else if (res.data.deviceLockStatus == 1) { + uni.getLocation({ + type: 'gcj02', // 国内地图更兼容 + isHighAccuracy: true, + accuracy:'best', + success: (res) => { + console.log('精确坐标:', res) + this.lslat = res.latitude + this.lslon = res.longitude + }, + fail: (err) => { + console.error('获取位置失败:', err) + this.lslat = null + this.lslon = null + } + }) + let that = this + uni.showModal({ + title: '提示', + content: '您是否要临时锁车?', + showCancel: true, + success: function(res) { + if (res.confirm) { + that.wenbentxt = '车辆临时锁车中...' + that.wenbentxtflag = true + let query = { + orderId: that.orderobj.orderId, + lat: that.lslat, + lon: that.lslon, + requiredIot: true + } + let url = '/app/order/closeDevice?' + that.$tansParams(query) + that.$u.put(url).then((res) => { + if (res.code == 200) { + that.wenbentxt = '' + that.wenbentxtflag = false + uni.showToast({ + title: '临时锁车成功', + icon: 'success', + duration: 2000 + }) + that.orderobj.deviceLockStatus = 0 + } else if(res.code == 20001){ + that.wenbentxt = '蓝牙临时锁车中...' + const findDevice = () =>{ + that.ver_dataflag = 2 + const matchedDevice = that.devicesarr.find(device => { + return device.name.slice(-12) == that.mac.slice(-12) + }) + if (matchedDevice) { + xBlufi.notifyStartDiscoverBle({ + 'isStart': false + }) + xBlufi.notifyConnectBle({ + isStart: true, + deviceId: matchedDevice.deviceId, + name: matchedDevice.name + }) + that.deviceid = matchedDevice.deviceId + that.devicename = matchedDevice.name + setTimeout(()=>{ + if(that.ver_dataflag == 3){ + that.orderobj.deviceLockStatus = 0 + xBlufi.notifySendCustomData({ + customData: "11llosesub300@", + }) + setTimeout(()=>{ + xBlufi.notifySendCustomData({ + customData: "11reboot@" + }) + that.wenbentxt = '' + that.wenbentxtflag = false + },2000) + let lanya = '' + if(that.jiance == true){ + lanya = '蓝牙未开启' + }else{ + lanya = '蓝牙已开启' + } + let data = { + mac:that.mac, + reason:'临时锁车' + lanya, + command:'11llosesub300@', + longitude:that.lslon, + latitude:that.lslat, + result:'失败' + } + that.$u.post(`/app/commandLog/bluetooth`,data).then(res => { + console.log(res,'蓝牙') + }) + let query = { + orderId: that.orderobj.orderId, + lat: that.lslat, + lon: that.lslon, + requiredIot: false + } + let url = '/app/order/closeDevice?' + that.$tansParams(query) + that.$u.put(url).then((res) =>{}) + }else{ + that.ver_dataflag = 1 + that.shibainum = 0 + that.wenbentxt = '' + that.wenbentxtflag = false + that.ljsbflag = true + that.chongshinum = '锁车' + } + },4000) + } else { + if(that.shibainum < 3){ + that.shibainum++ + that.findDeviceTimer = setTimeout(findDevice.bind(that), 1000) // 使用 bind 保持 this 上下文 + }else{ + that.ver_dataflag = 1 + that.shibainum = 0 + that.wenbentxt = '' + that.wenbentxtflag = false + that.ljsbflag = true + that.chongshinum = '锁车' + let lanya = '' + if(that.jiance == true){ + lanya = '蓝牙未开启' + }else{ + lanya = '蓝牙已开启' + } + let data = { + mac:that.mac, + orderId: that.orderobj.orderId, + reason:'用户蓝牙临时锁车失败' + lanya, + command:'11llosesub300@', + lat: that.lslat, + lon: that.lslon, + result:'失败' + } + that.$u.post(`/app/commandLog/bluetooth`,data).then(res => {}) + } + } + } + findDevice() + } else { + that.wenbentxt = '' + that.wenbentxtflag = false + uni.showToast({ + title: res.msg, + icon: 'none', + duration: 2000 + }) + } + }) + } else if (res.cancel) { + console.log('取消') // 用户点击取消 + } + } + }) + } + } + }else{ + uni.navigateTo({ + url:'/page_user/yongche/orderxq?id=' + this.orderobj.orderId + }) + } + }else if(res.code == 40001){ + uni.navigateTo({ + url:'/page_user/yongche/orderxq?id=' + this.orderobj.orderId + }) + } + }) + }, // 获取本人正在使用的订单设备 getorderdevice() { this.$u.get("/app/orderDevice/mineUsing").then((res) => { @@ -561,237 +1982,217 @@ if (res.data) { this.orderobj = res.data this.orderAreaReturnVerify = res.data.orderAreaReturnVerify - this.orderflag = true + this.orderAreaId = res.data.orderAreaId + this.areaId = res.data.orderAreaId + this.deviceMac = res.data.deviceMac + this.mac = res.data.deviceMac + this.orderflag = true + this.isPageActive = true + this.getMyLocation() + this.initWebSocket() //WebSocket接受数据 + this.$u.get(`/app/area/detail?id=${this.orderAreaId}`).then((res) => { + if (res.code == 200) { + const polylines = this.convertBoundaryToPolyline(res.data.boundaryStr) + this.polyline.push(polylines) + this.getParking() + } + }) + + // 如果有数据,启动定时器每分钟执行一次 + this.startOrderDeviceTimer() } else { - this.orderflag = false + uni.reLaunch({ + url:'/pages/nearbystores/index' + }) + this.orderAreaId = '' + this.orderflag = false + this.newMarkers = '' + console.log(this.covers) + // 如果没有数据,停止定时器 + this.stopOrderDeviceTimer() } } }) }, - // 点击跳转轮播图跳转 - btnshangjia(e){ - console.log(e,'1212121',this.tiaozhuanlist[e].urlType); - if(this.tiaozhuanlist[e].urlType == 1){ - uni.navigateTo({ - url: '/page_fenbao/webview?url=' + this.tiaozhuanlist[e].url - }) - }else{ - uni.navigateTo({ - url: '/' + this.tiaozhuanlist[e].url + + // 启动订单设备定时器 + startOrderDeviceTimer() { + // 先清除可能存在的定时器 + this.stopOrderDeviceTimer() + + // 创建新的定时器,每分钟执行一次 + this.orderDeviceTimer = setInterval(() => { + // 检查页面是否活跃 + if (!this.isPageActive) { + this.stopOrderDeviceTimer() + return + } + + // 执行获取订单设备的请求 + this.$u.get("/app/orderDevice/mineUsing").then((res) => { + if (res.code == 200) { + if (res.data) { + // 更新订单数据 + this.orderobj = res.data + this.orderAreaReturnVerify = res.data.orderAreaReturnVerify + this.orderAreaId = res.data.orderAreaId + this.areaId = res.data.orderAreaId + this.deviceMac = res.data.deviceMac + this.mac = res.data.deviceMac + this.orderflag = true + this.isPageActive = true + + // 如果WebSocket连接断开,重新连接 + if (!this.socketTask || this.socketTask.readyState !== 1) { + this.initWebSocket() + } + } else { + // 如果没有数据,停止定时器 + this.orderAreaId = '' + this.orderflag = false + this.newMarkers = '' + this.stopOrderDeviceTimer() + } + } + }).catch(err => { + console.error('定时获取订单设备失败:', err) + // 发生错误时也停止定时器 + this.stopOrderDeviceTimer() }) + }, 60000) // 60000毫秒 = 1分钟 + }, + + // 停止订单设备定时器 + stopOrderDeviceTimer() { + if (this.orderDeviceTimer) { + clearInterval(this.orderDeviceTimer) + this.orderDeviceTimer = null + console.log('订单设备定时器已停止') } }, - // 点击显示客服 - btnkf(){ - if(this.kefulist.length > 0){ - this.kefuflag = true - }else{ - uni.showToast({ - title: '当前暂无客服', - icon: 'none', - duration: 2000 - }) - } - }, - // 获取客服 - getkefu(){ - this.$u.get(`/app/customerService/indexList?radius=1000¢er=${this.jinweidu}`).then(res => { - if(res.code == 200){ - this.kefulist = res.after - this.kefuarr = res.before + // 请求客服 + getkefu() { + this.$u.get(`/app/customerService/list?pageNum=1&pageSize=999`).then(res => { + if (res.code == 200) { + this.kefulist = res.rows } }) }, - // 获取广告轮播图 - getlunbo(){ - this.$u.get("/app/ad").then(res => { - if(res.code == 200){ - this.lists = [] - this.tiaozhuanlist = res.data - if(res.data.length > 0 && res.data[0] != null){ - res.data.forEach(item =>{ - this.lists.push({ - image:item.picture, - title: item.adId - }) - }) - }else{ - this.lists.push({ - image:"https://api.ccttiot.com/smartmeter/img/static/uTZBBRuyRexKd6c4VE9d", - title: "" - }) - } - }else{ - this.lists.push({ - image:"https://api.ccttiot.com/smartmeter/img/static/uTZBBRuyRexKd6c4VE9d", - title: "" + // 点击去下单 + btndetaxq() { + this.$u.get(`/getInfo`).then(res => { + if (res.code == 200) { + this.taocanflag = false + uni.navigateTo({ + url: '/page_fenbao/storedlist/trueorder?modelId=' + this.cheobj.modelId + '&sn=' + this.cheobj.sn + }) + } else if (res.code == 401) { + uni.showModal({ + title: '提示', + content: '您当前未登录,是否前去登录?', + showCancel: true, + success: function(res) { + if (res.confirm) { + uni.reLaunch({ + url: '/pages/login/login' + }) + } else if (res.cancel) { + + } + } }) } }) }, - // 获取个人用户信息 - getinfo(){ - this.$u.get("/getInfo").then(res => { - if(res.code == 200){ - this.getzhifu() - this.info = res.user - this.getMyLocation() - this.getgonggao() - }else if(res.code == 401){ - this.getlogo() - } - }) - }, - // 静默登录 - getlogo(){ - let taht = this - wx.login({ - success(res) { - if (res.code) { - let data = { - loginCode: res.code, - appId:taht.$store.state.appid + // 点击响铃寻车 + btnxlxc() { + this.$u.put(`/app/device/iot/ring?id=${this.cheobj.id}&lat=${this.xllat}&lon=${this.xllng}`).then((res) => { + if (res.code == 200) { + uni.showToast({ + title: '操作成功', + icon: 'success', + duration: 2000 + }) + } else if (res.code == 401) { + uni.showModal({ + title: '提示', + content: '您当前未登录,是否前去登录?', + showCancel: true, + success: function(res) { + if (res.confirm) { + uni.reLaunch({ + url: '/pages/login/login' + }) + } else if (res.cancel) { + + } } - taht.$u.post('/wxLogin', data).then(res => { - if (res.code == 200) { - uni.setStorageSync('token', res.token) - taht.getinfo() - taht.getlunbo() - }else{ - taht.getinfo() - } - }) - } - }, - }) - }, - // 点击头部滚动通知 - btntopgg(){ - this.$u.get(`/app/notice/${this.announcements.noticeId}`).then(resp =>{ - if(resp.code == 200){ - this.gonggaoxq = resp.data - this.gonggaoflag = true + }) + } else { + uni.showToast({ + title: res.msg, + icon: 'none', + duration: 2000 + }) } }) }, - // 点击公告我知道了 - btnggtc(){ - this.gonggaoflag = false - uni.setStorageSync('noticeId', this.announcements.noticeId) + // 点击隐藏车辆弹窗 + btncheyc() { + this.taocanflag = false + this.newMarkers = '' }, - // 获取最新公告 - getgonggao(){ - this.$u.get("/app/notice/new?noticeType=1").then(res =>{ - if(res.code == 200){ - this.announcements = res.data - if(res.data){ - this.$u.get(`/app/notice/${res.data.noticeId}`).then(resp =>{ - if(resp.code == 200){ - this.gonggaoxq = resp.data - if(resp.data.noticeId != uni.getStorageSync('noticeId')){ - this.gonggaoflag = true - } - } - }) - } - } + + // 点击选择骑行套餐 + btntcxz(index) { + this.tcindex = index + }, + // 点击跳转到帮助中心 + btnbz() { + uni.navigateTo({ + url: '/page_user/bangzhu' }) }, // 点击拨打平台客服电话 - btnptkf(tel){ - uni.makePhoneCall({ - phoneNumber: tel, - success: function(res) { - console.log('拨打电话成功', res) - }, - fail: function(err) { - console.error('拨打电话失败', err) - } - }) - }, - // 点击进行跳转页面 - btntiao(num){ - if(num == 1){ //跳转到地图页 - uni.switchTab({ - url:'/pages/nearbystores/index' - }) - }else if(num == 2){ //跳转到使用帮助页 - uni.navigateTo({ - url:'/page_user/bangzhu' - }) - }else if(num == 3){ //跳转到车辆故障上报 - uni.navigateTo({ - url:'/page_user/guzhang/index' - }) - }else{ //跳转到意见反馈页 - uni.navigateTo({ - url:'/page_user/yijian' - }) - } - }, - // 点击附近门店跳转到门店详情页 - btnxq(){ + btnptkf(tel){ + uni.makePhoneCall({ + phoneNumber: tel, + success: function(res) { + console.log('拨打电话成功', res) + }, + fail: function(err) { + console.error('拨打电话失败', err) + } + }) + }, + // 点击跳转到租车门店 + btnmendain() { uni.navigateTo({ - url:'/page_fenbao/storedlist/index' + url: '/page_fenbao/storedlist/index' }) }, - // 点击门店拨打电话 - btntel() { - uni.makePhoneCall({ - phoneNumber: '18888888888', - success: function(res) { - console.log('拨打电话成功', res) - }, - fail: function(err) { - console.error('拨打电话失败', err) - } - }) - }, - // 点击跳转 - btnpage(num){ - if(num == 1){ //跳转到附近门店页面 - uni.navigateTo({ - url:'/page_fenbao/storedlist/fujinshop' - }) - }else if(num == 2){ //跳转到我的订单页面 - uni.navigateTo({ - url:'/pages/myorder/index' - }) - }else if(num == 3){ //跳转到租借车辆页面 - uni.switchTab({ - url:'/pages/myorder/returned/index' - }) - }else{ - uni.navigateTo({ - url:'/page_fenbao/index' + // 点击右侧图标 + btntap(num) { + if (num == 3) { + uni.showToast({ + title: '导览暂未开放', + icon: 'none', + duration: 2000 }) + } else { + this.covers = [] + this.rtindex = num + this.shoptcflag = false + this.getqingqiu() } }, - // 点击跳转到地图页 - btnzk(){ - uni.switchTab({ - url:'/pages/nearbystores/index' - }) - }, - // 获取自身位置 - getMyLocation() { - uni.getLocation({ - type: 'wgs84', - success: (res) => { - this.jinweidu =res.longitude + ',' + res.latitude - this.getkefu() - this.latitude = Number(res.latitude.toFixed(5)) - 0.005 - this.longitude = Number(res.longitude.toFixed(5)) + 0.005 - this.setMapScale() - }, - fail: (err) => { - console.error('获取位置失败:', err) - } - }) + // 点击调用回到地图中心点 + btnhuiz() { + this.setMapScale() }, // 回到地图中心点 async setMapScale(e, val) { - let mapContext = uni.createMapContext('map', this) + let mapContext = uni.createMapContext('map', this); let setScale = () => { return new Promise((resolve, reject) => { mapContext.getScale({ @@ -800,7 +2201,7 @@ } }) }) - } + }; await setScale() mapContext.moveToLocation({ success: (res) => { @@ -810,73 +2211,641 @@ } }) }, + + // 请求附近车辆and门店 + getqingqiu() { + if (this.rtindex == 1) { + this.iconPath = 'https://api.ccttiot.com/smartmeter/img/static/upX2lLilhrRi4tttdHlo' + } else if (this.rtindex == 2) { + this.iconPath = this.iconobj.mappic + this.$u.get(`/app/device/listNearBy?radius=10000¢er=${this.jingweidu}&areaId=${this.orderobj.orderAreaId == undefined ? null : this.orderobj.orderAreaId}`).then((res) => { + if (res.code == 200) { + this.covers = [] + this.listData = [] + this.$set(this, 'covers', [...this.covers, ...this.newMarkers]) + if(this.sockedata.latitude){ + this.covers.push({ + latitude: this.sockedata.latitude, + longitude: this.sockedata.longitude, + width: 8, + height: 8, + iconPath: 'https://api.ccttiot.com/smartmeter/img/static/uow9Zq3edTUYCVHI9H60', + }) + } + this.listData = res.data + res.data.forEach(item => { + const shopCover = { + // 门店后面拼接1,车辆拼接2,3是导览 + id: this.rtindex == 1 ? parseInt(item.id + "1") : this.rtindex == + 2 ? parseInt(item.id + "2") : parseInt(item.id + "3"), + latitude: item.latitude, + longitude: item.longitude, + width: 35, + height: 40, + iconPath: this.iconPath, + callout: { + content: item.vehicleNum == null ? item.sn : '' + item.vehicleNum, // 修改为你想要显示的文字内容 + color: '#0D75E5', // 修改为文字颜色 + fontSize: 10, // 修改为文字大小 + borderRadius: 10, // 修改为气泡圆角大小 + bgColor: '#fff', // 修改为气泡背景颜色 + padding: 3, // 修改为气泡内边距 + display: 'ALWAYS', // 修改为气泡的显示策略 + } + } + this.covers.push(shopCover) + }) + } + }) + } else if (this.rtindex == 3) { + this.iconPath = 'https://api.ccttiot.com/smartmeter/img/static/un7ecyEN8vsJhlEnXfD4' + } else { + this.iconPath = null + } + }, + // 获取自身位置 + getMyLocation() { + uni.getLocation({ + type: 'wgs84', + success: (res) => { + this.latitude = Number(res.latitude) - 0.005 + this.longitude = Number(res.longitude) + 0.005 + this.jingweidu = this.longitude + ',' + this.latitude + this.getqingqiu() + }, + fail: (err) => { + console.error('获取位置失败:', err) + } + }) + }, + + convertBoundaryToPolyline(boundary) { + if (!boundary) return null + const points = JSON.parse(boundary).map(coord => ({ + latitude: coord[1], + longitude: coord[0] + })) + const polyline = { + points: points, + fillColor: "#55888820", + strokeColor: "#22FF00", + strokeWidth: 1, + zIndex: 1, + isOperationArea: true + } + return polyline + }, + convertBoundaryToPolylines(boundaries, num) { + if (!Array.isArray(boundaries)) { + console.error('边界数据不是数组:', boundaries) + return [] + } + + const polylines = boundaries.map(boundary => { + if (!boundary) { + console.warn('边界数据为空') + return null + } + + let coords + try { + coords = JSON.parse(boundary) + } catch (error) { + console.error('解析边界JSON失败:', error) + return null + } + + if (!Array.isArray(coords)) { + console.error('解析后的边界数据不是数组:', coords) + return null + } + + const points = coords.map(coord => { + if (!Array.isArray(coord) || coord.length < 2) { + console.warn('坐标数据格式错误:', coord) + return null + } + return { + latitude: parseFloat(coord[1]), + longitude: parseFloat(coord[0]) + } + }).filter(point => point !== null) + + if (points.length < 3) { + console.warn('有效坐标点不足3个,无法构成多边形') + return null + } + + // 根据类型设置不同的样式 + let style = {} + if (num == 1) { // 停车区 + style = { + fillColor: "#88888850", + strokeColor: "#88888850", + strokeWidth: 1, + zIndex: 1, + isOperationArea: false + } + } else if (num == 2) { // 禁停区 + style = { + fillColor: "#FFF5D640", + strokeColor: "#FF473E", + strokeWidth: 2, + zIndex: 1, + isOperationArea: false + } + } else if (num == 3) { // 禁行区 + style = { + fillColor: "#FFD1CF40", + strokeColor: "#FFC107", + strokeWidth: 2, + zIndex: 1, + isOperationArea: false + } + } + + return { + points: points, + ...style + } + }).filter(polyline => polyline !== null) + + return polylines + }, + toggleIconAndCallout() { + if (this.cheobj == '') { + uni.showToast({ + title: '请选选择车辆', + icon: 'none', + duration: 2000 + }) + } else { + this.showIconAndCallout = !this.showIconAndCallout + if (this.showIconAndCallout) { + const newMarkers = [] + this.parkingList.forEach(item => { + newMarkers.push({ + id: parseFloat(item.id), + latitude: parseFloat(item.latitude), + longitude: parseFloat(item.longitude), + width: 40, + height: 60, + iconPath: item.type == 1 ? + 'https://lxnapi.ccttiot.com/bike/img/static/up2xXqAgwCX5iER600k3' : + item.type == 2 ? + 'https://lxnapi.ccttiot.com/bike/img/static/uDNY5Q4zOiZTCBTA2Jdq' : + 'https://lxnapi.ccttiot.com/bike/img/static/u53BAQcFIX3vxsCzEZ7t', + callout: { + content: item.name, + color: '#ffffff', + fontSize: 14, + borderRadius: 10, + bgColor: item.type == 1 ? '#3A7EDB' : item.type == 2 ? '#FF473E' : + '#FFC107', + padding: 6, + display: 'ALWAYS' + }, + isCalloutVisible: true // 添加标记 + }) + }) + this.newMarkers = newMarkers + this.$set(this, 'covers', [...this.covers, ...newMarkers]) + } else { + // 过滤掉所有气泡显示的标记 + this.$set(this, 'covers', this.covers.filter(marker => !marker.isCalloutVisible)) + } + } + }, + getParking() { + this.$u.get(`/app/areaSub/listByArea?areaId=${this.areaId}`).then((res) => { + if (res.code === 200 && Array.isArray(res.data)) { + // 缓存数据 + const filteredData = res.data.filter(item => item.status != 1); + this.cachedParkingData[this.areaId] = filteredData + + const type1Data = [] + const type2Data = [] + const type3Data = [] + + filteredData.forEach(row => { + if(row.type == 1) type1Data.push(row) + else if(row.type == 2) type2Data.push(row) + else if(row.type == 3) type3Data.push(row) + }) + + const processBoundaries = (data, type) => { + const validBoundaries = data + .map(row => row.boundaryStr) + .filter(boundary => boundary && typeof boundary === 'string' && boundary.trim() !== '') + + if(validBoundaries.length > 0) { + const polylines = this.convertBoundaryToPolylines(validBoundaries, type) + if(polylines && polylines.length > 0) { + return polylines + } + } + return [] + } + + // 先处理所有边界数据 + const type1Polylines = processBoundaries(type1Data, 1) + const type2Polylines = processBoundaries(type2Data, 2) + const type3Polylines = processBoundaries(type3Data, 3) + + // 保留现有的运营区边界 + const operationAreaPolylines = this.polyline.filter(p => p.isOperationArea) + + // 合并所有边界数据 + const allPolylines = [ + ...operationAreaPolylines, + ...type1Polylines, + ...type2Polylines, + ...type3Polylines + ] + + // 缓存多边形数据 + this.cachedPolyline = allPolylines + + // 更新显示 + this.polyline = allPolylines + this.parkingList = filteredData + this.isFirstLoad = false + } + }) + }, + updatePolylineFromCache() { + // 保留现有的运营区边界 + const operationAreaPolylines = this.polyline.filter(p => p.isOperationArea) + + // 从缓存中获取其他边界数据 + const otherPolylines = this.cachedPolyline.filter(p => !p.isOperationArea) + + // 合并数据 + const allPolylines = [...operationAreaPolylines, ...otherPolylines] + + // 更新显示 + this.polyline = allPolylines + }, + // 请求运营区停车点,禁行区, + getArea() { + this.polyline = [] + this.$u.get(`/app/area/detail?id=${this.areaId}`).then((res) => { + if (res.code == 200) { + const polylines = this.convertBoundaryToPolyline(res.data.boundaryStr) + this.polyline.push(polylines) + this.getParking() + } + }) + }, + // 第一次请求运营区停车点,禁行区, + getAone() { + this.$u.get("/getInfo").then(res => { + if(res.code == 200){ + this.user = res.user + this.$u.get(`/app/area/nearby?id=${res.user.areaId == null ? '' : res.user.areaId}&radius=1000¢er=${this.jingweidu}`).then((resp) => { + if (resp.code == 200) { + if(resp.data){ + this.yyid = resp.data.id + } + if(resp.data && resp.data.boundaryStr) { + const polylines = this.convertBoundaryToPolyline(resp.data.boundaryStr) + if(polylines) { + this.polyline = [polylines] + this.getParking() + if(resp.data && resp.data.id){ + this.loadNearbyDevices(resp.data.id) + } + } + } + } + }) + } + }) + }, + + loadNearbyDevices(areaId) { + if (this.rtindex == 2) { + this.$u.get(`/app/device/listNearBy?radius=10000¢er=${this.jingweidu}&areaId=${areaId}`).then((res) => { + if (res.code == 200) { + this.listData = res.data + this.updateMarkers() + } + }) + } + }, + + updateMarkers() { + const newMarkers = [] + this.listData.forEach(item => { + if(item.latitude && item.longitude) { + const marker = { + id: this.rtindex == 1 ? parseInt(item.id + "1") : + this.rtindex == 2 ? parseInt(item.id + "2") : + parseInt(item.id + "3"), + latitude: parseFloat(item.latitude), + longitude: parseFloat(item.longitude), + width: 35, + height: 40, + iconPath: this.getIconPath(), + callout: { + content: item.vehicleNum || item.sn || '', + color: '#0D75E5', + fontSize: 10, + borderRadius: 10, + bgColor: '#fff', + padding: 3, + display: 'ALWAYS' + } + } + newMarkers.push(marker) + } + }) + this.tempCovers = newMarkers + this.covers = this.tempCovers + }, + + getIconPath() { + if (this.rtindex == 1) { + return 'https://api.ccttiot.com/smartmeter/img/static/upX2lLilhrRi4tttdHlo' + } else if (this.rtindex == 2) { + return this.iconobj.mappic + } else if (this.rtindex == 3) { + return 'https://api.ccttiot.com/smartmeter/img/static/un7ecyEN8vsJhlEnXfD4' + } + return null + }, + + updatePolyline(newPolylines) { + // 使用Vue的响应式更新 + this.tempPolyline = [...newPolylines] + this.polyline = this.tempPolyline + }, + + updateCovers(newCovers) { + // 使用Vue的响应式更新 + this.tempCovers = [...newCovers] + this.covers = this.tempCovers + }, + } } \ No newline at end of file diff --git a/pages/my.vue b/pages/my.vue index 2dd0392..cfa5c58 100644 --- a/pages/my.vue +++ b/pages/my.vue @@ -1,7 +1,7 @@ @@ -157,6 +157,12 @@ // this.getlunbo() }, methods: { + // 点击返回首页 + btnfh(){ + uni.reLaunch({ + url:'/pages/nearbystores/index' + }) + }, // 点击跳转到商家合作 btnshangjia(){ uni.navigateTo({ diff --git a/pages/myorder/returned/index.vue b/pages/myorder/returned/index.vue index cd67119..bf7ec57 100644 --- a/pages/myorder/returned/index.vue +++ b/pages/myorder/returned/index.vue @@ -18,17 +18,18 @@ 车牌号:{{deivceobj.deviceVehicleNum == null ? '--' : deivceobj.deviceVehicleNum}} SN:{{deivceobj.deviceSn == null ? '--' : deivceobj.deviceSn}} - + + 点击断开 + mode=""> 已连接 连接中... - + 点击连接 + mode=""> 未连接 @@ -60,9 +61,13 @@ 鸣笛寻车 - + - {{deivceobj.deviceLockStatus == 0 ? '点击开锁' : '临时锁车'}} + 点击开锁 + + + + 临时锁车 @@ -238,7 +243,8 @@ isRefreshing: false, orderid:'', qixingobj:{}, - shibainum:0 + shibainum:0, + jiance:false }; }, computed: { @@ -381,7 +387,6 @@ title: '加载中...', mask: true }) - // console.log(that.lslat,that.lslon,'开坐垫锁'); if (that.ver_dataflag == 3) { xBlufi.notifySendCustomData({ customData: "11hpen@" @@ -437,18 +442,52 @@ } else if(res.code == 20001){ uni.hideLoading() if(that.ver_dataflag != 3){ - uni.showModal({ - title: '提示', - content: '设备离线,请点击右上角连接车辆', - showCancel: false, - success: function(res) { - if (res.confirm) { - - } else if (res.cancel) { - - } - } + uni.showLoading({ + title: '坐垫锁开启中...', + mask: true }) + this.ver_dataflag = 2 + const matchedDevice = this.devicesarr.find(device => { + return device.name.slice(-12) == this.mac.slice(-12) + }) + if (matchedDevice) { + xBlufi.notifyStartDiscoverBle({ + 'isStart': false + }) + xBlufi.notifyConnectBle({ + isStart: true, + deviceId: matchedDevice.deviceId, + name: matchedDevice.name + }) + this.deviceid = matchedDevice.deviceId + this.devicename = matchedDevice.name + setTimeout(()=>{ + uni.hideLoading() + xBlufi.notifySendCustomData({ + customData: "11hpen@" + }) + },4000) + } else { + if(this.shibainum < 3){ + this.shibainum++ + this.findDeviceTimer = setTimeout(this.findDevice.bind(this), 1000) // 使用 bind 保持 this 上下文 + }else{ + this.ver_dataflag = 1 + this.shibainum = 0 + uni.showModal({ + title: '提示', + content: '开启坐垫锁失败,请重试', + showCancel: false, + success: function(res) { + if (res.confirm) { + + } else if (res.cancel) { + + } + } + }) + } + } } } else { uni.hideLoading() @@ -514,15 +553,6 @@ if (res.code == 200) { if (res.data) { this.mac = res.data.deviceMac - // if(this.ver_dataflag != 3){ - // setTimeout(()=>{ - // console.log('11ly',this.ljflag) - // if(this.ljflag == true){ - // this.ljflag = false - // this.findDevice() - // } - // },1000) - // } this.cheflag = false this.orderAreaReturnVerify = res.data.orderAreaReturnVerify this.deivceobj = res.data @@ -592,6 +622,7 @@ this.ver_dataflag = 1 console.log(this.ver_dataflag,'断开断开'); clearTimeout(this.uploadTimer) //清除每十秒传一次的定时 + this.jiance = true // this.findDevice() } break; @@ -624,6 +655,7 @@ case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS_START: if (!options.result) { console.log('蓝牙未开启') + this.jiance = true return } else { this.lanyaflag = false @@ -793,319 +825,344 @@ }, // 点击启动and关闭 - btnqd() { - if (this.deivceobj.deviceLockStatus == 0) { - uni.getLocation({ - type: 'gcj02', // 国内地图更兼容 - isHighAccuracy: true, - accuracy:'best', - success: (res) => { - console.log('精确坐标:', res) - this.lslat = res.latitude - this.lslon = res.longitude - }, - fail: (err) => { - console.error('获取位置失败:', err) - this.lslat = null - this.lslat = null - } + btnqd(deviceLockStatus) { + if(this.jiance == true){ + xBlufi.initXBlufi(1) + xBlufi.notifyStartDiscoverBle({ + 'isStart': true }) - if(this.ver_dataflag != 3){ - let that = this - uni.showModal({ - title: '提示', - content: '您是否要解锁车辆?', - showCancel: true, - success: function(res) { - if (res.confirm) { - uni.showLoading({ - title: '加载中...', - mask: true - }) - let query = { - orderId: that.deivceobj.orderId, - lat: that.lslat, - lon: that.lslon, - requiredIot: true - } - - let url = '/app/order/openDevice?' + that.$tansParams(query) - that.$u.put(url).then((res) => { - if (res.code == 200) { - uni.showToast({ - title: '解锁成功', - icon: 'success', - duration: 2000 - }) - that.deivceobj.deviceLockStatus = 1 - that.getorderdevice() - } else if(res.code == 20001){ - uni.hideLoading() - uni.showModal({ - title: '提示', - content: '设备离线,请点击右上角连接车辆', - showCancel: false, - success: function(res) { - if (res.confirm) { - - } - } - }) - } else { - uni.hideLoading() - uni.showToast({ - title: res.msg, - icon: 'none', - duration: 2000 - }) + xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent) + } + this.$u.get("/app/orderDevice/mineUsing").then((res) => { + if (res.code == 200) { + if(res.data){ + if(res.data.deviceStatus == 9){ + uni.showModal({ + title: '提示', + content: '车辆已被强制锁车,请联系客服', + showCancel: false, + success: function(res) { + if (res.confirm) { + } - }) - } - } - }) - }else{ - let that = this - uni.showModal({ - title: '提示', - content: '您是否要解锁车辆?', - showCancel: true, - success: function(res) { - if (res.confirm) { - xBlufi.notifySendCustomData({ - customData: "11opensub5@" - }) - uni.showLoading({ - title: '加载中...', - mask: true - }) - let query = { - orderId: that.deivceobj.orderId, - lat: that.lslat, - lon: that.lslon, - requiredIot: false } - let url = '/app/order/openDevice?' + that.$tansParams(query) - that.$u.put(url).then((res) => { - if (res.code == 200) { - uni.showToast({ - title: '解锁成功', - icon: 'success', - duration: 2000 - }) - that.deivceobj.deviceLockStatus = 1 - that.getorderdevice() - let data = { - mac:that.mac, - reason:'解锁', - command:'11opensub5@', - longitude:that.lslon, - latitude:that.lslat, - result:'成功' - } - that.$u.post(`/app/commandLog/bluetooth`,data).then(res => {}) - } else if(res.code == 20001){ - uni.hideLoading() - uni.showModal({ - title: '提示', - content: '设备离线,请点击右上角连接车辆', - showCancel: false, - success: function(res) { - if (res.confirm) { - - } - } - }) - } else { - uni.hideLoading() - uni.showToast({ - title: res.msg, - icon: 'none', - duration: 2000 - }) - } + }) + }else{ + if (deviceLockStatus == 0) { + uni.getLocation({ + type: 'gcj02', // 国内地图更兼容 + isHighAccuracy: true, + accuracy:'best', + success: (res) => { + console.log('精确坐标:', res) + this.lslat = res.latitude + this.lslon = res.longitude + }, + fail: (err) => { + console.error('获取位置失败:', err) + this.lslat = null + this.lslat = null + } }) - } else if (res.cancel) { - - } - } - }) - } - } else if (this.deivceobj.deviceLockStatus == 1) { - uni.getLocation({ - type: 'gcj02', // 国内地图更兼容 - isHighAccuracy: true, - accuracy:'best', - success: (res) => { - console.log('精确坐标:', res) - this.lat = res.latitude - this.lon = res.longitude - }, - fail: (err) => { - this.lat = null - this.lon = null - console.error('获取位置失败:', err) - } - }) - if(this.ver_dataflag != 3){ - let that = this - uni.showModal({ - title: '提示', - content: '您是否要临时锁车?', - showCancel: true, - success: function(res) { - if (res.confirm) { - uni.showLoading({ - title: '加载中...', - mask: true - }) - let query = { - orderId: that.deivceobj.orderId, - lat: that.lat, - lon: that.lon, - requiredIot: true - } - let url = '/app/order/closeDevice?' + that.$tansParams(query) - that.$u.put(url).then((res) => { - if (res.code == 200) { - uni.hideLoading() - uni.showToast({ - title: '临时锁车成功', - icon: 'success', - duration: 2000 - }) - that.deivceobj.deviceLockStatus = 0 - that.getorderdevice() - } else if(res.code == 20001){ - uni.hideLoading() - uni.showModal({ - title: '提示', - content: '设备离线,请点击右上角连接车辆', - showCancel: false, - success: function(res) { - if (res.confirm) { - - } - } - }) - } else { - uni.hideLoading() - uni.showToast({ - title: res.msg, - icon: 'none', - duration: 2000 - }) - } - }) - } else if (res.cancel) { - console.log('取消') // 用户点击取消 - } - } - }) - }else{ - let that = this - uni.showModal({ - title: '提示', - content: '您是否要临时锁车?', - showCancel: true, - success: function(res) { - if (res.confirm) { - uni.showLoading({ - title: '加载中...', - mask: true - }) - let query = { - orderId: that.deivceobj.orderId, - lat: that.lat, - lon: that.lon, - requiredIot: false - } - let url = '/app/order/closeDevice?' + that.$tansParams(query) - that.$u.put(url).then((res) => { - if (res.code == 200) { - uni.showLoading({ - title: '加载中...', - mask: true - }) - if (that.ver_dataflag == 3) { - xBlufi.notifySendCustomData({ - customData: "11llosesub300@", + let that = this + uni.showModal({ + title: '提示', + content: '您是否要解锁车辆?', + showCancel: true, + success: function(res) { + if (res.confirm) { + uni.showLoading({ + title: '车辆解锁中...', + mask: true }) - that.deivceobj.deviceLockStatus = 0 - let data = { - mac:that.mac, - reason:'临时锁车', - command:'11llosesub300@', - longitude:that.lon, - latitude:that.lat, - result:'成功' + let query = { + orderId: that.deivceobj.orderId, + lat: that.lslat, + lon: that.lslon, + requiredIot: true } - that.$u.post(`/app/commandLog/bluetooth`,data).then(res => { - console.log(res,'蓝牙') - }) - setTimeout(()=>{ - xBlufi.notifySendCustomData({ - customData: "11reboot@" - }) - uni.hideLoading() - },2000) - } else { - uni.hideLoading() - let that = this - uni.showModal({ - title: '提示', - content: '请点击右上角连接蓝牙控制,蓝牙连接需尽可能靠近车辆!', - showCancel: false, - success: function(res) { - if (res.confirm) { + let url = '/app/order/openDevice?' + that.$tansParams(query) + that.$u.put(url).then((res) => { + if (res.code == 200) { + uni.hideLoading() + uni.showToast({ + title: '解锁成功', + icon: 'success', + duration: 2000 + }) + that.deivceobj.deviceLockStatus = 1 + // that.getorderdevice() + } else if(res.code == 20001){ + console.log(111); + uni.showLoading({ + title: '蓝牙解锁中...', + mask: true + }) + const findDevice = () =>{ + that.ver_dataflag = 2 + const matchedDevice = that.devicesarr.find(device => { + return device.name.slice(-12) == that.mac.slice(-12) + }) + if (matchedDevice) { + xBlufi.notifyStartDiscoverBle({ + 'isStart': false + }) + xBlufi.notifyConnectBle({ + isStart: true, + deviceId: matchedDevice.deviceId, + name: matchedDevice.name + }) + that.deviceid = matchedDevice.deviceId + that.devicename = matchedDevice.name + setTimeout(()=>{ + if(that.ver_dataflag == 3){ + uni.hideLoading() + xBlufi.notifySendCustomData({ + customData: "11opensub5@" + }) + that.deivceobj.deviceLockStatus = 1 + let query = { + orderId: that.deivceobj.orderId, + lat: that.lslat, + lon: that.lslon, + requiredIot: false + } + let url = '/app/order/openDevice?' + that.$tansParams(query) + that.$u.put(url).then((res) =>{}) + }else{ + that.ver_dataflag = 1 + that.shibainum = 0 + uni.hideLoading() + uni.showModal({ + title: '提示', + content: '车辆解锁失败,请检查手机蓝牙是否打开或微信蓝牙是否授权,开启手机定位', + showCancel: false, + success: function(res) { + if (res.confirm) { + + } else if (res.cancel) { + + } + } + }) + } + },4000) + } else { + if(that.shibainum < 3){ + that.shibainum++ + that.findDeviceTimer = setTimeout(findDevice.bind(that), 1000) // 使用 bind 保持 this 上下文 + }else{ + that.ver_dataflag = 1 + that.shibainum = 0 + uni.hideLoading() + uni.showModal({ + title: '提示', + content: '车辆解锁失败,请检查手机蓝牙是否打开或微信蓝牙是否授权,开启手机定位', + showCancel: false, + success: function(res) { + if (res.confirm) { + + } else if (res.cancel) { + + } + } + }) + } + } } + findDevice() + } else { + uni.hideLoading() + uni.showToast({ + title: res.msg, + icon: 'none', + duration: 2000 + }) } }) - let data = { - mac:that.mac, - reason:'临时锁车', - command:'close', - longitude:that.lon, - latitude:that.lat, - result:'蓝牙未连接' - } - that.$u.post(`/app/commandLog/bluetooth`,data).then(res => { - console.log(res,'蓝牙') - }) } - } else if(res.code == 20001){ - uni.hideLoading() - uni.showModal({ - title: '提示', - content: '设备离线,请点击右上角连接车辆', - showCancel: false, - success: function(res) { - if (res.confirm) { - - } - } - }) - } else { - uni.hideLoading() - uni.showToast({ - title: res.msg, - icon: 'none', - duration: 2000 - }) } }) - } else if (res.cancel) { - console.log('取消') // 用户点击取消 - } + } else if (deviceLockStatus == 1) { + uni.getLocation({ + type: 'gcj02', // 国内地图更兼容 + isHighAccuracy: true, + accuracy:'best', + success: (res) => { + console.log('精确坐标:', res) + this.lat = res.latitude + this.lon = res.longitude + }, + fail: (err) => { + this.lat = null + this.lon = null + console.error('获取位置失败:', err) + } + }) + let that = this + uni.showModal({ + title: '提示', + content: '您是否要临时锁车?', + showCancel: true, + success: function(res) { + if (res.confirm) { + uni.showLoading({ + title: '临时锁车中...', + mask: true + }) + let query = { + orderId: that.deivceobj.orderId, + lat: that.lat, + lon: that.lon, + requiredIot: true + } + let url = '/app/order/closeDevice?' + that.$tansParams(query) + that.$u.put(url).then((res) => { + if (res.code == 200) { + uni.hideLoading() + uni.showToast({ + title: '临时锁车成功', + icon: 'success', + duration: 2000 + }) + that.deivceobj.deviceLockStatus = 0 + // that.getorderdevice() + } else if(res.code == 20001){ + console.log(222); + // uni.hideLoading() + uni.showLoading({ + title: '蓝牙锁车中...', + mask: true + }) + const findDevice = () =>{ + that.ver_dataflag = 2 + const matchedDevice = that.devicesarr.find(device => { + return device.name.slice(-12) == that.mac.slice(-12) + }) + if (matchedDevice) { + xBlufi.notifyStartDiscoverBle({ + 'isStart': false + }) + xBlufi.notifyConnectBle({ + isStart: true, + deviceId: matchedDevice.deviceId, + name: matchedDevice.name + }) + that.deviceid = matchedDevice.deviceId + that.devicename = matchedDevice.name + setTimeout(()=>{ + if(that.ver_dataflag == 3){ + uni.hideLoading() + let data = { + mac:that.mac, + reason:'临时锁车', + command:'11llosesub300@', + longitude:that.lon, + latitude:that.lat, + result:'成功' + } + that.$u.post(`/app/commandLog/bluetooth`,data).then(res => { + console.log(res,'蓝牙') + }) + + xBlufi.notifySendCustomData({ + customData: "11llosesub300@", + }) + that.deivceobj.deviceLockStatus = 0 + let query = { + orderId: that.deivceobj.orderId, + lat: that.lat, + lon: that.lon, + requiredIot: false + } + let url = '/app/order/closeDevice?' + that.$tansParams(query) + that.$u.put(url).then((res) =>{}) + setTimeout(()=>{ + xBlufi.notifySendCustomData({ + customData: "11reboot@" + }) + uni.hideLoading() + },3000) + }else{ + that.ver_dataflag = 1 + that.shibainum = 0 + uni.hideLoading() + uni.showModal({ + title: '提示', + content: '车辆临时锁车失败,请检查手机蓝牙是否打开或微信蓝牙是否授权,开启手机定位', + showCancel: false, + success: function(res) { + if (res.confirm) { + + } else if (res.cancel) { + + } + } + }) + } + },4000) + } else { + if(that.shibainum < 3){ + that.shibainum++ + that.findDeviceTimer = setTimeout(findDevice.bind(that), 1000) // 使用 bind 保持 this 上下文 + }else{ + that.ver_dataflag = 1 + that.shibainum = 0 + uni.hideLoading() + uni.showModal({ + title: '提示', + content: '车辆临时锁车失败,请检查手机蓝牙是否打开或微信蓝牙是否授权,开启手机定位', + showCancel: false, + success: function(res) { + if (res.confirm) { + + } else if (res.cancel) { + + } + } + }) + } + } + } + findDevice() + } else { + uni.hideLoading() + uni.showToast({ + title: res.msg, + icon: 'none', + duration: 2000 + }) + } + }) + } else if (res.cancel) { + console.log('取消') // 用户点击取消 + } + } + }) + } } - }) + }else{ + uni.showToast({ + title: '获取数据失败', + icon: 'none', + duration: 2000 + }) + } } - } + }) }, // 点击鸣笛寻车 btnfm() { + if(this.jiance == true){ + xBlufi.initXBlufi(1) + xBlufi.notifyStartDiscoverBle({ + 'isStart': true + }) + xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent) + } uni.showLoading({ - title: '加载中...', + title: '响铃中...', mask: true }) this.$u.put(`/app/device/iot/ring?id=${this.deivceobj.deviceId}`).then((res) => { @@ -1117,29 +1174,76 @@ duration: 2000 }) } else if (res.code == 20001) { - if (this.ver_dataflag == 3) { - uni.hideLoading() - xBlufi.notifySendCustomData({ - customData: "11play1@" + uni.showLoading({ + title: '响铃中...', + mask: true + }) + let that = this + const findDevice = () =>{ + that.ver_dataflag = 2 + const matchedDevice = that.devicesarr.find(device => { + return device.name.slice(-12) == that.mac.slice(-12) }) - } else { - uni.hideLoading() - let that = this - uni.showModal({ - title: '提示', - content: '请点击右上角连接蓝牙控制,蓝牙连接需尽可能靠近车辆!', - showCancel: false, - success: function(res) { - if (res.confirm) { - if(that.ver_dataflag != 3){ - - } - } else if (res.cancel) { - + if (matchedDevice) { + xBlufi.notifyStartDiscoverBle({ + 'isStart': false + }) + xBlufi.notifyConnectBle({ + isStart: true, + deviceId: matchedDevice.deviceId, + name: matchedDevice.name + }) + that.deviceid = matchedDevice.deviceId + that.devicename = matchedDevice.name + setTimeout(()=>{ + if(that.ver_dataflag == 3){ + uni.hideLoading() + xBlufi.notifySendCustomData({ + customData: "11play1@" + }) + }else{ + that.ver_dataflag = 1 + that.shibainum = 0 + uni.hideLoading() + uni.showModal({ + title: '提示', + content: '车辆响铃失败,请检查手机蓝牙是否打开或微信蓝牙是否授权,开启手机定位', + showCancel: false, + success: function(res) { + if (res.confirm) { + + } else if (res.cancel) { + + } + } + }) } + },4000) + } else { + if(that.shibainum < 3){ + that.shibainum++ + that.findDeviceTimer = setTimeout(findDevice.bind(that), 1000) // 使用 bind 保持 this 上下文 + }else{ + that.ver_dataflag = 1 + that.shibainum = 0 + uni.hideLoading() + uni.showModal({ + title: '提示', + content: '车辆响铃失败,请检查手机蓝牙是否打开或微信蓝牙是否授权,开启手机定位', + showCancel: false, + success: function(res) { + if (res.confirm) { + + } else if (res.cancel) { + + } + } + }) } - }) + } } + findDevice() + } else { uni.hideLoading() uni.showToast({ @@ -1153,25 +1257,75 @@ // 点击去进行换车 btnghbike() { if(this.deivceobj.deviceOnlineStatus == 0){ - if(this.ver_dataflag == 3){ - uni.navigateTo({ - url: '/page_user/huanbike?sn=' + this.deivceobj.deviceSn + '&orderid=' + this.deivceobj.orderId + '&deviceid=' + this.deviceid + '&devicename=' + this.devicename - }) - }else{ - let that = this - uni.showModal({ - title: '提示', - content: '请点击右上角连接蓝牙控制,蓝牙连接需尽可能靠近车辆!', - showCancel: false, - success: function(res) { - if (res.confirm) { - - } else if (res.cancel) { - - } - } - }) - } + uni.hideLoading() + const findDevice = () =>{ + uni.showLoading({ + title: '蓝牙连接中...', + mask: true + }) + this.ver_dataflag = 2 + const matchedDevice = this.devicesarr.find(device => { + return device.name.slice(-12) == this.mac.slice(-12) + }) + if (matchedDevice) { + xBlufi.notifyStartDiscoverBle({ + 'isStart': false + }) + xBlufi.notifyConnectBle({ + isStart: true, + deviceId: matchedDevice.deviceId, + name: matchedDevice.name + }) + this.deviceid = matchedDevice.deviceId + this.devicename = matchedDevice.name + setTimeout(()=>{ + if(this.ver_dataflag == 3){ + uni.hideLoading() + uni.navigateTo({ + url: '/page_user/huanbike?sn=' + this.deivceobj.deviceSn + '&orderid=' + this.deivceobj.orderId + '&deviceid=' + this.deviceid + '&devicename=' + this.devicename + }) + }else{ + this.ver_dataflag = 1 + this.shibainum = 0 + uni.hideLoading() + uni.showModal({ + title: '提示', + content: '蓝牙连接失败,请检查手机蓝牙是否打开或微信蓝牙是否授权,开启手机定位', + showCancel: false, + success: function(res) { + if (res.confirm) { + + } else if (res.cancel) { + + } + } + }) + } + },4000) + } else { + if(this.shibainum < 3){ + this.shibainum++ + this.findDeviceTimer = setTimeout(findDevice.bind(this), 1000) // 使用 bind 保持 this 上下文 + }else{ + this.ver_dataflag = 1 + this.shibainum = 0 + uni.hideLoading() + uni.showModal({ + title: '提示', + content: '蓝牙连接失败,请检查蓝牙是否打开再重试', + showCancel: false, + success: function(res) { + if (res.confirm) { + + } else if (res.cancel) { + + } + } + }) + } + } + } + findDevice() }else{ uni.navigateTo({ url: '/page_user/huanbike?sn=' + this.deivceobj.deviceSn + '&orderid=' + this.deivceobj.orderId + '&deviceid=' + this.deviceid + '&devicename=' + this.devicename @@ -1200,26 +1354,76 @@ btnhc() { if (this.orderAreaReturnVerify == true) { if(this.deivceobj.deviceOnlineStatus == 0){ - if(this.ver_dataflag == 3){ - let flag = false - uni.navigateTo({ - url: '/page_user/hcshenhe?sn=' + this.deivceobj.deviceSn + '&orderid=' + this.deivceobj.orderId + '&orderAreaId=' + this.deivceobj.orderAreaId + '&flag=' + flag + '&mac=' + this.mac + uni.hideLoading() + let that = this + const findDevice = () =>{ + uni.showLoading({ + title: '蓝牙连接中...', + mask: true }) - }else{ - let that = this - uni.showModal({ - title: '提示', - content: '请点击右上角连接蓝牙还车,蓝牙连接需尽可能靠近车辆!', - showCancel: false, - success: function(res) { - if (res.confirm) { - - } else if (res.cancel) { - + that.ver_dataflag = 2 + const matchedDevice = that.devicesarr.find(device => { + return device.name.slice(-12) == that.mac.slice(-12) + }) + if (matchedDevice) { + xBlufi.notifyStartDiscoverBle({ + 'isStart': false + }) + xBlufi.notifyConnectBle({ + isStart: true, + deviceId: matchedDevice.deviceId, + name: matchedDevice.name + }) + that.deviceid = matchedDevice.deviceId + that.devicename = matchedDevice.name + setTimeout(()=>{ + if(that.ver_dataflag == 3){ + let flag = false + uni.navigateTo({ + url: '/page_user/hcshenhe?sn=' + that.deivceobj.deviceSn + '&orderid=' + that.deivceobj.orderId + '&orderAreaId=' + that.deivceobj.orderAreaId + '&flag=' + flag + '&mac=' + that.mac + }) + }else{ + that.ver_dataflag = 1 + that.shibainum = 0 + uni.hideLoading() + uni.showModal({ + title: '提示', + content: '蓝牙连接失败,请检查手机蓝牙是否打开或微信蓝牙是否授权,开启手机定位', + showCancel: false, + success: function(res) { + if (res.confirm) { + + } else if (res.cancel) { + + } + } + }) } + },4000) + } else { + if(that.shibainum < 3){ + that.shibainum++ + that.findDeviceTimer = setTimeout(findDevice.bind(that), 1000) // 使用 bind 保持 this 上下文 + }else{ + that.ver_dataflag = 1 + that.shibainum = 0 + uni.hideLoading() + uni.showModal({ + title: '提示', + content: '蓝牙连接失败,请检查手机蓝牙是否打开或微信蓝牙是否授权,开启手机定位', + showCancel: false, + success: function(res) { + if (res.confirm) { + + } else if (res.cancel) { + + } + } + }) } - }) + } } + findDevice() }else{ let flag = true uni.navigateTo({ @@ -1299,131 +1503,229 @@ }, // 还车统一调用 gethuan() { - if(this.ver_dataflag != 3){ - let that = this - uni.showModal({ - title: '提示', - content: '您确定要还车吗?', - showCancel: true, - success: function(res) { - if (res.confirm) { - uni.showLoading({ - title: '还车中...', - mask: true - }) - let data = { - orderId: that.deivceobj.orderId, - picture: that.imgs, - lon: that.lon, - lat: that.lat, - requiredIot: true - } - that.$u.put(`/app/order/end`, data).then(res => { - if (res.code == 200) { - that.cheflag = true + let that = this + uni.showModal({ + title: '提示', + content: '您确定要还车吗?', + showCancel: true, + success: function(res) { + if (res.confirm) { + uni.showLoading({ + title: '还车中...', + mask: true + }) + let data = { + orderId: that.deivceobj.orderId, + picture: that.imgs, + lon: that.lon, + lat: that.lat, + requiredIot: true + } + that.$u.put(`/app/order/end`, data).then(res => { + if (res.code == 200) { + that.cheflag = true + that.fjflag = false + uni.hideLoading() + uni.showToast({ + title: '还车成功', + icon: 'success', + duration: 2000 + }) + setTimeout(()=>{ + uni.navigateTo({ + url:'/page_user/yongche/orderxq?id=' + that.deivceobj.orderId + }) + },1000) + }else if(res.code == 20001){ + if(that.ver_dataflag == 3){ + xBlufi.notifySendCustomData({ + customData: "11llosesub300@" + }) that.fjflag = false - uni.hideLoading() - uni.showToast({ - title: '还车成功', - icon: 'success', - duration: 2000 - }) - setTimeout(()=>{ - uni.navigateTo({ - url:'/page_user/yongche/orderxq?id=' + that.deivceobj.orderId - }) - },1000) - }else if(res.msg == null) { - uni.hideLoading() - uni.showToast({ - title: '未知错误', - icon: 'none', - duration: 2000 - }) - } else { - uni.showModal({ - title: '提示', - content: res.msg, - showCancel: false, - success: function(res) { - if (res.confirm) { - - } else if (res.cancel) { - - } - } - }) - } - }) - } - } - }) - }else{ - let that = this - uni.showModal({ - title: '提示', - content: '您确定要还车吗?', - showCancel: true, - success: function(res) { - if (res.confirm) { - uni.showLoading({ - title: '还车中...', - mask: true - }) - xBlufi.notifySendCustomData({ - customData: "11llosesub300@" - }) - that.fjflag = false - let data = { - orderId: that.deivceobj.orderId, - picture: that.imgs, - lon: that.lon, - lat: that.lat, - requiredIot: false - } - that.$u.put(`/app/order/end`, data).then(res => { - if (res.code == 200) { - setTimeout(()=>{ - xBlufi.notifySendCustomData({ - customData: "11reboot@" - }) - uni.hideLoading() - that.getorderdevice() - setTimeout(()=>{ - uni.navigateTo({ - url:'/page_user/yongche/orderxq?id=' + that.deivceobj.orderId + let data = { + orderId: that.deivceobj.orderId, + picture: that.imgs, + lon: that.lon, + lat: that.lat, + requiredIot: false + } + that.$u.put(`/app/order/end`, data).then(res => { + if (res.code == 200) { + setTimeout(()=>{ + xBlufi.notifySendCustomData({ + customData: "11reboot@" + }) + uni.hideLoading() + that.getorderdevice() + setTimeout(()=>{ + uni.navigateTo({ + url:'/page_user/yongche/orderxq?id=' + that.deivceobj.orderId + }) + },1000) + },1000) + }else if(res.msg == null) { + uni.hideLoading() + uni.showToast({ + title: '未知错误', + icon: 'none', + duration: 2000 + }) + } else { + uni.hideLoading() + uni.showModal({ + title: '提示', + content: res.msg, + showCancel: false, + success: function(res) { + if (res.confirm) { + + } else if (res.cancel) { + + } + } }) - },1000) - },1000) - }else if(res.msg == null) { - uni.hideLoading() - uni.showToast({ - title: '未知错误', - icon: 'none', - duration: 2000 - }) - } else { - uni.hideLoading() - uni.showModal({ - title: '提示', - content: res.msg, - showCancel: false, - success: function(res) { - if (res.confirm) { - - } else if (res.cancel) { - - } } }) + }else{ + // uni.hideLoading() + const findDevice = () =>{ + uni.showLoading({ + title: '蓝牙还车中...', + mask: true + }) + that.ver_dataflag = 2 + const matchedDevice = that.devicesarr.find(device => { + return device.name.slice(-12) == that.mac.slice(-12) + }) + if (matchedDevice) { + xBlufi.notifyStartDiscoverBle({ + 'isStart': false + }) + xBlufi.notifyConnectBle({ + isStart: true, + deviceId: matchedDevice.deviceId, + name: matchedDevice.name + }) + that.deviceid = matchedDevice.deviceId + that.devicename = matchedDevice.name + setTimeout(()=>{ + if(that.ver_dataflag == 3){ + xBlufi.notifySendCustomData({ + customData: "11closesub300@" + }) + that.fjflag = false + let data = { + orderId: that.deivceobj.orderId, + picture: that.imgs, + lon: that.lon, + lat: that.lat, + requiredIot: false + } + that.$u.put(`/app/order/end`, data).then(res => { + if (res.code == 200) { + setTimeout(()=>{ + xBlufi.notifySendCustomData({ + customData: "11reboot@" + }) + uni.hideLoading() + that.getorderdevice() + setTimeout(()=>{ + uni.navigateTo({ + url:'/page_user/yongche/orderxq?id=' + that.deivceobj.orderId + }) + },1000) + },1000) + }else if(res.msg == null) { + uni.hideLoading() + uni.showToast({ + title: '未知错误', + icon: 'none', + duration: 2000 + }) + } else { + uni.hideLoading() + uni.showModal({ + title: '提示', + content: res.msg, + showCancel: false, + success: function(res) { + if (res.confirm) { + + } else if (res.cancel) { + + } + } + }) + } + }) + }else{ + that.ver_dataflag = 1 + that.shibainum = 0 + uni.hideLoading() + uni.showModal({ + title: '提示', + content: '车辆还车失败,请检查手机蓝牙是否打开或微信蓝牙是否授权,开启手机定位', + showCancel: false, + success: function(res) { + if (res.confirm) { + + } else if (res.cancel) { + + } + } + }) + } + },4000) + } else { + if(that.shibainum < 3){ + that.shibainum++ + that.findDeviceTimer = setTimeout(findDevice.bind(that), 1000) // 使用 bind 保持 this 上下文 + }else{ + that.ver_dataflag = 1 + that.shibainum = 0 + uni.hideLoading() + uni.showModal({ + title: '提示', + content: '车辆还车失败,请检查手机蓝牙是否打开或微信蓝牙是否授权,开启手机定位', + showCancel: false, + success: function(res) { + if (res.confirm) { + + } else if (res.cancel) { + + } + } + }) + } + } + } + findDevice() } - }) - } else if (res.cancel) { - - } + } else if(res.msg == null) { + uni.hideLoading() + uni.showToast({ + title: '未知错误', + icon: 'none', + duration: 2000 + }) + } else { + uni.showModal({ + title: '提示', + content: res.msg, + showCancel: false, + success: function(res) { + if (res.confirm) { + + } else if (res.cancel) { + + } + } + }) + } + }) } - }) - } + } + }) }, // 点击跳转到最近停车点 btntcd() { diff --git a/pages/nearbystores/index.vue b/pages/nearbystores/index.vue index 320f287..2276627 100644 --- a/pages/nearbystores/index.vue +++ b/pages/nearbystores/index.vue @@ -1,5 +1,6 @@ @@ -306,16 +344,42 @@ yyid: '', cachedPolyline: [], // 缓存多边形数据 cachedParkingData: {}, // 缓存停车区域数据 - isFirstLoad: true // 是否是首次加载 + isFirstLoad: true ,// 是否是首次加载 + + gonggaoxq:{}, + gonggaoflag:false, + announcements: {}, + lists: [], + tiaozhuanlist:[], + kefuflag:false, + kefulist:[], + kefuarr:[], + jinweidu:'', + parkingList:[], + qbtype:'', + adminflag:false, + guanliflag:false, + list:[], + searchKey: '', + displayList:[], + show:false, + weizhifu:false, + weizhifuid:'' } }, - onLoad() { - + onLoad(option) { + if(option.qbtype){ + this.qbtype = option.qbtype + } }, onShow() { + this.getinfo() + + uni.getLocation({ type: 'wgs84', success: (res) => { + this.jinweidu = res.longitude + ',' + res.latitude this.xllat = res.latitude this.xllng = res.longitude }, @@ -327,9 +391,12 @@ this.covers = [] this.sockedata = '' this.getMyLocation() - this.setMapScale() - this.getkefu() - this.getorderdevice() + setTimeout(()=>{ + this.setMapScale() + this.getgonggao() + this.getlunbo() + this.getkefu() + },1000) this.polyline = [] this.isFirstLoad = true // 重置首次加载标志 setTimeout(()=>{ @@ -338,16 +405,338 @@ }, onUnload() { this.clearTimer() - this.isPageActive = false - this.closeWebSocket() }, onHide() { this.clearTimer() - // 页面隐藏时关闭连接 - this.isPageActive = false - this.closeWebSocket() }, methods: { + // 点击去支付 + btnweizhifu(){ + uni.navigateTo({ + url:'/page_user/yongche/orderxq?id=' + this.weizhifuid + }) + }, + // 获取个人信息 + getinfo(){ + this.$u.get("/getInfo").then(res => { + if(res.code == 200){ + this.user = res.user + this.getzhifu() + this.getorderdevice() + res.roles.filter(item => { + if(item == 'sys_admin'){ + this.adminflag = true + } + }) + if(res.roles != null || res.roles.length > 0){ + this.$u.get('/bst/area/list?pageNum=1&pageSize=999').then((res) => { + if (res.code == 200) { + this.guanliflag = true + this.list = res.rows.map(item => ({ + value: item.id, + label: item.name, + deptName: item.userName + })) + this.displayList = this.list; // 重置显示列表 + console.log(this.displayList,'0000'); + } + }) + } + }else if(res.code == 401){ + this.getlogo() + } + }) + }, + // 静默登录 + getlogo(){ + let taht = this + wx.login({ + success(res) { + if (res.code) { + let data = { + loginCode: res.code, + appId:taht.$store.state.appid + } + taht.$u.post('/wxLogin', data).then(res => { + if (res.code == 200) { + uni.setStorageSync('token', res.token) + taht.getinfo() + taht.getlunbo() + }else{ + taht.getinfo() + } + }) + } + }, + }) + }, + handleSearch(e) { + const value = e.detail.value; + console.log(e,value); + if (!value) { + // 搜索框为空时显示全部数据 + this.displayList = this.list; + } else { + // 有搜索内容时过滤数据 + this.displayList = this.list.filter(item => { + const label = String(item.label || '').toLowerCase(); + const deptName = String(item.deptName || '').toLowerCase(); + const searchValue = String(value || '').toLowerCase(); + return label.includes(searchValue) || deptName.includes(searchValue); + }); + } + }, + selectItem(item) { + this.confirm(item) + this.show = false + this.searchKey = '' // 选择后清空搜索框 + this.displayList = this.list // 重置显示列表 + }, + // 选择好运营区 + confirm(e) { + console.log(e,e.value) + uni.setStorageSync('adminAreaid', e.value) + uni.navigateTo({ + url: `/page_shanghu/guanli/admin_worke?id=${e.value}` + }) + }, + // 获取本人正在使用的订单设备 + getorderdevice() { + this.$u.get("/app/order/mineProcessing").then((res) => { + if (res.code == 200) { + if (res.data) { + this.orderflag = true + if(this.qbtype == 1){ + console.log('11'); + }else{ + uni.switchTab({ + url:'/pages/index/index' + }) + } + }else{ + this.orderflag = false + } + } + }) + }, + // 点击进行中订单进行跳转 + btnjinx(){ + uni.switchTab({ + url:'/pages/index/index' + }) + }, + // 点击扫码 + btnsaoma(){ + uni.scanCode({ + onlyFromCamera: true, + scanType: ['qrCode'], + success: res => { + console.log(res); + function getQueryParam(url, paramName) { + let regex = new RegExp(`[?&]${paramName}=([^&]*)`) + let results = regex.exec(url) + return results ? decodeURIComponent(results[1].replace(/\+/g, ' ')) : null + } + let sceneValue = res.result + let decodedValue = decodeURIComponent(sceneValue) + this.sn = getQueryParam(decodedValue, 's') + this.$u.get("/app/order/mineProcessing").then(res =>{ + if(res.code == 200){ + if(res.data){ + uni.switchTab({ + url:'/pages/nearbystores/index' + }) + }else{ + this.$u.get(`/app/device/availableDetail?sn=${this.sn}`).then((res) => { + if (res.code == 200) { + if(res.data){ + this.modelId = res.data.modelId + uni.navigateTo({ + url:'/page_fenbao/storedlist/trueorder?modelId=' + this.modelId + '&sn=' + this.sn + }) + }else{ + console.log('前台'); + uni.showModal({ + title: '提示', + content: '当前车辆不可用', + showCancel: false, + confirmText: '知道了' + }) + } + }else{ + console.log('系统'); + uni.showModal({ + title: '提示', + content: res.msg, + showCancel: false, + confirmText: '知道了' + }) + } + }) + } + } + }) + }, + fail: err => { + console.error('扫描失败:', err) + uni.showToast({ + title: '扫描失败', + icon: 'none' + }) + } + }) + }, + + // 点击显示客服 + btnkf(){ + if(this.kefulist.length > 0){ + this.kefuflag = true + }else{ + uni.showToast({ + title: '当前暂无客服', + icon: 'none', + duration: 2000 + }) + } + }, + // 获取客服 + getkefu(){ + this.$u.get(`/app/customerService/indexList?radius=1000¢er=${this.jinweidu}&areaId=${this.user.areaId}`).then(res => { + if(res.code == 200){ + this.kefulist = res.after + this.kefuarr = res.before + } + }) + }, + // 点击进行跳转页面 + btntiao(num){ + if(num == 2){ //跳转到使用帮助页 + uni.navigateTo({ + url:'/page_user/bangzhu' + }) + }else if(num == 3){ //跳转到车辆故障上报 + uni.navigateTo({ + url:'/page_user/guzhang/index' + }) + } + }, + btnpage(num){ + if(num == 2){ //跳转到我的订单页面 + uni.navigateTo({ + url:'/pages/myorder/index' + }) + }else{ + uni.navigateTo({ + url:'/page_fenbao/index' + }) + } + }, + // 请求查询是否有未支付订单 + getzhifu(){ + this.$u.get("/app/order/unpaid").then((res) => { + if (res.code == 200) { + if(res.data){ + this.weizhifuid = res.data.id + this.weizhifu = true + let that = this + uni.showModal({ + title: '提示', + content: '您当前还有未支付订单,是否前去支付?', + showCancel: true, + success: function (res) { + if (res.confirm) { + uni.navigateTo({ + url:'/page_user/yongche/orderxq?id=' + that.weizhifuid + }) + } else if (res.cancel) { + console.log('取消'); // 用户点击取消 + } + } + }) + }else{ + this.weizhifu = false + } + } + }) + }, + // 获取广告轮播图 + getlunbo(){ + this.$u.get("/app/ad").then(res => { + if(res.code == 200){ + this.lists = [] + this.tiaozhuanlist = res.data + if(res.data.length > 0 && res.data[0] != null){ + res.data.forEach(item =>{ + this.lists.push({ + image:item.picture, + title: item.adId + }) + }) + }else{ + this.lists.push({ + image:"https://api.ccttiot.com/smartmeter/img/static/uTZBBRuyRexKd6c4VE9d", + title: "" + }) + } + }else{ + this.lists.push({ + image:"https://api.ccttiot.com/smartmeter/img/static/uTZBBRuyRexKd6c4VE9d", + title: "" + }) + } + }) + }, + // 点击跳转轮播图跳转 + btnshangjia(e){ + if(this.tiaozhuanlist[e].urlType == 1){ + uni.navigateTo({ + url: '/page_fenbao/webview?url=' + this.tiaozhuanlist[e].url + }) + }else{ + uni.navigateTo({ + url: '/' + this.tiaozhuanlist[e].url + }) + } + }, + // 点击跳转到我的 + btnmy(){ + uni.switchTab({ + url:'/pages/my' + }) + }, + // 点击头部滚动通知 + btntopgg(){ + this.$u.get(`/app/notice/${this.announcements.noticeId}`).then(resp =>{ + if(resp.code == 200){ + this.gonggaoxq = resp.data + this.gonggaoflag = true + } + }) + }, + // 点击公告我知道了 + btnggtc(){ + this.gonggaoflag = false + uni.setStorageSync('noticeId', this.announcements.noticeId) + }, + // 获取最新公告 + getgonggao(){ + this.$u.get("/app/notice/new?noticeType=1").then(res =>{ + if(res.code == 200){ + this.announcements = res.data + if(res.data){ + this.$u.get(`/app/notice/${res.data.noticeId}`).then(resp =>{ + if(resp.code == 200){ + this.gonggaoxq = resp.data + if(resp.data.noticeId != uni.getStorageSync('noticeId')){ + this.gonggaoflag = true + } + } + }) + } + } + }) + }, + // 拖动查询中心点的数据 regionchange(e) { this.iconflag = true @@ -435,444 +824,68 @@ console.log("定时器已清除") } }, - btnjjqx(){ - this.orderflag = true - this.fjflag = false - }, - //WebSocket 自动重连实现 - initWebSocket() { - if (!this.isPageActive || !this.deviceMac) return - let token = uni.getStorageSync('token') - // 关闭已有连接 - if (this.socketTask) { - this.socketTask.close() - this.socketTask = null - } - // 创建新连接 - this.socketTask = uni.connectSocket({ - url: `wss://ele.ccttiot.com/prod-api/ws/device?token=${token}&mac=${this.deviceMac}`, - success: () => { - console.log('WebSocket连接建立中...') - }, - fail: (err) => { - console.error('WebSocket连接失败:', err) - this.scheduleReconnect() - } - }); - // 监听连接打开 - this.socketTask.onOpen(() => { - console.log('WebSocket连接已打开') - this.reconnectAttempts = 0; // 重置重连计数器 - // 发送订阅消息(如果需要) - this.socketTask.send({ - data: JSON.stringify({ - action: 'subscribe' - }), - success: () => console.log('订阅消息发送成功'), - fail: (err) => console.error('订阅消息发送失败:', err) - }) - }) - // 监听消息接收 - this.socketTask.onMessage((res) => { - console.log('收到实时消息:', res.data) - this.messages.push(res.data) // 存储消息 - try { - const data = JSON.parse(res.data) - console.log('解析后的JSON数据:', data) - // 这里可以处理具体的业务逻辑 - this.sockedata = data - this.covers = [] - const newMarkers = [] - this.parkingList.forEach(item => { - newMarkers.push({ - id: parseFloat(item.id), - latitude: parseFloat(item.latitude), - longitude: parseFloat(item.longitude), - width: 40, - height: 60, - iconPath: item.type == 1 ? - 'https://lxnapi.ccttiot.com/bike/img/static/up2xXqAgwCX5iER600k3' : - item.type == 2 ? - 'https://lxnapi.ccttiot.com/bike/img/static/uDNY5Q4zOiZTCBTA2Jdq' : - 'https://lxnapi.ccttiot.com/bike/img/static/u53BAQcFIX3vxsCzEZ7t', - callout: { - content: item.name, - color: '#ffffff', - fontSize: 14, - borderRadius: 10, - bgColor: item.type == 1 ? '#3A7EDB' : item.type == 2 ? '#FF473E' : - '#FFC107', - padding: 6, - display: 'ALWAYS' - }, - isCalloutVisible: true // 添加标记 - }) - }) - this.newMarkers = newMarkers - this.$set(this, 'covers', [...this.covers, ...newMarkers]) - if(this.sockedata.latitude){ - this.covers.push({ - latitude: this.sockedata.latitude, - longitude: this.sockedata.longitude, - width: 8, - height: 8, - iconPath: 'https://api.ccttiot.com/smartmeter/img/static/uow9Zq3edTUYCVHI9H60', - }) - } - this.covers.push({ - latitude: data.latitude, - longitude: data.longitude, - width: 8, - height: 8, - iconPath: 'https://api.ccttiot.com/smartmeter/img/static/uow9Zq3edTUYCVHI9H60', - }) - } catch (e) { - console.log('原始消息内容:', res.data) - } - }); - // 监听错误 - this.socketTask.onError((err) => { - console.error('WebSocket错误:', err) - this.scheduleReconnect() - }); - // 监听连接关闭 - this.socketTask.onClose((res) => { - console.log('WebSocket连接已关闭', res) - if (this.isPageActive) { - this.scheduleReconnect() - } - }) - }, - // 关闭WebSocket连接 - closeWebSocket() { - if (this.socketTask) { - this.socketTask.close({ - success: () => { - console.log('WebSocket已主动关闭') - this.socketTask = null - }, - fail: (err) => { - console.error('WebSocket关闭失败:', err) - this.socketTask = null - } - }) - } - }, - // 安排重连 - scheduleReconnect() { - if (!this.isPageActive || this.reconnectAttempts >= this.maxReconnectAttempts) { - console.log('已达到最大重连次数或页面已关闭,停止重连') - return - } - this.reconnectAttempts++; - console.log(`尝试第 ${this.reconnectAttempts} 次重连,等待 ${this.reconnectInterval/1000} 秒...`) - setTimeout(() => { - this.initWebSocket() - }, this.reconnectInterval) - // 指数退避策略,增加重连间隔 - this.reconnectInterval = Math.min(this.reconnectInterval * 2, 30000) // 最大不超过30秒 - }, - // 点击结束订单 - btnjsdd() { - if (this.orderAreaReturnVerify == true) { - uni.navigateTo({ - url: '/page_user/hcshenhe?sn=' + this.orderobj.deviceSn + '&orderid=' + this.orderobj.orderId + '&orderAreaId=' + this.orderobj.orderAreaId - }) - } else { - uni.getLocation({ - type: 'gcj02', // 国内地图更兼容 - isHighAccuracy: true, - success: (res) => { - this.latsc = res.latitude - this.lonsc = res.longitude - this.getfeiyong() - }, - fail: (err) => { - console.error('获取位置失败:', err) - this.getfeiyong() - } - }) - } - }, - // 点击还车判断是否需要另外缴费 - getfeiyong() { - let data = { - orderId: this.orderobj.orderId, - lon: this.lonsc, - lat: this.latsc, - checkLocation:true - } - this.$u.post(`/app/order/calcFee`, data).then(res => { - if (res.code == 200) { - this.fajinobj = res.data - if (res.data.manageFee > 0 || res.data.dispatchFee > 0) { - this.fjflag = true - this.orderflag = false - } else { - this.gethuan() - } - }else if(res.code == 30001){ - uni.showToast({ - title: '必须在停车点内还车', - icon: 'none', - duration: 5000 - }) - }else if(res.code == 30002){ - uni.showToast({ - title: '不允许在禁停区内还车', - icon: 'none', - duration: 5000 - }) - }else if(res.code == 30003){ - uni.showToast({ - title: '必须在运营区内还车', - icon: 'none', - duration: 5000 - }) - } - }) - }, - // 点击缴纳罚金继续还车 - btnfajin() { - this.gethuan() - }, - // 还车统一调用 - gethuan() { - let that = this - uni.showModal({ - title: '提示', - content: '您确定要还车吗?', - showCancel: true, - success: function(res) { - if (res.confirm) { - let data = { - orderId: that.orderobj.orderId, - picture: that.imgs, - lon: that.lonsc, - lat: that.latsc - } - that.$u.put(`/app/order/end`, data).then(res => { - if (res.code == 200) { - uni.showToast({ - title: '还车成功', - icon: 'success', - duration: 2000 - }) - setTimeout(()=>{ - that.fjflag = false - that.orderflag = false - setTimeout(()=>{ - uni.navigateTo({ - url:'/page_user/yongche/orderxq?id=' + that.orderobj.orderId - }) - },1000) - },1000) - } else { - uni.showToast({ - title: res.msg, - icon: 'none', - duration: 2000 - }) - } - }) - } else if (res.cancel) { - - } - } - }) - }, - // 点击跳转到最近停车点 - btntcd() { - uni.navigateTo({ - url: '/pages/myorder/returned/tingche?areaId=' + this.orderobj.orderAreaId - }) - }, - - // 点击跳转到车辆 - btntz() { - uni.switchTab({ - url: '/pages/myorder/returned/index' - }) - }, - // 点击跳转导航 - danghang() { - if (this.orderobj.deviceLatitude && this.orderobj.deviceLongitude) { - uni.openLocation({ - latitude: this.orderobj.deviceLatitude, //纬度-目的地/坐标点 - longitude: this.orderobj.deviceLongitude, //经度-目的地/坐标点 - name: '', //地点名称 - address: '' //详细地点名称 - }) - } else { + // 点击地图中的店铺操作 + handleMarkerClick(e) { + if(this.orderflag == true){ uni.showToast({ - title: '车辆暂无法导航', + title: '当前已有进行中订单', icon: 'none', duration: 2000 }) - } - }, - // 点击启动and关闭 - btnqd() { - if (this.orderobj.deviceLockStatus == 0) { - let that = this - uni.showModal({ - title: '提示', - content: '您是否要解锁车辆?', - showCancel: true, - success: function(res) { - if (res.confirm) { - that.$u.put(`/app/order/openDevice?orderId=${that.orderobj.orderId}`).then(( - res) => { - if (res.code == 200) { - uni.showToast({ - title: '解锁成功', - icon: 'success', - duration: 2000 - }) - that.getorderdevice() - } else { - uni.showToast({ - title: res.msg, - icon: 'none', - duration: 2000 - }) - } - }) - } else if (res.cancel) { - console.log('取消') + }else{ + let id = String(e.detail.markerId) + if (id.slice(-1) == 1) { + console.log('店铺') + this.covers.filter(item => { + if (item.id == id) { + item.iconPath = 'https://api.ccttiot.com/smartmeter/img/static/u8ONjRuMpydcZ4WuA6vP' + this.shoptcflag = true } - } - }) - } else if (this.orderobj.deviceLockStatus == 1) { - uni.getLocation({ - type: 'wgs84', - success: (res) => { - this.latsc = res.latitude - this.lngsc = res.longitude - }, - fail: (err) => { - console.error('获取位置失败:', err) - this.latsc = null - this.lngsc = null - } - }) - let that = this - uni.showModal({ - title: '提示', - content: '您是否要临时锁车?', - showCancel: true, - success: function(res) { - if (res.confirm) { - let query = { - orderId: that.orderobj.orderId, - lat: that.latsc, - lon: that.lngsc, - } - let url = '/app/order/closeDevice?' + that.$tansParams(query) - that.$u.put(url).then((res) => { - if (res.code == 200) { - uni.showToast({ - title: '临时锁车成功', - icon: 'success', - duration: 2000 - }) - that.getorderdevice() - } else { - uni.showToast({ - title: res.msg, - icon: 'none', - duration: 2000 - }) - } - }) - } else if (res.cancel) { - console.log('取消') - } - } - }) - } - }, - // 获取本人正在使用的订单设备 - getorderdevice() { - this.$u.get("/app/orderDevice/mineUsing").then((res) => { - if (res.code == 200) { - if (res.data) { - this.orderobj = res.data - this.orderAreaReturnVerify = res.data.orderAreaReturnVerify - this.orderAreaId = res.data.orderAreaId - this.areaId = res.data.orderAreaId - this.deviceMac = res.data.deviceMac - this.orderflag = true - this.isPageActive = true - this.initWebSocket() //WebSocket接受数据 - - this.$u.get(`/app/area/detail?id=${this.orderAreaId}`).then((res) => { - if (res.code == 200) { - const polylines = this.convertBoundaryToPolyline(res.data.boundaryStr) - this.polyline.push(polylines) - this.getParking() + }) + } else if (id.slice(-1) == 2) { + console.log('车辆') + if (this.orderAreaId == '') { + this.covers.filter(item => { + if (item.id == id) { + this.taocanflag = true + this.$u.get(`/app/device/availableDetail?id=${id.slice(0, -1)}`).then((res) => { + if (res.code == 200) { + this.cheobj = res.data + this.areaId = res.data.areaId + this.getArea() + }else{ + uni.showToast({ + title: res.msg, + icon: 'none', + duration: 2000 + }) + } + }) } }) } else { - this.orderAreaId = '' - this.orderflag = false - this.newMarkers = '' - console.log(this.covers) + console.log('进行中订单'); + uni.showToast({ + title: '当前已有订单', + icon: 'none', + duration: 2000 + }) } + } else if (id.slice(-1) == 3) { + console.log('导览') } - }) - }, - // 点击地图中的店铺操作 - handleMarkerClick(e) { - let id = String(e.detail.markerId) - if (id.slice(-1) == 1) { - console.log('店铺') - this.covers.filter(item => { - if (item.id == id) { - item.iconPath = 'https://api.ccttiot.com/smartmeter/img/static/u8ONjRuMpydcZ4WuA6vP' - this.shoptcflag = true - } - }) - } else if (id.slice(-1) == 2) { - console.log('车辆') - if (this.orderAreaId == '') { - this.covers.filter(item => { - if (item.id == id) { - this.taocanflag = true - this.$u.get(`/app/device/availableDetail?id=${id.slice(0, -1)}`).then((res) => { - if (res.code == 200) { - this.cheobj = res.data - this.areaId = res.data.areaId - this.getArea() - }else{ - uni.showToast({ - title: res.msg, - icon: 'none', - duration: 2000 - }) - } - }) - } - }) - } else { - console.log('进行中订单'); - uni.showToast({ - title: '当前已有订单', - icon: 'none', - duration: 2000 - }) - } - } else if (id.slice(-1) == 3) { - console.log('导览') } }, - // 请求客服 - getkefu() { - this.$u.get(`/app/customerService/list?pageNum=1&pageSize=999`).then(res => { - if (res.code == 200) { - this.kefulist = res.rows - } - }) + // 点击进入商户中心 + btngl(){ + if (this.list.length < 2) { + uni.setStorageSync('adminAreaid', this.list[0].value); + uni.navigateTo({ + url: `/page_shanghu/guanli/admin_worke?id=${this.list[0].value}` + }) + } else { + this.show = true + } }, // 点击去下单 btndetaxq() { @@ -943,12 +956,7 @@ btntcxz(index) { this.tcindex = index }, - // 点击跳转到帮助中心 - btnbz() { - uni.navigateTo({ - url: '/page_user/bangzhu' - }) - }, + // 点击拨打平台客服电话 btnptkf() { uni.makePhoneCall({ @@ -1306,10 +1314,10 @@ }, // 第一次请求运营区停车点,禁行区, getAone() { - this.$u.get("/getInfo").then(res => { - if(res.code == 200){ - this.user = res.user - this.$u.get(`/app/area/nearby?id=${res.user.areaId == null ? '' : res.user.areaId}&radius=1000¢er=${this.jingweidu}`).then((resp) => { + // this.$u.get("/getInfo").then(res => { + // if(res.code == 200){ + // this.user = res.user + this.$u.get(`/app/area/nearby?id=${this.user.areaId == null ? '' : this.user.areaId}&radius=1000¢er=${this.jingweidu}`).then((resp) => { if (resp.code == 200) { if(resp.data){ this.yyid = resp.data.id @@ -1326,8 +1334,8 @@ } } }) - } - }) + // } + // }) }, loadNearbyDevices(areaId) { @@ -1423,6 +1431,327 @@ opacity: 1; } } + @keyframes fadeIn { + from { + opacity: 0; + } + to { + opacity: 1; + } + } + .rukou{ + width: 198rpx; + height: 56rpx; + margin-top: 290rpx; + margin-left: 40rpx; + } + .custom-select { + .mask { + position: fixed; + top: 0; + left: 0; + right: 0; + bottom: 0; + background: rgba(0, 0, 0, 0.5); + z-index: 999; + } + + .select-content { + position: fixed; + left: 0; + right: 0; + bottom: 0; + background: #fff; + border-radius: 20rpx 20rpx 0 0; + z-index: 1000; + height: 50vh; // 最大高度 + // min-height: 400rpx; // 添加最小高度 + display: flex; + flex-direction: column; + padding-bottom: 20rpx; + + .select-header { + padding: 20rpx 30rpx; + display: flex; + justify-content: space-between; + align-items: center; + border-bottom: 1px solid #eee; + + .close { + font-size: 40rpx; + color: #999; + } + } + + .search-box { + padding: 15rpx 20rpx; + border-bottom: 1px solid #eee; + + input { + width: 100%; + height: 60rpx; + background: #f5f5f5; + border-radius: 30rpx; + padding: 0 30rpx; + font-size: 28rpx; + } + } + + .select-list { + flex: 1; + max-height: calc(50vh - 140rpx); + min-height: 260rpx; // 为列表添加最小高度 + + .select-item { + display: flex; + // flex-direction: column; + justify-content: space-between; + align-items: center; + padding: 20rpx 30rpx; + border-bottom: 1px solid #eee; + font-size: 28rpx; + + &.highlight { + background-color: #f0f9ff; + color: #2d8cf0; + } + + &:active { + background: #f5f5f5; + } + } + } + } + } + .kefutc{ + animation: fadeIn 0.5s ease-in-out forwards; + position: fixed; + top: 580rpx; + left: 50%; + transform: translateX(-50%); + z-index: 10; + .bot{ + margin-top: 30rpx; + .wz{ + margin-top: 10rpx; + font-weight: 600; + font-size: 28rpx; + color: #3D3D3D; + } + .wzs{ + margin-top: 10rpx; + font-size: 24rpx; + color: #7C7C7C; + } + } + .top{ + width: 538rpx; + height: 122rpx; + background: #FFFFFF; + box-shadow: 0rpx 0rpx 10rpx 0rpx rgba(0,0,0,0.1); + border-radius: 14rpx 14rpx 14rpx 14rpx; + display: flex; + justify-content: space-between; + align-items: center; + padding-right: 14rpx; + box-sizing: border-box; + margin-top: 20rpx; + .dianhua{ + font-size: 24rpx; + color: #666; + padding-left: 26rpx; + box-sizing: border-box; + } + .boda{ + width: 94rpx; + height: 94rpx; + background: #DCEDFF; + border-radius: 8rpx 8rpx 8rpx 8rpx; + text-align: center; + padding-top: 8rpx; + box-sizing: border-box; + image{ + width: 42rpx; + height: 40rpx; + } + text{ + display: block; + } + } + } + .bj{ + position: absolute; + top: -280rpx; + z-index: -1; + left: 50%; + transform: translateX(-50%); + width: 614rpx; + height: 1140rpx; + } + } + .guanggao{ + width: 700rpx; + height: 180rpx; + margin: auto; + margin-top: 34rpx; + position: relative; + overflow: hidden; + .kefu{ + width: 108rpx; + height: 146rpx; + position: absolute; + bottom: -80rpx; + right: 10rpx; + } + /deep/ .u-swiper-image{ + width: 700rpx !important; + height: 180rpx !important; + border-radius: 10rpx; + } + } + .botbox{ + position: fixed; + bottom: 0; + left: 0; + width: 750rpx; + height: 520rpx; + background-color: #fff; + border-radius: 50rpx 50rpx 0 0; + .saoma{ + image{ + width: 56rpx; + height: 56rpx; + margin-right: 8rpx; + } + font-size: 40rpx; + font-weight: 600; + color: #fff; + display: flex; + align-items: center; + justify-content: center; + width: 686rpx; + height: 90rpx; + background-color: #4C97E7; + border-radius: 50rpx; + margin: auto; + margin-top: 34rpx; + } + .kuaijie{ + display: flex; + justify-content: space-between; + padding: 0 26rpx; + box-sizing: border-box; + margin-top: 32rpx; + image{ + width: 96rpx; + height: 116rpx; + } + } + } + .topimg{ + width: 136rpx; + height: 56rpx; + position: fixed; + top: 104rpx; + left: 36rpx; + z-index: 99; + } + + .noticetc{ + width: 680rpx; + height: 950rpx; + background-color: #fff; + border-radius: 20rpx; + padding: 0 20rpx; + box-sizing: border-box; + position: fixed; + top: 340rpx; + left: 50%; + transform: translateX(-50%); + z-index: 99; + .btn{ + width: 600rpx; + height: 100rpx; + line-height: 100rpx; + text-align: center; + border-radius: 50rpx; + background-color: #4297F3; + color: #fff; + font-size: 32rpx; + font-weight: 600; + margin: auto; + margin-top: 30rpx; + } + .name{ + width: 100%; + text-align: center; + font-size: 36rpx; + font-weight: 600; + margin-top: 30rpx; + } + .biaoti{ + font-size: 32rpx; + margin-top: 20rpx; + } + .cont{ + width: 100%; + height: 620rpx; + overflow: scroll; + background-color: #ececec; + margin-top: 20rpx; + padding: 20rpx; + box-sizing: border-box; + } + } + .scroll-text { + width: 100%; + overflow: hidden; + box-sizing: border-box; + display: inline-block; + white-space: nowrap; + animation: scroll 8s linear infinite; + height: 72rpx; + line-height: 72rpx; + } + .scroll-item { + display: inline-block; + padding: 0 10px; + font-size: 16px; + height: 72rpx; + line-height: 72rpx; + } + @keyframes scroll { + 0% { + transform: translateX(100%); + } + 100% { + transform: translateX(-100%); + } + } + .gonggao{ + width: 682rpx; + height: 72rpx; + overflow: hidden; + background: #FFFFFF; + box-shadow: 0rpx 4rpx 10rpx 0rpx rgba(0,0,0,0.3); + border-radius: 53rpx 53rpx 53rpx 53rpx; + position: fixed; + left: 50%; + transform: translateX(-50%); + z-index: 99; + display: flex; + align-items: center; + margin-bottom: 10rpx; + margin: auto; + margin-top: 186rpx; + padding-left: 70rpx; + .container{ + width: 560rpx; + overflow: hidden; + height: 72rpx; + line-height: 72rpx; + } + } .fixdivce { padding: 12rpx 22rpx 12rpx 22rpx; position: fixed; @@ -1818,11 +2147,11 @@ position: fixed; left: 50%; transform: translateX(-50%); - bottom: 220rpx; + bottom: 0; z-index: 99; background-color: #fff; border-radius: 30rpx; - width: 700rpx; + width: 100%; margin: auto; padding-bottom: 30rpx; box-sizing: border-box; @@ -2135,6 +2464,7 @@ height: 130vh; position: absolute; top: -30vh; + z-index: -1; .center-marker { position: absolute; top: 50%;