浇花器

This commit is contained in:
3321822538@qq.com 2025-04-17 10:20:41 +08:00
parent f5b6a50aed
commit 3570f4d736
11 changed files with 224 additions and 155 deletions

View File

@ -21,7 +21,7 @@ const install = (Vue, vm) => {
// });
Vue.prototype.$u.http.setConfig({
baseUrl: 'https://yxd.ccttiot.com/prod-api',
// baseUrl: 'http://192.168.2.56:8081',
// baseUrl: 'http://192.168.0.107:8081',
loadingText: '努力加载中~',
loadingTime: 800,
// 设置自定义头部content-type
@ -115,15 +115,15 @@ const install = (Vue, vm) => {
};
vm.$u.post(`/loginByopenid?jsCode=${res.code}`,data).then(res=>{
if (res.code == 10003) {
uni.navigateTo({
url:'/pages/login/login'
})
// uni.navigateTo({
// url:'/pages/login/login'
// })
} else if (res.code == 200) {
// console.log("老用户登录",res.data)
uni.switchTab({
url:'/pages/index/index'
})
// uni.switchTab({
// url:'/pages/index/index'
// })
}
});

View File

@ -23,7 +23,7 @@
设置浇水
</view>
<view class="ts">
距离下次浇水时间还有{{xctime}}
请设置浇水时间
</view>
<view class="shifen" @click="show = true">
<text>{{hour}}</text> <text>{{minutekq}}</text>

View File

@ -101,8 +101,18 @@
if (res.code == 200) {
this.userid = res.data.userId
}else if(res.code == 401){
uni.navigateTo({
url:'/pages/login/login'
uni.showModal({
title: '提示',
content: '您还未登录,是否前去登录?',
success: function (res) {
if (res.confirm) {
uni.navigateTo({
url:'/pages/login/login'
})
} else if (res.cancel) {
}
}
})
}
})
@ -116,6 +126,7 @@
userId:this.userid,
pre:e.slice(0,5)
}
console.log(data);
this.$u.post(`/app/bandDevice`,data).then((res) => {
if (res.code == 200) {
uni.showToast({
@ -152,7 +163,7 @@
'isStart': false
})
if (that.devicesList.length > 0) {
that.flags = true
// that.flags = true
this.$u.get(`/app/device/isBand/${this.arr}`).then(res =>{
if(res.code == 200){
res.data.forEach(item =>{

View File

@ -118,7 +118,8 @@
file:'',
intervalId: null,
progress:0,
shengjiflag:false
shengjiflag:false,
xctime:'--'
}
},
//
@ -139,10 +140,18 @@
onLoad(option) {
xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent)
this.deviceid = option.deviceid
if(option.ver != undefined && option.ver != null){
this.ver = option.ver
this.getbanben()
if(option.xctime){
if(option.xctime != '--' && option.ver){
this.ver = option.ver
this.xctime = option.xctime
console.log(11);
}else{
this.ver = 1
this.xctime = option.xctime
console.log(22);
}
}
this.getshebxq()
},
methods: {
@ -154,7 +163,7 @@
content: '您确定要解绑当前设备吗?',
success: function(res) {
if (res.confirm) {
that.$u.delete(`//app/device/unbind/${that.deviceid}`).then(res => {
that.$u.delete(`/app/device/unbind/${that.deviceid}`).then(res => {
if (res.code == 200) {
uni.showToast({
title: '解绑成功',
@ -185,6 +194,7 @@
this.$u.get(`/app/getDeviceInfo/${this.deviceid}`).then(res => {
if (res.code == 200) {
this.user = res.data
this.getbanbens()
}
})
},
@ -198,11 +208,20 @@
this.xptxt = e[0].label
},
getbanben(){
this.$u.get(`/app/getVersion?version=${this.ver.slice(3)}`).then(res => {
this.$u.get(`/app/model/${this.user.modelId}`).then(res => {
if (res.code == 200) {
this.file = res.data.file
console.log(this.file);
// this.file = 'https://www.zenghi.com/gj/water_flower.bin'
this.file = res.data.asDeviceVersion.file
console.log(this.file)
// this.file = 'https://wc.chuangtewl.com/download/water_flower.bin'
}
})
},
getbanbens(){
this.$u.get(`/app/model/${this.user.modelId}`).then(res => {
if (res.code == 200) {
this.file = res.data.asDeviceVersion.file
console.log(this.file)
// this.file = 'https://wc.chuangtewl.com/download/water_flower.bin'
}
})
},
@ -219,8 +238,15 @@
//
gjconfirm(e) {
// this.gjtxt = e[0].label
if(this.ver != ''){
if(this.file != ''){
// if(this.ver != ''){
if(this.file == '' || this.file == null){
uni.showToast({
title: '暂无新版本',
icon: 'none',
duration: 2000
})
}else{
console.log('更新');
var data = {
sum: 100,
http: this.file
@ -230,20 +256,14 @@
})
this.shengjiflag = true
this.startProgress()
}else{
uni.showToast({
title: '暂无新版本',
icon: 'none',
duration: 2000
})
}
}else{
uni.showToast({
title: '请连接蓝牙获取版本号',
icon: 'none',
duration: 2000
})
}
// }else{
// uni.showToast({
// title: '',
// icon: 'none',
// duration: 2000
// })
// }
},
//
btnqx() {

View File

@ -3,10 +3,7 @@
<u-navbar :is-back="true" :title='tit' title-color="#000" :border-bottom="false" :background="bgc"
id="navbar">
</u-navbar>
<view class="" v-html="cont">
</view>
<view class="" v-html="cont"></view>
</view>
</template>
@ -29,7 +26,6 @@
path: '/pages/index/index'
}
},
//
onShareTimeline: function() {
return {
@ -55,7 +51,7 @@
}
}
</script>
<style lang="less">
/deep/ .u-title{
margin-bottom: 22rpx;
@ -69,6 +65,4 @@
box-sizing: border-box;
background-color: #fff;
}
</style>

View File

@ -390,26 +390,26 @@
}
},
onLoad() {
wx.openBluetoothAdapter({
success: function (res) {
console.log('蓝牙适配器初始化成功');
},
fail: function (err) {
console.error('蓝牙适配器初始化失败,可能是因为没有权限', err);
uni.showToast({
title: '蓝牙适配器初始化失败,可能是因为没有权限',
icon: 'none',
duration:2000
})
}
})
this.vardataflag = 1
xBlufi.initXBlufi(1)
let that = this
xBlufi.listenDeviceMsgEvent(true, that.funListenDeviceMsgEvent)
xBlufi.notifyStartDiscoverBle({
'isStart': true
})
wx.openBluetoothAdapter({
success: function (res) {
console.log('蓝牙适配器初始化成功');
},
fail: function (err) {
console.error('蓝牙适配器初始化失败,可能是因为没有权限', err);
uni.showToast({
title: '蓝牙适配器初始化失败,可能是因为没有权限',
icon: 'none',
duration:2000
})
}
})
this.vardataflag = 1
xBlufi.initXBlufi(1)
let that = this
xBlufi.listenDeviceMsgEvent(true, that.funListenDeviceMsgEvent)
xBlufi.notifyStartDiscoverBle({
'isStart': true
})
},
onShow() {
//
@ -465,19 +465,7 @@
taht.getinfo()
uni.setStorageSync('token', res.token)
}else{
uni.showModal({
title: '提示',
content: '您还未登录,是否前去登录?',
success: function (res) {
if (res.confirm) {
uni.navigateTo({
url:'/pages/login/login'
})
} else if (res.cancel) {
}
}
})
}
})
}
@ -801,7 +789,7 @@
btnsz() {
xBlufi.listenDeviceMsgEvent(false, this.funListenDeviceMsgEvent)
uni.navigateTo({
url: '/page_user/upload?deviceid=' + this.shebid + '&ver=' + this.ver
url: '/page_user/upload?deviceid=' + this.shebid + '&ver=' + this.ver + '&xctime=' + this.xctime
})
},
//
@ -961,78 +949,99 @@
},
//
getchuli() {
const inputString = this.datalist
const [ver, restOfString] = inputString.split('@')
this.ver = ver || ''
console.log(this.ver, restOfString, 'ververver')
const processedString = restOfString
const pairs = processedString.split(';')
console.log(pairs,'10101010');
const showObject = {}
const pSetObjects = {}
const inputString = this.datalist;
// @
const hasAtSymbol = inputString.includes('@');
let processedString;
if (hasAtSymbol) {
const [ver, restOfString] = inputString.split('@');
this.ver = ver || '';
processedString = restOfString || ''; // restOfString undefined
} else {
processedString = inputString; // @使
this.ver = ''; // @ver
}
console.log(this.ver, processedString, 'ververver');
const pairs = processedString.split(';').filter(Boolean); //
console.log(pairs, '10101010');
const showObject = {};
const pSetObjects = {};
//
pairs.forEach(pair => {
const [key, value] = pair.split(':')
const [key, value] = pair.split(':');
if (key === 'show') {
showObject.showArray = value.split(',').map(Number)
showObject.showArray = value.split(',').map(Number);
} else if (key.startsWith('p_set')) {
pSetObjects[key] = value.split(',').map(Number)
pSetObjects[key] = value.split(',').map(Number);
}
})
this.ver_data = pSetObjects //
this.jstimeobj = pSetObjects
this.showobj = showObject//
});
this.ver_data = pSetObjects; //
this.jstimeobj = pSetObjects;
this.showobj = showObject; //
//
this.yschecked = this.showobj.showArray[1] !== 1
this.etchecked = this.showobj.showArray[0] !== 1
//
const calculateTimeDifference = (date1, date2) => {
const diffMs = Math.abs(date1 - date2)
const diffMinutes = Math.floor(diffMs / (1000 * 60))
const diffHours = Math.floor(diffMinutes / 60)
const remainingMinutes = diffMinutes % 60
return { hours: diffHours, minutes: remainingMinutes }
}
const formatTime = (seconds) => {
const minutes = Math.floor(seconds / 60)
const remainingSeconds = seconds % 60
return `${minutes}${remainingSeconds}`
}
const getTimeFromArray = (timeArray) => {
const [hour, minute, , second] = timeArray
const date = new Date()
date.setHours(hour, minute, second, 0) // 0
return date
}
let nextTime = null
let nextTimeDiff = null
let nextWaterDuration = null
let prevTime = null
for (const key in this.ver_data) {
if (this.ver_data.hasOwnProperty(key) && this.ver_data[key][3] === 1) {
const timeArray = this.ver_data[key]
const timeDate = getTimeFromArray(timeArray)
const diff = calculateTimeDifference(timeDate, new Date())
if (timeDate > new Date()) {
if (!nextTime || (diff.hours * 60 + diff.minutes < (nextTimeDiff?.hours || 0) * 60 + (nextTimeDiff?.minutes || 0))) {
nextTimeDiff = diff
nextTime = timeDate
nextWaterDuration = formatTime(timeArray[2])
}
} else if (!prevTime || timeDate > prevTime) {
prevTime = timeDate;
}
}
}
//
this.xctime = nextTime ? `${nextTimeDiff.hours}${nextTimeDiff.minutes}` : '无距离下次浇水时间'
this.xctimesc = nextWaterDuration || '未知'
this.sctimejs = prevTime ? prevTime.toTimeString().slice(0, 5) : '无上次浇水时间'
this.xctimesj = nextTime ? nextTime.toTimeString().slice(0, 5) : '无下次浇水时间'
console.log('下次浇水时间', this.xctimesj, '距离下次浇水时间', this.xctime, '上次浇水时间', this.sctimejs)
}
this.yschecked = this.showobj.showArray[1] !== 1;
this.etchecked = this.showobj.showArray[0] !== 1;
//
const calculateTimeDifference = (date1, date2) => {
const diffMs = Math.abs(date1 - date2);
const diffMinutes = Math.floor(diffMs / (1000 * 60));
const diffHours = Math.floor(diffMinutes / 60);
const remainingMinutes = diffMinutes % 60;
return { hours: diffHours, minutes: remainingMinutes };
};
const formatTime = (seconds) => {
const minutes = Math.floor(seconds / 60);
const remainingSeconds = seconds % 60;
return `${minutes}${remainingSeconds}`;
};
const getTimeFromArray = (timeArray) => {
const [hour, minute, , second] = timeArray;
const date = new Date();
date.setHours(hour, minute, second, 0); // 0
return date;
};
let nextTime = null;
let nextTimeDiff = null;
let nextWaterDuration = null;
let prevTime = null;
for (const key in this.ver_data) {
if (this.ver_data.hasOwnProperty(key) && this.ver_data[key][3] === 1) {
const timeArray = this.ver_data[key];
const timeDate = getTimeFromArray(timeArray);
const diff = calculateTimeDifference(timeDate, new Date());
if (timeDate > new Date()) {
if (!nextTime || (diff.hours * 60 + diff.minutes < (nextTimeDiff?.hours || 0) * 60 + (nextTimeDiff?.minutes || 0))) {
nextTimeDiff = diff;
nextTime = timeDate;
nextWaterDuration = formatTime(timeArray[2]);
}
} else if (!prevTime || timeDate > prevTime) {
prevTime = timeDate;
}
}
}
//
this.xctime = nextTime ? `${nextTimeDiff.hours}${nextTimeDiff.minutes}` : '无距离下次浇水时间';
this.xctimesc = nextWaterDuration || '未知';
this.sctimejs = prevTime ? prevTime.toTimeString().slice(0, 5) : '无上次浇水时间';
this.xctimesj = nextTime ? nextTime.toTimeString().slice(0, 5) : '无下次浇水时间';
console.log('下次浇水时间', this.xctimesj, '距离下次浇水时间', this.xctime, '上次浇水时间', this.sctimejs);
},
}
}
</script>

View File

@ -40,8 +40,9 @@
其他登录方式
</view>
<button class="lofo" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">
<image src="https://api.ccttiot.com/smartmeter/img/static/uxWMldLMb888YHm0qOgN" mode=""></image>
<button style="color: #ccc;margin-top: 30rpx;" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">
<!-- <image src="https://api.ccttiot.com/smartmeter/img/static/uxWMldLMb888YHm0qOgN" mode=""></image> -->
快捷登录
</button>
</view>
</template>

View File

@ -8,11 +8,15 @@
<view class="denglu" @click="denglu">
登录
</view>
<view class="zhuce" style="margin-top: 30rpx;" @click="denglus">
暂不登录
</view>
</view>
</view>
</template>
<script>
var xBlufi = require("@/components/blufi/xBlufi.js")
export default {
data() {
return {
@ -36,7 +40,20 @@
}
},
onLoad() {
wx.openBluetoothAdapter({
success: function (res) {
console.log('蓝牙适配器初始化成功');
},
fail: function (err) {
console.error('蓝牙适配器初始化失败,可能是因为没有权限', err);
// uni.showToast({
// title: '',
// icon: 'none',
// duration:2000
// })
}
})
xBlufi.initXBlufi(1)
},
methods:{
//
@ -50,6 +67,11 @@
uni.navigateTo({
url:'/pages/login/denglu'
})
},
denglus(){
uni.switchTab({
url:'/pages/index/index'
})
}
}
}
@ -66,7 +88,7 @@
.anniu{
position: fixed;
left: 50%;
bottom: 198rpx;
bottom: 140rpx;
transform: translateX(-50%);
.zhuce{
width: 614rpx;

View File

@ -56,8 +56,9 @@
其他登录方式
</view>
<button class="lofo" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">
<image src="https://api.ccttiot.com/smartmeter/img/static/uxWMldLMb888YHm0qOgN" mode=""></image>
<button style="color: #ccc;margin-top: 30rpx;" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">
<!-- <image src="https://api.ccttiot.com/smartmeter/img/static/uxWMldLMb888YHm0qOgN" mode=""></image> -->
快捷登录
</button>

View File

@ -31,7 +31,6 @@
</view>
</view>
</view>
<view class="bot">
</view>
@ -49,7 +48,6 @@
退出登录 <image src="https://api.ccttiot.com/smartmeter/img/static/uKpBiM6T9kj4BddzJtDc" mode=""></image>
</view>
</view>
<tab-bar :indexs='2'></tab-bar>
</view>
</template>
@ -84,6 +82,9 @@
}
},
onLoad() {
},
onShow() {
this.getinfo()
this.gettiken()
},
@ -94,6 +95,20 @@
if (res.code == 200) {
this.userobj = res.data
this.imageSrc = res.data.avatar
}else if(res.code == 401){
uni.showModal({
title: '提示',
content: '您还未登录,是否前去登录?',
success: function (res) {
if (res.confirm) {
uni.navigateTo({
url:'/pages/login/login'
})
} else if (res.cancel) {
}
}
})
}
})
},
@ -129,7 +144,6 @@
}
})
},
//
btnyjfk(){
uni.navigateTo({
@ -142,7 +156,6 @@
url:'/page_user/kefu'
})
},
//
btnxq(num){
if(num == 1){

View File

@ -11,8 +11,6 @@
bgc: {
backgroundColor: "#E2EFDF",
},
}
},
//