Browse Source

最新代码

最新
master
facaige888 1 month ago
parent
commit
f9a9472e9b
  1. 10
      app.js
  2. 1
      app.json
  3. 49
      pages/datalist/brand.js
  4. 8
      pages/datalist/brand.wxml
  5. 1
      pages/datalist/brand.wxss
  6. 84
      pages/elselist/elselist.js
  7. 6
      pages/elselist/elselist.json
  8. 29
      pages/elselist/elselist.wxml
  9. 12
      pages/elselist/elselist.wxss
  10. 154
      pages/index/index.js
  11. 49
      pages/index/index.wxml
  12. 41
      pages/index/index.wxss
  13. 250
      pages/newdetail/newdetail.js
  14. 31
      pages/newdetail/newdetail.wxml
  15. 24
      pages/newdetail/newdetail.wxss
  16. 29
      pages/newzk/newlist.js
  17. 11
      pages/playvideo/video.js
  18. 4
      project.config.json
  19. BIN
      utils/image/code.webp
  20. BIN
      utils/image/ffffff.jpg
  21. BIN
      utils/image/qrpic.png

10
app.js

@ -16,13 +16,15 @@ App({
globalData: {
userInfo: null,
deviceId:null,
writeUuid:'0000ffe2-0000-1000-8000-00805f9b34fb',
notifiUuid:'0000ffe1-0000-1000-8000-00805f9b34fb',
serviceUuid:'0000ffe0-0000-1000-8000-00805f9b34fb',
writeUuid:' 0000FFE2-0000-1000-8000-00805F9B34FB',
notifiUuid:' 0000FFE1-0000-1000-8000-00805F9B34FB',
serviceUuid:' 0000FFE0-0000-1000-8000-00805F9B34FB',
bleDeviceId: "", // 设备ID
bleServiceId: "", // 服务UUID
notifyCharId: "", // 监听特征值UUID
writeCharId: "" // 写入特征值UUID
writeCharId: "" , // 写入特征值UUID
currentDevice:""
}
})

1
app.json

@ -6,6 +6,7 @@
"pages/newdetail/newdetail",
"pages/playvideo/video",
"pages/service/service",
"pages/elselist/elselist",
"pages/newzk/newlist"
],
"permission": {

49
pages/datalist/brand.js

@ -13,25 +13,31 @@ Page({
}
});
this.setData({ list });
if(!e.currentTarget.dataset.haveChildren){
if(!e.currentTarget.dataset.have){
wx.navigateTo({
url: '/pages/detail/detail?name='+id // 支持参数传递
url: '/pages/newdetail/newdetail?name='+id // 支持参数传递
// url: '/pages/detail/detail?name='+id // 支持参数传递
})
}
},
// 在生命周期函数中加载数据
onLoad(options) {
wx.showToast({
title: `点击了子项 ${options.name}`,
icon: 'none'
});
// wx.showToast({
// title: `点击了子项 ${options.name}`,
// icon: 'none'
// });
const s = options.name;
wx.request({
url: 'https://keytest.aik518.com/prod-api/work_key/obd/key/type_blue?blueName='+s,
url: 'https://keytest.aik518.com/prod-api/work_key/obd/zk_key/type_blue?blueName='+"BYD_OBD",
// url: 'https://keytest.aik518.com/prod-api/work_key/obd/zk_key/type_blue?blueName='+s,
method: 'GET', // 请求方法
success: res => {
console.log(res);
wx.setNavigationBarTitle({ title: res.data.data[0].name })
this.setData({
list:res.data.data
list:res.data.data,
children:res.data.data[0].children
// list: res.data.map(item => ({
// ...item,
// isExpanded: false,
@ -56,18 +62,31 @@ handleItemClick: function (e) {
const childIndex = e.currentTarget.dataset.childIndex;
// const {parentIndex, childIndex} = e.currentTarget.dataset
// const childData = this.data.list[parentIndex].children[childIndex]
// const childId = e.currentTarget.dataset.child;
if(childIndex.haveChildren){
this.setData({list:childIndex.children});
// this.setData({list:childIndex.children});
wx.navigateTo({
url: '/pages/elselist/elselist?name='+childIndex.name, // 支持参数传递
// url: '/pages/detail/detail?name='+childIndex.id // 支持参数传递
success (res) {
// 通过eventChannel向被打开页面传送数据
res.eventChannel.emit('getCartDatalist', childIndex) //触发事件
}
})
}else{
wx.navigateTo({
url: '/pages/detail/detail?name='+childIndex.id // 支持参数传递
url: '/pages/newdetail/newdetail?name='+childIndex.id // 支持参数传递
// url: '/pages/detail/detail?name='+childIndex.id // 支持参数传递
})
}
wx.showToast({
title: `点击了子项 ${childIndex.id}`,
icon: 'none'
});
// wx.showToast({
// title: `点击了子项 ${childIndex.id}`,
// icon: 'none'
// });
},

8
pages/datalist/brand.wxml

@ -1,14 +1,16 @@
<scroll-view scroll-y style="height: 100vh;">
<view
wx:for="{{list}}"
wx:for="{{children}}"
wx:key="id"
class="list-item"
style="background-color: {{item.haveChildren ? 'lightblue' : 'white'}}"
data-index="{{index}}"
bindtap="toggleExpand"
data-id="{{item.id}}"
data-have="{{item.haveChildren}}"
>
{{item.name}}{{item.haveChildren ? '▼' : '▶'}}
<!-- style="background-color: {{item.haveChildren ? 'lightblue' : 'white'}}" -->
<!-- {{item.haveChildren ? '▼' : '▶'}} -->
{{item.name}}
<view wx:if="{{item.haveChildren}}" class="sublist" >
<view
wx:for="{{item.children}}"

1
pages/datalist/brand.wxss

@ -9,5 +9,4 @@
.sublist-item {
padding: 5px;
border-bottom: 1px solid #ddd;
}

84
pages/elselist/elselist.js

@ -0,0 +1,84 @@
Page({
data: {
list:[],
children:[]
},
toggleExpand(e) {
const id = e.currentTarget.dataset.id;
const canGo = e.currentTarget.dataset.have;
// const list = this.data.list.map(item => {
// if (item.id === id) {
// return { ...item, haveChildren: !item.haveChildren };
// } else {
// return { ...item, haveChildren: false };
// }
// });
// this.setData({ list });
if(!canGo){
wx.navigateTo({
url: '/pages/newdetail/newdetail?name='+id // 支持参数传递
// url: '/pages/detail/detail?name='+id // 支持参数传递
})
}
},
// 在生命周期函数中加载数据
onLoad(options) {
let that = this;
const s = options.name;
const eventChannel = this.getOpenerEventChannel(); //取到事件对象
wx.setNavigationBarTitle({ title: s });
eventChannel.on("getCartDatalist",data=>{//发布事件
that.setData({
list:data,
children: data.children //cartDataList为此页的数据模型
// this.setData({list:childIndex.children});
});
console.log(that.data.cartDataList,"我被传过来了");
});
console.log(eventChannel);
},
refresh: function(e) {
wx.navigateTo({
url: '/pages/detail/detail?id=1&name=example'
});
},
// 点击事件处理函数
handleItemClick: function (e) {
// const index = e.currentTarget.dataset.index; // 主列表索引
// const subIndex = e.currentTarget.dataset.subIndex; // 子列表索引
// const subItem = this.data.list[index].sublist[subIndex];
// wx.showToast({ title: `点击了 ${subItem.name}`, icon: 'none' });
const childIndex = e.currentTarget.dataset.childIndex;
// const {parentIndex, childIndex} = e.currentTarget.dataset
// const childData = this.data.list[parentIndex].children[childIndex]
// const childId = e.currentTarget.dataset.child;
console.log(childIndex);
if(childIndex.haveChildren){
wx.navigateTo({
url: '/pages/elselist/elselist', // 支持参数传递
// url: '/pages/detail/detail?name='+childIndex.id // 支持参数传递
success (res) {
// 通过eventChannel向被打开页面传送数据
res.eventChannel.emit('getCartDatalist', childIndex) //触发事件
}
})
}else{
console.log(childIndex.id);
wx.navigateTo({
url: '/pages/newdetail/newdetail?name='+childIndex.id // 支持参数传递
// url: '/pages/detail/detail?name='+childIndex.id // 支持参数传递
})
}
wx.showToast({
title: `点击了子项 ${childIndex.id}`,
icon: 'none'
});
},
})

6
pages/elselist/elselist.json

@ -0,0 +1,6 @@
{
"usingComponents": {
},
"navigationBarTitleText": "OBD分类"
}

29
pages/elselist/elselist.wxml

@ -0,0 +1,29 @@
<scroll-view scroll-y style="height: 100vh;">
<view
wx:for="{{children}}"
wx:key="id"
class="list-item"
data-index="{{index}}"
bindtap="toggleExpand"
data-id="{{item.id}}"
data-have="{{item.haveChildren}}"
>
<!-- style="background-color: {{item.haveChildren ? 'lightblue' : 'white'}}" -->
<!-- {{item.haveChildren ? '▼' : '▶'}} -->
{{item.name}}
<view wx:if="{{item.haveChildren}}" class="sublist" >
<view
wx:for="{{item.children}}"
wx:for-item="child"
wx:key="id"
catchtap="handleItemClick"
class="sublist-item"
data-parent-index="{{index}}"
data-child-index="{{child}}"
>
{{child.name}}
</view>
</view>
</view>
</scroll-view>

12
pages/elselist/elselist.wxss

@ -0,0 +1,12 @@
.list-item {
padding: 10px;
border-bottom: 1px solid #ccc;
}
.sublist {
margin-left: 20px;
}
.sublist-item {
padding: 5px;
}

154
pages/index/index.js

@ -7,20 +7,28 @@ Page({
// 开始搜索 请给出一个微信小程序可展开列表并且展开后是一个列表,并且宽度占满屏幕,展开后父列表改变背景颜色,缩起其它已展开的列表的示例代码
startSearch() {
wx.navigateTo({
url: '/pages/datalist/brand?name='+"" // 支持参数传递
// url: '/pages/newzk/newlist?name='+deviceName // 支持参数传递
})
if (this.data.isSearching) return;
wx.openBluetoothAdapter({
mode: 'central', // ios必须要带这个参数
success: () => {
this.setData({ isSearching: true });
this.startDiscovery();
},
fail: (err) => {
wx.showToast({ title: '请开启手机蓝牙', icon: 'none' });
console.error('蓝牙初始化失败:', err);
}
});
// if (this.data.isSearching) return;
// wx.openBluetoothAdapter({
// mode: 'central', // ios必须要带这个参数
// success: () => {
// this.setData({ isSearching: true });
// this.startDiscovery();
// },
// fail: (err) => {
// wx.showToast({ title: '请开启手机蓝牙', icon: 'none' });
// console.error('蓝牙初始化失败:', err);
// }
// });
// wx.navigateTo({
// // url: '/pages/datalist/brand?name='+'FORD_OBD' // 支持参数传递
@ -47,7 +55,42 @@ Page({
// 监听发现设备
listenDevices() {
const systemInfo = wx.getSystemInfoSync();
if (systemInfo.platform === 'android') {
console.log('当前为Android设备');
} else if (systemInfo.platform === 'ios') {
console.log('当前为iOS设备');
getApp().globalData.currentDevice = "ios"
}
wx.onBluetoothDeviceFound((res) => {
let deviceType = getApp().globalData.currentDevice
console.log("当前设备==》"+deviceType)
if(deviceType.includes("ios")){
res.devices.forEach(device => {
// console.log(device.RSSI+device.deviceid+device.advertisData);
if (device.advertisData) {
// console.log('设备名称:', device.name);
// console.log('广播数据原始Buffer:', device.advertisData);
if(device.name.includes("OBD")){
const hexData = this.ab2hex(device.advertisData);
console.log(`设备 ${device.name || device.deviceId} 的 advertisData: ${hexData}`);
// 提取 MAC 地址(假设在第 2-8 字节)
const mac = this.getMacFromAdvertisData(device.advertisData);
console.log(`设备 MAC: ${mac}`);
console.log(`设备 id: ${device.deviceId}`);
wx.setStorageSync(device.deviceId, mac)
}
// parseAdvertiseData(device.advertisData);
}
});
}
const newDevices = res.devices.filter(device =>
!this.data.deviceList.some(d => d.deviceId === device.deviceId),
);
@ -59,12 +102,44 @@ Page({
);
// this.setData({ devices: filteredDevices });
// }
// console.error(filteredDevices.advertisData)
// if (filteredDevices.advertisData) {
// const hexData = this.ab2hex(filteredDevices.advertisData);
// console.error(`设备 ${filteredDevices.name || filteredDevices.deviceId} 的 advertisData: ${hexData}`);
// // 提取 MAC 地址(假设在第 2-8 字节)
// const mac = this.getMacFromAdvertisData(filteredDevices.advertisData);
// console.error(`设备 MAC: ${mac}`);
// }
this.setData({
deviceList: [...this.data.deviceList, ...filteredDevices]
});
});
},
// ArrayBuffer 转 16 进制
ab2hex(buffer) {
return Array.prototype.map.call(
new Uint8Array(buffer),
bit => ('00' + bit.toString(16)).slice(-2)
).join('');
},
onShareAppMessage() {
return {
title: 'OBD小程序',
path: '/pages/index/index'
};
},
// 提取 MAC 地址
getMacFromAdvertisData(buffer) {
const macBuffer = buffer.slice(2, 8);
return Array.prototype.map.call(
new Uint8Array(macBuffer),
x => ('00' + x.toString(16)).slice(-2)
).join(':').toUpperCase();
},
// 停止搜索
stopDiscovery() {
@ -81,25 +156,39 @@ Page({
const deviceId = e.currentTarget.dataset.deviceid;
const deviceName = e.currentTarget.dataset.blename;
const app = getApp();
// wx.getConnectedBluetoothDevices({
// })
let panduan = getApp().globalData.deviceId;
let currentD = getApp().globalData.currentDevice;
console.log(panduan+'==='+deviceId+"==="+currentD);
if(panduan!=''&&deviceId==panduan&&currentD==''){
wx.navigateTo({
url: '/pages/datalist/brand?name='+deviceName // 支持参数传递
// url: '/pages/newzk/newlist?name='+deviceName // 支持参数传递
})
}else{
wx.createBLEConnection({
deviceId,
success: () => {
getApp().globalData.deviceId = deviceId;
wx.navigateTo({
// url: '/pages/datalist/brand?name='+deviceName // 支持参数传递
url: '/pages/newzk/newlist?name='+deviceName // 支持参数传递
url: '/pages/datalist/brand?name='+deviceName // 支持参数传递
// url: '/pages/newzk/newlist?name='+deviceName // 支持参数传递
})
this.discoverServices(deviceId);
wx.showToast({ title: '连接成功'+deviceName+deviceId, icon: 'success' });
// wx.showToast({ title: '连接成功'+deviceName+deviceId, icon: 'success' });
}
});
}
wx.onBLEConnectionStateChange((res) => {
if (!res.connected) {
@ -133,20 +222,27 @@ Page({
// let writeUuid = '', notifiUuid = '';
characteristics.forEach(char => {
if (char.properties.writeNoResponse){
// if (char.properties.writeNoResponse){
// let uuidNo = char.uuid;
// let upUuid = uuidNo.toUpperCase();
// getApp().globalData.writeUuid = upUuid; // 可写特征
// }
console.log(char.uuid);
if(char.uuid == '0000FFE1-0000-1000-8000-00805F9B34FB'){
let uuidNo = char.uuid;
let upUuid = uuidNo.toUpperCase();
getApp().globalData.writeUuid = upUuid; // 可写特征
getApp().globalData.notifiUuid = upUuid;
}
// if(char.properties.notify){
// let uuidNo = char.uuid;
// let upUuid = uuidNo.toUpperCase();
// getApp().globalData.notifiUuid = upUuid;
// }
if(char.uuid == '0000ffe3-0000-1000-8000-00805f9b34fb'){
if(char.uuid == '0000FFE2-0000-1000-8000-00805F9B34FB'){
let uuidNo = char.uuid;
let upUuid = uuidNo.toUpperCase();
getApp().globalData.notifiUuid = upUuid;
getApp().globalData.writeUuid = upUuid;
}
// if (char.properties.) getApp().globalData.notifyUUID = char.uuid; // 通知特征
@ -156,15 +252,15 @@ Page({
// console.log('通知特征值:', notifiUuid);
// 启用通知(必须)
if (notifyUUID) {
wx.notifyBLECharacteristicValueChange({
deviceId: deviceId,
serviceId: serviceId,
characteristicId: notifyUUID,
state: true,
success: () => console.log('通知已启用')
});
}
// if (notifyUUID) {
// wx.notifyBLECharacteristicValueChange({
// deviceId: deviceId,
// serviceId: serviceId,
// characteristicId: notifyUUID,
// state: true,
// success: () => console.log('通知已启用')
// });
// }
},
fail: (err) => console.error('获取特征值失败', err)
});

49
pages/index/index.wxml

@ -5,25 +5,41 @@
<text class="device-notice">请确保OBD设备已经连接汽车OBD接口,并未与其它手机连接</text>
<!-- <view class="gradient-view" style="display: flex; flex-direction: row; align-items: center; margin-top: 20rpx; height: 150rpx;margin-left: 20rpx; margin-right: 20rpx;" bindtap="goToMain">
<image src="/utils/image/ic_blue_remote.png" mode="aspectFill" style="width: 50rpx; height: 50rpx; margin-left: 10rpx; margin-right: 10rpx;"></image>
<!-- <view class="gradient-view" style="display: flex; flex-direction: row; align-items: center; margin-top: 20rpx; height: 150rpx;margin-left: 20rpx; margin-right: 20rpx; position: relative;" bindtap="goToMain">
<image src="/utils/image/ic_blue_remote.png" mode="aspectFill" style="width: 80rpx; height: 50rpx; margin-left: 10rpx; margin-right: 10rpx;padding: 10rpx;"></image>
<view style="display: flex; flex-direction: column;">
<text class="textContent" >NISSAN_OBD</text>
<text class="textContent" style="display: flex; font-size: 25rpx; color: rgb(88, 92, 92);">C8:C8:C8:C8:C8:C8</text>
<text class="textContent" style="display: flex; font-size: 35rpx; color: rgb(26, 231, 231); ">NISSAN_OBD</text>
<text class="textContent" style="display: flex; font-size: 22rpx; color: rgb(88, 92, 92);">C8:C8:C8:C8:C8:C8</text>
</view>
<view style="display: flex; flex-direction: row; align-items: center;position: relative; width: 100%;justify-content: flex-end;">
<text class="device-rssi">-56</text>
<image src="/utils/image/rss_line.png" mode="aspectFill" style="width: 50rpx; height: 50rpx; margin-left: 10rpx; "></image>
<view style="display: flex; flex-direction: row; align-items: center;position: relative; width: 100%;justify-content: flex-end; padding: 20rpx; ">
<text class="device-rssi" style="font-size: 25rpx; ">-56</text>
<image src="/utils/image/rss_line.png" mode="aspectFill" style="width: 40rpx; height: 40rpx; margin-left: 10rpx; "></image>
<button class="device-name" style="width: 160rpx; ">连接</button>
</view> -->
</view>
<!-- <view class="x-view" style="display: flex; flex-direction: row; align-items: center; margin-top: 20rpx; height: 150rpx;margin-left: 20rpx; margin-right: 20rpx; position: relative;" bindtap="goToMain">
<image src="/utils/image/ic_blue_remote.png" mode="aspectFill" style="width: 80rpx; height: 50rpx; margin-left: 10rpx; margin-right: 10rpx;padding: 10rpx;"></image>
<view style="display: flex; flex-direction: column;">
<text class="textContent" style="display: flex; font-size: 35rpx; color: rgb(26, 231, 231); ">NISSAN_OBD</text>
<text class="textContent" style="display: flex; font-size: 22rpx; color: rgb(88, 92, 92);">C8:C8:C8:C8:C8:C8</text>
</view>
<view style="display: flex; flex-direction: row; align-items: center;position: relative; width: 100%;justify-content: flex-end; padding: 20rpx; ">
<text class="device-rssi" style="font-size: 25rpx; ">-56</text>
<image src="/utils/image/rss_line.png" mode="aspectFill" style="width: 40rpx; height: 40rpx; margin-left: 10rpx; "></image>
<button class="device-name" style="width: 160rpx; ">连接</button>
</view>
</view> -->
<view class="device-list">
<view
<!-- <view
wx:for="{{deviceList}}"
wx:key="deviceId"
class="device-item"
@ -35,6 +51,23 @@
<text class="device-rssi">信号强度: {{item.RSSI}}dBm</text>
<text class="device-rssi">MAC: {{item.deviceId}}</text>
<button class="device-name" >连接</button>
</view> -->
<view class="gradient-view" style="display: flex; flex-direction: row; align-items: center; margin-top: 20rpx; height: 150rpx;margin-left: 20rpx; margin-right: 20rpx; position: relative;" wx:for="{{deviceList}}"
wx:key="deviceId"
bindtap="connectDevice"
data-deviceid="{{item.deviceId}}"
data-blename="{{item.name}}">
<image src="/utils/image/ic_blue_remote.png" mode="aspectFill" style="width: 80rpx; height: 50rpx; margin-left: 10rpx; margin-right: 10rpx;padding: 10rpx;"></image>
<view style="display: flex; flex-direction: column;">
<text class="textContent" style="display: flex; font-size: 35rpx; color: rgb(26, 231, 231); ">{{item.name || '未知设备'}}</text>
<text class="textContent" style="display: flex; font-size: 22rpx; color: rgb(88, 92, 92);">{{item.deviceId}}</text>
</view>
<view style="display: flex; flex-direction: row; align-items: center;position: relative; width: 100%;justify-content: flex-end; padding: 20rpx; ">
<text class="device-rssi" style="font-size: 25rpx; ">{{item.RSSI}}</text>
<image src="/utils/image/rss_line.png" mode="aspectFill" style="width: 40rpx; height: 40rpx; margin-left: 10rpx; "></image>
<button class="device-name" style="width: 160rpx; ">连接</button>
</view>
</view>
</view>

41
pages/index/index.wxss

@ -27,7 +27,42 @@
font-size: 32rpx;
}
.device-rssi {
color: #666;
font-size: 28rpx;
.gradient-view{
height: 100rpx;
display: flex;
flex-direction: row;
align-items: center;
/* 圆角 */
border-radius: 20rpx;
/* 边 */
border: 3rpx solid #E0E3DA;
box-shadow:5rpx 5rpx 5rpx 5rpx #E0E3DA;
background-color: #ffffff;
margin: 10rpx;
/* padding使得文字和图片不至于贴着边框 */
padding: 10rpx;
}
.x-view{
height: 100rpx;
display: flex;
flex-direction: row;
align-items: center;
/* 圆角 */
border-radius: 20rpx;
/* 边 */
border: 3rpx solid #E0E3DA;
box-shadow:5rpx 5rpx 5rpx 5rpx #c5dcee;
background-color: #e4e7e9;
margin: 10rpx;
/* padding使得文字和图片不至于贴着边框 */
padding: 10rpx;
}

250
pages/newdetail/newdetail.js

@ -14,7 +14,9 @@ Page({
commandMap:[],
support:"",
codeList:[],
videoUrl:""
videoUrl:"",
title:"",
showDelete:false
},
// 在生命周期函数中加载数据
onLoad(options) {
@ -23,12 +25,13 @@ onLoad(options) {
//     })
 
wx.showToast({
title: `点击了子项 ${options.name}`,
icon: 'none'
});
// wx.showToast({
// title: `点击了子项 ${options.name}`,
// icon: 'none'
// });
// wx.showLoading({title:"等待页面初始化"})
const s = options.name;
// console.log(s);
wx.request({
url: 'https://keytest.aik518.com/prod-api/work_key/obd/zk_key/type/search',
method: 'POST', // 请求方法
@ -41,14 +44,33 @@ onLoad(options) {
},
success: res => {
console.log(res);
let list = res.data.records[0].commandMap;
let obdCommondList = res.data.dict.obd_command;
for(var i=0;i<list.length;i++){
let childCommond = list[i];
for(var b = 0;b<obdCommondList.length;b++){
if(childCommond.key==obdCommondList[b].value){
list[i].key = obdCommondList[b].label;
}
}
// if(childCommond.key=="newKeyAdd"){
// list[i].key="新增钥匙";
// }else if(childCommond.key=="oldKeyAdd"){
// list[i].key="老版新增钥匙";
// }else if(childCommond.key=="Keys_DECALL"){
// list[i].key="删除钥匙";
// }
};
wx.setNavigationBarTitle({ title: res.data.records[0].name })
this.setData({
obd_command:res.data.dict.obd_command,
commandMap:res.data.records[0].commandMap,
commandMap:list,
support:res.data.records[0].support,
videoUrl:res.data.records[0].videoUrl,
codeList:res.data.records[0].type.codeList
videoUrl:res.data.records[0].videoMiniUrl,
codeList:res.data.records[0].type.codeList,
title:res.data.records[0].name,
showDelete:res.data
})
@ -79,7 +101,29 @@ onLoad(options) {
}
})
},initBluetooth:function () {
},getserviceKeydata(s){
var that = this;
wx.request({
url: 'https://keytest.aik518.com/prod-api/work_key/obd/zk_key/calc_key?hexStr='+s,
method: 'GET', // 请求方法
success: res => {
//{"code":1,"data":{"flag":true,"hex":"000C0077655F103F009F1FA70A76"},"dict":null,"i18nMsg":"请求成功","msg":"请求成功"}
// 000C0077655F103F009F1FA70A76
let hex = res.data.data.hex;
console.log(res.data+"==="+hex+"===");
let lastHex = "C5"+hex;
that.sendCommonOrder(lastHex,true);
}
})
},
onShareAppMessage() {
return {
title: 'OBD小程序',
path: '/pages/index/index'
};
}
,initBluetooth:function () {
wx.getConnectedBluetoothDevices({
services: [getApp().globalData.serviceUuid],
success: (res) => {
@ -105,6 +149,7 @@ reconnectDevice:function(){
getCharacteristics:function(){
console.error("成功==>设备id:", getApp().globalData.deviceId)
console.error("成功===>服务UUID:", getApp().globalData.serviceUuid)
this.enableNotify();
},
enableNotify:function (){
@ -137,7 +182,7 @@ enableNotify:function (){
});
},listenData:function () {
wx.onBLECharacteristicValueChange((res) => {
//A3001246554E4354494F4E5F535441525408 卡住的返回数据
const value = new Uint8Array(res.value);
let hex = this.bytesToHex(value);
console.log("当前页面收到数据:", value +"==="+hex);
@ -175,7 +220,8 @@ enableNotify:function (){
if(hex.startsWith("A3")){
let firstlenth = hex.substring(2,6); //1246
let ff = parseInt(firstlenth,16);
// A30010C50009E44CE7E549BF40F9E5A3
// ff====>16hex.length===>32firstlenth===>0010
console.log("ff====>"+ff+"hex.length===>"+hex.length+"firstlenth===>"+firstlenth);
if(ff*2 ==hex.length){
let realOrder = hex.substring(6,8);
@ -185,7 +231,7 @@ enableNotify:function (){
let realCount = 0;
if(number !=="00"){
let type = hex.substring(18,20);
let numberLenth = parseInt(number);
let numberLenth = parseInt(number,16);
let indexLast = 20+numberLenth*2;
let count = hex.substring(20,indexLast);
if(type =="A1"){
@ -193,7 +239,12 @@ enableNotify:function (){
}else if(type =="A2"){
realCount = parseInt(count,16);
}else if(type =="A3"){
let realNotice = "";
for (var n = 0; n < count.length; n += 2) {
realNotice += count.substr(n+1, 1);
}
realCount = parseInt(realNotice);
}
}
@ -210,7 +261,13 @@ enableNotify:function (){
// inputContent = hex.substring();
}
//A30010C50009E44CE7E549BF40F9E5A3
if(realOrder=="C5"){
let lastIndex = hex.length-2;
let c5Hex = hex.substring(8,lastIndex);
this.getserviceKeydata(c5Hex);
return;
}
this.showOrder(realOrder,content,inputType,realCount);
}else{
@ -235,7 +292,7 @@ enableNotify:function (){
let realCount = 0;
if(number !=="00"){
let type = firstOrder.substring(18,20);
let numberLenth = parseInt(number);
let numberLenth = parseInt(number,16);
let indexLast = 20+numberLenth*2;
let count = firstOrder.substring(20,indexLast);
if(type =="A1"){
@ -243,12 +300,31 @@ enableNotify:function (){
}else if(type =="A2"){
realCount = parseInt(count,16);
}else if(type =="A3"){
let realNotice = "";
for (var n = 0; n < count.length; n += 2) {
realNotice += count.substr(n+1, 1);
}
realCount = parseInt(realNotice);
}
}
if(realOrder=="A3"){
//A3 00 0D A1 10 00 00 01 02 A1 10 11 27
//A3000A A3 A2 F000002 608
//A3000AA3 A1 F000003112 本田 输入框命令
content = hex.substring(10,18);
inputType = hex.substring(8,10);
// noticeConetntLengh = hex.substring(18,20);
// inputContent = hex.substring();
}
if(realOrder=="C5"){
let lastIndex = firstOrder.length-2;
let c5Hex = firstOrder.substring(8,lastIndex);
this.getserviceKeydata(c5Hex);
return;
}
this.showOrder(realOrder,content2,inputType,realCount);
}else{
let secondOrder = hex.substring(yy*2,firstOrder.length);
@ -267,8 +343,9 @@ enableNotify:function (){
let number = secondOrder.substring(16,18);
let realCount = 0;
if(number !=="00"){
// A3 00 0F A1 10 00 00 1D 04 A3 39 32 34 30 F6
let type = secondOrder.substring(18,20);
let numberLenth = parseInt(number);
let numberLenth = parseInt(number,16);
let indexLast = 20+numberLenth*2;
let count = secondOrder.substring(20,indexLast);
if(type =="A1"){
@ -276,10 +353,34 @@ enableNotify:function (){
}else if(type =="A2"){
realCount = parseInt(count,16);
}else if(type =="A3"){
let realNotice = "";
for (var n = 0; n < count.length; n += 2) {
realNotice += count.substr(n+1, 1);
}
realCount = parseInt(realNotice);
}
}
if(realOrder=="A3"){
//A3 00 0D A1 10 00 00 01 02 A1 10 11 27
//A3000A A3 A2 F000002 608
//A3000AA3 A1 F000003112 本田 输入框命令
content = hex.substring(10,18);
inputType = hex.substring(8,10);
// noticeConetntLengh = hex.substring(18,20);
// inputContent = hex.substring();
}
if(realOrder=="C5"){
let lastIndex = secondOrder.length-2;
let c5Hex = secondOrder.substring(8,lastIndex);
this.getserviceKeydata(c5Hex);
return;
}
this.showOrder(realSecondOrder,content3,inputType,realCount);
}
}
@ -385,6 +486,10 @@ showOrder(realOrder,content,inputType,realCount){
// wx.hideLoading()
// }, 2000)
}else if(realOrder=="A1"){
if(ccc.includes('10000005')||ccc.includes('10000010')){
this.addObdBurnCount();
}
wx.hideLoading();
wx.showModal({
title: '提示',
@ -446,7 +551,13 @@ showOrder(realOrder,content,inputType,realCount){
lastHex = "0"+key;
}
}else if(inputType=="A3"){
let spendHex = "";
for(let i=0;i<key.length;i++ ){
let a = key.substring(i,i+1);
a = "3"+a;
spendHex = spendHex+a;
}
lastHex = spendHex;
}
let contentLengh = lastHex.length/2;
@ -474,6 +585,14 @@ showOrder(realOrder,content,inputType,realCount){
}
},
hex_to_ascii(hex) {
hex = hex.toString();
let str = '';
for (var n = 0; n < hex.length; n += 2) {
str += String.fromCharCode(parseInt(hex.substr(n, 2), 16));
}
return str;
},sendCommonOrder:function (hexString,isAllHex){
let hex = hexString;
if(isAllHex){
@ -507,11 +626,106 @@ const bytes = new Uint8Array(hex.match(/[\da-f]{2}/gi).map(h => parseInt(h, 16))
return bytes.buffer;
}
},sendBlueOrder:function(e){
// let id = getApp().globalData.deviceId;
// let deviceType = getApp().globalData.currentDevice;
// let mac = wx.getStorageSync(id);
// console.log(id+"==="+deviceType+"=="+mac)
const oder = "aa"+e.currentTarget.dataset.name;
// let oo = "aa60000001";
// let oo = "aa53000009";
// this.sendCommonOrder(oder,true);
this.checkObdBurnCount(oder)
},
handleItemClick:function (params) {
const order = "aa"+params.currentTarget.dataset.id;
this.checkObdBurnCount(order)
},
checkObdBurnCount:function (e) {
const oder = e;
this.sendCommonOrder(oder,true);
// let macAddress = getApp().globalData.deviceId;
// let deviceType = getApp().globalData.currentDevice;
// if(deviceType.includes('ios')){
// macAddress = wx.getStorageSync(getApp().globalData.deviceId);
// }
// wx.request({
// // /work_key/obd/count/{mac}
// url: 'https://keytest.aik518.com/prod-api/work_key/obd/count/'+macAddress,
// method: 'GET', // 请求方法
// success: res => {
// //{"code":1,"data":{"oldPin":"0862","newPin":"0746","flag":true},"dict":null,"i18nMsg":"请求成功","msg":"请求成功"}
// // A3000AAA5501 0CC2FB 76
// let currentCount = res.data.data.count;
// console.log(res.data+"===当前烧录次数"+currentCount);
// let intCount = parseInt(currentCount);
// if(intCount>6){
// wx.showModal({
// title: '温馨提示',
// content: '当前设备已经烧录6次,不能继续烧录',
// cancelText:false,
// complete: (res) => {
// if (res.confirm) {
// }
// }
// })
// }else{
// this.sendCommonOrder(oder,true);
// }
// }
// })
}
,
addObdBurnCount:function(){
// const s = options.name;
let macAddress = getApp().globalData.deviceId;
let deviceType = getApp().globalData.currentDevice;
if(deviceType.includes('ios')){
macAddress = wx.getStorageSync(getApp().globalData.deviceId);
}
wx.request({
url: 'https://keytest.aik518.com/prod-api/work_key/obd/count/add',
method: 'POST', // 请求方法
data:{
mac: macAddress
},
// data: JSON.stringify({ // 手动序列化对象为 JSON 字符串
// mac: macAddress,
// language: 'zh'
// }),
header: {
'Content-Type': 'application/json' // 关键标识‌:ml-citation{ref="1,4" data="citationList"}
},
success: res => {
console.log(res);
// this.setData({
// obd_command:res.data.dict.obd_command,
// commandMap:res.data.records[0].commandMap,
// support:res.data.records[0].support,
// videoUrl:res.data.records[0].videoMiniUrl,
// codeList:res.data.records[0].type.codeList
// })
}
});
},
startNotifi:function(){

31
pages/newdetail/newdetail.wxml

@ -1,9 +1,26 @@
<view class="container1">
<text class="text-item" bindtap="handleTextTap" data-id="{{videoUrl}}" data-name="{{videoUrl}}" wx:key="id">
演示视频
</text>
<view class="container-view" >
<text class="text-item" bindtap="handleTextTap" data-id="{{videoUrl}}" data-name="{{videoUrl}}" wx:key="id">演示视频</text>
<!-- <view class="divider"></view>
<text class="text-item" bindtap="sendBlueOrder" data-key="{{commandMap[0].value}}" data-name="{{commandMap[0].value}}" wx:key="id">增加钥匙/{{commandMap[0].value}}</text> -->
<view class="divider"></view>
<text class="text-item" bindtap="sendBlueOrder" data-key="{{commandMap[0].value}}" data-name="{{commandMap[0].value}}" wx:key="id">增加钥匙/{{commandMap[0].value}}</text>
<view class="divider"></view>
<text class="text-item" bindtap="service" data-id="{{support}}" data-url="{{support}}" wx:key="id">联系客服:{{support}}</text>
<view class="list">
<view
wx:for="{{commandMap}}"
wx:key="id"
class="list-item"
bindtap="handleItemClick"
data-id="{{item.value}}"
>
<text class="text-item">{{item.key}}</text>
</view>
</view>
<text class="text-item" bindtap="service" data-id="{{support}}" data-url="{{support}}" wx:key="id">联系客服:</text>
<!-- <view>
<image class="qrcode" show-menu-by-longpress="1" src="https://mp-356f0dff-3257-4311-9774-dd14ef66bbf8.cdn.bspapp.com/imageUrl/name_card.jpg" mode="widthFix"></image>
</view> -->
<view style="width: 100%; justify-content: center;" class="view_class">
<image src="/utils/image/qrpic.png" show-menu-by-longpress="true" class="qr"></image>
</view>
</view>

24
pages/newdetail/newdetail.wxss

@ -1,4 +1,4 @@
.container1 {
.container-view {
display: flex;
flex-direction: column;
background-color: #f5f5f5;
@ -10,10 +10,32 @@
color: #333;
height: 100rpx;
align-items: center;
padding-left: 20rpx;
display: flex;
}
.view_class{
display: flex;
}
.qr{
align-items: center;
width: 60%;
height: 450rpx;
display: flex;
justify-content: center;
}
.divider {
width: 100%;
height: 1rpx;
background-color: #ccc;
}
.list-item {
font-size: 30rpx;
height: 100rpx;
color: #333;
border-bottom: 1rpx solid #eee;
align-items: center;
display: flex;
border-bottom: 1rpx solid #ccc;
}

29
pages/newzk/newlist.js

@ -6,13 +6,13 @@ Page({
},
// 在生命周期函数中加载数据
onLoad(options) {
wx.showToast({
title: `点击了子项 ${options.name}`,
icon: 'none'
});
// wx.showToast({
// title: `点击了子项 ${options.name}`,
// icon: 'none'
// });
const s = options.name;
wx.request({
url: 'https://keytest.aik518.com/prod-api/work_key/obd/zk_key/type_blue?blueName='+"NISSAN_OBD",
url: 'https://keytest.aik518.com/prod-api/work_key/obd/zk_key/type_blue?blueName='+s,
method: 'GET', // 请求方法
success: res => {
this.setData({
@ -25,7 +25,16 @@ onLoad(options) {
})
}
})
},
}
,
onShareAppMessage() {
return {
title: 'OBD小程序',
path: '/pages/index/index'
};
}
,
refresh: function(e) {
let id = e.currentTarget.dataset;
wx.navigateTo({
@ -46,10 +55,10 @@ handleItemClick: function (e) {
wx.navigateTo({
url: '/pages/newdetail/newdetail?name='+dataid // 支持参数传递
})
wx.showToast({
title: `点击了子项 ${dataid}`,
icon: 'none'
});
// wx.showToast({
// title: `点击了子项 ${dataid}`,
// icon: 'none'
// });
},

11
pages/playvideo/video.js

@ -4,10 +4,7 @@ Page({
},
onLoad(options) {
const s = decodeURIComponent(options.url);
wx.showToast({
title: `点击了子项 ${s}`,
icon: 'none'
});
console.log(s);
@ -27,6 +24,12 @@ Page({
playVideo() {
this.videoContext.play();
},
onShareAppMessage() {
return {
title: 'OBD小程序',
path: '/pages/index/index'
};
},
// Pause video
pauseVideo() {

4
project.config.json

@ -3,7 +3,9 @@
"libVersion": "trial",
"setting": {
"coverView": true,
"es6": true,
"urlCheck": true,
"es6": false,
"es5": true,
"postcss": true,
"minified": true,
"enhance": true,

BIN
utils/image/code.webp

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

BIN
utils/image/ffffff.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 560 KiB

BIN
utils/image/qrpic.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 288 KiB

Loading…
Cancel
Save