This commit is contained in:
3321822538@qq.com 2024-07-11 18:02:47 +08:00
parent 0953423479
commit 20ddd6de97
8 changed files with 647 additions and 14 deletions

28
components/share.js Normal file
View File

@ -0,0 +1,28 @@
export default {
data() {
return {
// 默认的全局分享内容
share: {
title: '共享智能开关',
path: '/pages/shouye/index', // 全局分享的路径,比如 首页
// imageUrl: '/static/image/1.png', // 分享时显示的图片
}
}
},
// 1.发送给朋友
onShareAppMessage(res) {
return {
title: this.share.title,
path: this.share.path,
// imageUrl: this.share.imageUrl,
}
},
//2.分享到朋友圈
onShareTimeline(res) {
return {
title: this.share.title,
path: this.share.path,
// imageUrl: this.share.imageUrl,
}
},
}

View File

@ -17,6 +17,9 @@ import'./common/css/iconfont.css'
import tabbar from '@/components/tab-bar/tab-bar.vue';
// import customizeAnswer from'@/components/customizeAnswer/customizeAnswer.vue'
// Vue.use('customizeAnswer',customizeAnswer)
Vue.use('tab-bar',tabbar)

View File

@ -109,7 +109,7 @@
export default {
data() {
return {
indexactive: 0,
indexactive: -1,
checked: false,
lanyaflag:false,
deviceobj: {},
@ -126,7 +126,9 @@
name: '',
ver_data: '',
devicesList: [],
onlineStatus: ''
onlineStatus: '',
jine:'',
dingobj:{}
}
},
onLoad(option) {
@ -304,7 +306,7 @@
this.$u.get(`/app/device/${this.id}/withSuitList`).then((res) => {
if (res.code == 200) {
this.deviceobj = res.data;
this.indexactive = res.data.suitList[0].suitId;
// this.indexactive = res.data.suitList[0].suitId;
this.zfobj = res.data.suitList[0]
// let targetDateStr = this.deviceobj.expireTime
// let targetParts = targetDateStr.split(/[- :]/);
@ -333,6 +335,12 @@
icon: 'none',
duration: 1000
})
}else if(this.indexactive == -1){
uni.showToast({
title: '请选择套餐 !',
icon: 'none',
duration: 1000
})
} else if (this.onlineStatus == 1) {
let that = this
let data = {
@ -443,10 +451,49 @@
clearInterval(this.timer);
that.timer = null;
}
// 111111111111111111111111
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 * 60
});
},
fail(err) {
console.error('获取已连接蓝牙设备信息失败:', err);
}
})
that.$u.get(`/app/bill/recharge/${dingobj}/bluetoothSuccess`).then(res => {
if(res.code == 200){
console.log('蓝牙离线充值成功');
setTimeout(()=>{
uni.reLaunch({
url: '/pages/shouye/index'
})
},1000)
}
})
} else {
console.log('手机未连接网络');
// this.baiflag = false
}
}
})
}
})
// 11111111111111111111111
//
uni.reLaunch({
url: '/pages/shouye/index'
})
uni.setStorageSync('time', that.expireTimeStr)
},fail(err) {
setTimeout(()=>{
@ -477,6 +524,7 @@
},
btnactive(item) {
this.jine = item.value
this.sytime = item.value
this.zfobj = item
this.indexactive = item.suitId;
@ -502,6 +550,12 @@
let uniqueDevicesList = Array.from(new Set(this.devicesList));
// this.devicesList
this.devicesList = uniqueDevicesList;
}else{
// uni.showToast({
// title: '',
// icon: 'none',
// duration: 3000
// })
}
});
}

View File

@ -13,7 +13,7 @@
</view>
<input type="text" v-model="price" placeholder="输入价格" />
<view class="title" style="margin-top: 50rpx;">
通电时长
通电时长分钟)
</view>
<input type="text" v-model="value" placeholder="输入通电时长" />
<view class="title" style="margin-top: 50rpx;">

View File

@ -2,13 +2,14 @@
<view class="page">
<u-navbar title="套餐列表" :border-bottom="false" :background="bgc" title-color='#fff' back-icon-color="#fff" title-size='36'
height='50'></u-navbar>
<view class="box">
<view class="box" v-if="loading">
<u-swipe-action :show="item.show" :index="index" v-for="(item, index) in list" :key="item.suitId" @click="click(item)" @open="open" :options="options">
<view class="boxlist" @click="btnedit(item)">
<view class="toptime">
<text>{{item.name}}{{item.value}}分钟</text> <text>{{item.price}}</text>
</view>
<view class="bumday">
<view class="bumday" v-if="item.description">
<text class="shi">{{item.description.length > 20 ? item.description.substring(0, 20) + '...' : item.description}}</text></text>
</view>
</view>
@ -29,6 +30,7 @@
data() {
return {
list: [],
loading:false,
disabled: false,
btnWidth: 180,
show: false,
@ -57,6 +59,7 @@
this.$u.get(`/app/suit/listByDeviceId/${this.deviceId}`).then((res) => {
if (res.code == 200) {
this.list = res.data
this.loading = true
}
});
},

542
page_fenbao/zhuce.vue Normal file
View File

@ -0,0 +1,542 @@
<template>
<view class="pages">
<u-navbar title="设备录入" :border-bottom="false" :background="bgc" title-size='38' title-color='#fff' back-icon-color="#fff"
height='50'></u-navbar>
<view class="title">
<text>设备录入列表</text>
<!-- <image src="https://api.ccttiot.com/smartmeter/img/static/uCfe9273aC89tGOT7n1G" mode="widthFix"></image>
<text class="sm"> {{texts}} </text -->
</view>
<view class="dblist" v-for="(item, index) in devicesList" :key="index">
<view class="lt">
<image src="https://api.ccttiot.com/smartmeter/img/static/uoQO0pUZ1UHcW5uVKkuR" mode=""></image>
</view>
<view class="cen">
<view class="name">
智能开关录入
</view>
<view class="mac">
MAC{{item.localName.substring(5)}}
</view>
</view>
<view class="rt">
<text style="margin-bottom: 10rpx;" :id="item.deviceId" @tap="createBLEConnections(item)">响铃</text>
<text :id="item.deviceId" @tap="createBLEConnection(item)">录入</text>
</view>
</view>
<view class="anniu" @click="Search">
<button>重新扫描</button>
</view>
<view class="mask" v-if="titleflag">
<view class="titles">
温馨提示
</view>
<text>无法扫描到附近设备:</text>
<text>1.确保待连接设备在附近且蓝牙处于打开状态</text>
<text>2.确保设备未与其他设备进行蓝牙连接</text>
<text>确保设备未被添加过</text>
<text>...</text>
<button @click="btnyc">好的</button>
</view>
<view class="containers" v-show="statusflag">
<uni-section>
<uni-load-more :status="status" />
</uni-section>
</view>
</view>
</template>
<script>
const app = getApp();
var xBlufi = require("@/page_components/blufi/xBlufi.js");
let _this = null;
export default {
data() {
return {
titleflag: false, //
bgc: {
backgroundColor: "#F7FAFE",
},
devicesList: [
// {name:'110000',
// mac:'11111'}
],
searching: false,
texts: '正在扫描设备...',
btnflag: true,
tishiflag: false,
option: '',
bluthlist: [], //
status: 'loading',
statusflag: false,
Bluetoothmac: '',
gps: {},
mac: '',
status: false,
storeId:'',
bgc: {
backgroundColor: "#8883f0",
},
}
},
onLoad(option) {
// console.log(option);
this.storeId = option.sn
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) {
this.tishiflag = true
this.texts = '扫描完毕,暂无发现设备'
} else {
this.texts = '扫描到以下设备,请点击录入!'
}
this.status = true
}, 2000)
},
onShow: function() {
// this.openBluetoothAdapter()
// xBlufi.listenDeviceMsgEvent(false, this.funListenDeviceMsgEvent);
// xBlufi.notifyStartDiscoverBle({
// 'isStart': false
// });
},
onUnload: function() {
xBlufi.listenDeviceMsgEvent(false, this.funListenDeviceMsgEvent);
xBlufi.notifyStartDiscoverBle({
'isStart': false
});
},
// onHide(){
// xBlufi.listenDeviceMsgEvent(false, this.funListenDeviceMsgEvent);
// xBlufi.notifyStartDiscoverBle({
// 'isStart': false
// });
// },
onBeforeUnmount(){
xBlufi.listenDeviceMsgEvent(false, this.funListenDeviceMsgEvent);
xBlufi.notifyStartDiscoverBle({
'isStart': false
});
},
mounted() {
this.videoContext = uni.createVideoContext('myVideo', this)
},
methods: {
btnyc() {
this.titleflag = false
},
funListenDeviceMsgEvent: function(options) {
switch (options.type) {
case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS:
if (options.result) {
let devicesarr = options.data
// console.log(devicesarr,100100);
devicesarr.forEach(device => {
const mac = device.name.substring(5);
if (device.name.substring(0, 4) == "CTKG") {
this.devicesList.push(device);
console.log(this.devicesList);
let uniqueDevicesList = Array.from(new Set(this.devicesList));
// this.devicesList
this.devicesList = uniqueDevicesList;
}
});
}
break;
case xBlufi.XBLUFI_TYPE.TYPE_CONNECTED:
console.log("连接回调:" + JSON.stringify(options));
if (options.result) {
uni.hideLoading();
// uni.showToast({
// title: '',
// icon: 'none'
// });
{
console.log("连接回调options.data.deviceId" + options.data.deviceId,
"连接回调options.data.name" + options.data.name);
let data = {
sn:this.storeId,
mac:this.mac
}
this.$u.post('/app/device', data).then((res) => {
if (res.code == 200) {
uni.showToast({
title: '录入成功',
icon: 'none',
duration: 2000
});
uni.removeStorageSync('mac');
let vm = this
uni.showModal({
title: '提示',
content: '你已录入成功,是否返回首页?',
success: function (res) {
if (res.confirm) {
setTimeout(()=>{
uni.navigateTo({
url:'/pages/shouye/index'
})
},1000)
} else if (res.cancel) {
console.log('用户点击了取消');
}
}
})
} else {
uni.showToast({
title: res.msg,
icon: 'none',
duration: 2000
});
}
})
}
}
break;
case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS_START:
if (!options.result) {
console.log("蓝牙未开启", options);
uni.showToast({
title: '蓝牙未开启,请打开手机蓝牙',
icon: 'none',
duration: 3000
});
} else {
this.searching = true
//
// _this.setData({
// searching: true
// });
}
break;
case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS_STOP:
if (options.result) {
let uniqueDevicesList = Array.from(new Set(this.devicesList));
console.log(uniqueDevicesList,'uniqueDevicesListuniqueDevicesList');
// this.devicesList
this.devicesList = uniqueDevicesList;
let list = []
// this.devicesList.forEach(device => {
// MAC MAC 6
// let macFromName = device.name.substring(device.name.length - 12);
// console.log(macFromName);
// this.mac
// 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;
}
},
createBLEConnections(e) {
xBlufi.notifyStartDiscoverBle({
'isStart': false
});
console.log(e, '蓝牙信息101010')
const deviceId = e.deviceId
this.Bluetoothmac = e.localName.substring(5) // mac
this.mac = e.localName.substring(5)
let name = e.name;
xBlufi.notifyConnectBle({
isStart: true,
deviceId: e.deviceId,
name:e.name
})
//
xBlufi.notifySendCustomData({
customData: "BEEP2@"
})
let that = this
},
//4
createBLEConnection(e) {
xBlufi.notifyStartDiscoverBle({
'isStart': false
});
console.log(e, '蓝牙信息101010')
const deviceId = e.deviceId
this.Bluetoothmac = e.localName.substring(5)
this.mac = e.localName.substring(5)
let name = e.name;
xBlufi.notifyConnectBle({
isStart: true,
deviceId: e.deviceId,
name:e.name
});
let that = this
},
//
Search() {
if (this.status) {
xBlufi.notifyStartDiscoverBle({
'isStart': true
});
//
this.bluthlist = []
this.devicesList = []
//
// this.startBluetoothDevicesDiscovery()
this.statusflag = true
this.texts = '正在扫描蓝牙设备...'
setTimeout(() => {
this.statusflag = false
if (this.searching) {
xBlufi.notifyStartDiscoverBle({
'isStart': false
});
//
if (this.devicesList.length == 0) {
this.tishiflag = true
this.texts = '扫描完毕,暂无发现设备'
} else {
this.texts = '扫描到以下设备,请点击录入!'
}
} else {
xBlufi.notifyStartDiscoverBle({
'isStart': true
});
}
}, 2000)
}
},
//
btnhd() {
this.tishiflag = false
}
}
}
</script>
<style lang="scss">
page {
background-color: #F7FAFE !important;
}
.containers {
width: 100%;
height: 100vh;
position: fixed;
top: 0;
padding-top: 130rpx;
box-sizing: border-box;
left: 0;
z-index: 999 !important;
/* background-color: #fff; */
z-index: 99;
}
.pages {
// padding-top: 136rpx !important;
padding: 0 66rpx;
box-sizing: border-box;
}
// text{
// display: block;
// }
.sm {
color: #77808D;
border-radius: 0rpx 0rpx 0rpx 0rpx;
// margin-top: 48rpx;
display: inline-block;
}
.title {
margin-bottom: 84rpx;
margin-top: 50rpx;
image {
display: inline-block;
width: 48rpx;
height: 48rpx;
vertical-align: bottom;
margin-right: 10rpx;
}
text:nth-child(1) {
font-weight: 400;
font-size: 66rpx;
color: #262B37;
line-height: 88rpx;
text-align: left;
font-style: normal;
text-transform: none;
display: block;
margin-bottom: 48rpx;
}
}
.dblist {
display: flex;
width: 100%;
margin-top: 34rpx;
background: #FFFFFF;
box-shadow: 0rpx 10rpx 64rpx 0rpx rgba(0, 0, 0, 0.08);
padding: 20rpx 0 24rpx 18rpx;
box-sizing: border-box;
text-align: center;
border-radius: 10rpx;
.lt {
padding-left: 10rpx;
box-sizing: border-box;
margin-right: 38rpx;
image {
width: 42rpx;
// height: 112rpx;
}
}
.cen {
width: 370rpx;
padding-left: 10rpx;
box-sizing: border-box;
.name {
font-family: AlibabaPuHuiTi, AlibabaPuHuiTi;
font-weight: 400;
font-size: 32rpx;
color: #262B37;
line-height: 40rpx;
text-align: left;
font-style: normal;
text-transform: none;
margin-top: 10rpx;
}
.mac {
font-family: AlibabaPuHuiTi, AlibabaPuHuiTi;
font-weight: 400;
font-size: 26rpx;
color: #262B37;
line-height: 32rpx;
text-align: left;
font-style: normal;
text-transform: none;
margin-top: 16rpx;
}
}
.rt {
margin-top: 22rpx;
text {
display: inline-block;
width: 108rpx;
height: 60rpx;
background: rgba(255, 255, 255, 0);
border: 2rpx solid #8883F0;
filter: blur(0px);
border-radius: 20rpx;
text-align: center;
line-height: 60rpx;
color: #8883F0;
}
}
}
.anniu {
padding: 0 90rpx;
width: 100%;
box-sizing: border-box;
position: fixed;
left: 0;
bottom: 112rpx;
button {
background: #8883F0;
border-radius: 52rpx 52rpx 52rpx 52rpx;
color: #fff;
}
}
.mask {
width: 622rpx;
height: 710rpx;
background: #FFFFFF;
filter: blur(0px);
border-radius: 20rpx;
position: fixed;
top: 475rpx;
left: 50%;
transform: translateX(-50%);
padding-top: 38rpx;
padding-left: 60rpx;
padding-right: 60rpx;
box-sizing: border-box;
.titles {
font-size: 48rpx;
color: #262B37;
line-height: 70rpx;
text-align: center;
margin-bottom: 24rpx;
}
text {
display: block;
font-size: 32rpx;
color: #262B37;
line-height: 56rpx;
text-align: left;
}
button {
margin-top: 46rpx;
width: 266rpx;
height: 96rpx;
background: #8883F0;
border-radius: 52rpx 52rpx 52rpx 52rpx;
color: #fff;
text-align: center;
line-height: 96rpx;
}
}
</style>

View File

@ -419,11 +419,14 @@
this.pagenum = 1
this.wateringList = []
this.titlist = item.name
this.$u.get(
`/app/device/list?storeId=${item.storeId}&pageNum=${this.pagenum}&pageSize=${this.pagesize}`
).then((res) => {
this.$u.get(`/app/device/list?storeId=${item.storeId}&pageNum=${this.pagenum}&pageSize=${this.pagesize}`).then((res) => {
if (res.code == 200) {
this.total = res.total
// if(this.pagenum > 1){
// this.wateringList = this.wateringList.concat(res.rows)
// }else{
// this.wateringList = res.rows
// }
if (res.rows.length > 0) {
//
this.wateringList = this.wateringList.concat(res.rows)

View File

@ -11,7 +11,7 @@
</view>
<!-- 正在进行中的订单 -->
<!-- <view class="ongoing_order">
<!-- <view class="ongoing_order">
<view class="order_top">
<view class="order_lt">
<image src="https://api.ccttiot.com/smartmeter/img/static/uFNuOet0fB5Bwe1c26sk" mode=""></image>
@ -907,7 +907,7 @@
.order_top {
width: 622rpx;
height: 94rpx;
background: rgba(0, 0, 0, 0.6);
background: rgba(0, 0, 0, 0.4);
box-shadow: 0rpx 4rpx 10rpx 0rpx rgba(0,0,0,0.3);
border-radius: 40rpx 40rpx 40rpx 40rpx;
display: flex;