This commit is contained in:
Sliverber 2024-06-08 18:01:46 +08:00
parent fbe59000dd
commit 3367519fcb
12 changed files with 389 additions and 209 deletions

View File

@ -20,7 +20,7 @@ const install = (Vue, vm) => {
// },
// });
Vue.prototype.$u.http.setConfig({
// baseUrl: 'http://124.221.246.124:2288/dev-api/',
// baseUrl: 'http://192.168.2.88/dev-api',
baseUrl: 'https://znb.ccttiot.com/prod-api/',
loadingText: '努力加载中~',
loadingTime: 800,

View File

@ -131,14 +131,20 @@
channelId:0,
orderid:'',
realprice:0,
payinfo:{}
payinfo:{},
fl:0
}
},
onLoad(options) {
this.getsxf()
// this.getdevice()
this.eleprice=options.price
this.tenantBearServiceFee=options.tenantBearServiceFee
if(options.tenantBearServiceFee=='true'){
this.tenantBearServiceFee=true
}else if(options.tenantBearServiceFee=='false'){
this.tenantBearServiceFee=false
}
this.deviceId=options.deviceId
setTimeout(()=>{
this.checkPrice('50')
@ -218,14 +224,15 @@
checkPrice(item) {
const price = parseFloat(item.replace('元', ''));
if (this.tenantBearServiceFee==false) {
if (this.tenantBearServiceFee==true) {
console.log('111');
this.price = price;
this.arrivalAmount=price
this.xsf =price*this.fl
this.realprice = parseFloat((this.price + this.xsf).toFixed(2));
this.Quantity = price/this.eleprice
} else {
console.log('2');
this.price = price;
this.xsf =price*this.fl
this.realprice = parseFloat((this.price).toFixed(2));

View File

@ -555,18 +555,20 @@
switch (options.type) {
case xBlufi.XBLUFI_TYPE.TYPE_STATUS_CONNECTED: {
console.log('状态', options.result)
uni.showModal({
title: '很抱歉提醒你!',
content: '小程序与设备异常断开',
showCancel: false,
success: function(res) {
// uni.navigateBack({
// url: '../search/search'
// });
}
});
this.statusflag = false
uni.hideLoading();
if( options.result==false){
uni.showModal({
title: '很抱歉提醒你!',
content: '小程序与设备异常断开',
showCancel: false,
success: function(res) {
// uni.navigateBack({
// url: '../search/search'
// });
}
});
this.statusflag = false
uni.hideLoading();
}
}
break;

View File

@ -163,11 +163,11 @@
if (options.result) {
let devicesarr = options.data
// this.devicesList = options.data
// console.log(mac,'devicesarrdevicesarr');
console.log(devicesarr,'devicesarrdevicesarr');
devicesarr.forEach(device => {
const mac = device.name.substring(6);
if (device.name.substring(0, 5) === "CTPOW") {
if (device.name.substring(0, 4) === "CTPO") {
// this.$u.get(`/app/device/${mac}/isBind`).then((res) => {
// if (res.data == false) {
this.devicesLists.push(device);

View File

@ -55,7 +55,7 @@
</view>
</view> -->
<view class="anniu">
<view class="anniu" @click="Search">
<button>重新扫描</button>
</view>
@ -83,7 +83,7 @@
<view class="modal-title">确认绑定</view>
<view class="modal-body">是否确认绑定设备</view>
<view class="modal-footer">
<view class="btn" @click="closeConfirmModal" style="background: #ccc;">取消</view>
<view class="btn" @click="closeConfirmModal" style="background: #ccc;">取消</view>
<view class="btn" @click="confirmBind">确定</view>
</view>
</view>
@ -124,44 +124,26 @@
isband: false,
status: false,
showConfirmModal: false, //
sn:''
}
},
onLoad(e) {
console.log(e);
this.mac = e.mac
this.$u.get(`/app/device/${this.mac}/isBind`).then((res) => {
if (res.data == false) {
xBlufi.initXBlufi(1);
console.log("xBlufi", xBlufi.XMQTT_SYSTEM);
xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent);
xBlufi.notifyStartDiscoverBle({
'isStart': true
});
//
setTimeout(() => {
xBlufi.notifyStartDiscoverBle({
'isStart': false
if(e.mac){
this.sn=e.mac
this.$u.get(`/app/device/${ e.mac}/isBind`).then((res) => {
if (res.data == false) {
this.getmacInfo()
} else {
uni.showToast({
title: '改设备已经被绑定',
icon: 'none',
duration: 3000
});
//
if (this.devicesList.length == 0) {
uni.showToast({
title: '暂无发现对应设备,请靠近设备',
icon: 'none'
});
} else {
this.texts = '扫描到以下设备,请点击连接!'
}
this.status = true
}, 2000)
} else {
uni.showToast({
title: '改设备已经被绑定',
icon: 'none',
duration: 3000
});
}
})
}
})
}
},
onShow: function() {
@ -218,6 +200,43 @@
this.videoContext = uni.createVideoContext('myVideo', this)
},
methods: {
getmacInfo(){
this.$u.get(`/app/device/sn/${ this.sn}`).then((res) => {
if (res.code == 200) {
this.mac=res.data.mac
xBlufi.initXBlufi(1);
console.log("xBlufi", xBlufi.XMQTT_SYSTEM);
xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent);
xBlufi.notifyStartDiscoverBle({
'isStart': true
});
//
setTimeout(() => {
xBlufi.notifyStartDiscoverBle({
'isStart': false
});
//
if (this.devicesList.length == 0) {
uni.showToast({
title: '暂无发现对应设备,请靠近设备',
icon: 'none'
});
} else {
this.texts = '扫描到以下设备,请点击连接!'
}
this.status = true
}, 2000)
} else {
uni.showToast({
title: '改设备已经被绑定',
icon: 'none',
duration: 3000
});
}
})
},
openConfirmModal() {
this.showConfirmModal = true;
},
@ -248,65 +267,65 @@
if (this.ishave && this.isband) {
uni.setStorageSync('mac', this.mac);
let that = this
setTimeout(() => {
uni.switchTab({
url: '/pages/index/index'
})
}, )
// uni.getLocation({
// type: 'wgs84',
// success: function (lb) {
// setTimeout(() => {
// uni.switchTab({
// url: '/pages/index/index'
// })
// }, )
uni.getLocation({
type: 'wgs84',
success: function (lb) {
// that.gps.lat = lb.latitude;
// that.gps.lon = lb.longitude;
// that.$u.put(`/app/device/bind/${that.mac}`, that.gps).then((res) => {
// if(res.code==200){
// uni.showToast({
// title: '',
// icon: 'none',
// duration: 2000
// });
// uni.removeStorageSync('mac');
// setTimeout(()=>{
// uni.switchTab({
// url:'/pages/index/index'
// })
// },)
// }else{
that.gps.lat = lb.latitude;
that.gps.lon = lb.longitude;
that.$u.put(`/app/device/bind/${that.mac}`, that.gps).then((res) => {
if(res.code==200){
uni.showToast({
title: '绑定成功',
icon: 'none',
duration: 2000
});
uni.removeStorageSync('mac');
setTimeout(()=>{
uni.switchTab({
url:'/pages/index/index'
})
},)
}else{
// }
// })
}
})
// }, fail: function (error) {
// console.error('', error);
// that.gps.lat = 0;
// that.gps.lon = 0;
// that.$u.put(`/app/device/bind/${that.mac}`, that.gps).then((res) => {
// if(res.code==200){
// uni.showToast({
// title: '',
// icon: 'none',
// duration: 2000
// });
// uni.removeStorageSync('mac');
// setTimeout(()=>{
// uni.switchTab({
// url:'/pages/index/index'
// })
// },)
// }else{
// setTimeout(()=>{
// uni.switchTab({
// url:'/pages/index/index'
// })
// },)
// }
// })
// //
// }
}, fail: function (error) {
console.error('获取位置信息失败:', error);
that.gps.lat = 0;
that.gps.lon = 0;
that.$u.put(`/app/device/bind/${that.mac}`, that.gps).then((res) => {
if(res.code==200){
uni.showToast({
title: '绑定成功',
icon: 'none',
duration: 2000
});
uni.removeStorageSync('mac');
setTimeout(()=>{
uni.switchTab({
url:'/pages/index/index'
})
},)
}else{
setTimeout(()=>{
uni.switchTab({
url:'/pages/index/index'
})
},)
}
})
//
}
// })
})
}
@ -342,7 +361,7 @@
if (options.result) {
let devicesarr = options.data
// this.devicesList = options.data
// console.log(devicesarr,'devicesarrdevicesarr');
// console.log(devicesarr, 'devicesarrdevicesarr');
devicesarr.forEach(device => {
const mac = device.name.substring(6);
if (device.name.substring(0, 5) === "CTPOW") {
@ -353,6 +372,7 @@
// this.devicesList
this.devicesList = uniqueDevicesList;
// }
// })
@ -427,7 +447,7 @@
filteredDevices.forEach(device => {
// MAC MAC 6
let macFromName = device.name.substring(device.name.length - 12);
// console.log(macFromName);
console.log(macFromName,'macFromName',this.mac);
// this.mac
if (macFromName == this.mac) {
// this.ishave true
@ -495,24 +515,21 @@
//
// this.startBluetoothDevicesDiscovery()
this.statusflag = true
this.status = false
this.texts = '正在扫描蓝牙设备...'
setTimeout(() => {
this.statusflag = false
this.status = true
if (this.searching) {
xBlufi.notifyStartDiscoverBle({
'isStart': false
});
//
if (this.devicesList.length == 0) {
uni.showToast({
title: '暂无发现对应设备,请靠近设备',
icon: 'none'
});
this.tishiflag = true
this.texts = '扫描完毕,暂无发现浇花器设备'
} else {
this.texts = '扫描到以下设备,请点击连接!'
}
xBlufi.notifyStartDiscoverBle({
'isStart': false
});
} else {
xBlufi.notifyStartDiscoverBle({
'isStart': true
@ -520,25 +537,28 @@
}
}, 2000)
}
},
funListenDeviceMsgEvents: function(options) {
let that = this;
switch (options.type) {
case xBlufi.XBLUFI_TYPE.TYPE_STATUS_CONNECTED: {
console.log('状态', options.result)
uni.showModal({
title: '很抱歉提醒你!',
content: '小程序与设备异常断开',
showCancel: false,
success: function(res) {
// uni.navigateBack({
// url: '../search/search'
// });
}
});
this.statusflag = false
uni.hideLoading();
if( options.result==false){
uni.showModal({
title: '很抱歉提醒你!',
content: '小程序与设备异常断开',
showCancel: false,
success: function(res) {
// uni.navigateBack({
// url: '../search/search'
// });
}
});
this.statusflag = false
uni.hideLoading();
}
}
break;

View File

@ -506,19 +506,20 @@
switch (options.type) {
case xBlufi.XBLUFI_TYPE.TYPE_STATUS_CONNECTED:
{
console.log('状态', options.result)
uni.showModal({
title: '很抱歉提醒你!',
content: '小程序与设备异常断开',
showCancel: false,
success: function (res) {
// uni.navigateBack({
// url: '../search/search'
// });
}
});
this.statusflag = false
uni.hideLoading();
if( options.result==false){
uni.showModal({
title: '很抱歉提醒你!',
content: '小程序与设备异常断开',
showCancel: false,
success: function(res) {
// uni.navigateBack({
// url: '../search/search'
// });
}
});
this.statusflag = false
uni.hideLoading();
}
}
break;

View File

@ -46,8 +46,11 @@
<image src="https://api.ccttiot.com/smartmeter/img/static/uoQO0pUZ1UHcW5uVKkuR" mode=""></image>
</view>
<view class="mid_right">
<view class="mid_top">
{{ deviceInfo.deviceName }}
<view class="mid_top" v-if="deviceInfo.remark!=null">
{{ deviceInfo.remark }}
</view>
<view class="mid_top" v-if="deviceInfo.remark==null">
{{ deviceInfo.deviceName}}电表
</view>
<view class="mid_bot">
<view class="txt" v-if="deviceInfo">电表号{{ deviceInfo.deviceId }}</view>
@ -69,6 +72,8 @@
</view>
</view>
<view class="bot_right">
<div class="tip" v-if="deviceInfo.powerStatus==0">断电</div>
<div class="tip" v-if="deviceInfo.powerStatus==1">正常</div>
<view class="cont">
<view class="tit">
{{deviceInfo.totalElectriQuantity}}KWH
@ -141,7 +146,14 @@
</view>
<view class="bot">配网</view>
</view>
<view class="cont" @click="offdevice(deviceInfo.deviceId)" style="width: 112rpx;">
<view class="top">
<image src="https://api.ccttiot.com/smartmeter/img/static/umIcXWUnUfhQMlRG4k35" mode="">
</image>
</view>
<view class="bot">解绑设备</view>
</view>
</view>
</view>
<!-- <view class="button" @click="topay()">电费充值</view>
@ -397,10 +409,8 @@
}
} else {
setTimeout(() => {
this.$refs.canvas.init(this.initChart)
}, 500);
this.$refs.canvas.init(this.initChart)
if (uni.getStorageSync('billNo')) {
let billNo = uni.getStorageSync('billNo')
this.$u.get(`/app/bill/recharge/${billNo}/bluetoothSuccess`).then((res) => {
@ -415,7 +425,7 @@
});
}
}
}, 2000);
}, 1000);
},
onPullDownRefresh() {
this.logins();
@ -425,6 +435,17 @@
},
methods: {
offdevice(deviceId){
this.$u.put(`/app/device/tenant/unbind/${deviceId}`).then((res) => {
if(res.code==200){
this.logins();
}
// console.log(this.deviceInfo,'this.deviceInfo');
});
},
tocz() {
this.showtip = false
uni.navigateTo({
@ -485,30 +506,33 @@
});
},
opendevice() {
let stause = 0
if (this.deviceInfo.powerStatus == 1) {
stause = 0
} else {
stause = 1
}
console.log(stause, 'stausestause');
this.$u.put(`/app/device/${this.deviceInfo.deviceId}/changePower?status=` + stause).then((res) => {
// this.$forceUpdate()
if (res.code == 200) {
// this.groupList=res.rows
setTimeout(() => {
this.getdevice()
}, 2000)
// this.loadings=true
// this.initChart()
if(this.deviceInfo.deviceId){
let stause = 0
if (this.deviceInfo.powerStatus == 1) {
stause = 0
} else {
uni.showToast({
title: res.msg,
icon: 'none'
});
stause = 1
}
});
console.log(stause, 'stausestause');
this.$u.put(`/app/device/${this.deviceInfo.deviceId}/changePower?status=` + stause).then((res) => {
// this.$forceUpdate()
if (res.code == 200) {
// this.groupList=res.rows
setTimeout(() => {
this.getdevice()
}, 2000)
// this.loadings=true
// this.initChart()
} else {
uni.showToast({
title: res.msg,
icon: 'none'
});
}
});
}
},
getgroup() {
// this.isLoading=true
@ -570,8 +594,26 @@
onlyFromCamera: true,
scanType: ['qrCode'],
success: res => {
console.log('扫描结果:', res);
this.qrResult = res.result; //
let qParam = res.result;
// 2: URLq
let decodedUrl = decodeURIComponent(qParam);
// 3: 使URL
let sn = null;
let queryParams = decodedUrl.split('?')[1];
if (queryParams) {
let params = queryParams.split('&');
params.forEach(param => {
let [key, value] = param.split('=');
if (key === 'sn') {
sn = value;
}
});
}
uni.navigateTo({
url:'/pages/device/joinDevice?mac='+sn
})
},
fail: err => {
console.error('扫描失败:', err);

View File

@ -11,7 +11,7 @@
</view>
<view class="right">
<image class="img1" src="https://api.ccttiot.com/smartmeter/img/static/uGvS4RQvbw7OOfhzy6xf"
mode="" style="margin-right: 30rpx;" @click="opendevices"></image>
mode="" style="margin-right: 30rpx;" @click="opendevice"></image>
<image class="img1" src="https://api.ccttiot.com/smartmeter/img/static/uNEKwe2WKsJdtQzOdEay"
mode="" @click="toewm()"></image>
</view>
@ -95,7 +95,7 @@
</view>
<view class="card3">
<view class="tit">其他</view>
<view class="cont_box">
<view class="cont_box" style="padding-left: 50rpx;" >
<!-- <view class="cont" style="width: 56rpx;" @click="topage(0)">
<view class="top">
<image src="https://api.ccttiot.com/smartmeter/img/static/uj4DT6WructS782RY0J7" mode="" style="width: 58rpx;height: 56rpx;" ></image>
@ -138,10 +138,36 @@
</view>
</view>
<view class="cont_box" style="padding-left: 30rpx;">
<view class="cont_box" style="justify-content: flex-start;margin-left: -20rpx;" >
<view class="cont" style="width: 115rpx;" @click="showpopup=true">
<view class="top">
<image src="https://api.ccttiot.com/smartmeter/img/static/uVrCrCViHDwZ8eOFB2dP" mode=""
style="width: 58rpx;height: 58rpx;"></image>
</view>
<view class="bot">添加电量</view>
</view>
</view>
</view>
<u-popup v-model="showpopup" mode="center" border-radius='20'>
<view class="popcard" v-if="showpopup">
<view class="tit">
充值电量
</view>
<view class="ipt">
<u-input v-model="money" placeholder=" " border='surround' placeholder-style='font-size: 24rpx;' />
</view>
<view class="btnbox">
<view class="btn2" @click="showpopup=false">
取消
</view>
<view class="btn1" @click="addele()">
确定
</view>
</view>
</view>
</u-popup>
<!-- <view class="button">电费充值</view> -->
<!-- <view class="zhanwei" style="width: 100%;height: 300rpx;">
@ -179,8 +205,10 @@
"水表",
],
showpopup:false,
curtitidx: 0,
id: ''
id: '',
money:''
}
@ -188,7 +216,7 @@
onLoad(option) {
setTimeout(() => {
console.log(this.$refs)
this.$refs.canvas.init(this.initChart)
}, 1000)
let id = option.id
this.id = id
@ -201,11 +229,25 @@
},
methods: {
addele(){
this.$u.post(`/app/device/addElectricity/${this.id}?amount=` + this.money).then((res) => {
// this.$forceUpdate()
if (res.code == 200) {
this.showpopup=false
this.getDevice(this.id)
}else{
uni.showToast({
title: res.msg,
icon: 'none'
});
}
});
},
initChart(canvas, width, height, canvasDpr) {
let that = this
console.log(canvas, width, height, canvasDpr)
let value = 100;
let value2 = this.deviceInfo.totalElectriQuantity
let value2 = this.deviceInfo.surplusElectriQuantity
const option = {
// backgroundColor:"#061740",
// title: {
@ -331,7 +373,7 @@
this.deviceInfo = res.data
console.log(this.deviceInfo, 'resres');
this.loadings = true
this.initChart()
this.$refs.canvas.init(this.initChart)
}
});
@ -348,10 +390,7 @@
// this.$forceUpdate()
if (res.code == 200) {
// this.groupList=res.rows
setTimeout(() => {
this.getDevice(this.id)
}, 2000)
this.getDevice(this.id)
// this.loadings=true
// this.initChart()
} else {
@ -362,9 +401,9 @@
}
});
},
opendevices() {
// opendevices() {
},
// },
swiperchange(e) {
this.curtitidx = e.detail.current
console.log(e, 'aaaa');
@ -435,6 +474,72 @@
}
.page {
.popcard{
display: flex;
justify-content: center;
flex-wrap: wrap;
// padding: 40rpx;
width: 550rpx;
height: 400rpx;
border-radius: 20rpx;
.tit{
display: flex;
justify-content: center;
width: 100%;
align-items: center;
font-size: 28rpx;
font-weight: 700;
}
.ipt{
margin-top: 60rpx;
width: 80%;
// width: 60%;
.u-input::placeholder {
font-size: 20px;
color: red;
}
}
.btnbox{
width: 100%;
display: flex;
flex-wrap: nowrap;
border-radius: 0 0 20rpx 20rpx;
.btn2{
display: flex;
align-items: center;
justify-content: center;
width: 50%;
// justify-content: center;
// width: 200rpx;
// height: 70rpx;
// border-radius: 20rpx;
font-size: 32rpx;
font-family: HarmonyOS Sans SC, HarmonyOS Sans SC;
font-weight: 400;
color: #FFFFFF;
background-color: #2A82E4;
}
.btn1{
display: flex;
align-items: center;
justify-content: center;
width: 50%;
// justify-content: center;
// width: 200rpx;
// height: 70rpx;
// border-radius: 20rpx;
font-size: 32rpx;
font-family: HarmonyOS Sans SC, HarmonyOS Sans SC;
font-weight: 400;
color: #000;
background-color: #fff;
border: 1rpx solid #ccc;
}
}
}
.zhuhu {
margin-top: 20rpx;
padding: 0 40rpx;

View File

@ -8,9 +8,10 @@
备注
</view>
<view class="info">
<view class="txt">
<view class="txt" v-if="deviceInfo.remark">
{{deviceInfo.remark}}
</view>
<view class="iconfont icon-xiangyou1"></view>
</view>
</view>
@ -247,7 +248,7 @@
duration: 2000
});
uni.navigateBack({
delta: 1 //
delta: 2 //
});
}

View File

@ -172,7 +172,7 @@
year: this.yeartime.year,
month: this.yeartime.month,
groupBy: 'create_day'
groupBy: 'create_date'
}
this.loging=false
this.$u.get('app/bill/landlordCount', data).then((res) => {
@ -543,8 +543,9 @@
}
.page {
padding: 0 59rpx;
padding-bottom: 150rpx;
.title {
margin-top: 120rpx;
font-size: 48rpx;

View File

@ -104,19 +104,20 @@ export default {
switch (options.type) {
case xBlufi.XBLUFI_TYPE.TYPE_STATUS_CONNECTED:
{
console.log('状态', options.result)
uni.showModal({
title: '很抱歉提醒你!',
content: '小程序与设备异常断开',
showCancel: false,
success: function (res) {
// uni.navigateBack({
// url: '../search/search'
// });
}
});
this.statusflag = false
uni.hideLoading();
if( options.result==false){
uni.showModal({
title: '很抱歉提醒你!',
content: '小程序与设备异常断开',
showCancel: false,
success: function(res) {
// uni.navigateBack({
// url: '../search/search'
// });
}
});
this.statusflag = false
uni.hideLoading();
}
}
break;

View File

@ -1145,7 +1145,7 @@ function init() {
// && devices.devices[0].name != 'SMART_R2XS'
// && devices.devices[0].name != 'SMART_R2XS'
// )
if (devices.devices[0].name.indexOf("CTPOW") != -1){
if (devices.devices[0].name.indexOf("CTKG") != -1||devices.devices[0].name.indexOf("CTPO") != -1){
// console.log("跳过",devices.devices[0].name)
// isnotexist = false;
isnotexist = true;