diff --git a/app.js b/app.js index 0894cc5..c198728 100644 --- a/app.js +++ b/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:"" } }) diff --git a/app.json b/app.json index d3920a1..57c216f 100644 --- a/app.json +++ b/app.json @@ -6,6 +6,7 @@ "pages/newdetail/newdetail", "pages/playvideo/video", "pages/service/service", + "pages/elselist/elselist", "pages/newzk/newlist" ], "permission": { diff --git a/pages/datalist/brand.js b/pages/datalist/brand.js index adc2d99..9b60e35 100644 --- a/pages/datalist/brand.js +++ b/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' + // }); }, diff --git a/pages/datalist/brand.wxml b/pages/datalist/brand.wxml index 6f1c09c..fc5903a 100644 --- a/pages/datalist/brand.wxml +++ b/pages/datalist/brand.wxml @@ -1,14 +1,16 @@ - {{item.name}}{{item.haveChildren ? '▼' : '▶'}} + + + {{item.name}} {{child.name}} diff --git a/pages/datalist/brand.wxss b/pages/datalist/brand.wxss index 61919d1..4fe299b 100644 --- a/pages/datalist/brand.wxss +++ b/pages/datalist/brand.wxss @@ -9,5 +9,4 @@ .sublist-item { padding: 5px; - border-bottom: 1px solid #ddd; } \ No newline at end of file diff --git a/pages/elselist/elselist.js b/pages/elselist/elselist.js new file mode 100644 index 0000000..6a317ab --- /dev/null +++ b/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' + }); +}, + + +}) \ No newline at end of file diff --git a/pages/elselist/elselist.json b/pages/elselist/elselist.json new file mode 100644 index 0000000..a1328df --- /dev/null +++ b/pages/elselist/elselist.json @@ -0,0 +1,6 @@ +{ + "usingComponents": { + + }, + "navigationBarTitleText": "OBD分类" +} diff --git a/pages/elselist/elselist.wxml b/pages/elselist/elselist.wxml new file mode 100644 index 0000000..fc5903a --- /dev/null +++ b/pages/elselist/elselist.wxml @@ -0,0 +1,29 @@ + + + + + {{item.name}} + + + {{child.name}} + + + + \ No newline at end of file diff --git a/pages/elselist/elselist.wxss b/pages/elselist/elselist.wxss new file mode 100644 index 0000000..4fe299b --- /dev/null +++ b/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; +} \ No newline at end of file diff --git a/pages/index/index.js b/pages/index/index.js index fb84176..bfeab50 100644 --- a/pages/index/index.js +++ b/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; + // 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.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&¤tD==''){ + 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) }); diff --git a/pages/index/index.wxml b/pages/index/index.wxml index a88607c..2d2354c 100644 --- a/pages/index/index.wxml +++ b/pages/index/index.wxml @@ -5,25 +5,41 @@ 请确保OBD设备已经连接汽车OBD接口,并未与其它手机连接 - + + + + + - 信号强度: {{item.RSSI}}dBm MAC: {{item.deviceId}} - + --> + + + + + {{item.name || '未知设备'}} + {{item.deviceId}} + + + + {{item.RSSI}} + + + diff --git a/pages/index/index.wxss b/pages/index/index.wxss index 95592b4..8adca79 100644 --- a/pages/index/index.wxss +++ b/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; } diff --git a/pages/newdetail/newdetail.js b/pages/newdetail/newdetail.js index 93740c8..141829c 100644 --- a/pages/newdetail/newdetail.js +++ b/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,21 +44,40 @@ 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 { + //{"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 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(){ diff --git a/pages/newdetail/newdetail.wxml b/pages/newdetail/newdetail.wxml index 7ce93a5..3db0dbc 100644 --- a/pages/newdetail/newdetail.wxml +++ b/pages/newdetail/newdetail.wxml @@ -1,9 +1,26 @@ - - - 演示视频 - + + 演示视频 + - 增加钥匙/{{commandMap[0].value}} - - 联系客服:{{support}} + + + {{item.key}} + + + + 联系客服: + + + + + \ No newline at end of file diff --git a/pages/newdetail/newdetail.wxss b/pages/newdetail/newdetail.wxss index 149f26f..b6c748f 100644 --- a/pages/newdetail/newdetail.wxss +++ b/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; } \ No newline at end of file diff --git a/pages/newzk/newlist.js b/pages/newzk/newlist.js index 2c87741..5953c74 100644 --- a/pages/newzk/newlist.js +++ b/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' + // }); }, diff --git a/pages/playvideo/video.js b/pages/playvideo/video.js index 2c90102..57ecedc 100644 --- a/pages/playvideo/video.js +++ b/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() { diff --git a/project.config.json b/project.config.json index a9801ed..aa81cea 100644 --- a/project.config.json +++ b/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, diff --git a/utils/image/code.webp b/utils/image/code.webp new file mode 100644 index 0000000..0ae26f8 Binary files /dev/null and b/utils/image/code.webp differ diff --git a/utils/image/ffffff.jpg b/utils/image/ffffff.jpg new file mode 100644 index 0000000..015e506 Binary files /dev/null and b/utils/image/ffffff.jpg differ diff --git a/utils/image/qrpic.png b/utils/image/qrpic.png new file mode 100644 index 0000000..5a05f2a Binary files /dev/null and b/utils/image/qrpic.png differ