From 5f2c7e6a13a58df282a11143f2ac0c0ed7195f83 Mon Sep 17 00:00:00 2001 From: whycq <10027870+whycq@user.noreply.gitee.com> Date: 星期一, 24 四月 2023 17:52:39 +0800 Subject: [PATCH] # --- pages/home/home.vue | 11 pages.json | 18 + pages/print/printUNI.vue | 723 +++++++++++++++++++++++++++++++++++++++++++++++++++ pages/print/print.vue | 58 ++++ pages/pakin/orderPakin.vue | 11 static/css/wms.css/wms.css | 3 6 files changed, 821 insertions(+), 3 deletions(-) diff --git a/pages.json b/pages.json index e962074..7a63b5b 100644 --- a/pages.json +++ b/pages.json @@ -1,6 +1,18 @@ { "pages": [ //pages鏁扮粍涓涓�椤硅〃绀哄簲鐢ㄥ惎鍔ㄩ〉锛屽弬鑰冿細https://uniapp.dcloud.io/collocation/pages { + "path": "pages/print/printUNI", + "style": { + "navigationBarTitleText": "UNI鎵撳嵃" + } + }, + { + "path": "pages/print/print", + "style": { + "navigationBarTitleText": "鎵撳嵃" + } + }, + { "path": "pages/login/login", "style": { "navigationBarTitleText": "鐧� 褰�" @@ -36,6 +48,12 @@ "navigationBarTitleText": "璁㈠崟鍏ュ簱" } }, + // { + // "path": "pages/print/print", + // "style": { + // "navigationBarTitleText": "鎵撳嵃" + // } + // }, { "path": "pages/login/logOut", "style": { diff --git a/pages/home/home.vue b/pages/home/home.vue index 532d678..e2e9aa2 100644 --- a/pages/home/home.vue +++ b/pages/home/home.vue @@ -22,18 +22,25 @@ { title: '缁勬墭鍏ュ簱', name: 'pakin', - color: 'purple', + color: 'cyan', cuIcon: 'list', url: '/pakin/pakin' }, { title: '璁㈠崟鍏ュ簱', name: 'orderPakin', - color: 'purple', + color: 'blue', cuIcon: 'list', url: '/pakin/orderPakin' }, { + title: '鎵撳嵃', + name: 'print', + color: 'blue', + cuIcon: 'list', + url: '/print/print' + }, + { title: '閫�鍑虹櫥褰�', name: 'logOut', color: 'grey', diff --git a/pages/pakin/orderPakin.vue b/pages/pakin/orderPakin.vue new file mode 100644 index 0000000..f93ca81 --- /dev/null +++ b/pages/pakin/orderPakin.vue @@ -0,0 +1,11 @@ +<template> + <view> + + </view> +</template> + +<script> +</script> + +<style> +</style> \ No newline at end of file diff --git a/pages/print/print.vue b/pages/print/print.vue new file mode 100644 index 0000000..ec0a463 --- /dev/null +++ b/pages/print/print.vue @@ -0,0 +1,58 @@ +<template> + <view> + <button @click="connectBluetooth">connect</button> + </view> +</template> + +<script> + export default { + data() { + return { + + } + }, + methods: { + connectBluetooth() { + let that = this + uni.openBluetoothAdapter({ + success(res) { + console.log(res) + uni.getBluetoothAdapterState({ + success(res) { + console.log(res); + if (!res.discovering) { + uni.startBluetoothDevicesDiscovery({ + success(res) { + console.log(res); + uni.onBluetoothDeviceFound(devices => { + console.log('寮�濮嬬洃鍚鎵惧埌鏂拌澶囩殑浜嬩欢'); + // this.$set(this.disabled, 3, false); + uni.getBluetoothDevices({ + success: res => { + this.newDeviceLoad = false; + console.log('鑾峰彇钃濈墮璁惧鎴愬姛:' + res.errMsg); + // console.log(JSON.stringify(res)) + }, + }); + }); + }, + fail(err) { + console.log(); + } + }) + } + } + }) + }, + }) + // 鐩戝惉钃濈墮璁惧鍒楄〃 + + }, + + } + } +</script> + +<style> + +</style> diff --git a/pages/print/printUNI.vue b/pages/print/printUNI.vue new file mode 100644 index 0000000..d9bc4da --- /dev/null +++ b/pages/print/printUNI.vue @@ -0,0 +1,723 @@ +<template> + <view> + <page-head :title="title"></page-head> + <view class="uni-padding-wrap uni-common-mt"> + <view> + 鏈摑鐗欏崗璁彧鏀寔浣庡姛鑰楄摑鐗欏崗璁産le銆傚鏋滄兂杩炴帴闈瀊le钃濈墮璁惧锛岃鍦ㄧぞ鍖烘悳绱� Native.js 钃濈墮銆� + </view> + <view class="uni-btn-v"> + <button type="primary" :disabled="disabled[0]" @click="openBluetoothAdapter"> + 鍒濆鍖栬摑鐗欐ā鍧� + </button> + <view v-if="!adapterState.available"> + {{ '钃濈墮閫傞厤鍣ㄤ笉鍙敤,璇峰垵濮嬪寲钃濈墮妯″潡' }} + </view> + <button + type="primary" + :loading="searchLoad" + :disabled="disabled[1]" + @click="startBluetoothDevicesDiscovery" + > + 寮�濮嬫悳绱㈣摑鐗欒澶� + </button> + <button + type="primary" + :disabled="disabled[2]" + @click="stopBluetoothDevicesDiscovery(false)" + > + 鍋滄鎼滅储钃濈墮璁惧 + </button> + <button + type="primary" + :loading="newDeviceLoad" + :disabled="disabled[3]" + @click="queryDevices" + > + 閫夋嫨璁惧 + </button> + <view v-if="equipment.length > 0"> + {{ + (connected ? '宸茶繛鎺ヨ澶�' : '宸查�夋嫨璁惧') + + ' : ' + + equipment[0].name + + ' (' + + equipment[0].deviceId + + ')' + }} + </view> + <button type="primary" :disabled="disabled[4]" @click="createBLEConnection"> + 杩炴帴钃濈墮璁惧 + </button> + <button type="primary" :disabled="disabled[5]" @click="getBLEDeviceServices"> + 閫夋嫨璁惧鏈嶅姟 + </button> + <view v-if="servicesData.length > 0">宸查�夋湇鍔uid锛歿{ servicesData[0].uuid }}</view> + <button type="primary" :disabled="disabled[6]" @click="getBLEDeviceCharacteristics"> + 鑾峰彇鏈嶅姟鐨勭壒寰佸�� + </button> + <view v-if="characteristicsData.length > 0"> + <view class="uni-list_name">uuid:{{ characteristicsData[0].uuid }}</view> + <view class="uni-list_item"> + 鏄惁鏀寔 read 鎿嶄綔:{{ characteristicsData[0].properties.read }} + </view> + <view class="uni-list_item"> + 鏄惁鏀寔 write 鎿嶄綔:{{ characteristicsData[0].properties.write }} + </view> + <view class="uni-list_item"> + 鏄惁鏀寔 notify 鎿嶄綔:{{ characteristicsData[0].properties.notify }} + </view> + <view class="uni-list_item"> + 鏄惁鏀寔 indicate 鎿嶄綔:{{ characteristicsData[0].properties.indicate }} + </view> + </view> + <!-- <button type="primary" :disabled="disabled[7]" @click="readBLECharacteristicValue"> + 璇诲彇鐗瑰緛鍊兼暟鎹� + </button> + <view v-if="valueChangeData.serviceId"> + <view class="list-name"> + 鐗瑰緛鍊兼渶鏂扮殑鍊�:{{ valueChangeData.value || '杩樻病鏈夋渶鏂板��' }} + </view> + </view> --> + <!-- <button type="primary" :disabled="disabled[8]" @click="w">鍐欏叆鐗瑰緛鍊兼暟鎹�</button> --> + <button type="primary" :disabled="disabled[9]" @click="closeBLEConnection"> + 鏂紑钃濈墮璁惧 + </button> + <button type="primary" :disabled="disabled[10]" @click="closeBluetoothAdapter"> + 鍏抽棴钃濈墮妯″潡 + </button> + </view> + </view> + <!-- 閬僵 --> + <view v-if="maskShow" class="uni-mask" @touchmove.stop.prevent="moveHandle" @click="maskclose"> + <scroll-view class="uni-scroll_box" scroll-y @touchmove.stop.prevent="moveHandle" @click.stop="moveHandle"> + <view class="uni-title"> + 宸茬粡鍙戠幇{{ list.length }}{{ showMaskType === 'device' ? '鍙拌澶�' : '涓湇鍔�' }}: + </view> + <view + class="uni-list-box" + v-for="(item, index) in list" + :key="index" + @click="tapQuery(item)" + > + <view v-if="showMaskType === 'device'"> + <view class="uni-list_name">{{ item.name || item.localName }}</view> + <view class="uni-list_item">淇″彿寮哄害:{{ item.RSSI }}dBm</view> + <view class="uni-list_item">UUID:{{ item.deviceId }}</view> + <!-- <view class="list-item" v-if="showMaskType === 'device'"> + Service鏁伴噺:{{ item.advertisServiceUUIDs.length }} + </view> --> + </view> + <view v-if="showMaskType === 'service'"> + <view class="uni-list_item" style="line-height:2.2;"> + UUID: {{ item.uuid }} + <text v-if="showMaskType === 'service'"> + {{ item.isPrimary ? '锛堜富鏈嶅姟锛�' : '' }} + </text> + </view> + </view> + <view v-if="showMaskType === 'characteristics'"> + <view class="uni-list_name">uuid:{{ item.uuid }}</view> + <view class="uni-list_item">鏄惁鏀寔 read 鎿嶄綔:{{ item.properties.read }}</view> + <view class="uni-list_item"> + 鏄惁鏀寔 write 鎿嶄綔:{{ item.properties.write }} + </view> + <view class="uni-list_item"> + 鏄惁鏀寔 notify 鎿嶄綔:{{ item.properties.notify }} + </view> + <view class="uni-list_item"> + 鏄惁鏀寔 indicate 鎿嶄綔:{{ item.properties.indicate }} + </view> + </view> + </view> + </scroll-view> + </view> + </view> +</template> +<script> +export default { + data() { + return { + title: 'bluetooth', + disabled: [false, true, true, true, true, true, true, true, true, true, true], + newDeviceLoad: false, + searchLoad: false, + maskShow: false, + equipment: [], + adapterState: { + discovering: false, + available: false + }, + connected: false, + showMaskType: 'device', + servicesData: [], + characteristicsData: [], + valueChangeData: {}, + isStop:true , + list: [] + }; + }, + onLoad() { + this.onBLEConnectionStateChange(); + }, + methods: { + moveHandle() {}, + /** + * 鍏抽棴閬僵 + */ + maskclose(){ + this.maskShow = false; + }, + /** + * 閫夋嫨璁惧 + */ + queryDevices() { + // this.newDeviceLoad = true; + this.showMaskType = 'device'; + this.maskShow = true; + }, + tapQuery(item) { + if (this.showMaskType === 'device') { + this.$set(this.disabled, 4, false); + if (this.equipment.length > 0) { + this.equipment[0] = item; + } else { + this.equipment.push(item); + } + this.newDeviceLoad = false; + } + if (this.showMaskType === 'service') { + this.$set(this.disabled, 6, false); + if (this.servicesData.length > 0) { + this.servicesData[0] = item; + } else { + this.servicesData.push(item); + } + } + if (this.showMaskType === 'characteristics') { + this.$set(this.disabled, 7, false); + if (this.characteristicsData.length > 0) { + this.characteristicsData[0] = item; + } else { + this.characteristicsData.push(item); + } + } + this.maskShow = false; + }, + /** + * 鍒濆鍖栬摑鐗欒澶� + */ + openBluetoothAdapter() { + uni.openBluetoothAdapter({ + success: e => { + console.log('鍒濆鍖栬摑鐗欐垚鍔�:' + e.errMsg); + console.log(JSON.stringify(e)); + this.isStop = false ; + this.$set(this.disabled, 0, true); + this.$set(this.disabled, 1, false); + this.$set(this.disabled, 10, false); + this.getBluetoothAdapterState(); + }, + fail: e => { + console.log(e) + console.log('鍒濆鍖栬摑鐗欏け璐ワ紝閿欒鐮侊細' + (e.errCode || e.errMsg)); + if (e.errCode !== 0) { + initTypes(e.errCode,e.errMsg); + } + } + }); + }, + /** + * 寮�濮嬫悳绱㈣摑鐗欒澶� + */ + startBluetoothDevicesDiscovery() { + uni.startBluetoothDevicesDiscovery({ + success: e => { + console.log('寮�濮嬫悳绱㈣摑鐗欒澶�:' + e.errMsg); + this.searchLoad = true; + this.$set(this.disabled, 1, true); + this.$set(this.disabled, 2, false); + this.$set(this.disabled, 3, false); + this.onBluetoothDeviceFound(); + }, + fail: e => { + console.log('鎼滅储钃濈墮璁惧澶辫触锛岄敊璇爜锛�' + e.errCode); + if (e.errCode !== 0) { + initTypes(e.errCode); + } + } + }); + }, + /** + * 鍋滄鎼滅储钃濈墮璁惧 + */ + stopBluetoothDevicesDiscovery(types) { + uni.stopBluetoothDevicesDiscovery({ + success: e => { + console.log('鍋滄鎼滅储钃濈墮璁惧:' + e.errMsg); + if (types) { + this.$set(this.disabled, 1, true); + } else { + this.$set(this.disabled, 1, false); + } + this.$set(this.disabled, 2, true); + // this.$set(this.disabled, 3, true); + this.searchLoad = false; + }, + fail: e => { + console.log('鍋滄鎼滅储钃濈墮璁惧澶辫触锛岄敊璇爜锛�' + e.errCode); + if (e.errCode !== 0) { + initTypes(e.errCode); + } + } + }); + }, + /** + * 鍙戠幇澶栧洿璁惧 + */ + onBluetoothDeviceFound() { + uni.onBluetoothDeviceFound(devices => { + console.log('寮�濮嬬洃鍚鎵惧埌鏂拌澶囩殑浜嬩欢'); + // this.$set(this.disabled, 3, false); + this.getBluetoothDevices(); + }); + }, + /** + * 鑾峰彇鍦ㄨ摑鐗欐ā鍧楃敓鏁堟湡闂存墍鏈夊凡鍙戠幇鐨勮摑鐗欒澶囥�傚寘鎷凡缁忓拰鏈満澶勪簬杩炴帴鐘舵�佺殑璁惧銆� + */ + getBluetoothDevices() { + uni.getBluetoothDevices({ + success: res => { + this.newDeviceLoad = false; + console.log('鑾峰彇钃濈墮璁惧鎴愬姛:' + res.errMsg); + // console.log(JSON.stringify(res)) + this.list = res.devices; + }, + fail: e => { + console.log('鑾峰彇钃濈墮璁惧閿欒锛岄敊璇爜锛�' + e.errCode); + if (e.errCode !== 0) { + initTypes(e.errCode); + } + } + }); + }, + /** + * 鑾峰彇鏈満钃濈墮閫傞厤鍣ㄧ姸鎬� + */ + getBluetoothAdapterState() { + console.log('--->'); + uni.getBluetoothAdapterState({ + success: res => { + console.log(JSON.stringify(res)); + this.adapterState = res; + }, + fail: e => { + console.log('鑾峰彇鏈満钃濈墮閫傞厤鍣ㄧ姸鎬佸け璐ワ紝閿欒鐮侊細' + e.errCode); + if (e.errCode !== 0) { + initTypes(e.errCode); + } + } + }); + }, + /** + * 杩炴帴浣庡姛鑰楄摑鐗� + */ + createBLEConnection() { + let deviceId = this.equipment[0].deviceId; + uni.showToast({ + title: '杩炴帴钃濈墮...', + icon: 'loading', + duration: 99999 + }); + uni.createBLEConnection({ + // 杩欓噷鐨� deviceId 闇�瑕佸凡缁忛�氳繃 createBLEConnection 涓庡搴旇澶囧缓绔嬮摼鎺� + deviceId, + success: res => { + console.log(res); + console.log('杩炴帴钃濈墮鎴愬姛:' + res.errMsg); + // 杩炴帴璁惧鍚庢柇寮�鎼滅储 骞朵笖涓嶈兘鎼滅储璁惧 + this.stopBluetoothDevicesDiscovery(true); + uni.hideToast(); + uni.showToast({ + title: '杩炴帴鎴愬姛', + icon: 'success', + duration: 2000 + }); + this.$set(this.disabled, 3, true); + this.$set(this.disabled, 4, true); + this.$set(this.disabled, 5, false); + this.$set(this.disabled, 9, false); + this.connected = true; + }, + fail: e => { + console.log('杩炴帴浣庡姛鑰楄摑鐗欏け璐ワ紝閿欒鐮侊細' + e.errCode); + if (e.errCode !== 0) { + initTypes(e.errCode); + } + } + }); + }, + /** + * 鏂紑涓庝綆鍔熻�楄摑鐗欒澶囩殑杩炴帴 + */ + closeBLEConnection() { + let deviceId = this.equipment[0].deviceId; + uni.closeBLEConnection({ + deviceId, + success: res => { + console.log(res); + console.log('鏂紑浣庡姛鑰楄摑鐗欐垚鍔�:' + res.errMsg); + this.$set(this.disabled, 1, false); + this.$set(this.disabled, 3, true); + this.$set(this.disabled, 4, true); + this.$set(this.disabled, 5, true); + this.$set(this.disabled, 6, true); + this.$set(this.disabled, 7, true); + this.$set(this.disabled, 8, true); + this.$set(this.disabled, 9, true); + this.equipment = []; + this.servicesData = []; + this.characteristicsData = []; + }, + fail: e => { + console.log('鏂紑浣庡姛鑰楄摑鐗欐垚鍔燂紝閿欒鐮侊細' + e.errCode); + if (e.errCode !== 0) { + initTypes(e.errCode); + } + } + }); + }, + /** + * 鑾峰彇鎵�鏈夋湇鍔� + */ + getBLEDeviceServices() { + let deviceId = this.equipment[0].deviceId; + console.log('鑾峰彇鎵�鏈夋湇鍔$殑 uuid:' + deviceId); + + uni.getBLEDeviceServices({ + // 杩欓噷鐨� deviceId 闇�瑕佸凡缁忛�氳繃 createBLEConnection 涓庡搴旇澶囧缓绔嬮摼鎺� + deviceId, + success: res => { + console.log(JSON.stringify(res.services)); + console.log('鑾峰彇璁惧鏈嶅姟鎴愬姛:' + res.errMsg); + this.$set(this.disabled, 7, true); + this.$set(this.disabled, 8, true); + this.showMaskType = 'service'; + this.list = res.services; + + this.characteristicsData = []; + if (this.list.length <= 0) { + toast('鑾峰彇鏈嶅姟澶辫触锛岃閲嶈瘯!'); + return; + } + this.maskShow = true; + }, + fail: e => { + console.log('鑾峰彇璁惧鏈嶅姟澶辫触锛岄敊璇爜锛�' + e.errCode); + if (e.errCode !== 0) { + initTypes(e.errCode); + } + } + }); + }, + /** + * 鑾峰彇鏌愪釜鏈嶅姟涓嬬殑鎵�鏈夌壒寰佸�� + */ + getBLEDeviceCharacteristics() { + let deviceId = this.equipment[0].deviceId; + let serviceId = this.servicesData[0].uuid; + console.log(deviceId); + console.log(serviceId); + uni.getBLEDeviceCharacteristics({ + // 杩欓噷鐨� deviceId 闇�瑕佸凡缁忛�氳繃 createBLEConnection 涓庡搴旇澶囧缓绔嬮摼鎺� + deviceId, + // 杩欓噷鐨� serviceId 闇�瑕佸湪 getBLEDeviceServices 鎺ュ彛涓幏鍙� + serviceId, + success: res => { + console.log(JSON.stringify(res)); + console.log('鑾峰彇鐗瑰緛鍊兼垚鍔�:' + res.errMsg); + this.$set(this.disabled, 7, true); + this.valueChangeData = {}; + this.showMaskType = 'characteristics'; + this.list = res.characteristics; + if (this.list.length <= 0) { + toast('鑾峰彇鐗瑰緛鍊煎け璐ワ紝璇烽噸璇�!'); + return; + } + this.maskShow = true; + }, + fail: e => { + console.log('鑾峰彇鐗瑰緛鍊煎け璐ワ紝閿欒鐮侊細' + e.errCode); + if (e.errCode !== 0) { + initTypes(e.errCode); + } + } + }); + }, + /** + * 鐩戝惉浣庡姛鑰楄摑鐗欒繛鎺ョ姸鎬佺殑鏀瑰彉浜嬩欢銆傚寘鎷紑鍙戣�呬富鍔ㄨ繛鎺ユ垨鏂紑杩炴帴锛岃澶囦涪澶憋紝杩炴帴寮傚父鏂紑绛夌瓑 + */ + onBLEConnectionStateChange() { + uni.onBLEConnectionStateChange(res => { + // 璇ユ柟娉曞洖璋冧腑鍙互鐢ㄤ簬澶勭悊杩炴帴鎰忓鏂紑绛夊紓甯告儏鍐� + console.log(`钃濈墮杩炴帴鐘舵�� -------------------------->`); + console.log(JSON.stringify(res)); + if (!res.connected) { + if(this.isStop) return ; + console.log('鏂紑浣庡姛鑰楄摑鐗欐垚鍔�:'); + this.$set(this.disabled, 1, false); + this.$set(this.disabled, 3, true); + this.$set(this.disabled, 4, true); + this.$set(this.disabled, 5, true); + this.$set(this.disabled, 6, true); + this.$set(this.disabled, 7, true); + this.$set(this.disabled, 8, true); + this.$set(this.disabled, 9, true); + this.searchLoad = false; + this.equipment = []; + this.servicesData = []; + this.characteristicsData = []; + this.valueChangeData = {}; + toast('宸茬粡鏂紑褰撳墠钃濈墮杩炴帴'); + } + }); + }, + /** + * 璇诲彇浣庡姛鑰楄摑鐗欒澶囩殑鐗瑰緛鍊肩殑浜岃繘鍒舵暟鎹�笺�傛敞鎰忥細蹇呴』璁惧鐨勭壒寰佸�兼敮鎸� read 鎵嶅彲浠ユ垚鍔熻皟鐢� + */ + readBLECharacteristicValue() { + let deviceId = this.equipment[0].deviceId; + let serviceId = this.servicesData[0].uuid; + let characteristicId = this.characteristicsData[0].uuid; + console.log(deviceId); + console.log(serviceId); + console.log(characteristicId); + uni.readBLECharacteristicValue({ + // 杩欓噷鐨� deviceId 闇�瑕佸凡缁忛�氳繃 createBLEConnection 涓庡搴旇澶囧缓绔嬮摼鎺� + deviceId, + // 杩欓噷鐨� serviceId 闇�瑕佸湪 getBLEDeviceServices 鎺ュ彛涓幏鍙� + serviceId, + // 杩欓噷鐨� characteristicId 闇�瑕佸湪 getBLEDeviceCharacteristics 鎺ュ彛涓幏鍙� + characteristicId, + success: res => { + console.log('璇诲彇璁惧鏁版嵁鍊兼垚鍔�'); + console.log(JSON.stringify(res)); + this.notifyBLECharacteristicValueChange(); + }, + fail(e) { + console.log('璇诲彇璁惧鏁版嵁鍊煎け璐ワ紝閿欒鐮侊細' + e.errCode); + if (e.errCode !== 0) { + initTypes(e.errCode); + } + } + }); + this.onBLECharacteristicValueChange(); + }, + /** + * 鐩戝惉浣庡姛鑰楄摑鐗欒澶囩殑鐗瑰緛鍊煎彉鍖栦簨浠躲�傚繀椤诲厛鍚敤 notifyBLECharacteristicValueChange 鎺ュ彛鎵嶈兘鎺ユ敹鍒拌澶囨帹閫佺殑 notification銆� + */ + onBLECharacteristicValueChange() { + // 蹇呴』鍦ㄨ繖閲岀殑鍥炶皟鎵嶈兘鑾峰彇 + uni.onBLECharacteristicValueChange(characteristic => { + console.log('鐩戝惉浣庡姛鑰楄摑鐗欒澶囩殑鐗瑰緛鍊煎彉鍖栦簨浠舵垚鍔�'); + console.log(JSON.stringify(characteristic)); + this.valueChangeData = characteristic; + }); + }, + /** + * 璁㈤槄鎿嶄綔鎴愬姛鍚庨渶瑕佽澶囦富鍔ㄦ洿鏂扮壒寰佸�肩殑 value锛屾墠浼氳Е鍙� uni.onBLECharacteristicValueChange 鍥炶皟銆� + */ + notifyBLECharacteristicValueChange() { + let deviceId = this.equipment[0].deviceId; + let serviceId = this.servicesData[0].uuid; + let characteristicId = this.characteristicsData[0].uuid; + let notify = this.characteristicsData[0].properties.notify; + console.log(deviceId); + console.log(serviceId); + console.log(characteristicId); + console.log(notify); + uni.notifyBLECharacteristicValueChange({ + state: true, // 鍚敤 notify 鍔熻兘 + // 杩欓噷鐨� deviceId 闇�瑕佸凡缁忛�氳繃 createBLEConnection 涓庡搴旇澶囧缓绔嬮摼鎺� + deviceId, + // 杩欓噷鐨� serviceId 闇�瑕佸湪 getBLEDeviceServices 鎺ュ彛涓幏鍙� + serviceId, + // 杩欓噷鐨� characteristicId 闇�瑕佸湪 getBLEDeviceCharacteristics 鎺ュ彛涓幏鍙� + characteristicId, + success(res) { + console.log('notifyBLECharacteristicValueChange success:' + res.errMsg); + console.log(JSON.stringify(res)); + } + }); + }, + /** + * 鏂紑钃濈墮妯″潡 + */ + closeBluetoothAdapter(OBJECT) { + uni.closeBluetoothAdapter({ + success: res => { + console.log('鏂紑钃濈墮妯″潡鎴愬姛'); + this.isStop = true ; + this.$set(this.disabled, 0, false); + this.$set(this.disabled, 1, true); + this.$set(this.disabled, 2, true); + this.$set(this.disabled, 3, true); + this.$set(this.disabled, 4, true); + this.$set(this.disabled, 5, true); + this.$set(this.disabled, 6, true); + this.$set(this.disabled, 7, true); + this.$set(this.disabled, 8, true); + this.$set(this.disabled, 9, true); + this.$set(this.disabled, 10, true); + this.equipment = []; + this.servicesData = []; + this.characteristicsData = []; + this.valueChangeData = {}; + this.adapterState = []; + this.searchLoad =false; + toast('鏂紑钃濈墮妯″潡'); + } + }); + } + } +}; + +/** + * 鍒ゆ柇鍒濆鍖栬摑鐗欑姸鎬� + */ +function initTypes(code, errMsg) { + switch (code) { + case 10000: + toast('鏈垵濮嬪寲钃濈墮閫傞厤鍣�'); + break; + case 10001: + toast('鏈娴嬪埌钃濈墮锛岃鎵撳紑钃濈墮閲嶈瘯锛�'); + break; + case 10002: + toast('娌℃湁鎵惧埌鎸囧畾璁惧'); + break; + case 10003: + toast('杩炴帴澶辫触'); + break; + case 10004: + toast('娌℃湁鎵惧埌鎸囧畾鏈嶅姟'); + break; + case 10005: + toast('娌℃湁鎵惧埌鎸囧畾鐗瑰緛鍊�'); + break; + case 10006: + toast('褰撳墠杩炴帴宸叉柇寮�'); + break; + case 10007: + toast('褰撳墠鐗瑰緛鍊间笉鏀寔姝ゆ搷浣�'); + break; + case 10008: + toast('鍏朵綑鎵�鏈夌郴缁熶笂鎶ョ殑寮傚父'); + break; + case 10009: + toast('Android 绯荤粺鐗规湁锛岀郴缁熺増鏈綆浜� 4.3 涓嶆敮鎸� BLE'); + break; + default: + toast(errMsg); + } +} + +/** + * 寮瑰嚭妗嗗皝瑁� + */ +function toast(content, showCancel = false) { + uni.showModal({ + title: '鎻愮ず', + content, + showCancel + }); +} +</script> + +<style> + +.uni-title { + /* width: 100%; */ + /* height: 80rpx; */ + text-align: center; +} + +.uni-mask { + position: fixed; + top: 0; + left: 0; + bottom: 0; + display: flex; + align-items: center; + width: 100%; + background: rgba(0, 0, 0, 0.6); + padding: 0 30rpx; + box-sizing: border-box; +} + +.uni-scroll_box { + height: 70%; + background: #fff; + border-radius: 20rpx; +} +.uni-list-box { + margin: 0 20rpx; + padding: 15rpx 0; + border-bottom: 1px #f5f5f5 solid; + box-sizing: border-box; +} +.uni-list:last-child { + border: none; +} +.uni-list_name { + font-size: 30rpx; + color: #333; +} +.uni-list_item { + font-size: 24rpx; + color: #555; + line-height: 1.5; +} + +.uni-success_box { + position: absolute; + left: 0; + bottom: 0; + min-height: 100rpx; + width: 100%; + background: #fff; + box-sizing: border-box; + border-top: 1px #eee solid; +} +.uni-success_sub { + /* width: 100%%; */ + height: 100rpx; + display: flex; + justify-content: space-between; + align-items: center; + padding: 0 30rpx; +} +.uni-close_button { + padding: 0 20rpx; + height: 60rpx; + line-height: 60rpx; + background: #ce3c39; + color: #ffffff; + border-radius: 10rpx; +} +.uni-success_content { + height: 600rpx; + margin: 30rpx; + margin-top: 0; + border: 1px #eee solid; + padding: 30rpx; +} +.uni-content_list { + padding-bottom: 10rpx; + border-bottom: 1px #f5f5f5 solid; +} +.uni-tips { + text-align: center; + font-size: 24rpx; + color: #666; +} +</style> diff --git a/static/css/wms.css/wms.css b/static/css/wms.css/wms.css index 7b90e87..a4ce720 100644 --- a/static/css/wms.css/wms.css +++ b/static/css/wms.css/wms.css @@ -2,7 +2,8 @@ display: flex; min-height: 80rpx; background-color: #FFF; - margin-top: 20rpx; + margin: auto 20rpx; + border-radius: 20rpx; box-shadow: 0px 0px 30px 0px rgba(0,0,0,0.2); } .list:first-child { -- Gitblit v1.9.1