DESKTOP-2IO5MST\huting 1 년 전
부모
커밋
7c2d6132be

+ 17
- 9
pages/bluetooth/bluetooth.vue 파일 보기

import { ref, reactive } from "vue"; import { ref, reactive } from "vue";
import { onLoad, onReady } from "@dcloudio/uni-app"; import { onLoad, onReady } from "@dcloudio/uni-app";
import { fileURL } from "@/datas/fileURL.js"; import { fileURL } from "@/datas/fileURL.js";


const imgURL = `${fileURL}image/`; const imgURL = `${fileURL}image/`;
const selectedUrl = "common/selected.png`"; const selectedUrl = "common/selected.png`";


const state = reactive({ const state = reactive({
fee: "", fee: "",
id: "",
cardId: "", cardId: "",
showPopup: false, //显示激活成功提示 showPopup: false, //显示激活成功提示
curDeviceId: "", //当前选中的设备ID curDeviceId: "", //当前选中的设备ID
onLoad((option) => { onLoad((option) => {
routeType.value = option.routeType ? option.routeType : "1"; routeType.value = option.routeType ? option.routeType : "1";
state.cardId = option.cardId; state.cardId = option.cardId;

if (option.fee) { if (option.fee) {
state.fee = option.fee; state.fee = option.fee;
} }
if (option.id) {
state.id = option.id;
}
console.log("传过来的参数", option) console.log("传过来的参数", option)
}); });


let foundDevices = []; //扫描到的蓝牙列表 let foundDevices = []; //扫描到的蓝牙列表
uni.closeBluetoothAdapter(); //先关闭蓝牙 uni.closeBluetoothAdapter(); //先关闭蓝牙


console.log('执行断开蓝牙方法')
//打开蓝牙 //打开蓝牙
uni.openBluetoothAdapter({ uni.openBluetoothAdapter({
success: function (res) {
success: function (item : any) {
console.log('初始化蓝牙模块', item)
uni.startBluetoothDevicesDiscovery({ uni.startBluetoothDevicesDiscovery({
success: function (res) { success: function (res) {
console.log(res);
console.log('开始搜寻附近的蓝牙外围设备', res);
//扫描结果的监听 //扫描结果的监听
uni.onBluetoothDeviceFound(function (res) { uni.onBluetoothDeviceFound(function (res) {
// console.log(res.devices);
console.log('监听寻找到新设备的事件', res, res.devices);
for (let i = 0; i < res.devices.length; i++) { for (let i = 0; i < res.devices.length; i++) {
let name = res.devices[i]["name"]; let name = res.devices[i]["name"];
let prefixName = ""; let prefixName = "";
break; break;
} }
device._name = _name; device._name = _name;
console.log("device._name", device._name)
if (deviceList.value.length == 0) { if (deviceList.value.length == 0) {
// #ifdef MP-ALIPAY // #ifdef MP-ALIPAY
if (device._name == '聚利' || device._name == '万集' || device._name == '天地融' || device._name == '建投') { if (device._name == '聚利' || device._name == '万集' || device._name == '天地融' || device._name == '建投') {
foundDevices.push(device); foundDevices.push(device);
console.log("device._name", device._name)
} }
// #endif // #endif

// #ifdef MP-WEIXIN // #ifdef MP-WEIXIN
foundDevices.push(device); foundDevices.push(device);
// #endif // #endif
console.log(e); console.log(e);
let item = e; let item = e;
//停止扫描蓝牙 //停止扫描蓝牙
console.info("停止扫描蓝牙");
console.info("停止搜寻附近的蓝牙外围设备");
uni.stopBluetoothDevicesDiscovery({ uni.stopBluetoothDevicesDiscovery({
success: function (res) { success: function (res) {
console.log(device); console.log(device);
uni.navigateBack({ uni.navigateBack({
delta: 1 delta: 1
}) })
} else if (routeType.value == "6") {
uni.navigateTo({
url: "/subpackage/after-sale/activation-once-again/activation-once-again?state=true&id=" + state.id
});
} else { } else {
return; return;
} }
// oks(); // oks();
} else { } else {
//断开蓝牙 //断开蓝牙
// bluetoothUtil.disconnectDevice();
bluetoothUtil.disconnectDevice();
datas.setData("bluLinkStatus", false); datas.setData("bluLinkStatus", false);
datas.setData("connectPrefixName", ""); datas.setData("connectPrefixName", "");
tools.showToastAlert("蓝牙已断开"); tools.showToastAlert("蓝牙已断开");

+ 772
- 869
static/etc/TDRAPI/TDRObuSDK.js
파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
파일 보기


+ 4
- 1
static/etcUtil/index.js 파일 보기

let zzApi = require("../etc/WJAPI/wjBleAPI.js"); let zzApi = require("../etc/WJAPI/wjBleAPI.js");
let jtApi = require("../etc/JTAPI/BleUtil.js"); let jtApi = require("../etc/JTAPI/BleUtil.js");
const jlQZApi = require("../etc/JLQZAPI/JLObuSDK.js"); const jlQZApi = require("../etc/JLQZAPI/JLObuSDK.js");
import { login } from "../../utils/network/api";
import { import {
getItem getItem
} from "../../utils/storage"; } from "../../utils/storage";
*/ */
function disconnectDevice() { function disconnectDevice() {
var connectPrefixName = datas.getData("connectPrefixName"); var connectPrefixName = datas.getData("connectPrefixName");
console.log('断开蓝牙connectPrefixName',getItem('environment'),tdApi,datas.getData("connectPrefixName"))
switch (connectPrefixName) { switch (connectPrefixName) {
case "WJ": case "WJ":
wjApi.disconnectDevice(function(res) { wjApi.disconnectDevice(function(res) {
}); });
break; break;
case "TD": case "TD":
tdApi.disConnectDevice(function(res) {
console.log(tdApi,'==================================')
tdApi.disconnectDevice(function(res) {
datas.setData("bluLinkStatus", false); datas.setData("bluLinkStatus", false);
datas.setData("connectPrefixName", ""); datas.setData("connectPrefixName", "");
console.log(res, '=============') console.log(res, '=============')

+ 23
- 13
subpackage/after-sale/activation-once-again/activation-once-again.vue 파일 보기

isJH: "" isJH: ""
}); });
let cmdRandNum = ''; let cmdRandNum = '';
let ids = '';


onLoad((option) => { onLoad((option) => {
console.log('======重新激活开始======', option); console.log('======重新激活开始======', option);
ids = option.id;
//请求订单详情 //请求订单详情
queryOrderDetail(option.id); queryOrderDetail(option.id);
uni.$on('bluetoothLink', res => {
console.log(res,'===========123');
if (res.status) {
// getCardRenewal()
setTimeout(()=>{
getObuId()
})
}
//移除监听
console.log('======移除监听======', res)
// uni.$off('bluetoothLink')
})
// uni.$on('bluetoothLink', res => {
// console.log(res,'===========123');
// if (res.status) {
// // getCardRenewal()
// setTimeout(()=>{
// getObuId()
// })
// }
// //移除监听
// console.log('======移除监听======', res)
// // uni.$off('bluetoothLink')
// })
if(option.state){
setTimeout(()=>{
getObuId()
})
}
}); });


onShow((option) => { onShow((option) => {
} else { } else {
msg("请上传正确行驶证") msg("请上传正确行驶证")
} }
// navTo("/pages/bluetooth/bluetooth?routeType=6&id=" + ids);
}; };


//获取订单详情 //获取订单详情
activationRecordQuery().then((val) => { activationRecordQuery().then((val) => {
console.log("jihuo", val) console.log("jihuo", val)
state.activationNum = val.num state.activationNum = val.num
getObuId()
// getObuId()
}); });


}); });

+ 3
- 2
subpackage/after-sale/deviceInfo/deviceInfo.vue 파일 보기

obu.axleDistance = HexToInt(res.substring(44, 48)); obu.axleDistance = HexToInt(res.substring(44, 48));
obu.engineNum = HexToStrig(res.substring(86, 118)); obu.engineNum = HexToStrig(res.substring(86, 118));
obu.type = getVehicleType(HexToInt(res.substring(28, 30))); obu.type = getVehicleType(HexToInt(res.substring(28, 30)));
obu.userType = HexToInt(res.substring(30, 32)) == 1 ? "个人用户" :
"单位用户";
obu.userType = HexToInt(res.substring(30, 32)) == 1 ? "个人用户" : "单位用户";
obu.vehiclePlate = HexToStrig(res.substring(0, 24), 2); obu.vehiclePlate = HexToStrig(res.substring(0, 24), 2);
//获取车牌颜色 //获取车牌颜色
obu.vehiclePlateColor = getVehiclePlateColor(HexToInt(res obu.vehiclePlateColor = getVehiclePlateColor(HexToInt(res
}); });
//断开蓝牙 //断开蓝牙
bluetoothUtil.disconnectDevice(); bluetoothUtil.disconnectDevice();
tools.showToastAlert("蓝牙已断开");
console.log('蓝牙已断开=========')
return; return;
} }
alertF("OBU_00B400000A+rand+OBU_4F00指令长度不符" + res[1]); alertF("OBU_00B400000A+rand+OBU_4F00指令长度不符" + res[1]);

Loading…
취소
저장