浇花器
This commit is contained in:
parent
f5b6a50aed
commit
3570f4d736
|
@ -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'
|
||||
// })
|
||||
|
||||
}
|
||||
});
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
设置浇水
|
||||
</view>
|
||||
<view class="ts">
|
||||
距离下次浇水时间还有{{xctime}}
|
||||
请设置浇水时间
|
||||
</view>
|
||||
<view class="shifen" @click="show = true">
|
||||
<text>{{hour}}时</text> <text>{{minutekq}}分</text>
|
||||
|
|
|
@ -101,9 +101,19 @@
|
|||
if (res.code == 200) {
|
||||
this.userid = res.data.userId
|
||||
}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) {
|
||||
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
|
@ -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 =>{
|
||||
|
|
|
@ -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){
|
||||
if(option.xctime){
|
||||
if(option.xctime != '--' && option.ver){
|
||||
this.ver = option.ver
|
||||
this.getbanben()
|
||||
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() {
|
||||
|
|
|
@ -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 {
|
||||
|
@ -69,6 +65,4 @@
|
|||
box-sizing: border-box;
|
||||
background-color: #fff;
|
||||
}
|
||||
|
||||
|
||||
</style>
|
|
@ -465,20 +465,8 @@
|
|||
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 inputString = this.datalist;
|
||||
|
||||
const pairs = processedString.split(';')
|
||||
// 检查是否有 @ 分隔符
|
||||
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 = {}
|
||||
|
||||
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
|
||||
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 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 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
|
||||
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())
|
||||
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])
|
||||
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.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>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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>
|
||||
|
||||
|
||||
|
|
21
pages/my.vue
21
pages/my.vue
|
@ -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){
|
||||
|
|
|
@ -11,8 +11,6 @@
|
|||
bgc: {
|
||||
backgroundColor: "#E2EFDF",
|
||||
},
|
||||
|
||||
|
||||
}
|
||||
},
|
||||
// 分享到好友(会话)
|
||||
|
|
Loading…
Reference in New Issue
Block a user