diff --git a/common/http.interceptor.js b/common/http.interceptor.js
index ee90c50..24c7385 100644
--- a/common/http.interceptor.js
+++ b/common/http.interceptor.js
@@ -19,8 +19,8 @@ const install = (Vue, vm) => {
// },
// });
Vue.prototype.$u.http.setConfig({
- // baseUrl: 'http://192.168.2.143:10002',
- baseUrl: 'https://kg.chuangtewl.com/prod-api',
+ baseUrl: 'http://192.168.2.143:10002',
+ // baseUrl: 'https://kg.chuangtewl.com/prod-api',
// loadingText: '努力加载中~',
// loadingTime: 1000,
// 设置自定义头部content-type
diff --git a/page_components/bindsz.vue b/page_components/bindsz.vue
index 29e75f0..a6096db 100644
--- a/page_components/bindsz.vue
+++ b/page_components/bindsz.vue
@@ -16,17 +16,20 @@
-
+
-
+
+ 上传设备主图
+
@@ -961,7 +964,7 @@
.imgbox {
width: 250rpx;
height: 250rpx;
- // background: #EDEDED;
+ background: #EDEDED;
border-radius: 10rpx 10rpx 10rpx 10rpx;
image {
diff --git a/page_components/eletj.vue b/page_components/eletj.vue
index 606466e..769dc0e 100644
--- a/page_components/eletj.vue
+++ b/page_components/eletj.vue
@@ -1,61 +1,203 @@
+ :custom-back="btns" title-size='36' height='50' id="navbar">
-
-
-
-
- 设备
-
-
-
-
+
+
+
+
+ --
-
-
-
-
-
-
-
-
-
- {{ deviceInfo.deviceName == null ? '' : deviceInfo.deviceName }}
-
- 更新时间:{{deviceInfo.lastPullTime == null ? '--' : deviceInfo.lastPullTime}}
-
-
-
- S/N码:{{ deviceInfo.deviceNo == null ? '' : deviceInfo.deviceNo }}
- 在线
- 离线
- 空闲
- 使用中
- 维修中
-
-
+
+ --
-
+
+ --
-
-
-
-
- 剩余时长:{{formattedTime}}
-
-
+
+
+ 电压(V)
-
-
+
+ 电流(A)
+
+
+ 功率(W)
+
+
+
+ 点击刷新实时信息
+
-
+
+
+
+
+
+ 已结束
+
+
+ {{timeDifferenceString == '' ? '1分' : timeDifferenceString}}
+ {{du}}度
+ {{formattedTime}}
+
+
+ ¥{{detaobj.money}}
+
+
+ ¥{{feeprice}} ¥{{detaobj.suitPrice == null ? '--' : detaobj.suitPrice}}
+
+
+
+
+ 使用时长
+ 剩余时长
+
+
+ 预估金额,以实际金额为准
+ 金额
+
+
+
+
+
+ 价格明细
+
+
+
+ {{detaobj.suitTime == null ? '--' : detaobj.suitTime}}时 分钟
+ 秒
+ {{detaobj.suitTime}}度
+ 押金
+
+
+ {{detaobj.suitPrice == null ? '--' : detaobj.suitPrice}}元
+
+
+
+ 计价方式:计时收费
+ 按量收费
+ 分时段按量收费
+ 分时段按时收费
+
+
+
+
+
+ {{val}}元
+
+
+
+
+ {{timeindex + ':00'}}
+
+
+
+
+
+
+
+
+ 租借信息
+
+
+
+ 开始时间
+
+
+ {{detaobj.suitStartTime == null ? '--' : detaobj.suitStartTime}}
+
+
+
+
+ 店铺名称
+
+
+ {{detaobj.storeName == null ? '--' : detaobj.storeName}}
+
+
+
+
+ 详细地址
+
+
+ {{detaobj.storeAddress == null ? '--' : detaobj.storeAddress}}
+
+
+
+
+ 套餐名称
+
+
+ {{detaobj.suitName == null ? '--' : detaobj.suitName}}
+
+
+
+
+ 结束时间
+
+
+ {{detaobj.suitEndTime == null ? '--' : detaobj.suitEndTime}}
+
+
+
+
+ 设备编号
+
+
+ {{detaobj.deviceNo == null ?'--' : detaobj.deviceNo}}
+
+
+
+
+ 订单编号
+
+
+ {{detaobj.billNo == null ? '--' : detaobj.billNo}}
+
+
+
+
+
+
+ 立即支付
+ 结束订单
+
+
+ 立即支付
+ 结束订单
+
+
+
+
+
+
+ 您要提前结束此订单吗?
+
+
+ 当前预估消费金额为{{detaobj.money}}元,实际消费以实际金额为准
+
+
+
+ 取消
+
+
+ 确定
+
+
+
+
+
+
@@ -70,6 +212,7 @@
},
data() {
return {
+ trueboxfalg:false,
bgc: {
backgroundColor: "#8883f0",
},
@@ -99,225 +242,606 @@
storeId: '',
qrResult: '',
devicesList: [],
- setMode:null,
- vipflag:false,
- cztime:'',
- opflag:true,
- timer: null
+ setMode: null,
+ vipflag: false,
+ cztime: '',
+ opflag: '',
+ timer: null,
+ newArr: [],
+ detaobj: {},
+ timeDifferenceString: 0,
+ timerId: null,
+ sbid: '',
+ onlineStatus: '',
+ billId: '',
+ orderno: '',
+ jieshuflag: false,
+ feeprice: '',
+ temperature:'',
+ du:''
}
},
onLoad(option) {
let id = option.id
this.id = id
+ this.$u.put(`/app/bill/${this.id}/refreshPayResult`).then(res => {
+ this.getDevice()
+ })
// this.getDevice(id)
- if(option.flag){
- this.opflag = false
- }else{
- this.opflag = true
- }
-
+ // console.log(option);
+ if (option.flag) {
+ this.opflag = option.flag
+ }
},
computed: {
- formattedTime() {
- if (this.timeday.days > 0) {
- // 只展示天和小时
- return `${this.timeday.days}天${this.timeday.hours}小时`;
- } else if (this.timeday.hours > 0) {
- // 展示小时和分钟
- return `${this.timeday.hours}小时${this.timeday.minutes}分钟`;
- } else if (this.timeday.minutes > 0) {
- // 展示分钟和秒
- return `${this.timeday.minutes}分钟${this.timeday.seconds}秒`;
- } else {
- // 展示秒或0(如果秒也为0)
- return this.timeday.seconds > 0 ? `${this.timeday.seconds}秒` : '0';
- }
- }
- },
+ formattedTime() {
+ if (this.timeday.days > 0) {
+ // 只展示天和小时
+ return `${this.timeday.days}天${this.timeday.hours}小时`
+ } else if (this.timeday.hours > 0) {
+ // 展示小时和分钟
+ return `${this.timeday.hours}小时${this.timeday.minutes}分钟`
+ } else if (this.timeday.minutes > 0) {
+ // 展示分钟和秒
+ return `${this.timeday.minutes}分钟${this.timeday.seconds}秒`
+ } else {
+ // 展示秒或0(如果秒也为0)
+ return this.timeday.seconds > 0 ? `${this.timeday.seconds}秒` : '0'
+ }
+ }
+ },
// 分享到好友(会话)
- onShareAppMessage: function () {
- return {
- title: '创想物联',
- path: '/pages/shouye/index'
- }
- },
-
- // 分享到朋友圈
- onShareTimeline: function () {
- return {
- title: '创想物联',
- query: '',
- path: '/pages/shouye/index'
- }
- },
+ onShareAppMessage: function() {
+ return {
+ title: '创想物联',
+ path: '/pages/shouye/index'
+ }
+ },
+
+ // 分享到朋友圈
+ onShareTimeline: function() {
+ return {
+ title: '创想物联',
+ query: '',
+ path: '/pages/shouye/index'
+ }
+ },
onShow() {
setTimeout(() => {
- this.getDevice(this.id)
+ this.startTimers()
+ if (this.id) {
+ //判断有没有id 没有的话则直接返回首页
+ } else {
+ uni.reLaunch({
+ url: '/pages/shouye/index'
+ })
+ }
}, 100)
- this.getQiniuToken()
- },
- onUnload: function() {
- xBlufi.listenDeviceMsgEvent(false, this.funListenDeviceMsgEvent);
- xBlufi.notifyStartDiscoverBle({
- 'isStart': false
- });
- wx.closeBLEConnection({
- deviceId: this.objlist.deviceId,
- })
},
onHide() {
- xBlufi.listenDeviceMsgEvent(false, this.funListenDeviceMsgEvent);
- xBlufi.notifyStartDiscoverBle({
- 'isStart': false
- });
- wx.closeBLEConnection({
- deviceId: this.objlist.deviceId,
- })
- },
- onBeforeUnmount() {
- xBlufi.listenDeviceMsgEvent(false, this.funListenDeviceMsgEvent);
- xBlufi.notifyStartDiscoverBle({
- 'isStart': false
- });
- wx.closeBLEConnection({
- deviceId: this.objlist.deviceId,
- })
+ this.stopTimer();
},
beforeDestroy() {
- // 组件销毁前清除定时器,防止内存泄漏
- if (this.timer) {
- clearInterval(this.timer);
- this.timer = null;
- console.log('已销毁');
- }
- },
+ // 组件销毁前清除定时器,防止内存泄漏
+ if (this.timer) {
+ clearInterval(this.timer)
+ this.timer = null;
+ console.log('已销毁')
+ }
+ },
+ onUnload() {
+ this.stopTimer();
+ },
methods: {
- getQiniuToken() {
- this.$u.get("/common/qiniu/uploadInfo").then((res) => {
- if (res.code == 200) {
- this.token = res.token
- }
- });
+ btns() {
+ // if(this.opflag){
+ // uni.navigateBack()
+ // }else{
+ uni.reLaunch({
+ url: '/pages/shouye/index'
+ })
+ // }
},
- // btnpic(e) {
- // let _this = this
- // let math = 'static/' + _this.$u.guid(20)
- // const tempFilePaths = e.detail.avatarUrl
- // wx.uploadFile({
- // url: 'https://up-z2.qiniup.com',
- // name: 'file',
- // filePath: tempFilePaths,
- // formData: {
- // token: _this.token,
- // key: 'smartmeter/img/' + math
- // },
- // success: function(res) {
- // let str = JSON.parse(res.data)
- // console.log(str.key)
- // _this.userImgs = 'https://api.ccttiot.com/' + str.key
- // _this.imglist = _this.userImgs
- // _this.imgflag = false
- // let data = {
- // deviceId:_this.id,
- // customPicture:_this.imglist
- // }
- // _this.putdevice(data)
- // }
- // })
- // },
- putdevice(data) {
- this.$u.put('/app/device', data).then((res) => {
- if (res.code == 200) {
- uni.showToast({
- title: '修改成功',
- icon: 'success',
- duration: 2000
+ btnljzf(){
+ this.$u.get(`/app/pay/wx/${this.orderno}`).then((res) => {
+ if (res.code == 200) {
+ let that = this
+ uni.requestPayment({
+ provider: 'wxpay',
+ timeStamp: res.data.payParams.timeStamp,
+ nonceStr: res.data.payParams.nonceStr,
+ package: res.data.payParams.packageVal,
+ signType: res.data.payParams.signType,
+ paySign: res.data.payParams.paySign,
+ success: (res) => {
+ that.$u.put(
+ `/app/bill/${that.orderno}/refreshPayResult`
+ ).then(res => {})
+ // 支付成功逻辑
+ uni.showToast({
+ title: res.msg,
+ icon: 'success',
+ duration: 1000
+ })
+ setTimeout(() => {
+ that.jieshuflag = false
+ uni.reLaunch({
+ url: '/pages/shouye/index'
+ })
+ }, 1500)
+ },
+ fail(err) {
+ that.jieshuflag = false
+ // 支付失败逻辑
+ uni.showToast({
+ title: '支付失败',
+ icon: 'none',
+ duration: 2000
+ });
+ }
+ })
+ }
+ })
+ },
+ btnjieshu(){
+ this.trueboxfalg = true
+ },
+ btnbox() {
+ this.trueboxfalg = false
+ this.jieshuflag = true
+ if (this.onlineStatus == 1) {
+ if (this.detaobj.suitFeeType == 1 || this.detaobj.suitFeeType == 2) {
+ let data = {
+ billId: this.billId
+ }
+ this.$u.put(`/app/bill/endSmartUse`, data).then(res => {
+ if (res.code == 200) {
+ uni.showToast({
+ title: res.msg,
+ icon: 'success',
+ duration: 1000
+ })
+ setTimeout(() => {
+ this.jieshuflag = false
+ uni.reLaunch({
+ url: '/pages/shouye/index'
+ })
+ }, 1500)
+ } else {
+ this.getDevice()
+ this.jieshuflag = false
+ uni.showToast({
+ title: res.msg,
+ icon: 'none',
+ duration: 2000
+ })
+ }
})
} else {
- uni.showToast({
- title: res.msg,
- icon: 'none',
- duration: 2000
+ if (this.detaobj.status == 1) {
+ this.$u.get(`/app/pay/wx/${this.orderno}`).then((res) => {
+ if (res.code == 200) {
+ let that = this
+ uni.requestPayment({
+ provider: 'wxpay',
+ timeStamp: res.data.payParams.timeStamp,
+ nonceStr: res.data.payParams.nonceStr,
+ package: res.data.payParams.packageVal,
+ signType: res.data.payParams.signType,
+ paySign: res.data.payParams.paySign,
+ success: (res) => {
+ that.$u.put(`/app/bill/${that.orderno}/refreshPayResult`)
+ .then(res => {})
+ // 支付成功逻辑
+ uni.showToast({
+ title: res.msg,
+ icon: 'success',
+ duration: 1000
+ })
+ setTimeout(() => {
+ that.jieshuflag = false
+ uni.reLaunch({
+ url: '/pages/shouye/index'
+ })
+ }, 1500)
+ },
+ fail(err) {
+ that.getDevice()
+ that.jieshuflag = false
+ // 支付失败逻辑
+ uni.showToast({
+ title: '支付失败',
+ icon: 'none',
+ duration: 2000
+ });
+ }
+ })
+ }
+ })
+ } else {
+ let data = {
+ billId: this.billId
+ }
+ this.$u.put(`/app/bill/endTimingUse`, data).then(res => {
+ if (res.code == 200) {
+ this.$u.get(`/app/pay/wx/${this.orderno}`).then((res) => {
+ if (res.code == 200) {
+ let that = this
+ uni.requestPayment({
+ provider: 'wxpay',
+ timeStamp: res.data.payParams.timeStamp,
+ nonceStr: res.data.payParams.nonceStr,
+ package: res.data.payParams.packageVal,
+ signType: res.data.payParams.signType,
+ paySign: res.data.payParams.paySign,
+ success: (res) => {
+ that.$u.put(
+ `/app/bill/${that.orderno}/refreshPayResult`
+ ).then(res => {})
+ // 支付成功逻辑
+ uni.showToast({
+ title: res.msg,
+ icon: 'success',
+ duration: 1000
+ })
+ setTimeout(() => {
+ that.jieshuflag = false
+ uni.reLaunch({
+ url: '/pages/shouye/index'
+ })
+ }, 1500)
+ },
+ fail(err) {
+ that.jieshuflag = false
+ // 支付失败逻辑
+ uni.showToast({
+ title: '支付失败',
+ icon: 'none',
+ duration: 2000
+ });
+ }
+ })
+ }
+ })
+ } else {
+ this.getDevice()
+ this.jieshuflag = false
+ uni.showToast({
+ title: res.msg,
+ icon: 'none',
+ duration: 2000
+ })
+ }
+ })
+ }
+ }
+ } else {
+ console.log(this.temperature,'this.temperature');
+ if (this.temperature == '') {
+ uni.showLoading({
+ title: '切换中'
})
+ let that = this
+ xBlufi.initXBlufi(1);
+ xBlufi.listenDeviceMsgEvent(true, that.funListenDeviceMsgEvent);
+ xBlufi.notifyStartDiscoverBle({
+ 'isStart': true
+ })
+ setTimeout(() => {
+ xBlufi.notifyStartDiscoverBle({
+ 'isStart': false
+ })
+ if (that.devicesList.length > 0) {
+ xBlufi.notifyConnectBle({
+ isStart: true,
+ deviceId: that.deviceId,
+ name: that.name
+ })
+ }
+ }, 2000)
+ uni.showModal({
+ title: '温馨提示',
+ content: `检测到该设备未联网,为您切换为蓝牙模式,支付的时候靠近该设备,并打开蓝牙`,
+ showCancel: false,
+ success: function (res) {
+
+ }
+ })
+ }else{
+ if(this.detaobj.suitFeeType == 1 || this.detaobj.suitFeeType == 2){
+ let data = {
+ billId: this.billId,
+ totalEle:this.temperature
+ }
+ this.$u.put(`/app/bill/endSmartUse`, data).then(res => {
+ if (res.code == 200) {
+ uni.getNetworkType({
+ success(res) {
+ if (res.networkType !== 'none') {
+ uni.getConnectedBluetoothDevices({
+ success(res) {
+ setTimeout(()=> {
+ xBlufi.notifySendCustomData({
+ customData: 'close'
+ })
+ setTimeout(() => {
+ this.jieshuflag = false
+ uni.reLaunch({
+ url: '/pages/shouye/index'
+ })
+ },1000)
+ },1500)
+ },
+ fail(err) {
+ console.error('获取已连接蓝牙设备信息失败:',err)
+ }
+ })
+ } else {
+ console.log('手机未连接网络')
+ // this.baiflag = false
+ }
+ }
+ })
+ } else {
+ this.jieshuflag = false
+ uni.showToast({
+ title: res.msg,
+ icon: 'none',
+ duration: 2000
+ })
+ }
+ })
+ }else{
+ let data = {
+ billId: this.billId,
+ totalEle:this.temperature
+ }
+ this.$u.put(`/app/bill/endTimingUse`, data).then(res => {
+ if (res.code == 200) {
+ let that = this
+ uni.getNetworkType({
+ success(res) {
+ if (res.networkType !== 'none') {
+ uni.getConnectedBluetoothDevices({
+ success(res) {
+ setTimeout(()=> {
+ xBlufi.notifySendCustomData({
+ customData: 'close'
+ })
+ setTimeout(() => {
+ that.$u.get(`/app/pay/wx/${that.orderno}`).then((res) => {
+ if (res.code == 200) {
+
+ uni.requestPayment({
+ provider: 'wxpay',
+ timeStamp: res.data.payParams.timeStamp,
+ nonceStr: res.data.payParams.nonceStr,
+ package: res.data.payParams.packageVal,
+ signType: res.data.payParams.signType,
+ paySign: res.data.payParams.paySign,
+ success: (res) => {
+ that.$u.put(
+ `/app/bill/${that.orderno}/refreshPayResult`
+ ).then(res => {})
+ // 支付成功逻辑
+ uni.showToast({
+ title: res.msg,
+ icon: 'success',
+ duration: 1000
+ })
+ setTimeout(() => {
+ that.jieshuflag = false
+ uni.reLaunch({
+ url: '/pages/shouye/index'
+ })
+ }, 1500)
+ },
+ fail(err) {
+ that.jieshuflag = false
+ // 支付失败逻辑
+ uni.showToast({
+ title: '支付失败',
+ icon: 'none',
+ duration: 2000
+ });
+ }
+ })
+ }
+ })
+ },1000)
+ },1500)
+ },
+ fail(err) {
+ console.error('获取已连接蓝牙设备信息失败:',err)
+ }
+ })
+ } else {
+ console.log('手机未连接网络')
+ // this.baiflag = false
+ }
+ }
+ })
+ } else {
+ this.getDevice()
+ this.jieshuflag = false
+ uni.showToast({
+ title: res.msg,
+ icon: 'none',
+ duration: 2000
+ })
+ }
+ })
+ }
+
+ }
+ }
+
+ },
+
+ // 每一分钟请求更新一次
+ startTimers() {
+ // 确保没有重复的定时器
+ if (this.timerId !== null) {
+ clearInterval(this.timerId)
+ }
+ // 设置定时器,每分钟执行一次 timerCallback 函数
+ this.timerId = setInterval(this.getDevice, 60000)
+ },
+ // 销毁定时器
+ stopTimer() {
+ if (this.timerId !== null) {
+ clearInterval(this.timerId)
+ this.timerId = null
+ }
+ },
+ // 预估金额
+ getprice() {
+ this.$u.get(`app/bill/calcPrice?billId=${this.billId}`).then(res => {
+ if (res.code == 200) {
+ this.feeprice = res.data.toFixed(2)
}
})
},
// 获取设备详情
- getDevice(id) {
- this.$u.get("/app/device/" + id).then((res) => {
- // this.$forceUpdate()
+ getDevice() {
+ this.$u.get(`/app/bill/byNo/${this.id}`).then(res => {
if (res.code == 200) {
- this.deviceInfo = res.data
- this.storeId = res.data.storeId
- this.qrResult = 'CTKG-' + res.data.mac
- if (res.data.customPicture != null) {
- this.imglist = res.data.customPicture
- } else {
- this.imglist = res.data.picture
+ this.sbid = res.data.deviceId
+ this.getsb()
+ this.detaobj = res.data
+ this.billId = res.data.billId
+ this.orderno = res.data.billNo
+ this.getprice()
+ let dateTimeString = res.data.suitStartTime // 示例时间字符串
+ this.timeDifferenceString = this.calculateTimeDifference(dateTimeString); // 调用函数
+ // console.log(timeDifferenceString);
+ if (res.data.suitGearAmount.length > 0) {
+ this.newArr = []
+ for (let i = 0; i < res.data.suitGearTime.length; i++) {
+ let value = res.data.suitGearAmount[res.data.suitGearTime[i]];
+ this.newArr.push(value)
+ }
}
- if(this.deviceInfo.expireTime == null){
+ if(this.detaobj.suitEndEle){
+ let du = Number(this.detaobj.suitEndEle) - Number(this.detaobj.deviceTotalEle)
+ this.du = du.toFixed(2)
+ }
+ if (this.detaobj.suitExpireTime == null) {
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 now = new Date();
+ } else {
+ let expireTimeStr = this.detaobj.suitExpireTime
+ 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) {
this.timeday = 0
} else {
- this.timeday = this.formatMilliseconds(differenceInMs)
- this.startTimer()
+ if(this.timeday == ''){
+ this.timeday = this.formatMilliseconds(differenceInMs)
+ this.startTimer()
+ }
}
}
- this.loadings = true
}
})
},
+ getsb() {
+ this.$u.get(`/app/device/${this.sbid}`).then(res => {
+ if (res.code == 200) {
+ this.onlineStatus = res.data.onlineStatus
+ this.qrResult = res.data.mac
+ }
+ })
+ },
+
+ calculateTimeDifference(dateTimeString) {
+ // 将时间字符串转换为Date对象
+ const date = new Date(dateTimeString)
+ // 获取当前时间
+ const now = new Date()
+
+ // 计算时间差(毫秒)
+ const diff = now - date
+
+ // 将毫秒转换为天、小时、分钟和秒
+ const days = Math.floor(diff / (1000 * 60 * 60 * 24))
+ const hours = Math.floor((diff % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60))
+ const minutes = Math.floor((diff % (1000 * 60 * 60)) / (1000 * 60))
+ const seconds = Math.floor((diff % (1000 * 60)) / 1000)
+
+ // 创建一个对象来存储结果,并忽略零值
+ const timeDifference = {
+ days: days > 0 ? days : undefined,
+ hours: hours > 0 ? hours : undefined,
+ minutes: minutes > 0 ? minutes : undefined,
+ seconds: seconds > 0 ? seconds : undefined
+ };
+
+ // 转换为字符串,忽略未定义的属性
+ let result = ''
+ if (timeDifference.days !== undefined) {
+ result += `${timeDifference.days}天`
+ }
+ if (timeDifference.hours !== undefined) {
+ result += `${timeDifference.hours}时`
+ }
+ if (timeDifference.minutes !== undefined) {
+ result += `${timeDifference.minutes + 1}分`
+ }
+ // if (timeDifference.seconds !== undefined) {
+ // result += `${timeDifference.seconds}秒`
+ // }
+ return result;
+ },
+
+
+
startTimer() {
- this.timer = setInterval(() => {
- if (this.timeday.seconds > 0) {
- this.timeday.seconds--;
- } else if (this.timeday.minutes > 0) {
- this.timeday.seconds = 59; // 重置秒数为59
- this.timeday.minutes--;
- } else if (this.timeday.hours > 0) {
- this.timeday.minutes = 59; // 重置分钟数为59
- this.timeday.hours--;
- this.timeday.seconds = 0; // 同时重置秒数为0
- } else if (this.timeday.days > 0) {
- this.timeday.hours = 23; // 重置小时数为23
- this.timeday.minutes = 59; // 重置分钟数为59
- this.timeday.seconds = 0; // 重置秒数为0
- this.timeday.days--;
- } else {
- // 所有时间单位都已减为0,停止定时器
- clearInterval(this.timer);
- this.timer = null;
- console.log('时间已到期');
- }
- }, 1000); // 每秒执行一次
- },
+ this.timer = setInterval(() => {
+ if (this.timeday.seconds > 0) {
+ this.timeday.seconds--
+ } else if (this.timeday.minutes > 0) {
+ this.timeday.seconds = 59 // 重置秒数为59
+ this.timeday.minutes--
+ } else if (this.timeday.hours > 0) {
+ this.timeday.minutes = 59 // 重置分钟数为59
+ this.timeday.hours--
+ this.timeday.seconds = 0 // 同时重置秒数为0
+ } else if (this.timeday.days > 0) {
+ this.timeday.hours = 23 // 重置小时数为23
+ this.timeday.minutes = 59 // 重置分钟数为59
+ this.timeday.seconds = 0 // 重置秒数为0
+ this.timeday.days--
+ } else {
+ // 所有时间单位都已减为0,停止定时器
+ clearInterval(this.timer)
+ this.timer = null;
+ console.log('时间已到期')
+ }
+ }, 1000); // 每秒执行一次
+ },
// 计算天时分秒
- formatMilliseconds(milliseconds) {
- // 计算天数
- let days = Math.floor(milliseconds / (1000 * 60 * 60 * 24))
- // 计算剩余的小时数
- let hours = Math.floor((milliseconds % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60))
- // 计算剩余的分钟数
- let minutes = Math.floor((milliseconds % (1000 * 60 * 60)) / (1000 * 60))
- // 计算剩余的秒数
- let seconds = Math.floor((milliseconds % (1000 * 60)) / 1000)
- // 返回一个对象,包含天、小时、分钟和秒
- return {
- days: days,
- hours: hours,
- minutes: minutes,
- seconds: seconds
- }
+ formatMilliseconds(milliseconds) {
+ // 计算天数
+ let days = Math.floor(milliseconds / (1000 * 60 * 60 * 24))
+ // 计算剩余的小时数
+ let hours = Math.floor((milliseconds % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60))
+ // 计算剩余的分钟数
+ let minutes = Math.floor((milliseconds % (1000 * 60 * 60)) / (1000 * 60))
+ // 计算剩余的秒数
+ let seconds = Math.floor((milliseconds % (1000 * 60)) / 1000)
+ // 返回一个对象,包含天、小时、分钟和秒
+ return {
+ days: days,
+ hours: hours,
+ minutes: minutes,
+ seconds: seconds
+ }
},
opendevice() {
let stause = 0
@@ -326,13 +850,13 @@
} else {
stause = 1
}
- console.log(stause, 'stausestause');
+ // 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(this.id)
+ this.getDevice()
}, 2000)
// this.loadings=true
@@ -350,7 +874,7 @@
},
swiperchange(e) {
this.curtitidx = e.detail.current
- console.log(e, 'aaaa');
+ // console.log(e, 'aaaa');
},
changeidx(index) {
this.curtitidx = index
@@ -364,62 +888,69 @@
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;
-
+ switch (options.type) {
case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS:
if (options.result) {
let devicesarr = options.data
- // console.log(devicesarr,'devicesarrdevicesarr');
+ console.log(devicesarr,this.mac,'111');
devicesarr.forEach(device => {
- const mac = device.name.substring(5);
- if (device.name == this.qrResult) {
+ const mac = device.name.substring(4);
+ if (device.name.slice(5, 17) == this.qrResult) {
this.deviceId = device.deviceId
this.name = device.name
- this.mac = device.name.slice(5, 17)
- // console.log(this.mac, 'macmacmac');
- // this.devicesList = uniqueDevicesList;
+ // console.log(device.name,this.mac,'222');
+ this.devicesList.push(device);
+ let uniqueDevicesList = Array.from(new Set(this.devicesList));
+ // 将去重后的数组重新赋值给 this.devicesList
+ this.devicesList = uniqueDevicesList;
+ } else {
+ // uni.showToast({
+ // title: '未找到该设备,请确认该设备在附近',
+ // icon: 'none',
+ // duration: 3000
+ // })
}
})
}
break;
-
case xBlufi.XBLUFI_TYPE.TYPE_CONNECTED:
- // console.log("连接回调:" + JSON.stringify(options));
+ console.log("连接回调:" + JSON.stringify(options));
if (options.result) {
- uni.hideLoading();
- // uni.showToast({
- // title: '连接成功',
- // icon: 'none'
- // });
+ // console.log('125451245')
{
- console.log("连接回调options.data.deviceId:" + options.data.deviceId,
- "连接回调options.data.name:" + options.data.name);
+ xBlufi.notifyInitBleEsp32({
+ deviceId: this.deviceId
+ });
+ xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvents);
+ this.deviceIds = options.data.deviceId
+ this.name = this.name
}
- } else {
- uni.hideLoading()
- uni.showToast({
- title: '设备离线或不在范围内',
- icon: 'none',
- duration: 2000
- })
+ }else{
+
}
break;
-
+ case xBlufi.XBLUFI_TYPE.TYPE_RECIEVE_CUSTON_DATA:
+ this.ver_data = this.parseCustomData(options.data)
+ console.log("1收到设备发来的自定义数据结果:", this.ver_data);
+ this.temperature = this.ver_data.temperature / 1000
+ setTimeout(()=>{
+ // this.czflag = false
+ this.jieshuflag = false
+ uni.hideLoading()
+ },1000)
+ break;
+ case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS_STOP:
+ if (options.result) {
+ let uniqueDevicesList = Array.from(new Set(this.devicesList));
+ let filteredDevices = uniqueDevicesList.filter(device => device.name.substring(0, 4) === "CTKG");
+ // 将过滤后的数组重新赋值给 this.devicesList
+ this.devicesList = filteredDevices;
+ }
+ break;
case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS_START:
if (!options.result) {
- console.log("蓝牙未开启", options);
+ this.lanyaflag = true
uni.showToast({
title: '蓝牙未开启',
icon: 'none',
@@ -427,75 +958,69 @@
});
return
} else {
- // this.searching = true
- //蓝牙搜索开始
- // _this.setData({
- // searching: true
- // });
+ this.lanyaflag = false
}
-
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 = []
- filteredDevices.forEach(device => {
- // 从设备名称中提取 MAC 地址(假设 MAC 地址是设备名称的后6个字符)
- let macFromName = device.name.substring(device.name.length - 12);
- this.$u.get(`/app/device/${macFromName}/isBind`).then((res) => {
- if (res.data == false) {
- list.push(device)
- } else {
-
- }
- })
-
- });
- setTimeout(() => {
- this.devicesList = list
- }, 200)
-
- console.log('蓝牙停止搜索ok');
- } else {
- //蓝牙停止搜索失败
- console.log('蓝牙停止搜索失败');
- }
- this.searching = false
- // _this.setData({
- // searching: false
- // });
-
- break;
-
}
},
+
parseCustomData(data) {
- // 将字符串按照 "@" 分割成数组
+ // 将字符串按照 "@" 分割成数组
const dataArray = data.split('@');
-
- // 根据约定,解析各个字段的值
- const voltage = parseFloat(dataArray[0].substring(1)); // 去除前缀 "V",并将字符串转换为浮点数
- const switchState = dataArray[1].substring(1); // 去除前缀 "S"
- const current = parseFloat(dataArray[2].substring(1)); // 去除前缀 "A",并将字符串转换为浮点数
- const power = parseFloat(dataArray[4].substring(1)); // 去除前缀 "P",并将字符串转换为浮点数
- const remainingPower = parseFloat(dataArray[5].substring(1)); // 去除前缀 "M",并将字符串转换为浮点数
- const setMode = dataArray[6].substring(1); // 去除前缀 "T"
-
- // 返回解析后的数据对象
- return {
- voltage,
- switchState,
- current,
- power,
- remainingPower,
- setMode
+ // 初始化一个空对象来存储解析后的数据
+ 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;
},
+ // parseCustomData(data) {
+ // // 将字符串按照 "@" 分割成数组
+ // const dataArray = data.split('@');
+ // // 根据约定,解析各个字段的值
+ // const voltage = parseFloat(dataArray[0].substring(1)); // 去除前缀 "V",并将字符串转换为浮点数
+ // const switchState = dataArray[1].substring(1); // 去除前缀 "S"
+ // const current = parseFloat(dataArray[2].substring(1)); // 去除前缀 "A",并将字符串转换为浮点数
+ // const power = parseFloat(dataArray[4].substring(1)); // 去除前缀 "P",并将字符串转换为浮点数
+ // const remainingPower = parseFloat(dataArray[5].substring(1)); // 去除前缀 "M",并将字符串转换为浮点数
+ // const setMode = dataArray[6].substring(1); // 去除前缀 "T"
+
+ // // 返回解析后的数据对象
+ // return {
+ // voltage,
+ // switchState,
+ // current,
+ // power,
+ // remainingPower,
+ // setMode
+ // }
+ // },
+
}
}
@@ -511,7 +1036,217 @@
page {
background-color: #F7FAFE;
+ padding: 0 30rpx;
+ box-sizing: border-box;
+ padding-bottom: 300rpx;
+ overflow: scroll;
}
+
+ .truebox{
+ width: 500rpx;
+ height: 335rpx;
+ border-radius: 20rpx;
+ background-color: #fff;
+ position: fixed;
+ top: 40%;
+ left: 50%;
+ transform: translateX(-50%);
+ z-index: 99;
+ padding: 30rpx;
+ box-sizing: border-box;
+ .titvalue{
+ width: 100%;
+ text-align: center;
+ margin-top: 30rpx;
+ }
+ .truebtn{
+ display: flex;
+ margin-top: 30rpx;
+ .quxiao{
+ border-right: 1px solid #ccc;
+ }
+ view{
+ width: 50%;
+ text-align: center;
+ height: 90rpx;
+ line-height: 90rpx;
+ border-top: 1px solid #ccc;
+ }
+ }
+ }
+
+ .jieshu {
+ width: 558rpx;
+ height: 90rpx;
+ line-height: 90rpx;
+ background: #8883F0;
+ border-radius: 54rpx 54rpx 54rpx 54rpx;
+ font-size: 36rpx;
+ color: #FFFFFF;
+ // font-weight: 600;
+ text-align: center;
+ position: fixed;
+ bottom: 76rpx;
+ left: 50%;
+ transform: translateX(-50%);
+ }
+
+ .zujie {
+ margin-top: 32rpx;
+
+ .toptit {
+ font-size: 32rpx;
+ color: #333333;
+ font-weight: 600;
+ }
+
+ .emilist {
+ display: flex;
+ justify-content: space-between;
+ margin-top: 28rpx;
+
+ view {
+ font-size: 24rpx;
+ color: #808080;
+ }
+ }
+ }
+
+ .price_list {
+ border-bottom: 1px solid #D8D8D8;
+ padding-bottom: 26rpx;
+ box-sizing: border-box;
+
+ .top_price {
+ font-size: 32rpx;
+ color: #333333;
+ font-weight: 600;
+ margin-top: 24rpx;
+ margin-bottom: 28rpx;
+ }
+
+ .jisuan {
+ font-size: 24rpx;
+ color: #333333;
+ margin-top: 24rpx;
+ margin-bottom: 30rpx;
+ }
+
+ .qian {
+ width: 100%;
+ display: flex;
+ justify-content: space-between;
+
+ .yuan {
+ font-size: 24rpx;
+ color: #333333;
+ }
+
+ .yajin {
+ font-size: 24rpx;
+ color: #808080;
+ }
+ }
+ }
+
+ .list_box {
+ .ulbox {
+ width: 100%;
+ overflow: scroll;
+
+ .ulli {
+ display: flex;
+ width: 170vh;
+
+ .li {
+ flex: 1;
+ border: 1rpx solid #ccc;
+ text-align: center;
+ font-size: 32rpx;
+ color: #8883F0;
+ height: 88rpx;
+ line-height: 88rpx;
+ }
+ }
+
+ .olli {
+ display: flex;
+ width: 170vh;
+
+ .li {
+ flex: 1;
+ border: 1rpx solid #ccc;
+ text-align: center;
+ font-size: 22rpx;
+ color: #262B37;
+ height: 88rpx;
+ line-height: 88rpx;
+ }
+ }
+ }
+ }
+
+ .time_list {
+ width: 100%;
+ border-bottom: 1px solid #D8D8D8;
+ padding-bottom: 34rpx;
+ box-sizing: border-box;
+
+ .time_top {
+ display: flex;
+ justify-content: space-between;
+ margin-top: 20rpx;
+
+ view {
+ font-size: 40rpx;
+ color: #3D3D3D;
+ font-weight: 600;
+ }
+ }
+
+ .time_bot {
+ display: flex;
+ justify-content: space-between;
+ margin-top: 30rpx;
+
+ view {
+ font-size: 24rpx;
+ color: #666666;
+ }
+ }
+ }
+
+ .dltop {
+ width: 100%;
+ height: 204rpx;
+ background: #8883F0;
+ border-radius: 16rpx 16rpx 16rpx 16rpx;
+ margin: auto;
+ margin-top: 36rpx;
+
+ .dian_list {
+ display: flex;
+ justify-content: space-between;
+ text-align: center;
+ font-size: 34rpx;
+ color: #FFFFFF;
+
+ view {
+ width: 180rpx;
+ text-align: center;
+ margin-top: 22rpx;
+ }
+ }
+
+ .botwz {
+ font-size: 28rpx;
+ color: #FFFFFF;
+ width: 100%;
+ text-align: center;
+ margin-top: 16rpx;
+ }
+ }
+
.mask {
width: 750rpx;
height: 100vh;
@@ -523,6 +1258,7 @@
top: 0;
left: 0;
}
+
.tanc {
width: 610rpx;
height: 282rpx;
@@ -533,7 +1269,7 @@
left: 50%;
transform: translateX(-50%);
z-index: 2;
-
+
.tit {
width: 100%;
text-align: center;
@@ -542,7 +1278,7 @@
font-size: 32rpx;
color: #3D3D3D;
}
-
+
input {
width: 504rpx;
height: 62rpx;
@@ -552,7 +1288,7 @@
margin-top: 22rpx;
padding-left: 20rpx;
}
-
+
.xian {
width: 610rpx;
height: 2rpx;
@@ -560,12 +1296,12 @@
border-radius: 0rpx 0rpx 0rpx 0rpx;
margin-top: 26rpx;
}
-
+
.anniu {
display: flex;
justify-content: space-between;
height: 98rpx;
-
+
text {
padding: 24rpx;
text-align: center;
@@ -730,6 +1466,7 @@
}
}
}
+
.bot_right {
// margin-top: 50rpx;
display: flex;
@@ -739,6 +1476,7 @@
padding-left: 220rpx;
padding-right: 80rpx;
box-sizing: border-box;
+
.cont {
.tit {
font-size: 28rpx;
@@ -748,7 +1486,7 @@
line-height: 49rpx;
margin-left: 0;
}
-
+
.txt {
font-size: 26rpx;
font-family: HarmonyOS Sans SC, HarmonyOS Sans SC;
@@ -763,7 +1501,7 @@
width: 670rpx;
height: 60rpx;
background: #FFFFFF;
- border-radius:0 0 28rpx 28rpx;
+ border-radius: 0 0 28rpx 28rpx;
.tit {
margin-left: 40rpx;
diff --git a/page_components/fuwu/index.vue b/page_components/fuwu/index.vue
index d8a2638..876181f 100644
--- a/page_components/fuwu/index.vue
+++ b/page_components/fuwu/index.vue
@@ -66,13 +66,20 @@
-->
-
- 收费:{{item.value}}时 分钟 秒{{item.price}}元
+ 计时收费
+ 按量收费
+ 分时段按量收费
+ 分时段按时收费
+ ({{item.feeMode == 1 ? '单次收费' : '智能收费'}}):
+ {{item.value}}时 分钟 秒 {{item.price}}元
+ {{item.value}}度{{item.price}}元
+ 押金{{item.price}}元
+
-
-
+
套餐说明:{{item.description == null ? '无' : item.description}}
@@ -193,7 +182,13 @@
suitTimeUnit:'',
zfflag:true,
prices:'',
- sceneValue:''
+ sceneValue:'',
+ suitFeeMode:'',
+ suitFeeType:'',
+ suitGearAmount:[],
+ suitGearTime:[],
+ suitPrice:'',
+ payNo:''
}
},
onLoad(option) {
@@ -421,7 +416,8 @@
getmac() {
this.$u.get(`/app/device/${this.id}/bySn`).then((res) => {
if (res.code == 200) {
- this.mac = 'CTKG-' + res.data.mac
+ // this.mac = 'CTKG-' + res.data.mac
+ this.mac = res.data.mac
this.onlineStatus = res.data.onlineStatus
}
})
@@ -441,9 +437,27 @@
} else {
this.expireTimeStr = '1'
}
+ if(res.data.suitList){
+ this.mapGearTimeToGearAmount(res.data.suitList)
+ }
+ // console.log(res.data.suitList,'1212');
}
})
},
+ mapGearTimeToGearAmount(suitList) {
+ // 遍历 suitList 数组
+ suitList.forEach(suit => {
+ const gearTime = suit.gearTime;
+ const gearAmount = suit.gearAmount;
+ const arr = new Array(gearTime.length).fill(null);
+ gearTime.forEach((time, index) => {
+ if (time >= 0 && time < gearAmount.length) {
+ arr[index] = gearAmount[time];
+ }
+ });
+ suit.arr = arr;
+ });
+ },
btnzhifu() {
if (this.checked == false) {
uni.showToast({
@@ -465,30 +479,78 @@
suitId: that.zfobj.suitId,
money: that.zfobj.price,
suitTime: that.zfobj.value,
- suitTimeUnit:that.suitTimeUnit
+ suitTimeUnit:that.suitTimeUnit,
+ suitFeeMode:that.suitFeeMode,
+ suitFeeType:that.suitFeeType,
+ suitGearAmount:that.suitGearAmount,
+ suitGearTime:that.suitGearTime,
+ suitPrice:that.suitPrice
}
that.$u.post('/app/bill/recharge', data).then((res) => {
if (res.code == 200) {
that.orderno = res.data
// console.log(this.prices);
- if(this.prices == 0){
- that.$u.put(`/app/bill/${that.orderno}/refreshPayResult`).then(res => {})
- // 支付成功逻辑
- uni.reLaunch({
- url: '/pages/shouye/index'
+ // if(this.prices == 0){
+ // 0元购
+ // that.$u.put(`/app/bill/${that.orderno}/refreshPayResult`).then(res => {})
+ // // 支付成功逻辑
+ // uni.reLaunch({
+ // url: '/pages/shouye/index'
+ // })
+ // uni.setStorageSync('time', that.expireTimeStr)
+ // }
+ if(this.suitFeeType == 3 || this.suitFeeType == 4){
+ let data = {
+ billNo:that.orderno,
+ channelId:1
+ }
+ that.$u.put(`/app/bill/payDeposit`,data).then(res => {
+ if(res.code == 200){
+ that.payNo = res.data.payBill.payNo
+ uni.requestPayment({
+ provider: 'wxpay',
+ timeStamp: res.data.payParams.timeStamp,
+ nonceStr: res.data.payParams.nonceStr,
+ package: res.data.payParams.packageVal,
+ signType: res.data.payParams.signType,
+ paySign: res.data.payParams.paySign,
+ success: (res) => {
+ this.zhifuflag = true
+ // console.log(res, '支付成功')
+ if (that.timer) {
+ clearInterval(this.timer)
+ that.timer = null;
+ }
+ that.$u.put(`/app/bill/${that.payNo}/refreshPayResult`).then(res => {})
+ // 支付成功逻辑
+ uni.reLaunch({
+ // url: '/pages/shouye/index'
+ url:'/page_components/eletj?id=' + that.orderno
+ })
+ uni.setStorageSync('time', that.expireTimeStr)
+ },
+ fail(err) {
+ this.zhifuflag = true
+ // 支付失败逻辑
+ uni.showToast({
+ title: '支付失败',
+ icon: 'none',
+ duration: 2000
+ })
+ }
+ })
+ }
})
- uni.setStorageSync('time', that.expireTimeStr)
}else{
- // console.log('不是0元购');
that.$u.get(`/app/pay/wx/${that.orderno}`).then((res) => {
if (res.code == 200) {
uni.requestPayment({
provider: 'wxpay',
- timeStamp: res.data.timeStamp,
- nonceStr: res.data.nonceStr,
- package: res.data.packageVal,
- signType: res.data.signType,
- paySign: res.data.paySign,
+ timeStamp: res.data.payParams.timeStamp,
+ nonceStr: res.data.payParams.nonceStr,
+ package: res.data.payParams.packageVal,
+ signType: res.data.payParams.signType,
+ paySign: res.data.payParams.paySign,
success: (res) => {
this.zhifuflag = true
// console.log(res, '支付成功')
@@ -499,7 +561,7 @@
that.$u.put(`/app/bill/${that.orderno}/refreshPayResult`).then(res => {})
// 支付成功逻辑
uni.reLaunch({
- url: '/pages/shouye/index'
+ url:'/page_components/eletj?id=' + that.orderno
})
uni.setStorageSync('time', that.expireTimeStr)
},
@@ -510,17 +572,22 @@
title: '支付失败',
icon: 'none',
duration: 2000
- });
+ })
}
})
}
})
}
-x
} else if (res.code == 401) {
uni.reLaunch({
url: '/pages/login/login'
})
+ }else if(res.code == 500){
+ uni.showToast({
+ title:res.msg,
+ icon: 'none',
+ duration: 2000
+ });
}
})
} else {
@@ -549,13 +616,10 @@ x
}, 2000)
uni.showModal({
title: '温馨提示',
- content: '检测到该设备未联网,为您切换为蓝牙模式,支付的时候靠近该设备,并打开蓝牙',
- success: function(res) {
- if (res.confirm) {
-
- } else if (res.cancel) {
- console.log('用户点击了取消')
- }
+ content: `检测到该设备未联网,为您切换为蓝牙模式,支付的时候靠近该设备,并打开蓝牙`,
+ showCancel: false,
+ success: function (res) {
+
}
})
} else {
@@ -566,62 +630,153 @@ x
suitId: that.zfobj.suitId,
money: that.zfobj.price,
suitTime: that.zfobj.value,
- suitTimeUnit:that.suitTimeUnit
+ suitTimeUnit:that.suitTimeUnit,
+ suitFeeMode:that.suitFeeMode,
+ suitFeeType:that.suitFeeType,
+ suitGearAmount:that.suitGearAmount,
+ suitGearTime:that.suitGearTime,
+ suitPrice:that.suitPrice
}
that.$u.post('/app/bill/recharge', data).then((res) => {
if (res.code == 200) {
that.orderno = res.data
- if(this.prices == 0){
- that.$u.get('/app/bill/recharge/device/fail/list').then(res => {
- if (res.code == 200) {
- // console.log('获取订单状态',res);
- let dingobj = res.data[0].billNo
- // console.log(dingobj,'订单号');
- uni.getNetworkType({
- success(res) {
- if (res.networkType !== 'none') {
- uni.getConnectedBluetoothDevices({
- success(res) {
- xBlufi.notifySendCustomData({
- customData: "time@" + that.jine
- })
- },
- fail(err) {
- console.error('获取已连接蓝牙设备信息失败:',err)
- }
- })
- that.$u.get(`/app/bill/recharge/${dingobj}/bluetoothSuccess`).then(res => {
+ if(this.suitFeeType == 3 || this.suitFeeType == 4){
+ let data = {
+ billNo:that.orderno,
+ channelId:1
+ }
+ that.$u.put(`/app/bill/payDeposit`,data).then((res) => {
+ if (res.code == 200) {
+ that.payNo = res.data.payBill.payNo
+ uni.requestPayment({
+ provider: 'wxpay',
+ timeStamp: res.data.payParams.timeStamp,
+ nonceStr: res.data.payParams.nonceStr,
+ package: res.data.payParams.packageVal,
+ signType: res.data.payParams.signType,
+ paySign: res.data.payParams.paySign,
+ success: (res) => {
+ // console.log(res, '支付成功');
+ if (that.timer) {
+ clearInterval(this.timer);
+ that.timer = null;
+ }
+ // 111111111111111111111111
+ that.$u.put(`/app/payBill/${that.payNo}/refreshPayResult`).then(res =>{
+ // if(res.code == 200){
+ that.$u.get(`/app/bill/byNo/${that.orderno}`).then(res => {
if (res.code == 200) {
- this.zhifuflag = true
- console.log('蓝牙离线充值成功')
- setTimeout(() => {
- uni.reLaunch({
- url: '/pages/shouye/index'
+ if(res.data.status == 9){
+ uni.getNetworkType({
+ success(res) {
+ if (res.networkType !== 'none') {
+ uni.getConnectedBluetoothDevices({
+ success(res) {
+ that.jzflag = true
+ that.startLoading()
+ setTimeout(()=> {
+ xBlufi.notifySendCustomData({
+ customData: 'open'
+ })
+ setTimeout(() => {
+ that.zhifuflag = true
+ uni.reLaunch({
+ // url: '/pages/shouye/index'
+ url:'/page_components/eletj?id=' + that.orderno
+ })
+ },1000)
+ },1500)
+ },
+ fail(err) {
+ console.error('获取已连接蓝牙设备信息失败:',err)
+ }
+ })
+ } else {
+ console.log('手机未连接网络')
+ // this.baiflag = false
+ }
+ }
})
- },1000)
+ }else{
+ uni.showToast({
+ title: '支付失败',
+ icon: 'none',
+ duration: 2000
+ });
+ }
}
})
- } else {
- console.log('手机未连接网络')
- // this.baiflag = false
- }
+ // }
+ })
+ // 支付成功逻辑
+ uni.setStorageSync('time', that.expireTimeStr)
+ },
+ fail(err) {
+ this.zhifuflag = true
+ setTimeout(() => {
+ this.czflag = false
+ uni.hideLoading()
+ }, 500)
+ // 支付失败逻辑
+ uni.showToast({
+ title: '支付失败',
+ icon: 'none',
+ duration: 2000
+ });
}
})
- }
- })
+ }
+ })
+ // that.$u.get('/app/bill/recharge/device/fail/list').then(res => {
+ // if (res.code == 200) {
+ // // console.log('获取订单状态',res);
+ // let dingobj = res.data[0].billNo
+ // // console.log(dingobj,'订单号');
+ // uni.getNetworkType({
+ // success(res) {
+ // if (res.networkType !== 'none') {
+ // uni.getConnectedBluetoothDevices({
+ // success(res) {
+ // xBlufi.notifySendCustomData({
+ // customData: "time@" + that.jine
+ // })
+ // },
+ // fail(err) {
+ // console.error('获取已连接蓝牙设备信息失败:',err)
+ // }
+ // })
+ // that.$u.get(`/app/bill/recharge/${dingobj}/bluetoothSuccess`).then(res => {
+ // if (res.code == 200) {
+ // this.zhifuflag = true
+ // console.log('蓝牙离线充值成功')
+ // setTimeout(() => {
+ // uni.reLaunch({
+ // url: '/pages/shouye/index'
+ // })
+ // },1000)
+ // }
+ // })
+ // } else {
+ // console.log('手机未连接网络')
+ // // this.baiflag = false
+ // }
+ // }
+ // })
+ // }
+ // })
// 11111111111111111111111
// 支付成功逻辑
- uni.setStorageSync('time', that.expireTimeStr)
+ // uni.setStorageSync('time', that.expireTimeStr)
}else{
that.$u.get(`/app/pay/wx/${that.orderno}`).then((res) => {
if (res.code == 200) {
uni.requestPayment({
provider: 'wxpay',
- timeStamp: res.data.timeStamp,
- nonceStr: res.data.nonceStr,
- package: res.data.packageVal,
- signType: res.data.signType,
- paySign: res.data.paySign,
+ timeStamp: res.data.payParams.timeStamp,
+ nonceStr: res.data.payParams.nonceStr,
+ package: res.data.payParams.packageVal,
+ signType: res.data.payParams.signType,
+ paySign: res.data.payParams.paySign,
success: (res) => {
// console.log(res, '支付成功');
if (that.timer) {
@@ -630,7 +785,7 @@ x
}
// 111111111111111111111111
that.$u.put(`/app/bill/${that.orderno}/refreshPayResult`).then(res =>{
- if(res.code == 200){
+ // if(res.code == 200){
that.$u.get('/app/bill/recharge/device/fail/list').then(res => {
if (res.code == 200) {
console.log('获取订单状态',res);
@@ -659,7 +814,7 @@ x
console.log('蓝牙离线充值成功11')
setTimeout(() => {
uni.reLaunch({
- url: '/pages/shouye/index'
+ url:'/page_components/eletj?id=' + that.orderno
})
},1000)
}
@@ -672,7 +827,7 @@ x
})
}
})
- }
+ // }
})
// 支付成功逻辑
uni.setStorageSync('time', that.expireTimeStr)
@@ -694,10 +849,12 @@ x
}
})
}
- } else if (res.code == 401) {
- uni.reLaunch({
- url: '/pages/login/login'
- })
+ } else if (res.code == 500) {
+ uni.showToast({
+ title: res.msg,
+ icon: 'none',
+ duration: 2000
+ });
} else {
this.czflag = false
}
@@ -724,6 +881,11 @@ x
this.zfobj = item
this.indexactive = item.suitId
this.suitTimeUnit = item.timeUnit
+ this.suitPrice = item.price
+ this.suitGearAmount = item.gearAmount
+ this.suitGearTime = item.gearTime
+ this.suitFeeMode = item.feeMode
+ this.suitFeeType = item.feeType
if(item.timeUnit == 1){
this.jine = item.value * 24 * 60 * 60
}else if(item.timeUnit == 2){
@@ -741,14 +903,14 @@ x
// 获取附近蓝牙设备列表
funListenDeviceMsgEvent: function(options) {
- switch (options.type) {
+ switch (options.type) {
case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS:
if (options.result) {
let devicesarr = options.data
+ console.log(devicesarr,this.mac,'111');
devicesarr.forEach(device => {
const mac = device.name.substring(4);
- // console.log(device.name,this.mac,'111');
- if (device.name == this.mac) {
+ if (device.name.slice(5, 17) == this.mac.slice(5, 17)) {
this.deviceId = device.deviceId
this.name = device.name
// console.log(device.name,this.mac,'222');
@@ -884,10 +1046,12 @@ x
}
.ulbox{
width: 100%;
+ overflow: scroll;
.ulli{
display: flex;
+ width: 170vh;
.li{
- width: 25%;
+ flex: 1;
border: 1rpx solid #ccc;
text-align: center;
font-size: 32rpx;
@@ -898,8 +1062,9 @@ x
}
.olli{
display: flex;
+ width: 170vh;
.li{
- width: 25%;
+ flex: 1;
border: 1rpx solid #ccc;
text-align: center;
font-size: 22rpx;
diff --git a/page_fenbao/chongzhi.vue b/page_fenbao/chongzhi.vue
index ccae176..d259070 100644
--- a/page_fenbao/chongzhi.vue
+++ b/page_fenbao/chongzhi.vue
@@ -139,13 +139,15 @@
this.sn = JSON.parse(e.dingobj)
if (this.sn.length >= 1) {
this.jine = uni.getStorageSync('time')
- this.mac = 'CTKG-' + this.sn[0].deviceMac
+ // this.mac = 'CTKG-' + this.sn[0].deviceMac
+ this.mac = this.sn[0].deviceMac
this.billNo = this.sn[0].billNo
this.jine = this.jine + this.sn[0].suitTime
} else {
this.jine = uni.getStorageSync('time')
this.billNo = this.sn.billNo
- this.mac = 'CTKG-' + this.sn.deviceMac
+ // this.mac = 'CTKG-' + this.sn.deviceMac
+ this.mac = this.sn.deviceMac
this.jine = this.jine + this.sn.suitTime
}
@@ -215,7 +217,7 @@
// let macFromName = device.name.substring(device.name.length - 12);
// console.log(macFromName);
// 与 this.mac 进行比较
- if (device.name == this.mac) {
+ if (device.name.slice(5, 17) == this.mac) {
// 如果相同,则将 this.ishave 设置为 true
console.log(device);
this.deviceInfo = device
@@ -391,7 +393,7 @@
// console.log(devicesarr,this.mac);
devicesarr.forEach(device => {
const mac = device.name.substring(4);
- if (device.name == this.mac) {
+ if (device.name.slice(5, 17) == this.mac) {
this.deviceId = device.deviceId
this.name = device.name
this.devicesList.push(device);
diff --git a/page_fenbao/statulist/myorder/detailxq/index.vue b/page_fenbao/statulist/myorder/detailxq/index.vue
index 9746943..a6fd60b 100644
--- a/page_fenbao/statulist/myorder/detailxq/index.vue
+++ b/page_fenbao/statulist/myorder/detailxq/index.vue
@@ -37,6 +37,9 @@
用户{{detailobj.userName == undefined ? '--' : detailobj.userName}}
+
+ 用户手机号{{detailobj.userMobile == undefined ? '--' : detailobj.userMobile}}
+
收款人手机号{{detailobj.mchName == undefined ? '--' : detailobj.mchName}}
@@ -376,7 +379,7 @@
}
.listxq{
width: 680rpx;
- height: 1010rpx;
+ height: 1068rpx;
background: #FFFFFF;
border-radius: 20rpx 20rpx 20rpx 20rpx;
margin: auto;
diff --git a/page_fenbao/statulist/myorder/index.vue b/page_fenbao/statulist/myorder/index.vue
index 33790c6..e5d37e1 100644
--- a/page_fenbao/statulist/myorder/index.vue
+++ b/page_fenbao/statulist/myorder/index.vue
@@ -129,9 +129,10 @@
btndetail(item){
uni.navigateTo({
url:'/page_fenbao/statulist/myorder/detailxq/index?billId=' + item.billId
+ // url:'/page_components/eletj?id=' + item.billNo + '&flag=' + true
})
}
- }
+ }
}
diff --git a/page_fenbao/statulist/taocanlist/addtaocan/index.vue b/page_fenbao/statulist/taocanlist/addtaocan/index.vue
index d080608..28cb61b 100644
--- a/page_fenbao/statulist/taocanlist/addtaocan/index.vue
+++ b/page_fenbao/statulist/taocanlist/addtaocan/index.vue
@@ -3,7 +3,7 @@
-
+
-
+
@@ -303,7 +314,7 @@
deviceId: '',
name: '',
value: '',
- description: '',
+ // description: '',
price: '',
title: '',
suitId: '',
@@ -333,6 +344,15 @@
disabled: false
}
],
+ sfdan: [{
+ name: '计时收费',
+ disabled: false
+ },
+ {
+ name: '按量收费',
+ disabled: false
+ }
+ ],
gmsj: [{
name: '时',
disabled: false
@@ -372,10 +392,24 @@
yjflag: false,
duflag: false,
djflag: false,
- jeflag: false,
+ jeflag: true,
dangflag: false,
backgroundColor: Array(24).fill('#64B6A7'),
- backcolor: ''
+ backcolor: '',
+ duvalue: '',
+ qianvalue: '',
+ description: '',
+ feeMode: '1', ////收费模式(1单次收费 2智能收费)
+ feeType: "1", //收费类型(1计时收费 2按量收费 3分时段按量收费 4分时段按时收费)
+ timeUnit: '', //时长单位1-天,2-时,3-分,4-秒
+ gearAmount: [], //档位金额列表(必须4个)
+ gearTime: [], //时段档位列表(必须24个)
+ gdvalue: '',
+ pdvalue: '',
+ dfvalue: '',
+ jdvalue: '',
+ timevalue: ''
+
}
},
onLoad(option) {
@@ -441,6 +475,19 @@
// 收费模式 单次and智能
radioChange(e) {
// console.log(e);
+ if (e == '单次收费') {
+ this.feeMode = 1
+ this.valuetwo = '计时收费'
+ this.feeType = 1
+ this.gmsjflag = true
+ this.jeflag = true
+ this.duflag = false
+ this.yjflag = false
+ this.djflag = false
+ this.dangflag = false
+ } else {
+ this.feeMode = 2
+ }
},
radioGroupChange(e) {
// console.log(e);
@@ -448,6 +495,7 @@
// 收费类型// 收费类型// 收费类型
radioChanges(e) {
if (e == '按量收费') {
+ this.feeType = 2
this.duflag = true
this.jeflag = true
this.gmsjflag = false
@@ -455,6 +503,7 @@
this.djflag = false
this.dangflag = false
} else if (e == '计时收费') {
+ this.feeType = 1
this.gmsjflag = true
this.jeflag = true
this.duflag = false
@@ -462,6 +511,7 @@
this.djflag = false
this.dangflag = false
} else if (e == '分时段按量收费') {
+ this.feeType = 3
this.gmsjflag = false
this.jeflag = false
this.duflag = false
@@ -469,6 +519,7 @@
this.djflag = true
this.dangflag = false
} else if (e == '分时段按时收费') {
+ this.feeType = 4
this.gmsjflag = false
this.dangflag = true
this.jeflag = false
@@ -484,7 +535,13 @@
// 收费时间 收费时间 收费时间 收费时间
radioChangetime(e) {
- // console.log(e);
+ if (e == '时') {
+ this.timeUnit = 2
+ } else if (e == '分') {
+ this.timeUnit = 3
+ } else {
+ this.timeUnit = 4
+ }
},
// 选中任一radio时,由radio-group触发
radioGroupChangetime(e) {
@@ -568,14 +625,85 @@
this.$u.get(`/app/suit/${suitId}`).then((res) => {
if (res.code == 200) {
this.name = res.data.name
- this.price = res.data.price
- this.value = res.data.value
+ this.qianvalue = res.data.price
+ this.duvalue = res.data.value
this.description = res.data.description
this.deviceList = res.data.deviceList
- this.index = Number(res.data.timeUnit) - 1
this.deviceList.forEach(item => {
this.tcidlist.push(item.deviceId)
})
+ if (res.data.gearAmount) {
+ this.gdvalue = res.data.gearAmount[0]
+ this.pdvalue = res.data.gearAmount[1]
+ this.dfvalue = res.data.gearAmount[2]
+ this.jdvalue = res.data.gearAmount[3]
+ }
+ if (res.data.timeUnit == 2) {
+ this.valuethr = '时'
+ this.timeUnit = 2
+ } else if (res.data.timeUnit == 3) {
+ this.valuethr = '分'
+ this.timeUnit = 3
+ } else if (res.data.timeUnit == 4) {
+ this.valuethr = '秒'
+ this.timeUnit = 4
+ }
+ if (res.data.feeMode == 1) {
+ this.valueone = '单次收费'
+ this.feeMode = 1
+ } else {
+ this.valueone = '智能收费'
+ this.feeMode = 2
+ }
+ if (res.data.feeType == 1) {
+ this.valuetwo = '计时收费'
+ this.feeType = 1
+ this.gmsjflag = true
+ this.jeflag = true
+ this.duflag = false
+ this.yjflag = false
+ this.djflag = false
+ this.dangflag = false
+ } else if (res.data.feeType == 2) {
+ this.valuetwo = '按量收费'
+ this.feeType = 2
+ this.duflag = true
+ this.jeflag = true
+ this.gmsjflag = false
+ this.yjflag = false
+ this.djflag = false
+ this.dangflag = false
+ } else if (res.data.feeType == 3) {
+ this.valuetwo = '分时段按量收费'
+ this.feeType = 3
+ this.gmsjflag = false
+ this.jeflag = false
+ this.duflag = false
+ this.yjflag = true
+ this.djflag = true
+ this.dangflag = false
+ } else if (res.data.feeType == 4) {
+ this.valuetwo = '分时段按时收费'
+ this.feeType = 4
+ this.gmsjflag = false
+ this.dangflag = true
+ this.jeflag = false
+ this.duflag = false
+ this.yjflag = true
+ this.djflag = false
+ }
+ if (res.data.gearTime.length > 0) {
+ let colorMap = {
+ 0: "#64B6A7",
+ 1: "#468DFF",
+ 2: "#8883F0",
+ 3: "#FF4444"
+ }
+ let colorsFromGearTime = res.data.gearTime.map(index => colorMap[index] || 'defaultColor')
+ this.backgroundColor = colorsFromGearTime
+ }else{
+ this.backgroundColor = Array(24).fill('#64B6A7')
+ }
}
})
},
@@ -615,39 +743,10 @@
},
btnadd() {
+ console.log(this.backgroundColor, '121212');
let regex = /^\d+(\.\d{1,2})?$/
let regexs = /^\d+$/
- if (this.name == '') {
- uni.showToast({
- title: '套餐名称不能为空',
- icon: 'none',
- duration: 1000,
- })
- } else if (this.price == '') {
- uni.showToast({
- title: '价格不能为空',
- icon: 'none',
- duration: 1000,
- })
- } else if (!regex.test(this.price)) {
- uni.showToast({
- title: '价格必须是数字且小数点只能两位',
- icon: 'none',
- duration: 2000,
- })
- } else if (this.value == '') {
- uni.showToast({
- title: '时长不能为空',
- icon: 'none',
- duration: 1000,
- })
- } else if (!regexs.test(this.value)) {
- uni.showToast({
- title: '时长必须是整数',
- icon: 'none',
- duration: 2000,
- })
- } else if (this.description == '') {
+ if (this.description == '') {
uni.showToast({
title: '详细说明不能为空',
icon: 'none',
@@ -656,15 +755,33 @@
} else {
this.btnmsk = true
if (this.title == '确定') {
+ let colorMap = {
+ "#64B6A7": 0,
+ "#468DFF": 1,
+ "#8883F0": 2,
+ "#FF4444": 3
+ }
+ this.gearTime = []
+ this.backgroundColor.forEach(color => {
+ this.gearTime.push(colorMap[color]);
+ })
let arrs = [...this.deviceList.map(item => item.deviceId)]
+ if (this.feeType == 3 || this.feeType == 4) {
+ this.gearAmount = []
+ this.gearAmount.push(this.gdvalue, this.pdvalue, this.dfvalue, this.jdvalue)
+ }
let data = {
// deviceId: this.deviceId,
name: this.name,
- value: this.value,
- price: this.price,
+ value:this.feeType == 3 || this.feeType == 4 ? (this.duvalue = null) : this.duvalue,
+ price: this.qianvalue,
description: this.description,
- timeUnit: Number(this.index) + 1,
- deviceIds: arrs
+ timeUnit: this.feeType == 3 || this.feeType == 4 ? (this.timeUnit = null) : this.timeUnit,
+ deviceIds: arrs,
+ feeMode: this.feeMode,
+ feeType: this.feeType,
+ gearAmount: this.gearAmount,
+ gearTime: this.feeType === 3 || this.feeType === 4 ? this.gearTime : (this.gearTime = [])
}
this.$u.post('/app/suit', data).then((res) => {
if (res.code == 200) {
@@ -688,14 +805,33 @@
}
})
} else {
+ let colorMap = {
+ "#64B6A7": 0,
+ "#468DFF": 1,
+ "#8883F0": 2,
+ "#FF4444": 3
+ }
+ this.gearTime = []
+ this.backgroundColor.forEach(color => {
+ this.gearTime.push(colorMap[color]);
+ })
+ let arrs = [...this.deviceList.map(item => item.deviceId)]
+ if (this.feeType == 3 || this.feeType == 4) {
+ this.gearAmount = []
+ this.gearAmount.push(this.gdvalue, this.pdvalue, this.dfvalue, this.jdvalue)
+ }
let data = {
suitId: this.suitId,
- // deviceId: this.deviceId,
name: this.name,
- value: this.value,
- price: this.price,
+ value: this.duvalue,
+ price: this.qianvalue,
description: this.description,
- timeUnit: Number(this.index) + 1
+ timeUnit: this.timeUnit,
+ deviceIds: arrs,
+ feeMode: this.feeMode,
+ feeType: this.feeType,
+ gearAmount: this.gearAmount,
+ gearTime: this.feeType === 3 || this.feeType === 4 ? this.gearTime : (this.gearTime = [])
}
this.$u.put('/app/suit', data).then((res) => {
if (res.code == 200) {
diff --git a/page_fenbao/zhuce.vue b/page_fenbao/zhuce.vue
index 002f2b0..53ca1ed 100644
--- a/page_fenbao/zhuce.vue
+++ b/page_fenbao/zhuce.vue
@@ -185,7 +185,7 @@
if (options.result) {
this.devicesList = options.data
// let devicesarr = options.data
- // // console.log(devicesarr,100100);
+ console.log(options.data,100100);
// devicesarr.forEach(device => {
// if (device.name.substring(0, 4) == "CTKG" || device.name.substring(0, 4) == "CTPO") {
// this.devicesList.push(device);
diff --git a/page_user/sbdetail.vue b/page_user/sbdetail.vue
index 899c19f..609d97c 100644
--- a/page_user/sbdetail.vue
+++ b/page_user/sbdetail.vue
@@ -988,27 +988,67 @@
}
},
- parseCustomData(data) {
- // 将字符串按照 "@" 分割成数组
- const dataArray = data.split('@')
+ // parseCustomData(data) {
+ // // 将字符串按照 "@" 分割成数组
+ // const dataArray = data.split('@')
- // 根据约定,解析各个字段的值
- const voltage = parseFloat(dataArray[0].substring(1)) // 去除前缀 "V",并将字符串转换为浮点数
- const switchState = dataArray[1].substring(1)// 去除前缀 "S"
- const current = parseFloat(dataArray[2].substring(1)) // 去除前缀 "A",并将字符串转换为浮点数
- const power = parseFloat(dataArray[4].substring(1)) // 去除前缀 "P",并将字符串转换为浮点数
- const remainingPower = parseFloat(dataArray[5].substring(1)) // 去除前缀 "M",并将字符串转换为浮点数
- const setMode = dataArray[6].substring(1) // 去除前缀 "T"
+ // // 根据约定,解析各个字段的值
+ // const voltage = parseFloat(dataArray[0].substring(1)) // 去除前缀 "V",并将字符串转换为浮点数
+ // const switchState = dataArray[1].substring(1)// 去除前缀 "S"
+ // const current = parseFloat(dataArray[2].substring(1)) // 去除前缀 "A",并将字符串转换为浮点数
+ // const power = parseFloat(dataArray[4].substring(1)) // 去除前缀 "P",并将字符串转换为浮点数
+ // const remainingPower = parseFloat(dataArray[5].substring(1)) // 去除前缀 "M",并将字符串转换为浮点数
+ // const setMode = dataArray[6].substring(1) // 去除前缀 "T"
- // 返回解析后的数据对象
- return {
- voltage,
- switchState,
- current,
- power,
- remainingPower,
- setMode
- };
+ // // 返回解析后的数据对象
+ // return {
+ // voltage,
+ // switchState,
+ // current,
+ // power,
+ // remainingPower,
+ // setMode
+ // };
+ // },
+ 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;
},
}
diff --git a/page_user/setting.vue b/page_user/setting.vue
index 946c002..47c3fe7 100644
--- a/page_user/setting.vue
+++ b/page_user/setting.vue
@@ -238,6 +238,7 @@
onLoad(option) {
let id = option.id
this.id = id
+ this.getshua()
this.getQiniuToken()
this.getDevice(id)
this.getlistobj(id)
@@ -263,6 +264,9 @@
this.getgroup()
},
methods: {
+ getshua(){
+ this.$u.get(`/app/device/${this.id}/refreshIot`).then((res) => {})
+ },
getQiniuToken() {
this.$u.get("/common/qiniu/uploadInfo").then((res) => {
if (res.code == 200) {
diff --git a/pages/shouye/index.vue b/pages/shouye/index.vue
index 0ad48ee..1f57ad4 100644
--- a/pages/shouye/index.vue
+++ b/pages/shouye/index.vue
@@ -23,7 +23,7 @@
src="https://api.ccttiot.com/smartmeter/img/static/ublEB3HEjyfZbnKS2Ai9" mode="">
+ @click="btnitem(item.billNo)">
{{item.deviceName}}
@@ -88,6 +88,20 @@
+
+
+
+ ×
+
+
+ 您有一笔未支付订单,请及时去支付!
+
+
+ 去支付
+
+
+
+
@@ -96,6 +110,7 @@
export default {
data() {
return {
+ weiflag:false,
listflag: false,
params: {
year: true,
@@ -127,7 +142,8 @@
deviceCount: 0,
sylist: [],
networkInterval: null,
- wangluo: true
+ wangluo: true,
+ billNo:''
};
},
onLoad(option) {
@@ -152,6 +168,7 @@
onShow() {
this.logins()
this.getad()
+ this.getzf()
this.gethuidaio()
this.getshiy()
},
@@ -173,6 +190,23 @@
},
methods: {
+ btnqzf(){
+ uni.navigateTo({
+ url: '/page_components/eletj?id=' + this.billNo
+ })
+ },
+ getzf(){
+ this.$u.get("app/bill/unpaidTimingList").then((res) => {
+ if (res.code == 200) {
+ if(res.data.length > 0){
+ this.weiflag = true
+ this.billNo = res.data[0].billNo
+ }
+ }
+ })
+ },
+
+
startNetworkCheck() {
this.networkInterval = setInterval(() => {
uni.getNetworkType({
@@ -193,7 +227,7 @@
// 请求正在使用的设备列表
getshiy() {
- this.$u.get("/app/device/usingDevice").then((res) => {
+ this.$u.get("app/bill/usingList").then((res) => {
if (res.code == 200) {
this.sylist = res.data
}
@@ -633,6 +667,36 @@