国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

uniapp 藍(lán)牙連接設(shè)備 下發(fā)命令 監(jiān)聽藍(lán)牙與設(shè)備的連接狀態(tài)(兼容 微信小程序和支付寶小程序)

這篇具有很好參考價(jià)值的文章主要介紹了uniapp 藍(lán)牙連接設(shè)備 下發(fā)命令 監(jiān)聽藍(lán)牙與設(shè)備的連接狀態(tài)(兼容 微信小程序和支付寶小程序)。希望對(duì)大家有所幫助。如果存在錯(cuò)誤或未考慮完全的地方,請(qǐng)大家不吝賜教,您也可以點(diǎn)擊"舉報(bào)違法"按鈕提交疑問。

1:創(chuàng)建藍(lán)牙需要調(diào)用的Api文件?ly.js

// import { TextDecoder } from 'text-encoding-utf-8';
let bluetoothOpen = false; // 手機(jī)藍(lán)牙是否打開
let bluetoothConnect = false; // 設(shè)備和藍(lán)牙是否連接
let isHaveDevice = false; // 是否查找到設(shè)備
let deviceId = null; // 設(shè)備id
let serviceId = null; // 服務(wù)id
let notify = null; // 監(jiān)聽uuid
let writeId = null; // 寫入uuid
/**
 * 獲取手機(jī)藍(lán)牙是否打開
 */
const getBluetoothState = () => {
	// 主機(jī)模式
	return new Promise((resolve, reject) => {
		// mode: 'central',
		uni.openBluetoothAdapter({
			success: (r) => {
				console.log("藍(lán)牙初始化成功");
				// 獲取藍(lán)牙的匹配狀態(tài)
				uni.getBluetoothAdapterState({
					success: function(row) {
						console.log('藍(lán)牙狀態(tài):', row.available);
						if (row.available) {
							bluetoothOpen = true;
							resolve();
						} else {
							// 請(qǐng)開啟藍(lán)牙
							uni.showToast({
								title: '請(qǐng)打開藍(lán)牙',
								icon: 'none'
							})
							bluetoothOpen = false;
							bluetoothConnect = false;

							reject();
						}
					},
					fail: function(err) {
						// 請(qǐng)開啟藍(lán)牙
						uni.showToast({
							title: '請(qǐng)打開藍(lán)牙',
							icon: 'none'
						})
						bluetoothOpen = false;
						bluetoothConnect = false;
						reject();
					}
				})
			},
			fail: (err) => {
				// 請(qǐng)開啟藍(lán)牙
				console.log('藍(lán)牙初始化失敗'+ JSON.stringify(err));
				uni.showToast({
					title: '請(qǐng)前往手機(jī)設(shè)置,打開此APP藍(lán)牙權(quán)限',
					icon: 'none'
				})
				bluetoothOpen = false;
				bluetoothConnect = false;
				reject();
			}
		});
	});
};
/**
 * 開始搜索藍(lán)牙設(shè)備
 */
const discoveryBluetooth = () => {
	return new Promise((resolve) => {
		uni.startBluetoothDevicesDiscovery({
			success(res) {
				console.log('搜索藍(lán)牙外圍設(shè)備完成', res)
				setTimeout(() => {
					resolve();
				}, 2000);
			}
		});
	})
};
// 關(guān)閉藍(lán)牙搜索
const stopDiscoveryBluetooth = () => {
	uni.stopBluetoothDevicesDiscovery({
		success(r) {
			console.log("停止搜索藍(lán)牙設(shè)備", r);
		}
	});
};
/**
 * 獲取搜索到的設(shè)備信息
 */
const getBluetoothDevices = (deviceName) => {
	return new Promise((resolve, reject) => {
		uni.getBluetoothDevices({
			success(res) {
				console.log('獲取搜索到的設(shè)備信息', res.devices);

				bluetoothConnect = false;
				// 過濾掉name為空或者未知設(shè)備的設(shè)備
				let devices = res.devices.filter(function(obj) {
					return obj.name !== "" && obj.name !== "未知設(shè)備"
				});
				console.log('有名稱藍(lán)牙列表', devices, deviceName);
				devices && devices.forEach(item => {
					if (item.name && item.name === deviceName) {
						deviceId = item.deviceId;
						isHaveDevice = true;
						resolve(isHaveDevice);
						console.log('設(shè)備ID', deviceId, item);
					}
				});
			},
			fail: function() {
				console.log('搜索藍(lán)牙設(shè)備失敗');
				bluetoothConnect = false;
				isHaveDevice = false;
				reject(isHaveDevice);
			},
			complete: function() {
				console.log("藍(lán)牙搜索完成");
				// // 是否具有當(dāng)前設(shè)備
				// if (deviceId) {
				// 	isHaveDevice = true;
				// } else {
				// 	isHaveDevice = false;
				// }
				// resolve(isHaveDevice);
			}
		});
	});
}
/**
 * 連接藍(lán)牙
 * deviceId 藍(lán)牙設(shè)備id
 */
const connectBluetooth = () => {
	return new Promise((resolve, reject) => {
		uni.createBLEConnection({
			deviceId: deviceId, // 設(shè)備id
			success() {
				bluetoothConnect = true;
				console.log('連接藍(lán)牙成功', deviceId);
				// 藍(lán)牙連接成功后關(guān)閉藍(lán)牙搜索
				stopDiscoveryBluetooth();
				resolve();
				// 獲取服務(wù)id
				getServiceId();
			},
			fail(err) {
				bluetoothConnect = false;
				console.log("藍(lán)牙連接失敗",err);
				reject();
			}
		});
	});
};
// 獲取服務(wù)id
const getServiceId = () => {
	uni.getBLEDeviceServices({
		deviceId: deviceId,
		success(res) {
			let model = res.services[0];
			serviceId = model.uuid;
			console.log("獲取服務(wù)Id",serviceId, res)
			// 調(diào)用藍(lán)牙監(jiān)聽和寫入功能
			getCharacteId();
		}
	})
};
// 獲取藍(lán)牙低功耗設(shè)備某個(gè)服務(wù)中所有特征
const getCharacteId = () => {
	uni.getBLEDeviceCharacteristics({
		deviceId: deviceId, // 藍(lán)牙設(shè)備id
		serviceId: serviceId, // 藍(lán)牙服務(wù)UUID
		success(res) {
			console.log('數(shù)據(jù)監(jiān)聽', res);
			res.characteristics.forEach(item => {
				// 003
				if (item.properties.notify === true) {
					// 監(jiān)聽
					
					// 微信
					// #ifdef MP-WEIXIN
					notify = item.uuid;
					
					// #endif
					
					//支付寶
					// #ifdef MP-ALIPAY
						notify =  item.characteristicId;
					// #endif
					startNotice();
				}
				// 002
				if (item.properties.write === true) {
					// 寫入 
					
					// 微信
					// #ifdef MP-WEIXIN
					let writeId = item.uuid;
					uni.setStorageSync("writeId", item.uuid);
					// #endif
					
					//支付寶
					// #ifdef MP-ALIPAY
					let writeId = item.serviceId;
					uni.setStorageSync("writeId", item.characteristicId);
					// #endif
					
					
				}
			});
		},
		fail(err) {
			console.log("數(shù)據(jù)監(jiān)聽失敗", err)
		}
	})
};
// 啟用低功耗藍(lán)牙設(shè)備特征值變化時(shí)的notify功能
const startNotice = () => {
	uni.notifyBLECharacteristicValueChange({
		characteristicId: notify,
		deviceId: deviceId,
		serviceId: serviceId,
		state: true,
		success(res) {
			// 監(jiān)聽低功耗藍(lán)牙設(shè)備的特征值變化
			uni.onBLECharacteristicValueChange(result => {
				console.log("監(jiān)聽低功耗藍(lán)牙設(shè)備的特征值變化", result);
				if (result.value) {
					// let decoder = new TextDecoder('utf-8');
					// let data = decoder.decode(result.value);
					// let data = result.value;
					console.log('帽子返回?cái)?shù)據(jù)', result)
				}
			})
		}
	});
};


// 藍(lán)牙發(fā)送數(shù)據(jù)
const writeData = (buffer) => {
	return new Promise((resolve, reject) => {
		console.log(uni.getStorageSync("writeId"),'下發(fā)命令1writeId');
		console.log(deviceId,'下發(fā)命令2deviceId');
		console.log(serviceId,'下發(fā)命令3serviceId');
		console.log(buffer,'下發(fā)命令4buffer');
		
		uni.writeBLECharacteristicValue({
			characteristicId: uni.getStorageSync("writeId"),
			deviceId: deviceId,
			serviceId: serviceId,
			value: buffer,
			success(res) {
				console.log("writeBLECharacteristicValue success", res);
				resolve();
			},
			fail(err) {
				console.log("報(bào)錯(cuò)了", err);
				reject();
			}
		});
	});
};


const createBlec = () => {
	uni.createBLEConnection({
		deviceId:deviceId,
		success(res) {
			console.log(res, '斷開成功')
		},
		fail(err) {
			console.log("斷開失敗", err);
		}
	})
}

const BLECStateChange=()=>{
	 return new Promise((resolve, reject) => {
		 uni.onBLEConnectionStateChange(function (res) {
			 // 該方法回調(diào)中可以用于處理連接意外斷開等異常情況
			 console.log(`device ${res.deviceId} state has changed, connected: ${res.connected}`)
			 return resolve(res)
		  
		 })
	 })
	
}




// closeBLEConnection  deviceId  斷開藍(lán)牙
export default {
	getBluetoothState,
	discoveryBluetooth,
	stopDiscoveryBluetooth,
	getBluetoothDevices,
	connectBluetooth,
	getServiceId,
	getCharacteId,
	startNotice,
	writeData,
	createBlec,
	BLECStateChange
};

2 在頁面中使用index.vue?文章來源地址http://www.zghlxwxcb.cn/news/detail-850785.html

<template>
	<view class="device_container">
		<image src="@/static/bg.png" class="bg"></image>
		<view class="textimg">
			<image src="@/static/text.png"></image>
			<!-- <button type="default" @click="login">微信登錄</button>
			<button open-type="getAuthorize" scope='userInfo' @getAuthorize="loginAli"
				onError="onAuthError">支付寶登錄</button> -->

		</view>
		<view class="orderText" @click="clickOrder">
			訂單列表
		</view>
		<view class="card">
			<view class="tsip" @click="clicljydTisp">
			</view>
			<image class="mb" src="@/static/mb.png" style="width: 100%;height: 100%;"></image>
			<view class="info">
				<view class="beoka">
					<image src="@/static/beoka.png"></image>
				</view>
				<view class="infos">
					<view>
						產(chǎn)品型號(hào): {{deviceName?'Beoka12e432':'XXXXXXXXXX'}}
					</view>
					<view>
						產(chǎn)品編號(hào):{{deviceName?deviceName:'XXXX XXXX XXXX'}}
						<!-- 產(chǎn)品編號(hào):{{deviceName?'866 9288 98376':' XXXX XXXX XXXX'}} -->
					</view>
				</view>
				<view class="priceText">
					<view>
						計(jì)費(fèi)規(guī)則
					</view>
					<view>
						五分鐘內(nèi)歸還免費(fèi),20元/小時(shí),300元/24小時(shí)封頂1000元
					</view>

				</view>

			</view>
		</view>


		<view v-if="state">
			<view class="text" v-if="deviceName&&bluetoothStatus" @click="clickUse">
				立即使用
			</view>
			<view class="sm" v-else @click="snacode">掃碼連接設(shè)備 {{stateText}}</view>
		</view>
		<view class="" v-if="!state">
			<view class="ljgh" @click="clickReturn" v-if="deviceInfo.state==0">
				立即歸還
			</view>
			<view class="ljgh" @click="clickPay" v-if="deviceInfo.state==1">
				去支付
			</view>
		</view>
		<!-- 連接引導(dǎo)彈窗 -->
		<uni-popup ref="ljydPopup" type="center">
			<view class="ljyd">
				<view class="title">
					連接引導(dǎo)
					<image src="@/static/close.png" @click="clickClose('ljydPopup')"></image>
				</view>
				<view class="item">
					<view class="itemText">
						1.打開設(shè)備電源
					</view>
					<view class="itemImg">
						<image src="@/static/img1.png"></image>
					</view>
				</view>
				<view class="item">
					<view class="itemText">
						1.打開手機(jī)藍(lán)牙
					</view>
					<view class="itemImg">
						<image src="@/static/img2.png"></image>
					</view>
				</view>
				<view class="item">
					<view class="itemText">
						1.連接設(shè)備
					</view>
					<view class="itemImg">
						<image src="@/static/img3.png"></image>
					</view>
				</view>
			</view>

		</uni-popup>
		<!-- 歸還提示彈窗 -->
		<uni-popup ref="tispPopup" type="center" :is-mask-click='false'>
			<view class="tisp">
				<view class="tispTitle">
					提示
				</view>
				<view class="tispText">
					是否歸還該設(shè)備
				</view>
				<view class="tispBtn">
					<view class="close" @click="clickClose('tispPopup')">
						取消
					</view>
					<view class="confirm" @click="clickConfirm">
						確認(rèn)
					</view>
				</view>

			</view>
		</uni-popup>

		<!-- 歸還成功 -->
		<uni-popup ref="successPopup" type="center" :is-mask-click='false'>
			<view class="success">
				<view class="img">
					<image src="@/static/success.png"></image>
				</view>
				<view class="successtext">
					歸還成功
				</view>
				<view class="successConfirm" @click="clickConfirmSuccess">
					確認(rèn)
				</view>
			</view>

		</uni-popup>


	</view>
</template>

<script>
	// Hi-BEOKA-POC003AEE
	import bluetooth from '@/uilts/ly.js';
	import {
		oderList,
		deviceReturn,
		wxPay,
		createOrder
	} from "@/api/index.js"
	export default {
		data() {
			return {
				state: true,
				deviceState: null, //判斷是掃碼進(jìn)入的小程序還是 點(diǎn)擊小程序進(jìn)入的
				stateText: '未連接',
				bluetoothStatus: false, // 藍(lán)牙連接狀態(tài)
				deviceName: '', //藍(lán)牙名字
				deviceInfo: {}, //設(shè)備信息
				deviceConnectState: true, //監(jiān)聽狀態(tài)
			}
		},

		onLoad(e) {
			let str = e.q
			console.log('indexOnLoad');
			let _this = this
			if (str) {
				this.deviceState = true
				let bluetooth = str.substring(str.length - 18)
				this.deviceName = bluetooth
			} else {
				this.deviceState = true
			}

		},
		onShow() {
			// #ifdef  MP-ALIPAY
			console.log('---');
			my.tradePay({
				orderStr:'201711152100110410533667792',
			})
			// #endif
			let _this = this
			this.getOderList(() => {
				if (this.state && this.deviceName && !this.bluetoothStatus && this.deviceConnectState) {
					_this.initBluetooth(() => {
						console.log('連接成功');
					}, _this.deviceName)
				}
			})

		},
		onUnload() {

		},
		methods: {

			// 支付寶登錄
			loginAli() {
				my.getUserInfo({
					success: (res) => {
						console.log('支付寶用戶基礎(chǔ)信息', res);
						uni.showToast({
							title: res.userName,
							icon: 'none'
						})
					},
					complete: (err) => {
						console.log(err, '00000');

					}
				});

			},
			// 微信登錄
			login() {
				uni.login({
					provider: 'weixin',
					success: function(loginRes) {
						console.log(loginRes);
						// 獲取用戶信息
						uni.getUserInfo({
							provider: 'weixin',
							success: function(infoRes) {
								console.log('用戶昵稱為:' + JSON.stringify(infoRes.userInfo));
							}
						});
					}
				});
			},
			// 查詢訂單
			getOderList(callBack) {
				console.log('訂單信息請(qǐng)求');
				oderList({
					state: '',
					deviceId: ''
				}).then(res => {
					console.log(res.list, '訂單信息');
					let _this = this
					let v = res.list[0]
					if (v) {
						if (v.state == 0 || v.state == 1) {
							this.state = false
							this.deviceInfo = v
							this.deviceName = v.deviceId
						} else {
							this.state = true
							if (callBack) {
								callBack()
							}
						}


					} else {
						this.state = true
						// 獲取藍(lán)牙和設(shè)備連接狀態(tài)
					}
				})
			},


			// 獲取藍(lán)牙和設(shè)備是否已連接
			initBluetooth(callback, deviceName) {
				let _this = this;
				_this.stateText = '搜索藍(lán)牙'
				uni.showLoading({
					title: _this.stateText
				})
				// 初始化藍(lán)牙
				bluetooth.getBluetoothState().then(() => {
					// 搜索外圍藍(lán)牙設(shè)備
					bluetooth.discoveryBluetooth().then(() => {
						_this.discoveryLoading = true;
						// 獲取藍(lán)牙設(shè)備
						bluetooth.getBluetoothDevices(deviceName).then((isHaveDevice) => {
							if (isHaveDevice) {
								_this.stateText = '連接中...'
								// 搜索到指定設(shè)備,連接藍(lán)牙
								bluetooth.connectBluetooth().then((bluetoothConnect) => {
									console.log('連接成功');
									callback()
									_this.deviceName = deviceName
									_this.stateText = '連接成功'
									uni.hideLoading();
									_this.bluetoothStatus = true;

									// 監(jiān)聽藍(lán)牙與設(shè)備連接狀態(tài)
									bluetooth.BLECStateChange().then(res => {
										_this.bluetoothStatus = res.connected
										_this.deviceConnectState = res.connected
										_this.stateText = '未連接'
										console.log(res, '監(jiān)聽設(shè)備連接狀態(tài)');
									})
								}).catch((err) => {
									_this.stateText = '連接失敗'
									_this.bluetoothStatus = false;
									_this.deviceState = false
									uni.hideLoading();
									uni.showToast({
										title: '藍(lán)牙連接失敗',
										icon: 'none'
									})
								})
							} else {
								// 未搜到設(shè)備
								_this.bluetoothStatus = false;
								_this.deviceState = false
								uni.hideLoading();
								uni.showToast({
									title: '請(qǐng)打開設(shè)備',
									icon: 'none'
								})
							}
						}, () => {
							// 藍(lán)牙搜索失敗
							_this.bluetoothStatus = false;
							_this.deviceState = false
						});
					});
				}, () => {
					// 未開啟藍(lán)牙
					_this.bluetoothStatus = false;
					_this.deviceState = false
				});
			},
			// 向設(shè)備發(fā)送數(shù)據(jù)
			writeBlueData(buffer, type) {
				let _this = this
				bluetooth.writeData(buffer).then(res => {
					uni.showLoading({
						title: type == 1 ? "開啟中..." : "關(guān)閉中..."
					})
					if (type == 1) {

						console.log(_this.deviceName, type);
						createOrder({
							deviceId: _this.deviceName
						}).then(res => {
							console.log('訂單創(chuàng)建成功', res);
							uni.showToast({
								title: '開啟成功',
								icon: 'none'
							})
							_this.getOderList()

						}).catch(err => {
							uni.showToast({
								title: err.msg,
								icon: 'none'
							})
						})

					} else {
						deviceReturn({
							deviceId: _this.deviceName
						}).then(res => {
							_this.state = true
							_this.$refs.tispPopup.close()
							this.$refs.successPopup.open()

						}).catch(err => {
							uni.showToast({
								title: '歸還失敗',
								icon: 'none'
							})
						})

					}
					uni.hideLoading()


				})
			},
			// 立即使用 并向設(shè)備發(fā)送命令
			clickUse() {
				let _this = this
				let buffer = _this.arr2ab([170, 85, 1, 1, 1])
				console.log(buffer, 'buffer', _this.deviceName);

				if (this.bluetoothStatus) {

					_this.writeBlueData(buffer, 1)
				} else {
					_this.initBluetooth(() => {
						_this.writeBlueData(buffer, 1)
					}, _this.deviceName);
				}

			},
			// 掃碼
			snacode() {
				let _this = this;
				uni.scanCode({
					success: function(res) {
						let str = res.result
						let bluetooth = str.substring(str.length - 18)
						console.log('1111', bluetooth);
						_this.initBluetooth(() => {
							_this.deviceName = bluetooth

						}, bluetooth);

						_this.deviceState = true
					},
					fail: (err => {
						_this.deviceState = false
					})

				});
			},
			// 點(diǎn)擊歸還
			clickReturn() {
				let _this = this
				if (this.bluetoothStatus) {
					_this.$refs.tispPopup.open()
				} else {
					_this.initBluetooth(() => {
						_this.$refs.tispPopup.open()
					}, _this.deviceName);
				}

			},

			// 連接引導(dǎo)彈窗
			clicljydTisp() {
				console.log('999');
				this.$refs.ljydPopup.open()
			},
			// 歸還成功確認(rèn)彈窗
			clickConfirmSuccess() {
				this.$refs.successPopup.close()
				this.getOderList()

			},
			clickPay() {
				uni.navigateTo({
					url: '/pages/index/orderlist'
				})

			},

			// 確定歸還彈窗 確認(rèn)
			clickConfirm() {
				let _this = this
				let buffer = _this.arr2ab([170, 85, 1, 1, 0])
				_this.writeBlueData(buffer, 2)
				// if (this.bluetoothStatus) {
				// 	_this.writeBlueData(buffer, 2)
				// } else {
				// 	_this.initBluetooth(() => {
				// 		_this.writeBlueData(buffer, 2)
				// 	}, _this.deviceName);
				// }



			},
			// 10進(jìn)制轉(zhuǎn)換
			arr2ab(arr) {
				const buffer = new ArrayBuffer(arr.length);
				const dataView = new DataView(buffer);
				for (var i = 0; i < arr.length; i++) {
					dataView.setUint8(i, arr[i]);
				}
				return buffer;
			},

			// 點(diǎn)擊關(guān)閉
			clickClose(name) {
				this.$refs[name].close()
			},
			// 點(diǎn)擊訂單列表
			clickOrder() {
				uni.navigateTo({
					url: '/pages/index/orderlist'
				})
			},

		},

	}
</script>

<style lang="scss">
	page {
		height: 100%;
	}

	.bg {
		width: 100vw;
		height: 100vh;
	}

	.ljgh,
	.text,
	.sm {
		border-radius: 100px;
		background: #3A87EF;
		width: calc(100% - 96rpx);
		height: 112rpx;
		box-shadow: 0px 20px 60px 0px rgba(58, 96, 178, 0.30);
		text-align: center;
		line-height: 112rpx;
		color: #FFF;
		font-size: 32rpx;
		font-style: normal;
		font-weight: 500;
		position: fixed;
		bottom: 120rpx;
		left: 50%;
		transform: translateX(-50%);
		letter-spacing: 2rpx;
	}

	.textimg {
		width: 530rpx;
		height: 204rpx;

		image {
			width: 100%;
			height: 100%;
		}

		position: fixed;
		bottom: 120rpx;
		left: 16rpx;
		top: 10%;
	}

	.orderText {
		border-radius: 30rpx 0px 0px 30rpx;
		background: rgba(1, 31, 76, 0.45);
		width: 160rpx;
		height: 60rpx;
		text-align: center;
		font-family: PingFang HK;
		font-size: 28rpx;
		font-weight: 400;
		line-height: 60rpx;
		position: absolute;
		right: 0;
		top: 12.7%;
		color: #FFF;
	}

	.card {
		width: calc(100% - 64rpx);
		height: 520rpx;
		position: fixed;
		top: 43%;
		left: 50%;
		transform: translateX(-50%);

		.md {
			width: 100%;
			height: 100%;
		}

		.tsip {
			width: 32rpx;
			height: 32rpx;
			border-radius: 100%;
			position: absolute;
			right: 44rpx;
			top: 32rpx;
			// background-color: red;
			z-index: 1;

		}

		.info {
			position: absolute;
			top: 0;
			padding: 60rpx 40rpx 22rpx;
			box-sizing: border-box;

			.beoka {
				width: 65px;
				height: 20px;

				image {
					width: 65px;
					height: 20px;
				}

			}
		}

		.infos {
			font-size: 32rpx;
			font-style: normal;
			font-weight: 700;
			line-height: normal;
			margin-top: 44rpx;
			border-bottom: 2rpx dashed #E9ECF3;
			padding-bottom: 32rpx;

			view {
				margin-top: 32rpx;
			}
		}

		.priceText {
			box-sizing: border-box;
			height: 146rpx;
			border-radius: 8rpx;
			box-sizing: border-box;
			border: 2rpx solid rgba(0, 130, 180, 0.06);
			background: #E7F0F7;
			padding: 16rpx 22rpx;
			margin: 32rpx 0 20rpx;

			view {
				color: #3D4C5F;
				font-family: PingFang HK;
				font-size: 24rpx;
				font-weight: 400;
				line-height: 38rpx;
			}
		}
	}

	.ljyd {
		width: 644rpx;
		background-color: #fff;
		border-radius: 28rpx;
		padding-bottom: 16rpx;
		// height: 517px;

		.title {
			color: #333;
			text-align: center;
			font-size: 32rpx;
			font-style: normal;
			font-weight: 600;
			line-height: 44rpx;
			/* 137.5% */
			width: 100%;
			padding: 32rpx 0 48rpx;
			position: relative;

			image {
				width: 20rpx;
				height: 20rpx;
				position: absolute;
				right: 44rpx;
				top: 45rpx;
			}
		}

		.item {
			margin: 0 32rpx 32rpx;

			.itemText {
				color: var(--unnamed, #333);
				text-align: left;
				font-family: PingFang HK;
				font-size: 16px;
				font-style: normal;
				font-weight: 400;
				line-height: normal;
				letter-spacing: -0.408px;
				margin-bottom: 12rpx;
			}

			.itemImg {
				width: 340rpx;
				height: 210rpx;
				margin: auto;

				image {
					width: 100%;
					height: 100%;
				}
			}
		}
	}

	.tisp {
		width: 566rpx;
		height: 304rpx;
		border-radius: 28rpx;
		background: #FFF;
		padding: 32rpx;
		box-sizing: border-box;
		display: flex;
		flex-direction: column;
		justify-content: space-between;

		.tispTitle {
			color: #333;
			text-align: center;
			font-size: 32rpx;
			font-style: normal;
			font-weight: 600;
			line-height: 44rpx;
			/* 137.5% */
			width: 100%;
		}

		.tispText {
			text-align: center;
			color: #5C5C5C;
			font-size: 28rpx;
			font-style: normal;
			font-weight: 400;
			line-height: 44rpx;
			/* 157.143% */
		}

		.tispBtn {
			display: flex;
			justify-content: space-between;

			.close,
			.confirm {
				text-align: center;
				width: 234rpx;
				height: 72rpx;
				line-height: 72rpx;
				border-radius: 32rpx;
				font-size: 28rpx;
				font-weight: 400;
				letter-spacing: 2rpx;
			}

			.close {
				color: #3A87EF;
				background-color: #EBF3FF;

			}

			.confirm {
				color: #fff;
				background-color: #3A87EF;
			}

		}
	}

	.success {
		width: 566rpx;
		height: 432rpx;
		border-radius: 28rpx;
		background: #FFF;
		padding: 32rpx;
		box-sizing: border-box;

		.img {
			width: 344rpx;
			height: 206rpx;
			margin: 0 auto;

			image {

				width: 100%;
				height: 100%;
			}
		}

		.successtext {
			margin-top: 16rpx;
			color: #333;
			font-size: 32rpx;
			font-weight: 700;
			text-align: center;
		}

		.successConfirm {
			text-align: center;
			width: 234rpx;
			height: 72rpx;
			line-height: 72rpx;
			border-radius: 32rpx;
			font-size: 28rpx;
			font-weight: 400;
			letter-spacing: 2rpx;
			color: #fff;
			background-color: #3A87EF;
			margin: 30rpx auto 0;
		}
	}
</style>

到了這里,關(guān)于uniapp 藍(lán)牙連接設(shè)備 下發(fā)命令 監(jiān)聽藍(lán)牙與設(shè)備的連接狀態(tài)(兼容 微信小程序和支付寶小程序)的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場(chǎng)。本站僅提供信息存儲(chǔ)空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請(qǐng)注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實(shí)不符,請(qǐng)點(diǎn)擊違法舉報(bào)進(jìn)行投訴反饋,一經(jīng)查實(shí),立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

  • uniapp 藍(lán)牙小程序-兼容安卓和iOS

    uniapp 藍(lán)牙小程序-兼容安卓和iOS

    withTimeout方法可以在搜尋設(shè)備時(shí)等待指定的秒數(shù),如果30秒內(nèi)未搜索到則取消搜索? 計(jì)算數(shù)據(jù)校驗(yàn)和: 校驗(yàn)字節(jié)等于命令字節(jié)與所有數(shù)據(jù)字節(jié)之和的反碼。求和按帶進(jìn)位加 (ADDC)方式計(jì)算,每個(gè)進(jìn)位都被加到本次結(jié)果的最低位(LSB)。 vue頁面代碼?? js函數(shù)代碼?

    2024年02月03日
    瀏覽(19)
  • uniapp 安卓端實(shí)時(shí)監(jiān)聽網(wǎng)絡(luò)狀態(tài)

    寫在uniapp的APP.vue的onShow方法中 uni.onNetworkStatusChange(function(res) { ?? ??? ??? ??? ?if (res.isConnected) { ?? ??? ??? ??? ??? ?uni.showModal({ ?? ??? ??? ??? ??? ??? ?title: \\\'系統(tǒng)提示\\\', ?? ??? ??? ??? ??? ??? ?content: \\\'當(dāng)前設(shè)備網(wǎng)絡(luò)已恢復(fù)\\\', ?? ??? ??? ??? ??

    2024年02月05日
    瀏覽(20)
  • uniapp切換路由監(jiān)聽導(dǎo)航跳轉(zhuǎn)(在監(jiān)聽網(wǎng)絡(luò)狀態(tài)時(shí)非常常用)

    uniapp切換路由監(jiān)聽導(dǎo)航跳轉(zhuǎn)(在監(jiān)聽網(wǎng)絡(luò)狀態(tài)時(shí)非常常用)

    在實(shí)時(shí)監(jiān)聽網(wǎng)絡(luò)狀態(tài)的時(shí)候我們切換頁面經(jīng)常會(huì)用到此場(chǎng)景 注意:監(jiān)聽頁面跳轉(zhuǎn)變化要寫在onLaunch方法里面 ? ? ? ? 每次切換頁面的時(shí)候都會(huì)執(zhí)行調(diào)用watchRouter函數(shù)里面的方法 標(biāo)題 ?

    2024年02月15日
    瀏覽(18)
  • 小程序藍(lán)牙通訊設(shè)備數(shù)據(jù)對(duì)接實(shí)戰(zhàn)uniapp

    小程序藍(lán)牙通訊設(shè)備數(shù)據(jù)對(duì)接實(shí)戰(zhàn)uniapp

    ? ? ? 最近很閑,但是行業(yè)很卷!因?yàn)楣居杏布O(shè)備對(duì)接,但是介于原生app。閑來無事,便研究了下這個(gè)小程序通過藍(lán)牙與硬件設(shè)備進(jìn)行通訊。廢話少說上干貨! 本次講解的目錄大致分為三模塊。根據(jù)我寫的代碼做講解。 初始化并搜索藍(lán)牙 獲取并啟用service服務(wù) 數(shù)據(jù)讀取

    2024年02月09日
    瀏覽(27)
  • 藍(lán)牙鼠標(biāo)HID設(shè)備連接流程

    首先我們需要大致知道下HID( The Human Interface Device )是啥,手機(jī)和鼠標(biāo)分別扮演什么角色,這里我們大致了解下即可,然后又在看代碼。HID 定義了藍(lán)牙在人機(jī)接口設(shè)備中的協(xié)議、特征和使用規(guī)程。典型的應(yīng)用包括藍(lán)牙鼠標(biāo)、藍(lán)牙鍵盤、藍(lán)牙游戲手柄等。該協(xié)議改編自USB HID Pro

    2024年04月09日
    瀏覽(20)
  • 檢測(cè)已連接的藍(lán)牙設(shè)備 - iOS

    檢測(cè)藍(lán)牙已連接?的情況下更加具體的獲取一些當(dāng)前連接設(shè)備的信息數(shù)據(jù),具體實(shí)現(xiàn)方法如下: 以上便是此次分享的全部內(nèi)容,希望能對(duì)大家有所幫助!

    2024年02月12日
    瀏覽(23)
  • iOS設(shè)備和藍(lán)牙模塊連接基礎(chǔ)知識(shí)

    iOS設(shè)備和藍(lán)牙模塊連接基礎(chǔ)知識(shí)

    iOS設(shè)備和藍(lán)牙模塊連接基礎(chǔ)知識(shí) 一:iOS連接外設(shè)的幾種方式 如圖下面幾種方式: CoreBluetooth和ExternalAccessory,兩個(gè)框架,基本上是藍(lán)牙設(shè)備與iOS設(shè)備連接的方式 有圖可知,EAP要MFi認(rèn)證,要求設(shè)備的設(shè)計(jì)理念符合蘋果的要求,不僅可以進(jìn)行無線藍(lán)牙通信,還可以進(jìn)行有線通信(

    2023年04月20日
    瀏覽(33)
  • 【W(wǎng)indows】電腦修改已連接的藍(lán)牙設(shè)備名稱

    【W(wǎng)indows】電腦修改已連接的藍(lán)牙設(shè)備名稱

    問題 有好幾個(gè)同款的藍(lán)牙耳機(jī),連接電腦后默認(rèn)顯示名字一樣,想像手機(jī)上一樣備注這些耳機(jī)的名稱。 網(wǎng)上搜索半天,只有修改電腦本身藍(lán)牙名稱的方法,而不是修改連接的設(shè)備的名稱!摸索半天,得出下邊的方法 修改連接的藍(lán)牙設(shè)備名稱 注1: 此方法重啟后可能會(huì)恢復(fù)如

    2024年02月13日
    瀏覽(19)
  • 微信小程序連接藍(lán)牙設(shè)備并傳遞數(shù)據(jù)

    微信小程序連接藍(lán)牙設(shè)備并傳遞數(shù)據(jù)

    流程圖 分步詳解 wx.getSystemInfo(Object object) ?獲取系統(tǒng)信息 獲取操作系統(tǒng)及版本 頁面加載的時(shí)候(或者app.js中?) ↓ 初始化藍(lán)牙模塊? wx.openBluetoothAdapter(Object object) 在用戶藍(lán)牙開關(guān)未開啟或者手機(jī)不支持藍(lán)牙功能的情況下,通過錯(cuò)誤碼(errCode=10001),提示打開藍(lán)牙或藍(lán)牙功能

    2024年02月08日
    瀏覽(24)
  • 微信小程序 藍(lán)牙設(shè)備連接,控制開關(guān)燈

    微信小程序 藍(lán)牙設(shè)備連接,控制開關(guān)燈

    微信小程序中連接藍(lán)牙設(shè)備,信息寫入流程 1 、檢測(cè)當(dāng)前使用設(shè)備(如自己的手機(jī))是否支持藍(lán)牙/藍(lán)牙開啟狀態(tài) wx:openBluetoothAdapter({}) 2 、如藍(lán)牙已開啟狀態(tài),檢查藍(lán)牙適配器的狀態(tài) wx.getBluetoothAdapterState({}) 3 、添加監(jiān)聽藍(lán)牙適配器狀態(tài)變化 wx.onBluetoothAdapterStateChange({}) 4 、搜

    2024年02月12日
    瀏覽(24)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請(qǐng)作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包