床垫完善
This commit is contained in:
parent
3dfd82456e
commit
3494a779b0
|
@ -45,6 +45,55 @@
|
|||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 开关操作 -->
|
||||
<view class="lishi" v-if="type">
|
||||
<view class="lt">
|
||||
开关操作
|
||||
</view>
|
||||
<view class="rt">
|
||||
<image v-if="imgflag" @click="btnimg"
|
||||
src="https://api.ccttiot.com/smartmeter/img/static/uccaWar4FDp37op7haWM " mode=""></image>
|
||||
<image v-else @click="btnimgs" src="https://api.ccttiot.com/smartmeter/img/static/ur9HRtZKY7YcxGewJARz"
|
||||
mode=""></image>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 蓝牙连接 -->
|
||||
<view class="bluetoothbox" v-if="bluetoothflag">
|
||||
<view class="stop">
|
||||
设备已离线,正在连接该设备蓝牙
|
||||
</view>
|
||||
<view class="xtop">
|
||||
请将手机与设备尽量靠近,连接成功后可操作
|
||||
</view>
|
||||
<image src="https://api.ccttiot.com/smartmeter/img/static/ucDphMKsozqwwllJTAKL" mode=""></image>
|
||||
</view>
|
||||
|
||||
<!-- 蓝牙连接失败 -->
|
||||
<view class="bluetoothbox" v-if="shibaiflag">
|
||||
<image class="img" src="https://api.ccttiot.com/smartmeter/img/static/uTb3vSlbcHdPMFQMBjyL" mode=""></image>
|
||||
<view class="one">
|
||||
蓝牙连接失败
|
||||
</view>
|
||||
<view class="two">
|
||||
请确保手机足够靠近设备
|
||||
</view>
|
||||
<view class="thr">
|
||||
并且设备处于上电状态
|
||||
</view>
|
||||
<view class="anfour">
|
||||
<view class="qx" @click="btnlyqx">
|
||||
取消
|
||||
</view>
|
||||
<view class="cx" @click="topage">
|
||||
重新连接
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view v-if="btnmsk"
|
||||
style="width: 100%;height: 100vh;position: fixed;top: 0;left: 0;background-color: #000;opacity: .1;z-index: 999;">
|
||||
</view>
|
||||
|
||||
<!-- 商家信息 -->
|
||||
<view class="sjmsg">
|
||||
<view class="tit">
|
||||
|
@ -105,26 +154,46 @@
|
|||
收益明细
|
||||
</view>
|
||||
<view class="jy" v-for="(item,index) in obj.bonusList" :key="index">
|
||||
<view class="one">{{item.arrivalName == undefined ? '--' : item.arrivalName}}(<text v-if="item.arrivalType == 1">平台</text><text v-if="item.arrivalType == 2">公司</text><text v-if="item.arrivalType == 3">合作伙伴</text><text v-if="item.arrivalType == 4">渠道商</text><text v-if="item.arrivalType == 5">创业者</text><text v-if="item.arrivalType == 6">经营场所</text>){{item.point}}%</view>
|
||||
<!-- <view class="two">¥{{item.amount== undefined ? '--' : otem.amount}}</view> -->
|
||||
<view class="one">{{item.arrivalName == undefined ? '--' : item.arrivalName}}
|
||||
(<text v-if="item.arrivalType == 1">平台</text>
|
||||
<text v-if="item.arrivalType == 2">公司</text>
|
||||
<text v-if="item.arrivalType == 3">合作伙伴</text>
|
||||
<text v-if="item.arrivalType == 4">渠道商</text>
|
||||
<text v-if="item.arrivalType == 5">创业者</text>
|
||||
<text v-if="item.arrivalType == 6">经营场所</text>){{item.point}}%</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
var xBlufi = require("@/components/blufi/xBlufi.js")
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
bgc: {
|
||||
backgroundColor: "#F7FAFE",
|
||||
},
|
||||
id:'',
|
||||
obj:{},
|
||||
setMode: null,
|
||||
qrResult: '',
|
||||
isUsing: false,
|
||||
bluetoothflag: false,
|
||||
shibaiflag: false,
|
||||
btnmsk: false,
|
||||
deviceId:'',
|
||||
obj:{}
|
||||
name: '',
|
||||
imgflag:false,
|
||||
pictrim:true,
|
||||
type:''
|
||||
}
|
||||
},
|
||||
onLoad(option) {
|
||||
this.deviceId = option.deviceId
|
||||
this.$u.get('/app/user/userInfo').then(res =>{
|
||||
this.type = res.data.type
|
||||
})
|
||||
this.id = option.deviceId
|
||||
this.getxq()
|
||||
},
|
||||
// 分享到好友(会话)
|
||||
|
@ -144,13 +213,311 @@
|
|||
}
|
||||
},
|
||||
methods: {
|
||||
|
||||
getxq(){
|
||||
this.$u.get(`/app/device/${this.deviceId}`).then(res =>{
|
||||
this.$u.get(`/app/device/${this.id}`).then(res =>{
|
||||
if(res.code == 200){
|
||||
this.obj = res.data
|
||||
this.imgflag = res.data.isUsing
|
||||
this.qrResult = res.data.mac
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
// 点击临时开关
|
||||
btnimg() {
|
||||
if(this.pictrim == true){ //防止频繁点击
|
||||
this.pictrim = false
|
||||
setTimeout(()=>{
|
||||
this.pictrim = true
|
||||
},5000)
|
||||
if (this.obj.onlineStatus == 1) {
|
||||
this.$u.put(`/app/device/${this.id}/changePower?status=0`).then(res => {
|
||||
if (res.code == 200) {
|
||||
this.imgflag = false
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
icon: 'none',
|
||||
duration: 1000
|
||||
})
|
||||
}
|
||||
})
|
||||
} else {
|
||||
if (this.setMode == null) {
|
||||
this.btnmsk = false
|
||||
this.shibaiflag = false
|
||||
this.bluetoothflag = true
|
||||
xBlufi.initXBlufi(1)
|
||||
xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent)
|
||||
xBlufi.notifyStartDiscoverBle({
|
||||
'isStart': true
|
||||
})
|
||||
// 停止蓝牙搜索
|
||||
setTimeout(() => {
|
||||
xBlufi.notifyStartDiscoverBle({
|
||||
'isStart': false
|
||||
})
|
||||
xBlufi.notifyConnectBle({
|
||||
isStart: true,
|
||||
deviceId: this.deviceId,
|
||||
name: this.name
|
||||
})
|
||||
xBlufi.notifyInitBleEsp32({
|
||||
deviceId: this.deviceId
|
||||
})
|
||||
}, 1000)
|
||||
} else {
|
||||
let that = this
|
||||
uni.getNetworkType({
|
||||
success(res) {
|
||||
if (res.networkType !== 'none') {
|
||||
uni.getConnectedBluetoothDevices({
|
||||
success(res) {
|
||||
setTimeout(() => {
|
||||
xBlufi.notifySendCustomData({
|
||||
customData: '11close'
|
||||
})
|
||||
uni.showToast({
|
||||
title: '操作成功',
|
||||
icon: 'success',
|
||||
duration: 1000
|
||||
})
|
||||
this.imgflag = false
|
||||
that.btnmsk = false
|
||||
that.shibaiflag = false
|
||||
that.bluetoothflag = false
|
||||
}, 1000)
|
||||
},
|
||||
fail(err) {
|
||||
console.error('获取已连接蓝牙设备信息失败:', err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}else{
|
||||
uni.showToast({
|
||||
title: '请不要频繁点击',
|
||||
icon: 'none',
|
||||
duration: 1000
|
||||
})
|
||||
}
|
||||
},
|
||||
btnimgs() {
|
||||
if(this.pictrim == true){ //防止频繁点击
|
||||
this.pictrim = false
|
||||
setTimeout(()=>{
|
||||
this.pictrim = true
|
||||
},5000)
|
||||
if (this.obj.onlineStatus == 1) {
|
||||
///app/bill/switchDevice?billId=${this.id}&open=true
|
||||
this.$u.put(`/app/device/${this.id}/changePower?status=1`).then(res => {
|
||||
if (res.code == 200) {
|
||||
this.imgflag = true
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
icon: 'none',
|
||||
duration: 1000
|
||||
})
|
||||
}
|
||||
})
|
||||
} else {
|
||||
if (this.setMode == null) {
|
||||
this.btnmsk = false
|
||||
this.shibaiflag = false
|
||||
this.bluetoothflag = true
|
||||
xBlufi.initXBlufi(1)
|
||||
xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent)
|
||||
xBlufi.notifyStartDiscoverBle({
|
||||
'isStart': true
|
||||
})
|
||||
// 停止蓝牙搜索
|
||||
setTimeout(() => {
|
||||
xBlufi.notifyStartDiscoverBle({
|
||||
'isStart': false
|
||||
})
|
||||
xBlufi.notifyConnectBle({
|
||||
isStart: true,
|
||||
deviceId: this.deviceId,
|
||||
name: this.name
|
||||
})
|
||||
xBlufi.notifyInitBleEsp32({
|
||||
deviceId: this.deviceId
|
||||
})
|
||||
}, 1000)
|
||||
} else {
|
||||
let that = this
|
||||
uni.getNetworkType({
|
||||
success(res) {
|
||||
if (res.networkType !== 'none') {
|
||||
uni.getConnectedBluetoothDevices({
|
||||
success(res) {
|
||||
setTimeout(() => {
|
||||
xBlufi.notifySendCustomData({
|
||||
customData: '11open'
|
||||
})
|
||||
uni.showToast({
|
||||
title: '操作成功',
|
||||
icon: 'success',
|
||||
duration: 1000
|
||||
})
|
||||
this.imgflag = true
|
||||
that.btnmsk = false
|
||||
that.shibaiflag = false
|
||||
that.bluetoothflag = false
|
||||
}, 1000)
|
||||
},
|
||||
fail(err) {
|
||||
console.error('获取已连接蓝牙设备信息失败:', err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}else{
|
||||
uni.showToast({
|
||||
title: '请不要频繁点击',
|
||||
icon: 'none',
|
||||
duration: 1000
|
||||
})
|
||||
}
|
||||
},
|
||||
// 蓝牙连接取消
|
||||
btnlyqx() {
|
||||
this.shibaiflag = false
|
||||
this.bluetoothflag = false
|
||||
},
|
||||
// 蓝牙重新连接
|
||||
topage() {
|
||||
this.btnmsk = false
|
||||
this.shibaiflag = false
|
||||
this.bluetoothflag = true
|
||||
if (this.setMode == null) {
|
||||
xBlufi.initXBlufi(1)
|
||||
xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent)
|
||||
xBlufi.notifyStartDiscoverBle({
|
||||
'isStart': true
|
||||
})
|
||||
// 停止蓝牙搜索
|
||||
setTimeout(() => {
|
||||
xBlufi.notifyStartDiscoverBle({
|
||||
'isStart': false
|
||||
})
|
||||
xBlufi.notifyConnectBle({
|
||||
isStart: true,
|
||||
deviceId: this.deviceId,
|
||||
name: this.name
|
||||
})
|
||||
xBlufi.notifyInitBleEsp32({
|
||||
deviceId: this.deviceId
|
||||
})
|
||||
}, 1000)
|
||||
}
|
||||
},
|
||||
|
||||
// 搜索蓝牙部分
|
||||
funListenDeviceMsgEvent: function(options) {
|
||||
switch (options.type) {
|
||||
case xBlufi.XBLUFI_TYPE.TYPE_RECIEVE_MY_DATA:
|
||||
let loadPercent = options.data;
|
||||
let loadText = '文件读取中'
|
||||
// console.log("文件读取中", options.data)
|
||||
break;
|
||||
case xBlufi.XBLUFI_TYPE.TYPE_RECIEVE_CUSTON_DATA:
|
||||
let ver_data = this.parseCustomData(options.data)
|
||||
this.setMode = Math.floor(ver_data.setMode / 60)
|
||||
console.log("1收到设备发来的自定义数据结果:", ver_data, this.setMode)
|
||||
break;
|
||||
case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS:
|
||||
if (options.result) {
|
||||
let devicesarr = options.data
|
||||
devicesarr.forEach(device => {
|
||||
const mac = device.name.substring(5)
|
||||
if (device.name.slice(5, 17) == this.qrResult) {
|
||||
this.deviceId = device.deviceId
|
||||
this.name = device.name
|
||||
this.mac = device.name.slice(5, 17)
|
||||
}
|
||||
})
|
||||
}
|
||||
break;
|
||||
case xBlufi.XBLUFI_TYPE.TYPE_CONNECTED:
|
||||
// console.log("连接回调:" + JSON.stringify(options))
|
||||
if (options.result) {
|
||||
setTimeout(() => {
|
||||
this.bluetoothflag = false
|
||||
}, 3000)
|
||||
uni.hideLoading(); {
|
||||
console.log("连接回调options.data.deviceId:" + options.data.deviceId,
|
||||
"连接回调options.data.name:" + options.data.name)
|
||||
}
|
||||
} else {
|
||||
this.shibaiflag = true
|
||||
this.bluetoothflag = false
|
||||
uni.hideLoading()
|
||||
}
|
||||
break;
|
||||
case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS_START:
|
||||
if (!options.result) {
|
||||
setTimeout(() => {
|
||||
uni.hideLoading()
|
||||
this.bluetoothflag = false
|
||||
}, 3000)
|
||||
console.log("蓝牙未开启", options)
|
||||
this.shibaiflag = true
|
||||
return
|
||||
}
|
||||
break;
|
||||
case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS_STOP:
|
||||
if (options.result) {
|
||||
let uniqueDevicesList = Array.from(new Set(this.devicesList))
|
||||
// 将去重后的数组重新赋值给 this.devicesList
|
||||
this.devicesList = uniqueDevicesList
|
||||
let list = []
|
||||
setTimeout(() => {
|
||||
this.devicesList = list
|
||||
}, 200)
|
||||
console.log('蓝牙停止搜索ok')
|
||||
} else {
|
||||
//蓝牙停止搜索失败
|
||||
console.log('蓝牙停止搜索失败')
|
||||
}
|
||||
this.searching = false
|
||||
break
|
||||
}
|
||||
},
|
||||
parseCustomData(data) {
|
||||
const dataArray = data.split('@');
|
||||
const parsedData = {};
|
||||
const prefixMap = {
|
||||
'V': 'voltage',
|
||||
'S': 'switchState',
|
||||
'A': 'current',
|
||||
'P': 'power',
|
||||
'M': 'remainingPower',
|
||||
'T': 'setMode',
|
||||
'W': 'temperature'
|
||||
};
|
||||
// 遍历数组并解析每个字段
|
||||
for (let i = 0; i < dataArray.length; i++) {
|
||||
const field = dataArray[i];
|
||||
for (const prefix in prefixMap) {
|
||||
if (field.startsWith(prefix)) {
|
||||
const value = field.substring(1);
|
||||
const propertyName = prefixMap[prefix];
|
||||
parsedData[propertyName] = isNaN(parseFloat(value)) ? value : parseFloat(value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return parsedData;
|
||||
},
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -164,7 +531,118 @@
|
|||
/deep/ .u-icon__icon {
|
||||
padding-bottom: 15rpx;
|
||||
}
|
||||
|
||||
.bluetoothbox {
|
||||
width: 100%;
|
||||
height: 100vh;
|
||||
background-color: #f4f1f6;
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
z-index: 99;
|
||||
text-align: center;
|
||||
|
||||
.img {
|
||||
margin-top: 400rpx;
|
||||
width: 320rpx;
|
||||
height: 320rpx;
|
||||
}
|
||||
|
||||
.one {
|
||||
font-size: 36rpx;
|
||||
color: #000;
|
||||
}
|
||||
|
||||
.two {
|
||||
margin-top: 30rpx;
|
||||
font-size: 24rpx;
|
||||
color: #ccc;
|
||||
}
|
||||
|
||||
.thr {
|
||||
margin-top: 30rpx;
|
||||
font-size: 28rpx;
|
||||
color: #ccc;
|
||||
}
|
||||
|
||||
.anfour {
|
||||
display: flex;
|
||||
margin-top: 30rpx;
|
||||
justify-content: space-between;
|
||||
padding: 0 220rpx;
|
||||
box-sizing: border-box;
|
||||
|
||||
.qx {
|
||||
width: 100rpx;
|
||||
height: 70rpx;
|
||||
line-height: 70rpx;
|
||||
text-align: center;
|
||||
border: 1px solid #3D3D3D;
|
||||
border-radius: 10rpx;
|
||||
}
|
||||
|
||||
.cx {
|
||||
width: 200rpx;
|
||||
height: 70rpx;
|
||||
line-height: 70rpx;
|
||||
text-align: center;
|
||||
background-color: #8883F0;
|
||||
color: #fff;
|
||||
border-radius: 10rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.stop {
|
||||
font-size: 36rpx;
|
||||
color: #000;
|
||||
margin-top: 380rpx;
|
||||
}
|
||||
|
||||
.xtop {
|
||||
margin-top: 30rpx;
|
||||
font-size: 24rpx;
|
||||
color: #ccc;
|
||||
}
|
||||
|
||||
.xqx {
|
||||
width: 530rpx;
|
||||
height: 90rpx;
|
||||
line-height: 90rpx;
|
||||
border-radius: 20rpx;
|
||||
text-align: center;
|
||||
background-color: #fff;
|
||||
margin: auto;
|
||||
margin-top: 200rpx;
|
||||
}
|
||||
|
||||
image {
|
||||
width: 500rpx;
|
||||
height: 500rpx;
|
||||
margin-top: 100rpx;
|
||||
}
|
||||
}
|
||||
.lishi {
|
||||
width: 100%;
|
||||
height: 110rpx;
|
||||
background-color: #fff;
|
||||
padding: 24rpx;
|
||||
box-sizing: border-box;
|
||||
margin-top: 30rpx;
|
||||
border-radius: 20rpx;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
|
||||
.lt {
|
||||
font-size: 32rpx;
|
||||
}
|
||||
|
||||
.rt {
|
||||
image {
|
||||
width: 160rpx;
|
||||
height: 80rpx;
|
||||
}
|
||||
}
|
||||
}
|
||||
.pages {
|
||||
background-color: #F7FAFE !important;
|
||||
height: 100%;
|
||||
|
|
|
@ -115,7 +115,7 @@
|
|||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="qx" @click="kfflag = false" v-if="kfflag">
|
||||
<view class="qx" @click="btnkfflag" v-if="kfflag">
|
||||
×
|
||||
</view>
|
||||
<view class="mask" v-if="kfflag"></view>
|
||||
|
@ -179,7 +179,8 @@
|
|||
timer: null,
|
||||
titflag: false,
|
||||
kefulist: [],
|
||||
scrollTop:0
|
||||
scrollTop:0,
|
||||
billId:''
|
||||
}
|
||||
},
|
||||
onLoad(option) {
|
||||
|
@ -289,7 +290,7 @@
|
|||
}else{
|
||||
this.picimg = true
|
||||
}
|
||||
},500)
|
||||
},100)
|
||||
}
|
||||
},
|
||||
btnscrll() {
|
||||
|
@ -356,7 +357,8 @@
|
|||
}
|
||||
that.$u.post('/app/bill/recharge', data).then(res => {
|
||||
if (res.code == 200) {
|
||||
that.orderno = res.data
|
||||
that.orderno = res.data.billNo
|
||||
that.billId = res.data.billId
|
||||
that.$u.get(`/app/pay/wx/${that.orderno}`).then((res) => {
|
||||
if (res.code == 200) {
|
||||
uni.requestPayment({
|
||||
|
@ -366,84 +368,42 @@
|
|||
package: res.data.payParams.packageVal,
|
||||
signType: res.data.payParams.signType,
|
||||
paySign: res.data.payParams.paySign,
|
||||
success: (res) => {
|
||||
success: (res) => {
|
||||
if (that.timer) {
|
||||
clearInterval(this.timer);
|
||||
that.timer = null;
|
||||
}
|
||||
// 111111111111111111111111
|
||||
that.$u.put(
|
||||
`/app/bill/${that.orderno}/refreshPayResult`
|
||||
).then(res => {
|
||||
that.$u.put(`/app/bill/${that.orderno}/refreshPayResult`).then(res => {
|
||||
// if(res.code == 200){
|
||||
that.$u.get(
|
||||
'/app/bill/recharge/device/fail/list'
|
||||
).then(res => {
|
||||
that.$u.get('/app/bill/recharge/device/fail/list').then(res => {
|
||||
if (res.code == 200) {
|
||||
if (res.data
|
||||
.length != 0) {
|
||||
let dingobj =
|
||||
res.data[0]
|
||||
.billNo
|
||||
if (res.data.length != 0) {
|
||||
let dingobj = res.data[0].billNo
|
||||
uni.getNetworkType({
|
||||
success(
|
||||
res
|
||||
) {
|
||||
if (res
|
||||
.networkType !==
|
||||
'none'
|
||||
) {
|
||||
success(res) {
|
||||
if (res.networkType !== 'none') {
|
||||
uni.getConnectedBluetoothDevices({
|
||||
success(
|
||||
res
|
||||
) {
|
||||
that.jzflag =
|
||||
true
|
||||
success(res) {
|
||||
that.jzflag =true
|
||||
that.startLoading()
|
||||
setTimeout
|
||||
(() => {
|
||||
xBlufi
|
||||
.notifySendCustomData({
|
||||
customData: "11time@" +
|
||||
that
|
||||
.jine
|
||||
setTimeout(() => {
|
||||
xBlufi.notifySendCustomData({
|
||||
customData: "11time@" + that.jine
|
||||
})
|
||||
},
|
||||
1500
|
||||
)
|
||||
},1500)
|
||||
},
|
||||
fail(
|
||||
err
|
||||
) {
|
||||
console
|
||||
.error(
|
||||
'获取已连接蓝牙设备信息失败:',
|
||||
err
|
||||
)
|
||||
fail(err) {
|
||||
console.error('获取已连接蓝牙设备信息失败:',err)
|
||||
}
|
||||
})
|
||||
that.$u
|
||||
.get(
|
||||
`/app/bill/recharge/${dingobj}/bluetoothSuccess`
|
||||
)
|
||||
.then(
|
||||
res => {
|
||||
if (res
|
||||
.code ==
|
||||
200
|
||||
) {
|
||||
that.zhifuflag =
|
||||
true
|
||||
console
|
||||
.log(
|
||||
'蓝牙离线充值成功11'
|
||||
)
|
||||
that.$u.get(`/app/bill/recharge/${dingobj}/bluetoothSuccess`).then(res => {
|
||||
if (res.code == 200) {
|
||||
that.zhifuflag = true
|
||||
console.log('蓝牙离线充值成功11')
|
||||
setTimeout
|
||||
(() => {
|
||||
uni.reLaunch({
|
||||
url: '/pages/index/index?id=' +
|
||||
that
|
||||
.orderno
|
||||
(() => {
|
||||
uni.navigateTo({
|
||||
url: '/page_fenbao/dingdan?billId=' + that.billId
|
||||
})
|
||||
},
|
||||
1000
|
||||
|
@ -451,72 +411,34 @@
|
|||
}
|
||||
}
|
||||
)
|
||||
} else {
|
||||
console
|
||||
.log(
|
||||
'手机未连接网络'
|
||||
)
|
||||
// this.baiflag = false
|
||||
}
|
||||
}
|
||||
})
|
||||
} else {
|
||||
uni.getNetworkType({
|
||||
success(
|
||||
res
|
||||
) {
|
||||
if (res
|
||||
.networkType !==
|
||||
'none'
|
||||
) {
|
||||
success(res) {
|
||||
if (res.networkType !== 'none') {
|
||||
uni.getConnectedBluetoothDevices({
|
||||
success(
|
||||
res
|
||||
) {
|
||||
that.jzflag =
|
||||
true
|
||||
success(res) {
|
||||
that.jzflag = true
|
||||
that.startLoading()
|
||||
setTimeout
|
||||
(() => {
|
||||
xBlufi
|
||||
.notifySendCustomData({
|
||||
customData: "11time@" +
|
||||
that
|
||||
.jine
|
||||
setTimeout(() => {
|
||||
xBlufi.notifySendCustomData({
|
||||
customData: "11time@" + that.jine
|
||||
})
|
||||
},
|
||||
1500
|
||||
)
|
||||
},
|
||||
fail(
|
||||
err
|
||||
) {
|
||||
console
|
||||
.error(
|
||||
'获取已连接蓝牙设备信息失败:',
|
||||
err
|
||||
)
|
||||
},1500)
|
||||
},
|
||||
fail(err) {
|
||||
console.error('获取已连接蓝牙设备信息失败:',err)
|
||||
}
|
||||
})
|
||||
that.zhifuflag =
|
||||
true
|
||||
setTimeout
|
||||
(() => {
|
||||
uni.reLaunch({
|
||||
url: '/pages/index/index?id=' +
|
||||
that
|
||||
.orderno
|
||||
that.zhifuflag = true
|
||||
setTimeout(() => {
|
||||
uni.navigateTo({
|
||||
url: '/page_fenbao/dingdan?billId=' + that.billId
|
||||
})
|
||||
},
|
||||
1000
|
||||
)
|
||||
} else {
|
||||
console
|
||||
.log(
|
||||
'手机未连接网络'
|
||||
)
|
||||
// this.baiflag = false
|
||||
}
|
||||
},1000)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -580,7 +502,8 @@
|
|||
}
|
||||
that.$u.post('/app/bill/recharge', data).then(res => {
|
||||
if (res.code == 200) {
|
||||
that.orderno = res.data
|
||||
that.orderno = res.data.billNo
|
||||
that.billId = res.data.billId
|
||||
let data = {
|
||||
billNo: that.orderno,
|
||||
channelId: 1
|
||||
|
@ -597,12 +520,10 @@
|
|||
paySign: res.data.payParams.paySign,
|
||||
success: (res) => {
|
||||
that.zhifuflag = true
|
||||
that.$u.put(
|
||||
`/app/bill/${that.payNo}/refreshPayResult`
|
||||
).then(res => {
|
||||
that.$u.put(`/app/bill/${that.payNo}/refreshPayResult`).then(res => {
|
||||
// 支付成功逻辑
|
||||
uni.reLaunch({
|
||||
url: '/pages/index/index'
|
||||
uni.navigateTo({
|
||||
url: '/page_fenbao/dingdan?billId=' + that.billId
|
||||
})
|
||||
})
|
||||
},
|
||||
|
@ -676,6 +597,11 @@
|
|||
break;
|
||||
case xBlufi.XBLUFI_TYPE.TYPE_CONNECTED:
|
||||
console.log("连接回调:" + JSON.stringify(options));
|
||||
uni.showToast({
|
||||
title: '连接成功',
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
})
|
||||
if (options.result) {
|
||||
// console.log('125451245')
|
||||
{
|
||||
|
@ -777,6 +703,11 @@
|
|||
// 联系客服
|
||||
call() {
|
||||
this.kfflag = true
|
||||
this.picimg = false
|
||||
},
|
||||
btnkfflag(){
|
||||
this.kfflag = false
|
||||
this.picimg = true
|
||||
},
|
||||
// 拨打客服电话
|
||||
btncall(mobile) {
|
||||
|
@ -930,8 +861,8 @@
|
|||
}
|
||||
|
||||
.picdh {
|
||||
width: 30rpx;
|
||||
height: 25rpx;
|
||||
width: 40rpx;
|
||||
height: 35rpx;
|
||||
position: fixed;
|
||||
top: 53%;
|
||||
right: 76rpx;
|
||||
|
|
|
@ -65,7 +65,7 @@
|
|||
<text @click="btnriq(1)" :class="dateindex == 1 ? 'dateactive' : ''">今日</text>
|
||||
<text @click="btnriq(2)" :class="dateindex == 2 ? 'dateactive' : ''">昨日</text>
|
||||
<text @click="btnriq(3)" :class="dateindex == 3 ? 'dateactive' : ''">近七日</text>
|
||||
<text @click="btnriq(4)" :class="dateindex == 4 ? 'dateactive' : ''">近30日</text>
|
||||
<text @click="btnriq(4)" :class="dateindex == 4 ? 'dateactive' : ''">本月</text>
|
||||
</view>
|
||||
</view>
|
||||
<u-picker mode="time" v-model="show" :params="params" @confirm="confirm"></u-picker>
|
||||
|
@ -81,6 +81,10 @@
|
|||
<view class="je">{{tongobj.billCount == undefined ? '--' : tongobj.billCount}}</view>
|
||||
<view class="shu">订单总数</view>
|
||||
</view>
|
||||
<view class="sjone" v-if="infoobj.type == 2 || infoobj.type == 3">
|
||||
<view class="je">{{tongobj.addDeviceCount == undefined ? '--' : tongobj.addDeviceCount}}</view>
|
||||
<view class="shu">新增设备</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
@ -138,6 +142,14 @@
|
|||
<u-icon name="arrow-right" color="#3D3D3D" size="28"></u-icon>
|
||||
</view>
|
||||
</view>
|
||||
<view class="list_val" @click="btntuichu">
|
||||
<view class="lt">
|
||||
<image src="https://api.ccttiot.com/smartmeter/img/static/uHB7v39URI7EL8s9bSIC" mode=""></image> <text>退出登录</text>
|
||||
</view>
|
||||
<view class="rt">
|
||||
<u-icon name="arrow-right" color="#3D3D3D" size="28"></u-icon>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
|
@ -194,6 +206,30 @@
|
|||
}
|
||||
},
|
||||
methods: {
|
||||
btntuichu(){
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '您确定要退出登录吗?',
|
||||
success: function(res) {
|
||||
if (res.confirm) {
|
||||
try {
|
||||
const storageInfo = uni.getStorageInfoSync();
|
||||
const keys = storageInfo.keys; // 获取所有键
|
||||
keys.forEach(key => {
|
||||
uni.removeStorageSync(key); // 遍历并删除每个键
|
||||
});
|
||||
console.log('所有本地存储已删除');
|
||||
uni.reLaunch({
|
||||
url:'/pages/login/login'
|
||||
})
|
||||
} catch (e) {
|
||||
console.error('删除本地存储时发生错误:', e);
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
btnback(){
|
||||
uni.reLaunch({
|
||||
url:'/pages/index/index'
|
||||
|
@ -317,7 +353,7 @@
|
|||
this.gettongji()
|
||||
} else if (num == 4) {
|
||||
let today = new Date()
|
||||
let firstDayOfLastMonth = new Date(today.getFullYear(), today.getMonth() - 1,today.getDate() + 1)
|
||||
let firstDayOfLastMonth = new Date(today.getFullYear(), today.getMonth(), 1)
|
||||
let lastDayOfLastMonth = new Date(today.getFullYear(), today.getMonth(), today.getDate())
|
||||
this.firsTime = this.formatDate(firstDayOfLastMonth)
|
||||
this.lasTime = this.formatDate(lastDayOfLastMonth)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<template>
|
||||
<view class="page">
|
||||
<u-navbar title="订单详情" :border-bottom="false" :background="bgc" title-color='#3D3D3D' back-icon-color="#3D3D3D"
|
||||
<u-navbar title="订单详情" :custom-back="btnback" :border-bottom="false" :background="bgc" title-color='#3D3D3D' back-icon-color="#3D3D3D"
|
||||
title-size='36' height='44'></u-navbar>
|
||||
|
||||
<view class="shengyu">
|
||||
|
@ -102,6 +102,9 @@
|
|||
mode=""></image>
|
||||
</view>
|
||||
</view>
|
||||
<view class="" style="font-size: 32rpx;margin-top: 20rpx;color: red;text-align: center;">
|
||||
临时开关开启后才可操作遥控器
|
||||
</view>
|
||||
<!-- 结束订单 -->
|
||||
<view class="jieshu" v-if="msakflag">
|
||||
<view class="jieshus">
|
||||
|
@ -205,7 +208,8 @@
|
|||
isUsing: false,
|
||||
timer: null,
|
||||
timers: null,
|
||||
pictrim:true
|
||||
pictrim:true,
|
||||
billidflag:''
|
||||
}
|
||||
},
|
||||
onShow() {
|
||||
|
@ -230,6 +234,8 @@
|
|||
onLoad(option) {
|
||||
if (option.billId) {
|
||||
this.billId = option.billId
|
||||
} else if(option.idss){
|
||||
this.billidflag = 1
|
||||
} else {
|
||||
this.billId = option.id
|
||||
}
|
||||
|
@ -272,6 +278,10 @@
|
|||
}
|
||||
},
|
||||
methods: {
|
||||
btnback(){
|
||||
uni.navigateBack()
|
||||
},
|
||||
|
||||
startTimers() {
|
||||
if (this.timers) {
|
||||
clearInterval(this.timers); // 防止重复设置定时器
|
||||
|
@ -629,10 +639,10 @@
|
|||
} else {
|
||||
this.imgflag = false
|
||||
}
|
||||
if (this.detailobj.suitExpireTime == null) {
|
||||
if (this.detailobj.device.expireTime == null) {
|
||||
this.timeday = 0
|
||||
} else {
|
||||
let expireTimeStr = this.detailobj.suitExpireTime
|
||||
let expireTimeStr = this.detailobj.device.expireTime
|
||||
let expireTimeParts = expireTimeStr.split(" ")
|
||||
let expireDateParts = expireTimeParts[0].split("-")
|
||||
let expireTimePartsTime = expireTimeParts[1].split(":")
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
style="background-color: #17b402;"></text> 进行中 </view>
|
||||
<view style="color: #8883F0;" v-if="item.isFinished == true && item.status != 3"> <text
|
||||
style="background-color: #8883F0;"></text> 已完成 </view>
|
||||
<view v-if="item.status == 3" style="color: #e10328;"><text style="background-color: #e10328;"></text> 已退款</view>
|
||||
<view v-if="item.status == 3" style="red"><text style="background-red"></text> 已退款</view>
|
||||
<view class="" v-if="item.isUsing == false && item.isFinished == false && item.status != 3">
|
||||
<view v-if="item.status == 1" style="color: #004fd8;"><text
|
||||
style="background-color: #004fd8;"></text> 未支付</view>
|
||||
|
@ -25,8 +25,8 @@
|
|||
style="background-color: #5d5d5d;"></text> 系统超时取消</view>
|
||||
<view v-if="item.status == 6" style="color: #e6b000;"><text
|
||||
style="background-color: #e6b000;"></text> 支付中</view>
|
||||
<view v-if="item.status == 7" style="color: #e10328;"><text
|
||||
style="background-color: #e10328;"></text> 退款中</view>
|
||||
<view v-if="item.status == 7" style="red"><text
|
||||
style="background-red"></text> 退款中</view>
|
||||
<view v-if="item.status == 8" style="color: #004fd8;"><text
|
||||
style="background-color: #004fd8;"></text> 押金未支付</view>
|
||||
<view v-if="item.status == 9" style="color: #e6b000;"><text
|
||||
|
@ -34,7 +34,7 @@
|
|||
</view>
|
||||
</view>
|
||||
<view class="item_xx">
|
||||
<view class="">
|
||||
<view class="">
|
||||
订单号
|
||||
</view>
|
||||
<view class="">
|
||||
|
|
|
@ -51,9 +51,13 @@
|
|||
<view>套餐金额</view>
|
||||
<view>¥{{obj.money == undefined ? '--' : obj.money}}</view>
|
||||
</view>
|
||||
<view class="xiao">
|
||||
<view>到账金额</view>
|
||||
<view>¥{{obj.arrivalAmount == undefined ? '--' : obj.arrivalAmount}}</view>
|
||||
</view>
|
||||
<view class="xiao" v-if="obj.status == 3">
|
||||
<view>退款金额</view>
|
||||
<view style="color: red;">¥{{obj.refundAmount == undefined ? '--' : obj.refundAmount}}</view>
|
||||
<view style="color: #e10328;">¥{{obj.refundAmount == undefined ? '--' : obj.refundAmount}}</view>
|
||||
</view>
|
||||
<view class="xiao">
|
||||
<view>结束时间</view>
|
||||
|
@ -95,7 +99,7 @@
|
|||
</view>
|
||||
<view class="xiao" v-for="(item,index) in obj.bonusList" :key="index">
|
||||
<view class="one">{{item.arrivalName == undefined ? '--' : item.arrivalName}}(<text v-if="item.arrivalType == 1">平台</text><text v-if="item.arrivalType == 2">公司</text><text v-if="item.arrivalType == 3">合作伙伴</text><text v-if="item.arrivalType == 4">渠道商</text><text v-if="item.arrivalType == 5">创业者</text><text v-if="item.arrivalType == 6">经营场所</text>){{item.point}}%</view>
|
||||
<view class="two">¥{{item.amount == undefined ? '--' : item.amount}} <text v-if="obj.status == 3" style="margin-left: 20rpx;color: red;">(已退¥{{item.refundAmount}})</text> </view>
|
||||
<view class="two">¥{{item.amount == undefined ? '--' : item.amount}} <text v-if="obj.status == 3" style="margin-left: 20rpx;color: #e10328;">(已退¥{{item.refundAmount}})</text> </view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="sb" v-if="userflag" @click="btntz" style="width:680rpx;height: 100rpx;display: flex;justify-content: space-between;background: #FFFFFF;
|
||||
|
@ -219,7 +223,6 @@
|
|||
})
|
||||
}
|
||||
},
|
||||
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
@ -326,6 +329,7 @@
|
|||
background-color: #F7FAFE !important;
|
||||
height: 100vh;
|
||||
width: 100%;
|
||||
overflow: scroll;
|
||||
padding: 28rpx;
|
||||
box-sizing: border-box;
|
||||
.box{
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
</view>
|
||||
<view class="xiao">
|
||||
<view class="one">分成比例:</view>
|
||||
<view class="two">{{obj.point}}%</view>
|
||||
<view class="two">{{obj.point == undefined ? '--' : obj.point}}%</view>
|
||||
</view>
|
||||
<view class="xiao">
|
||||
<view class="one">创建时间:</view>
|
||||
|
@ -52,6 +52,14 @@
|
|||
<view class="one">累计订单:</view>
|
||||
<view class="two">{{obj.billCount == undefined ? '--' : obj.billCount}}单</view>
|
||||
</view>
|
||||
<view class="xiao" v-if="type == 2 || type == 3">
|
||||
<view class="one">本月新增设备:</view>
|
||||
<view class="two">{{obj.currentMonthAddDevice == undefined ? '--' : obj.currentMonthAddDevice}}台</view>
|
||||
</view>
|
||||
<view class="xiao" v-if="type == 2 || type == 3">
|
||||
<view class="one">上月新增设备:</view>
|
||||
<view class="two">{{obj.lastMonthAddDevice == undefined ? '--' : obj.lastMonthAddDevice}}台</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
|
@ -65,13 +73,15 @@
|
|||
backgroundColor: "#8883f0",
|
||||
},
|
||||
userId:'',
|
||||
obj:{}
|
||||
obj:{},
|
||||
type:''
|
||||
}
|
||||
},
|
||||
onLoad(option) {
|
||||
this.getuser()
|
||||
this.userId = option.userId
|
||||
this.getxq()
|
||||
},
|
||||
},
|
||||
// 分享到好友(会话)
|
||||
onShareAppMessage: function() {
|
||||
return {
|
||||
|
@ -96,7 +106,15 @@
|
|||
this.obj = res.data
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
// 获取本人信息
|
||||
getuser(){
|
||||
this.$u.get(`app/user/userInfo`).then(res =>{
|
||||
if(res.code == 200){
|
||||
this.type = res.data.type
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -150,7 +168,7 @@
|
|||
}
|
||||
.jiben{
|
||||
width: 680rpx;
|
||||
max-height: 480rpx;
|
||||
max-height: 530rpx;
|
||||
background: #FFFFFF;
|
||||
border-radius: 24rpx 24rpx 24rpx 24rpx;
|
||||
margin: auto;
|
||||
|
|
15
pages.json
15
pages.json
|
@ -30,6 +30,14 @@
|
|||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/luru",
|
||||
"style": {
|
||||
"navigationBarTitleText": "",
|
||||
"enablePullDownRefresh": false,
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/tj",
|
||||
"style": {
|
||||
|
@ -330,6 +338,13 @@
|
|||
"enablePullDownRefresh": false,
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},{
|
||||
"path": "dingdan",
|
||||
"style": {
|
||||
"navigationBarTitleText": "上传",
|
||||
"enablePullDownRefresh": false,
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
31
pages/my.vue
31
pages/my.vue
|
@ -1,6 +1,6 @@
|
|||
<template>
|
||||
<view class="page">
|
||||
333
|
||||
<button @click="click" style="margin-top:500rpx ;">按钮</button>
|
||||
|
||||
</view>
|
||||
</template>
|
||||
|
@ -17,6 +17,35 @@
|
|||
}
|
||||
},
|
||||
methods: {
|
||||
click(){
|
||||
// 检查是否支持生物认证
|
||||
uni.checkIsSupportSoterAuthentication({
|
||||
success: (res) => {
|
||||
// 调用人脸识别API
|
||||
wx.startFacialRecognitionVerify({
|
||||
name: '吴鹏', // 用户名称
|
||||
idCardNumber: '430523200402073551', // 身份证号码
|
||||
success: (result) => {
|
||||
if (result.errMsg === 'startFacialRecognitionVerify:ok') {
|
||||
// 处理人脸识别成功的情况
|
||||
console.log('人脸识别成功');
|
||||
}
|
||||
},
|
||||
fail: (error) => {
|
||||
// 处理人脸识别失败的情况
|
||||
uni.showToast({
|
||||
title: '人脸识别失败',
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
fail: (err) => {
|
||||
console.log('支持生物认证失败', err);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
241
pages/zhuce.vue
241
pages/zhuce.vue
|
@ -7,16 +7,14 @@
|
|||
</view>
|
||||
|
||||
<view class="dblist" v-for="(item, index) in devicesLists" :key="index">
|
||||
<view class="cen">
|
||||
<view class="cen" :id="item.deviceId" @click="createBLEConnections(item)">
|
||||
<view class="name">
|
||||
<view class="">
|
||||
状态:<text v-if="item.flags == true" style="color: red;">已录入</text> <text v-else
|
||||
状态:<text v-if="item.flags == true" style="color: #e10328;">已录入</text> <text v-else
|
||||
style="color:seagreen;">未录入</text>
|
||||
</view>
|
||||
<view class="" style="display: flex;">
|
||||
SN码: <input
|
||||
style="width: 200rpx;background-color: #ccc;padding: 5rpx;box-sizing: border-box;text-align: center;"
|
||||
v-model="item.sn" placeholder="输入SN" />
|
||||
<view class="" style="display: flex;width: 100%;">
|
||||
SN码:{{item.sn == undefined ? '--' : item.sn}}
|
||||
</view>
|
||||
</view>
|
||||
<view class="mac">
|
||||
|
@ -25,15 +23,16 @@
|
|||
<view class="" style="color: #8883F0;margin-top: 10rpx;margin-bottom: 10rpx;text-align: left;">
|
||||
蓝牙强度:{{item.RSSI}}
|
||||
</view>
|
||||
<view @click="btnshows(item,index)"
|
||||
<!-- <view @click="btnshows(item,index)"
|
||||
style="color: #8883F0;margin-top: 10rpx;margin-bottom: 10rpx;text-align: left;">
|
||||
型号选择:{{item.xuanz == undefined ? '--' : item.xuanz}}
|
||||
</view>
|
||||
</view> -->
|
||||
</view>
|
||||
<view class="rt">
|
||||
<text style="margin-bottom: 10rpx;" :id="item.deviceId" @click="createBLEConnections(item)">开关</text>
|
||||
<text @click="scanQRCode(item)" style="margin-bottom: 10rpx;">扫码</text>
|
||||
<text :id="item.deviceId" @click="createBLEConnection(item)">录入</text>
|
||||
<view class="rt" :id="item.deviceId" @click="createBLEConnections(item)">
|
||||
<!-- <text style="margin-bottom: 10rpx;" :id="item.deviceId" @click="createBLEConnections(item)">{{item.lj}}</text> -->
|
||||
<text style="margin-bottom: 10rpx;">选择</text>
|
||||
<!-- <text @click="scanQRCode(item)" style="margin-bottom: 10rpx;">扫码</text>
|
||||
<text :id="item.deviceId" @click="createBLEConnection(item)">录入</text> -->
|
||||
</view>
|
||||
</view>
|
||||
|
||||
|
@ -62,7 +61,7 @@
|
|||
|
||||
<script>
|
||||
const app = getApp();
|
||||
var xBlufi = require("@/components/blufi/xBlufi.js");
|
||||
var xBlufi = require("@/components/blufi/xBlufi.js");
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
|
@ -287,25 +286,37 @@
|
|||
this.titleflag = true
|
||||
} else {
|
||||
let arr = []
|
||||
// console.log(this.devicesLists,'101010');
|
||||
this.devicesLists.forEach(item => {
|
||||
arr.push(item.name.slice(5))
|
||||
})
|
||||
this.arrs = arr.join(',')
|
||||
this.$u.get(`/app/device/getExistMac/${this.arrs}`).then(res => {
|
||||
if (res.code == 200) {
|
||||
const existingDevices = new Set(res.data); // 将 res.data 转换为 Set,以提高查找效率
|
||||
this.devicesLists = this.devicesLists.map(device => {
|
||||
const trimmedName = device.name.slice(5); // 假设前缀总是5个字符长
|
||||
const flags = existingDevices.has(trimmedName); // true 如果存在,否则 false
|
||||
return {
|
||||
...device,
|
||||
flags, // 直接使用 flags 变量
|
||||
sn: '',
|
||||
}
|
||||
})
|
||||
}
|
||||
this.$u.get(`/app/device/getExistMac/${this.arrs}`).then(res => {
|
||||
if (res.code == 200 && Array.isArray(res.data)) {
|
||||
const existingDevices = new Map(res.data.map(item => [item.mac, true])); // 使用Map来存储已找到的MAC
|
||||
|
||||
this.devicesLists = this.devicesLists.map(device => {
|
||||
const trimmedName = device.name.slice(5); // 假设name中包含MAC地址的一部分
|
||||
const mac = trimmedName; // 如果trimmedName直接就是MAC,则不需要再处理
|
||||
device.found = existingDevices.has(mac); // 添加一个found属性来标记是否找到
|
||||
if (device.found) {
|
||||
const sn = res.data.find(val => val.mac === mac)?.sn; // 从res.data中找到匹配的sn
|
||||
if (sn) {
|
||||
device.sn = sn; // 设置sn
|
||||
}
|
||||
device.flags = true; // 设置flags为true,因为找到了匹配的MAC
|
||||
} else {
|
||||
device.flags = false; // 可选:如果你想要明确表示未找到
|
||||
}
|
||||
return device; // 但map函数仍然需要return来保持结构
|
||||
});
|
||||
this.devicesLists.sort((a, b) => {
|
||||
if (a.found && !b.found) return 1; // b排在a前面(即a在后面)
|
||||
if (!a.found && b.found) return -1; // a排在b前面
|
||||
return 0;
|
||||
});
|
||||
}
|
||||
})
|
||||
console.log(this.devicesLists,'0202')
|
||||
setTimeout(()=>{
|
||||
uni.hideLoading()
|
||||
},2000)
|
||||
|
@ -313,7 +324,9 @@
|
|||
} else {
|
||||
//蓝牙停止搜索失败
|
||||
this.mengcflag = false
|
||||
uni.hideLoading()
|
||||
setTimeout(()=>{
|
||||
uni.hideLoading()
|
||||
},2000)
|
||||
console.log('蓝牙停止搜索失败');
|
||||
}
|
||||
this.searching = false
|
||||
|
@ -323,66 +336,104 @@
|
|||
|
||||
// 发送开关
|
||||
createBLEConnections(e) {
|
||||
uni.showLoading({
|
||||
title: '执行中...'
|
||||
let Bluetoothmac = e.name.substring(5)
|
||||
uni.navigateTo({
|
||||
url:'/pages/luru?mac='+Bluetoothmac
|
||||
})
|
||||
this.arrs = ''
|
||||
this.qrResult = e.name //拿到所点击的mac号
|
||||
if (this.ver_data == null) { //判断是否有连接蓝牙
|
||||
xBlufi.initXBlufi(1)
|
||||
xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent)
|
||||
xBlufi.notifyStartDiscoverBle({
|
||||
'isStart': true
|
||||
})
|
||||
// 停止蓝牙搜索
|
||||
setTimeout(() => {
|
||||
xBlufi.notifyStartDiscoverBle({
|
||||
'isStart': false
|
||||
})
|
||||
xBlufi.notifyConnectBle({
|
||||
isStart: true,
|
||||
deviceId: this.deviceId,
|
||||
name: this.name
|
||||
})
|
||||
xBlufi.notifyInitBleEsp32({
|
||||
deviceId: this.deviceId
|
||||
})
|
||||
}, 1000)
|
||||
}else{ //有连接则发送命令
|
||||
let that = this //改变this指向
|
||||
uni.getNetworkType({
|
||||
success(res) {
|
||||
if (res.networkType !== 'none') {
|
||||
uni.getConnectedBluetoothDevices({
|
||||
success(res) {
|
||||
setTimeout(() => { //一秒后发送开启命令
|
||||
xBlufi.notifySendCustomData({
|
||||
customData: '11open'
|
||||
})
|
||||
setTimeout(()=>{ //发送开启命令两秒后发送关闭命令
|
||||
xBlufi.notifySendCustomData({
|
||||
customData: '11close'
|
||||
})
|
||||
setTimeout(()=>{ //发送关闭命令后一秒后断开连接
|
||||
uni.hideLoading()
|
||||
that.ver_data = null
|
||||
xBlufi.listenDeviceMsgEvent(false, that.funListenDeviceMsgEvent);
|
||||
wx.closeBLEConnection({
|
||||
deviceId: that.deviceId,
|
||||
})
|
||||
// console.log('guanbi');
|
||||
},1000)
|
||||
},2000)
|
||||
}, 1000)
|
||||
},
|
||||
fail(err) {
|
||||
console.error('获取已连接蓝牙设备信息失败:', err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// this.arrs = ''
|
||||
// this.qrResult = e.name //拿到所点击的mac号
|
||||
// if (this.ver_data == null) { //判断是否有连接蓝牙
|
||||
// xBlufi.initXBlufi(1)
|
||||
// xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent)
|
||||
// xBlufi.notifyStartDiscoverBle({
|
||||
// 'isStart': true
|
||||
// })
|
||||
// this.devicesList.forEach(device => {
|
||||
// if (device.name == this.qrResult) {
|
||||
// this.deviceId = device.deviceId
|
||||
// this.name = device.name
|
||||
// this.mac = device.name.slice(5, 17)
|
||||
// }
|
||||
// })
|
||||
// uni.showLoading({
|
||||
// title: '连接准备中...'
|
||||
// })
|
||||
// // 停止蓝牙搜索
|
||||
// setTimeout(() => {
|
||||
// setTimeout(()=>{
|
||||
// uni.showLoading({
|
||||
// title: '连接中...'
|
||||
// })
|
||||
// setTimeout(()=>{
|
||||
// uni.hideLoading()
|
||||
// uni.showToast({
|
||||
// title: '连接成功',
|
||||
// icon: 'success',
|
||||
// duration: 2000
|
||||
// })
|
||||
// this.devicesLists.forEach(item => {
|
||||
// if (item.name == this.qrResult) {
|
||||
// item.lj = '开关'
|
||||
// }
|
||||
// })
|
||||
// },2000)
|
||||
// },500)
|
||||
// xBlufi.notifyStartDiscoverBle({
|
||||
// 'isStart': false
|
||||
// })
|
||||
// xBlufi.notifyConnectBle({
|
||||
// isStart: true,
|
||||
// deviceId: this.deviceId,
|
||||
// name: this.name
|
||||
// })
|
||||
// xBlufi.notifyInitBleEsp32({
|
||||
// deviceId: this.deviceId
|
||||
// })
|
||||
// }, 1000)
|
||||
// }else{ //有连接则发送命令
|
||||
// uni.showLoading({
|
||||
// title: '执行中...'
|
||||
// })
|
||||
// let that = this //改变this指向
|
||||
// uni.getNetworkType({
|
||||
// success(res) {
|
||||
// if (res.networkType !== 'none') {
|
||||
// uni.getConnectedBluetoothDevices({
|
||||
// success(res) {
|
||||
// setTimeout(() => { //一秒后发送开启命令
|
||||
// xBlufi.notifySendCustomData({
|
||||
// customData: 'open'
|
||||
// })
|
||||
// setTimeout(()=>{ //发送开启命令两秒后发送关闭命令
|
||||
// xBlufi.notifySendCustomData({
|
||||
// customData: 'close'
|
||||
// })
|
||||
// setTimeout(()=>{ //发送关闭命令后一秒后断开连接
|
||||
// uni.hideLoading()
|
||||
// that.ver_data = null
|
||||
// xBlufi.listenDeviceMsgEvent(false, that.funListenDeviceMsgEvent);
|
||||
// wx.closeBLEConnection({
|
||||
// deviceId: that.deviceId,
|
||||
// })
|
||||
// that.devicesLists.forEach(item => {
|
||||
// if (item.name == that.qrResult) {
|
||||
// item.lj = '连接'
|
||||
// }
|
||||
// })
|
||||
// // console.log('guanbi');
|
||||
// },1000)
|
||||
// },2000)
|
||||
// }, 1000)
|
||||
// },
|
||||
// fail(err) {
|
||||
// console.error('获取已连接蓝牙设备信息失败:', err)
|
||||
// }
|
||||
// })
|
||||
// }
|
||||
// }
|
||||
// })
|
||||
// }
|
||||
},
|
||||
// 请求已经录入设备的mac
|
||||
getluru() {
|
||||
|
@ -478,9 +529,11 @@
|
|||
uni.showLoading({
|
||||
title: '请稍后...'
|
||||
})
|
||||
xBlufi.initXBlufi(1);
|
||||
xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent);
|
||||
xBlufi.notifyStartDiscoverBle({
|
||||
'isStart': true
|
||||
});
|
||||
})
|
||||
// 重新搜索清空蓝牙数组
|
||||
this.bluthlist = []
|
||||
this.devicesList = []
|
||||
|
@ -492,7 +545,7 @@
|
|||
this.texts = '正在扫描蓝牙设备...'
|
||||
setTimeout(() => {
|
||||
this.statusflag = false
|
||||
if (this.searching) {
|
||||
// if (this.searching) {
|
||||
xBlufi.notifyStartDiscoverBle({
|
||||
'isStart': false
|
||||
});
|
||||
|
@ -503,11 +556,11 @@
|
|||
} else {
|
||||
this.texts = '扫描到以下设备,请点击录入!'
|
||||
}
|
||||
} else {
|
||||
xBlufi.notifyStartDiscoverBle({
|
||||
'isStart': true
|
||||
})
|
||||
}
|
||||
// } else {
|
||||
// xBlufi.notifyStartDiscoverBle({
|
||||
// 'isStart': true
|
||||
// })
|
||||
// }
|
||||
}, 2000)
|
||||
// }
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue
Block a user