This commit is contained in:
3321822538@qq.com 2025-02-21 11:18:15 +08:00
parent 673e057684
commit 7242e801cc
7 changed files with 147 additions and 253 deletions

View File

@ -16,7 +16,7 @@ const install = (Vue, vm) => {
// },
// });
Vue.prototype.$u.http.setConfig({
// baseUrl: 'http://192.168.1.6:10002',
// baseUrl: 'http://192.168.2.83:10002',
baseUrl: 'https://kg.chuangtewl.com/prod-api',
// loadingText: '加载中...',
// loadingTime: 1000,

View File

@ -95,10 +95,10 @@
align-items: center;
justify-content: space-around;
.tab{
width: 44rpx;
display: flex;
flex-wrap: wrap;
justify-content: center;
width: 100rpx;
height: 100rpx;
display: block;
text-align: center;
image{
width: 40rpx;
height: 40rpx;

View File

@ -1,7 +1,8 @@
<template>
<view class="page">
<u-navbar :title="tittxt" :border-bottom="false" :background="bgc" back-icon-color="#000" title-color='#000'
title-size='36' height='50' id="navbar" :custom-back="btns">
title-size='36' height='50' id="navbar" >
<!-- :custom-back="btns" -->
</u-navbar>
<view class="zhuhu">
<view class="card1">
@ -31,7 +32,7 @@
<text style="color: #8883F0;border: 1px solid #8883F0;padding: 2rpx 8rpx;box-sizing: border-box;border-radius: 10rpx;">{{deviceInfo.storeName.length > 5 ? deviceInfo.storeName.slice(0,5) + '...' : deviceInfo.storeName}}</text>
</div>
</view>
<view v-if="deviceInfo.onlineStatus==0" style="font-size: 28rpx;color: #95989D;margin-top: 18rpx;">
<view style="font-size: 28rpx;color: #95989D;margin-top: 18rpx;">
<view style="display: flex;align-items: center;">
<image style="width: 38rpx;height: 38rpx;margin-right: 10rpx;" src="https://api.ccttiot.com/smartmeter/img/static/uFCAaWnRnqQK4SwPp7dm" mode=""></image>
<text style="color: #00BA88;" v-if="ver_dataflag == 3">蓝牙已连接</text>
@ -221,7 +222,7 @@
<image style="width: 44rpx;height: 44rpx;"
src="https://api.ccttiot.com/smartmeter/img/static/uOUM2aclDz2ZnRxOll9g" mode="aspectFit">
</image>
<view class="bot">设置</view>
<view class="bot">固件升级</view>
</view>
</view> -->
</view>
@ -412,7 +413,6 @@
path: '/pages/shouye/index'
}
},
//
onShareTimeline: function() {
return {
@ -585,15 +585,6 @@
url:'/pages/index/index'
})
},
groupChange(n) {
console.log('groupChange', n);
},
radioChange(n) {
console.log('radioChange', n);
},
//
btnshdd(){
uni.navigateTo({
@ -644,34 +635,28 @@
}
})
},
//
btnfirmware(){
uni.navigateTo({
url:'/pages/daili/gujian'
})
},
//
btnxzdw(){
this.showflag = true
console.log(1);
},
//
btnconfirm(e) {
console.log(e);
console.log(e)
this.danwei = e[0].label
this.damweiid = e[0].value
},
drawCanvas() {
const ctx = uni.createCanvasContext('qrcode', this)
ctx.setFillStyle('#fff')
ctx.fillRect(10, 10, 250, 250)
ctx.draw();
ctx.draw()
},
//
saveCanvas() {
@ -708,7 +693,6 @@
this.shibaiflag = false
this.bluetoothflag = false
},
//
btnkq() {
if(this.deviceInfo.allowSwitch == true){
@ -821,9 +805,8 @@
if (res.code == 200) {
this.token = res.token
}
});
})
},
//
btnpic() {
uni.chooseImage({
@ -893,7 +876,7 @@
console.log(that.modelId,'...........')
that.modelId.some(item => {
if(item == 2){
console.log('配网');
console.log('配网')
let zuih = ''
if(that.deviceId.slice(-1) == 8){
zuih = 'A'
@ -923,7 +906,7 @@
name: that.name
})
}else{
console.log('无配网');
console.log('无配网')
xBlufi.notifyStartDiscoverBle({
'isStart': false
})
@ -939,50 +922,6 @@
} else if (systemInfo.platform == 'ios') {
// iOS
that.findDevice()
// var falg = 0
// console.log("IOS")
// this.devicesarr.forEach(device => {
// console.log(device.name,that.qrResult, '111')
// console.log("IOSMAC",device)
// console.log("device.name",device.name)
// console.log("that.qrResult",that.qrResult)
// if (device.name.slice(-12) == that.qrResult.slice(-12)) {
// that.deviceId = device.deviceId
// console.log(that.deviceId, '11221');
// falg = 1;
// xBlufi.notifyStartDiscoverBle({
// 'isStart': false
// })
// xBlufi.notifyConnectBle({
// isStart: true,
// deviceId: device.deviceId,
// name: device.name
// })
// }
// })
// if(falg==0){
// setTimeout(()=>{
// this.devicesarr.forEach(device => {
// console.log(device.name, that.qrResult, '111')
// console.log("IOSMAC",device)
// console.log("device.name",device.name)
// console.log("that.qrResult",that.qrResult)
// if (device.name.slice(-12) == that.qrResult.slice(-12)) {
// that.deviceId = device.deviceId
// console.log(that.deviceId, '11221');
// falg = 1;
// xBlufi.notifyStartDiscoverBle({
// 'isStart': false
// })
// xBlufi.notifyConnectBle({
// isStart: true,
// deviceId: device.deviceId,
// name:device.name
// })
// }
// })
// },3000)
// }
}
}
}
@ -1020,8 +959,8 @@
this.qrResult = res.data.mac
this.modelId = res.data.modelTags
this.deviceId = res.data.mac.match(/.{2}/g).reverse().join(':')
console.log(this.deviceId,'02022');
if (res.data.onlineStatus == 0) { //线
console.log(this.deviceId,'02022')
if (this.ver_dataflag != 3) { //线
this.getlanya()
}
this.storeId = res.data.storeId
@ -1036,11 +975,10 @@
this.timeday = 0
} else {
let expireTimeStr = this.deviceInfo.expireTime
let expireTimeParts = expireTimeStr.split(" ");
let expireDateParts = expireTimeParts[0].split("-");
let expireTimePartsTime = expireTimeParts[1].split(":");
let expireDate = new Date(expireDateParts[0], expireDateParts[1] - 1, expireDateParts[
2], expireTimePartsTime[0], expireTimePartsTime[1], expireTimePartsTime[2])
let expireTimeParts = expireTimeStr.split(" ")
let expireDateParts = expireTimeParts[0].split("-")
let expireTimePartsTime = expireTimeParts[1].split(":")
let expireDate = new Date(expireDateParts[0], expireDateParts[1] - 1, expireDateParts[2], expireTimePartsTime[0], expireTimePartsTime[1], expireTimePartsTime[2])
let now = new Date()
let differenceInMs = expireDate - now
if (differenceInMs <= 0) {
@ -1082,10 +1020,10 @@
} else {
// 0
clearInterval(this.timer)
this.timer = null;
this.timer = null
// console.log('')
}
}, 1000); //
}, 1000) //
},
//
formatMilliseconds(milliseconds) {
@ -1105,7 +1043,6 @@
seconds: seconds
}
},
//
topage(num) {
this.btnmsk = true
@ -1137,7 +1074,6 @@
that.imgflag = false
that.tdtxt = '关闭'
},1000)
// that.getshuax()
} else if (res.code == 500) {
uni.showToast({
title: res.msg,
@ -1172,34 +1108,34 @@
if (res.confirm) {
that.btnmsk = false
setTimeout(() => {
that.deviceInfo.status = 1
that.imgflag = false
that.tdtxt = '关闭'
that.timeday = 0
xBlufi.notifySendCustomData({
customData: 'time0@'
})
xBlufi.notifySendCustomData({
customData: 'mmney0@'
})
xBlufi.notifySendCustomData({
customData: '11time0@'
})
xBlufi.notifySendCustomData({
customData: '11mmney0@'
})
let data = {
mac:that.qrResult,
reason:'归零',
command:'@time0@mmney0close',
result:'成功'
}
that.$u.post(`/app/commandLog/bluetooth`,data).then(res => {})
uni.showToast({
title: '归零成功',
icon: 'success',
duration: 2000
})
that.deviceInfo.status = 1
that.imgflag = false
that.tdtxt = '关闭'
that.timeday = 0
xBlufi.notifySendCustomData({
customData: 'time0@'
})
xBlufi.notifySendCustomData({
customData: 'mmney0@'
})
xBlufi.notifySendCustomData({
customData: '11time0@'
})
xBlufi.notifySendCustomData({
customData: '11mmney0@'
})
let data = {
mac:that.qrResult,
reason:'归零',
command:'@time0@mmney0close',
result:'成功'
}
that.$u.post(`/app/commandLog/bluetooth`,data).then(res => {})
uni.showToast({
title: '归零成功',
icon: 'success',
duration: 2000
})
}, 1000)
}
}
@ -1216,11 +1152,20 @@
uni.navigateTo({
url: "/page_fenbao/statulist/taocanlist/index?id=" + this.id + '&modevalue=' + 1
})
} else if (num == 4) { //
} else if (num == 4) { //
this.btnmsk = false
uni.navigateTo({
url: '/page_user/setting?id=' + this.id
})
if(this.ver_dataflag != 3){
uni.showToast({
title: '请在蓝牙连接的情况下进行',
icon: 'none',
duration: 2000
})
}else{
console.log(11);
}
// uni.navigateTo({
// url: '/page_user/setting?id=' + this.id
// })
} else if (num == 5) {
this.btnmsk = false
let that = this
@ -1273,14 +1218,12 @@
if (systemInfo.platform == 'android') {
// Android
uni.navigateTo({
url: '/page_components/wifilist/index?deviceId=' + that
.qrResult + '&name=' + that.name + '&wifi=' + that.deviceInfo.wifi + '&id=' + that.id
url: '/page_components/wifilist/index?deviceId=' + that.qrResult + '&name=' + that.name + '&wifi=' + that.deviceInfo.wifi + '&id=' + that.id
})
} else if (systemInfo.platform == 'ios') {
// iOS
uni.navigateTo({
url: '/page_fenbao/device/wifivideo?deviceId=' + that
.qrResult + '&name=' + that.name + '&wifi=' + that.deviceInfo.wifi + '&id=' + that.id
url: '/page_fenbao/device/wifivideo?deviceId=' + that.qrResult + '&name=' + that.name + '&wifi=' + that.deviceInfo.wifi + '&id=' + that.id
})
}else{
uni.showToast({
@ -1292,7 +1235,7 @@
}
},
fail: (err) => {
console.error('获取位置失败:', err);
console.error('获取位置失败:', err)
uni.showToast({
title: '位置信息未打开,无法配网,请授权后重试',
icon: 'none',
@ -1302,15 +1245,14 @@
})
},
fail: function (err) {
console.error('蓝牙适配器初始化失败', err);
console.error('蓝牙适配器初始化失败', err)
//
uni.showToast({
title: '手机蓝牙未打开',
icon: 'none'
});
})
}
})
} else if (num == 6) {
uni.pageScrollTo({
scrollTop: 0,//0
@ -1340,7 +1282,6 @@
icon: 'success',
duration: 2000
})
// this.getshuax()
setTimeout(() => {
this.getshuax()
this.cztime = ''
@ -1446,16 +1387,10 @@
case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS:
if (options.result) {
this.devicesarr = options.data
// devicesarr.forEach(device => {
// // this.devicesList.push(device);
// // let uniqueDevicesList = Array.from(new Set(this.devicesList));
// // // this.devicesList
// // this.devicesList = uniqueDevicesList;
// })
}
break;
break
case xBlufi.XBLUFI_TYPE.TYPE_CONNECTED:
console.log("连接回调:" + JSON.stringify(options));
console.log("连接回调:" + JSON.stringify(options))
if (options.result == true) {
setTimeout(()=>{
this.ver_dataflag = 3
@ -1464,54 +1399,26 @@
deviceId: options.data.deviceId
})
}else{
// this.ver_dataflag = 2
// this.getlanya()
}
break;
break
case xBlufi.XBLUFI_TYPE.TYPE_RECIEVE_MY_DATA:
console.log("文件读取中", options.data);
break;
console.log("文件读取中", options.data)
break
case xBlufi.XBLUFI_TYPE.TYPE_RECIEVE_CUSTON_DATA:
// this.setMode = this.parseCustomData(options.data)
this.ver_dataflag = 3
console.log("1收到设备发来的自定义数据结果", options.data);
break;
console.log("1收到设备发来的自定义数据结果", options.data)
break
case xBlufi.XBLUFI_TYPE.TYPE_INIT_ESP32_RESULT:
if (options.result) {
console.log('初始化成功');
console.log('初始化成功')
} else {
console.log('初始化失败');
break;
console.log('初始化失败')
break
}
break;
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;
},
}
}
</script>

View File

@ -15,8 +15,6 @@
</view>
<input type="text" class="ips" v-model="storeId" placeholder="请扫描设备上的二维码" style="margin-left: 32rpx;"
placeholder-class="my-placeholder"/>
<!-- <input type="text" class="ips" v-model="storeIds" v-if="storeIds" placeholder="请扫描设备上的二维码" style="margin-left: 32rpx;"
placeholder-class="my-placeholder" /> -->
</view>
<view class="machao">
MAC号{{obj.mac == undefined ? '--' : obj.mac}}
@ -330,7 +328,6 @@
},
//
btnsx() {
this.$u.get(`/app/device/v2/refreshIot?deviceNo=${this.storeId}`).then((res) => {
if (res.code == 200) {
this.getsn()

View File

@ -35,8 +35,8 @@
</view>
<view class="" style="display: flex;">
<view class="fd_da">
<view class="fd_lt"
:style="{ transform: `translateX(${-curtitidx * 100 > -300 ? 0 : -curtitidx * 120}rpx)`}">
<view class="fd_lt">
<!-- :style="{ transform: `translateX(${hua == 2 ? -curtitidx * 120 : curtitidx * 120}rpx)`}" -->
<view class="fd_tit" v-for="(item,index) in groupLists" :key="index"
:class="index==curtitidx?'act1':''" @click="changeidx(index)">
{{item.name.length > 5 ? item.name.slice(0, 5) + '...' : item.name}}
@ -115,22 +115,24 @@
</view>
<view class="card_left">
<view class="card_left_tit" @click="todetail(item.deviceId)">
{{item.deviceName.length > 4 ? item.deviceName.slice(0, 4) + '...' : item.deviceName}}
{{item.deviceName}}
<view class="card_left_sta" @click="todetail(item.deviceId)">
<text v-if="item.modelTags.some(tag => tag == 1)" style="margin-left: 20rpx;">
<text v-if="item.modelTags.some(tag => tag == 1)" style="margin-left: 20rpx;background-color: #0f5fe4d4;border: 1px solid #0f5fe4d4;">
蓝牙
</text>
<text v-if="item.modelTags.some(tag => tag == 2)">
WIFi
<text v-if="item.modelTags.some(tag => tag == 2) && item.onlineStatus1 == 1">
WiFi
</text>
<text v-if="item.modelTags.some(tag => tag == 3)">
<text v-if="item.modelTags.some(tag => tag == 2) && item.onlineStatus1 == 0" style="background-color: #ccc;border: 1px solid #ccc;">
WiFi
</text>
<text v-if="item.modelTags.some(tag => tag == 3) && item.onlineStatus1 == 1 || item.modelTags.some(tag => tag == 3) && item.onlineStatus2 == 1">
4G
</text>
<text v-if="item.modelTags.some(tag => tag == 3) && item.onlineStatus1 == 0 || item.modelTags.some(tag => tag == 3) && item.onlineStatus1 == 0" style="background-color: #ccc;border: 1px solid #ccc;">
4G
</text>
<text v-if="item.wifi == null && !item.modelTags.some(tag => tag == 3) && !item.modelTags.some(tag => tag == 1)" style="background-color: red;color: #fff;border: 1px solid red;">未配网</text>
<span style="display: flex;align-items: center;"v-if="item.wifi != null || item.modelTags.some(tag => tag == 3) || !item.modelTags.some(tag => tag == 1)">
<text v-if="item.onlineStatus == 0" style="background-color: red;color: #fff;border: 1px solid red;">离线</text>
<text v-else style="background-color: #00BA88;color: #fff;border: 1px solid #00BA88;">在线</text>
</span>
</view>
</view>
<view class="sta_txt" v-if="item.status==3" style="color:#fff;background-color: red;">
@ -326,11 +328,49 @@
deviceNo: '',
btnmsk:false,
pxzt:'onlineStatus',
pxflag:true
pxflag:true,
hua:''
}
},
onLoad() {
this.pagenum = 1
this.getgroup()
this.getlist()
this.deviceId = uni.getStorageSync('deviceIds')
this.name = uni.getStorageSync('name')
let that = this
setTimeout(() => {
if (this.userType === '01') { // '01'
if (uni.getStorageSync('mac')) {
this.mac = uni.getStorageSync('mac')
uni.getLocation({
type: 'wgs84',
success: function(lb) {
that.gps.lat = lb.latitude
that.gps.lon = lb.longitude
that.tobind()
},
fail: function(error) {
console.error('获取位置信息失败:', error)
that.gps.lat = 0
that.gps.lon = 0
that.tobind()
}
})
}
} else {
if (uni.getStorageSync('billNo')) {
let billNo = uni.getStorageSync('billNo')
this.$u.get(`/app/bill/recharge/${billNo}/bluetoothSuccess`).then((res) => {
if (res.code == 200) {
uni.removeStorageSync('billNo')
this.showtip = false
this.order()
}
})
}
}
}, 2000);
},
onShow() {
if(uni.getStorageSync('lianjie')){
@ -338,48 +378,6 @@
key: 'lianjie'
})
}
// this.gettanc()
this.pagenum = 1
// this.curtitidx = 0
// this.wateringList = []
// this.logins()
this.getgroup()
this.getlist()
this.deviceId = uni.getStorageSync('deviceIds')
this.name = uni.getStorageSync('name')
let that = this
setTimeout(() => {
if (this.userType === '01') { // '01'
if (uni.getStorageSync('mac')) {
this.mac = uni.getStorageSync('mac')
uni.getLocation({
type: 'wgs84',
success: function(lb) {
that.gps.lat = lb.latitude
that.gps.lon = lb.longitude
that.tobind()
},
fail: function(error) {
console.error('获取位置信息失败:', error)
that.gps.lat = 0
that.gps.lon = 0
that.tobind()
}
})
}
} else {
if (uni.getStorageSync('billNo')) {
let billNo = uni.getStorageSync('billNo')
this.$u.get(`/app/bill/recharge/${billNo}/bluetoothSuccess`).then((res) => {
if (res.code == 200) {
uni.removeStorageSync('billNo')
this.showtip = false
this.order()
}
})
}
}
}, 2000);
},
//
onShareAppMessage: function() {
@ -402,7 +400,7 @@
pxconfirm(e){
this.pxshow = false
this.paixutxt = e.label
this.pxdaoxu = e.value
this.pxzt = e.value
this.pagenum = 1
this.getlist()
},
@ -803,8 +801,10 @@
if (Math.abs(deltaX) > 50 && Math.abs(deltaX) > Math.abs(deltaY)) {
if (deltaX >= 0) {
// console.log("")
this.hua = 1
} else {
// console.log("")
this.hua = 2
}
} else if (Math.abs(deltaY) > 50 && Math.abs(deltaX) < Math.abs(deltaY)) {
if (deltaY < 100) {
@ -1069,24 +1069,16 @@
})
},
getlist() {
this.shujuflag = false
// if (this.storeId == null) {
this.$u.get(`/app/device/list?pageNum=${this.pagenum}&pageSize=${this.pagesize}&orderByColumn=${this.pxzt}&isAsc=${this.pxdaoxu}&storeId=${this.storeId == null ? '' : this.storeId}&keyword=${this.keyword}`).then((res) => {
if (res.code == 200) {
this.xiaflag = true
this.shuaxin = false
this.total = res.total
if (res.rows.length > 0) {
//
this.shujuflag = false
} else {
//
this.shujuflag = true
}
console.log(res.rows.length,'0202020202020202');
if (this.pagenum > 1) {
this.pagenum++
this.wateringList = res.rows
this.shujuflag = false
this.qingqiuflag = true
this.groupLists.forEach(groupItem => {
groupItem.wateringList
@ -2072,23 +2064,21 @@
}
.fd_da {
width: 440rpx;
overflow: hidden;
overflow-x: auto;
overflow: hidden;
overflow: scroll;
white-space: nowrap;
-ms-overflow-style: none;
/* 去除IE和Edge的默认滚动条 */
scrollbar-width: none;
/* 去除Firefox的默认滚动条 */
&::-webkit-scrollbar {
display: none;
}
.fd_lt {
display: flex;
transition: transform 0.3s ease;
padding-top: 10rpx;
.fd_tit {
text-align: center;
padding: 0 15rpx;

View File

@ -179,17 +179,17 @@
success: function(res) {
if (res.confirm) {
try {
const storageInfo = uni.getStorageInfoSync();
const keys = storageInfo.keys; //
const storageInfo = uni.getStorageInfoSync()
const keys = storageInfo.keys //
keys.forEach(key => {
uni.removeStorageSync(key); //
uni.removeStorageSync(key) //
});
console.log('所有本地存储已删除');
console.log('所有本地存储已删除')
uni.reLaunch({
url:'/pages/login/login'
})
} catch (e) {
console.error('删除本地存储时发生错误:', e);
console.error('删除本地存储时发生错误:', e)
}
}
}

View File

@ -275,8 +275,8 @@
this.revenuelist.push(item.incomeAmount)
this.quantitylist.push(item.orderCount)
})
console.log('营收',this.revenuelist);
console.log('订单',this.quantitylist);
console.log('营收',this.revenuelist)
console.log('订单',this.quantitylist)
this.$refs.canvas.init(this.initChart)
}
})