diff --git a/components/tab-bar/tab-bar.vue b/components/tab-bar/tab-bar.vue
index 49c34bc..6b11e1b 100644
--- a/components/tab-bar/tab-bar.vue
+++ b/components/tab-bar/tab-bar.vue
@@ -3,7 +3,7 @@
diff --git a/page_components/bindsz.vue b/page_components/bindsz.vue
index 0e0faad..42d23b2 100644
--- a/page_components/bindsz.vue
+++ b/page_components/bindsz.vue
@@ -1,26 +1,31 @@
-
+
-
+
-
-
-
+
+
-
+
-
+
设备名称
@@ -43,7 +48,7 @@
-
+
S/N
@@ -64,14 +69,15 @@
-
+
套餐设置
- {{taocan.length > 5 ? taocan.slice(0,5) + '...' : taocan}}
+ {{taocan.length > 5 ? taocan.slice(0,5) + '...' : taocan}}
+
@@ -86,17 +92,17 @@
-
-
- WiFi配网
-
-
-
+
+
+ WiFi配网
+
+
+
{{listobj.wifi == null ? '' : listobj.wifi}}
-
+
-
-
+
+
@@ -132,7 +138,7 @@
- 修改备注
+ 修改名称
@@ -181,48 +187,48 @@
-
+
-
+
正在连接该设备蓝牙
-
-
- 请将手机与设备尽量靠近
-
-
-
-
+
-
-
- 蓝牙连接失败
-
-
- 请确保手机足够靠近设备
-
-
- 并且设备处于上电状态
-
-
-
- 取消
-
-
- 重新连接
-
-
+
+
+ 蓝牙连接失败
+
+
+ 请确保手机足够靠近设备
+
+
+ 并且设备处于上电状态
+
+
+
+ 取消
+
+
+ 重新连接
+
+
@@ -233,8 +239,8 @@
export default {
data() {
return {
- bluetoothflag:false,
- shibaiflag:false,
+ bluetoothflag: false,
+ shibaiflag: false,
bgc: {
backgroundColor: "#8883f0",
},
@@ -252,7 +258,7 @@
}
],
id: '',
- xgname:'',
+ xgname: '',
deviceInfo: {},
groupList: {},
showpopup: false,
@@ -261,37 +267,37 @@
showpeice: false,
showremake: false,
listobj: {
- deviceName:'',
- storeName:'',
- deviceNo:'',
- model:'',
- wifi:'',
+ deviceName: '',
+ storeName: '',
+ deviceNo: '',
+ model: '',
+ wifi: '',
},
- showmc:false,
+ showmc: false,
pagenum: 1,
wateringList: [],
pagesize: 10,
- isLoading: false,
+ isLoading: false,
noMoreData: false,
total: 0,
- storeId:'',
- devicesList:[],
- setMode:null,
- mac:'',
- name:'',
- deviceId:'',
- isMch:false,
- taocan:'',
- token:'',
- userImgs:'',
- url:''
+ storeId: '',
+ devicesList: [],
+ setMode: null,
+ mac: '',
+ name: '',
+ deviceId: '',
+ isMch: false,
+ taocan: '',
+ token: '',
+ userImgs: '',
+ url: ''
}
},
onLoad(option) {
let id = option.id
this.id = id
this.getDevice(id)
-
+
},
onShow() {
this.wateringList = []
@@ -305,23 +311,23 @@
this.getao()
},
// 分享到好友(会话)
- 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'
+ }
+ },
methods: {
- btnlyqx(){
+ btnlyqx() {
this.shibaiflag = false
this.bluetoothflag = false
},
@@ -351,8 +357,8 @@
let str = JSON.parse(res.data)
_this.userImgs = 'https://api.ccttiot.com/' + str.key
let data = {
- deviceId:_this.id,
- customPicture:_this.userImgs
+ deviceId: _this.id,
+ customPicture: _this.userImgs
}
_this.$u.put('/app/device', data).then((res) => {
if (res.code == 200) {
@@ -371,7 +377,7 @@
// url设置为空,隐藏控件
this.url = ""
},
-
+
// getImage(e) {
// let _this = this
// let math = 'static/' + _this.$u.guid(20)
@@ -420,15 +426,15 @@
}
})
},
-
- getao(){
+
+ getao() {
this.$u.get(`/app/suit/listByDeviceId/${this.id}`).then(res => {
- if(res.code == 200){
- if(res.data.length <= 1){
+ if (res.code == 200) {
+ if (res.data.length <= 1) {
res.data.forEach(item => {
this.taocan += item.name
})
- }else{
+ } else {
res.data.forEach(item => {
this.taocan += item.name + ','
})
@@ -437,9 +443,9 @@
})
},
// 点击设置套餐
- btntc(){
+ btntc() {
uni.navigateTo({
- url:'/page_fenbao/statulist/taocanlist/index?id=' + this.id
+ url: '/page_fenbao/statulist/taocanlist/index?id=' + this.id
})
},
// 获取当前用户信息
@@ -447,140 +453,144 @@
this.$u.get("/app/user/userInfo").then((res) => {
if (res.code == 200) {
this.isMch = res.data.isMch
- }
+ }
})
},
// 点击wifi进行配网
- btnwifi(){
+ btnwifi() {
this.shibaiflag = false
- this.bluetoothflag = true
- // console.log(this.deviceId,'idididididdidii');
- if(this.setMode == null){
- xBlufi.initXBlufi(1)
- xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent);
- xBlufi.notifyStartDiscoverBle({
- 'isStart': true
- })
-
- // 停止蓝牙搜索
- setTimeout(() => {
- xBlufi.notifyStartDiscoverBle({
- 'isStart': false
- })
- xBlufi.notifyConnectBle({
- isStart: true,
- deviceId: this.deviceId,
- name: this.name
- })
- xBlufi.notifyInitBleEsp32({
- deviceId: this.deviceId
- })
- let name = ''
- let index = this.name.indexOf('-');
- if (index !== -1) {
- name = this.name.slice(index + 1);
- }
- let data = {
- storeId: this.storeId,
- mac: this.mac
- }
- this.$u.put('/app/device/bind', data).then((res) => {
- if (res.code == 200) {
- uni.hideLoading();
- this.shibaiflag = false
- this.bluetoothflag = false
- uni.removeStorageSync('mac');
- let systemInfo = uni.getSystemInfoSync();
- if (systemInfo.platform == 'android') {
- // 当前设备是 Android
- uni.navigateTo({
- url: '/page_components/wifilist/index?deviceId=' +this.deviceId + '&name=' +this.name
- })
- } else if (systemInfo.platform == 'ios') {
- // 当前设备是 iOS
- uni.navigateTo({
- url: '/page_fenbao/device/wifivideo?deviceId=' +this.deviceId + '&name=' +this.name
- })
- }
- }else if(res.msg == '设备编号和mac不能同时为空'){
- this.shibaiflag = true
- this.bluetoothflag = false
- // uni.showToast({
- // title: '连接失败',
- // icon: 'none',
- // duration: 2000
- // });
- } else {
- // uni.showToast({
- // title: res.msg,
- // icon: 'none',
- // duration: 2000
- // });
- // uni.navigateBack()
- }
- })
- }, 1000)
- }else{
- let name = ''
- let index = this.name.indexOf('-');
- if (index !== -1) {
- name = this.name.slice(index + 1);
- }
- let data = {
- storeId: this.storeId,
- mac: this.mac
- }
- this.$u.put('/app/device/bind', data).then((res) => {
- if (res.code == 200) {
- // uni.showToast({
- // title: '绑定成功',
- // icon: 'none',
- // duration: 2000
- // })
- this.shibaiflag = false
- this.bluetoothflag = false
- uni.hideLoading();
- uni.removeStorageSync('mac');
- let systemInfo = uni.getSystemInfoSync();
- if (systemInfo.platform == 'android') {
- // 当前设备是 Android
- uni.navigateTo({
- url: '/page_components/wifilist/index?deviceId=' +this.deviceId + '&name=' +this.name
- })
- } else if (systemInfo.platform == 'ios') {
- // 当前设备是 iOS
- uni.navigateTo({
- url: '/page_fenbao/device/wifivideo?deviceId=' +this.deviceId + '&name=' +this.name
- })
- }
- }else {
- if(res.msg == '设备编号和mac不能同时为空'){
- this.shibaiflag = true
- this.bluetoothflag = false
- uni.hideLoading()
- // uni.showToast({
- // title: '连接失败',
- // icon: 'none',
- // duration: 2000
- // })
- } else {
- this.shibaiflag = true
- this.bluetoothflag = false
- uni.hideLoading()
- uni.showToast({
- title:res.msg,
- icon: 'none',
- duration: 2000
- })
- // uni.navigateBack()
- }
- }
- })
+ this.bluetoothflag = true
+ // console.log(this.deviceId,'idididididdidii');
+ if (this.setMode == null) {
+ xBlufi.initXBlufi(1)
+ xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent);
+ xBlufi.notifyStartDiscoverBle({
+ 'isStart': true
+ })
+
+ // 停止蓝牙搜索
+ setTimeout(() => {
+ xBlufi.notifyStartDiscoverBle({
+ 'isStart': false
+ })
+ xBlufi.notifyConnectBle({
+ isStart: true,
+ deviceId: this.deviceId,
+ name: this.name
+ })
+ xBlufi.notifyInitBleEsp32({
+ deviceId: this.deviceId
+ })
+ let name = ''
+ let index = this.name.indexOf('-');
+ if (index !== -1) {
+ name = this.name.slice(index + 1);
}
- },
-
+ let data = {
+ storeId: this.storeId,
+ mac: this.mac
+ }
+ this.$u.put('/app/device/bind', data).then((res) => {
+ if (res.code == 200) {
+ uni.hideLoading();
+ this.shibaiflag = false
+ this.bluetoothflag = false
+ uni.removeStorageSync('mac');
+ let systemInfo = uni.getSystemInfoSync();
+ if (systemInfo.platform == 'android') {
+ // 当前设备是 Android
+ uni.navigateTo({
+ url: '/page_components/wifilist/index?deviceId=' + this
+ .deviceId + '&name=' + this.name
+ })
+ } else if (systemInfo.platform == 'ios') {
+ // 当前设备是 iOS
+ uni.navigateTo({
+ url: '/page_fenbao/device/wifivideo?deviceId=' + this
+ .deviceId + '&name=' + this.name
+ })
+ }
+ } else if (res.msg == '设备编号和mac不能同时为空') {
+ this.shibaiflag = true
+ this.bluetoothflag = false
+ // uni.showToast({
+ // title: '连接失败',
+ // icon: 'none',
+ // duration: 2000
+ // });
+ } else {
+ // uni.showToast({
+ // title: res.msg,
+ // icon: 'none',
+ // duration: 2000
+ // });
+ // uni.navigateBack()
+ }
+ })
+ }, 1000)
+ } else {
+ let name = ''
+ let index = this.name.indexOf('-');
+ if (index !== -1) {
+ name = this.name.slice(index + 1);
+ }
+ let data = {
+ storeId: this.storeId,
+ mac: this.mac
+ }
+ this.$u.put('/app/device/bind', data).then((res) => {
+ if (res.code == 200) {
+ // uni.showToast({
+ // title: '绑定成功',
+ // icon: 'none',
+ // duration: 2000
+ // })
+ this.shibaiflag = false
+ this.bluetoothflag = false
+ uni.hideLoading();
+ uni.removeStorageSync('mac');
+ let systemInfo = uni.getSystemInfoSync();
+ if (systemInfo.platform == 'android') {
+ // 当前设备是 Android
+ uni.navigateTo({
+ url: '/page_components/wifilist/index?deviceId=' + this.deviceId +
+ '&name=' + this.name
+ })
+ } else if (systemInfo.platform == 'ios') {
+ // 当前设备是 iOS
+ uni.navigateTo({
+ url: '/page_fenbao/device/wifivideo?deviceId=' + this.deviceId +
+ '&name=' + this.name
+ })
+ }
+ } else {
+ if (res.msg == '设备编号和mac不能同时为空') {
+ this.shibaiflag = true
+ this.bluetoothflag = false
+ uni.hideLoading()
+ // uni.showToast({
+ // title: '连接失败',
+ // icon: 'none',
+ // duration: 2000
+ // })
+ } else {
+ this.shibaiflag = true
+ this.bluetoothflag = false
+ uni.hideLoading()
+ uni.showToast({
+ title: res.msg,
+ icon: 'none',
+ duration: 2000
+ })
+ // uni.navigateBack()
+ }
+ }
+ })
+ }
+ },
+
sremakes() {
- if(this.wateringList.length == 0){
+ if (this.wateringList.length == 0) {
let that = this
uni.showModal({
title: '提示',
@@ -588,30 +598,30 @@
success: function(res) {
if (res.confirm) {
uni.navigateTo({
- url:'/page_fenbao/statulist/myshop/shopxx/index'
+ url: '/page_fenbao/statulist/myshop/shopxx/index?id=' + that.id
})
} else if (res.cancel) {
-
+
}
}
})
- }else{
+ } else {
this.showshop = true
}
},
- confirms(e){
+ confirms(e) {
console.log(e);
let data = {
deviceId: this.id,
- storeId:e[0].value
+ storeId: e[0].value
}
this.putdevice(data)
- setTimeout(()=>{
+ setTimeout(() => {
this.getlistobj(this.id)
- },1000)
+ }, 1000)
},
-
- gettanc(){
+
+ gettanc() {
this.$u.get('/app/store/listCount').then((res) => {
if (res.code == 200) {
this.total = res.total
@@ -633,7 +643,7 @@
}
})
},
-
+
onReachBottom() {
let sum = this.total / this.pagesize
if (this.pagenum - 1 < sum) {
@@ -685,7 +695,7 @@
this.showpeice = false
this.showmc = false
this.putdevice(data)
- }else if(num == 3){
+ } else if (num == 3) {
console.log(this.xgname);
let data = {
deviceId: this.id,
@@ -695,50 +705,50 @@
this.showpeice = false
this.showmc = false
this.putdevice(data)
- setTimeout(()=>{
+ setTimeout(() => {
this.getlistobj(this.id)
- },1000)
+ }, 1000)
}
},
deldevice() {
- uni.showModal({
- title: '确认解绑',
- content: '您确定要解绑设备吗?',
- success: (resModal) => {
- if (resModal.confirm) {
- this.$u.delete(`/app/device/mch/unbind/${this.id}`).then((res) => {
- if (res.code == 200) {
- uni.showToast({
- title: '解除成功',
- icon: 'none',
- duration: 2000
- });
- uni.navigateBack({
- delta: 2 // 返回上级页面
- });
- } else if(res.code == 500){
- uni.showToast({
- title: res.msg,
- icon: 'none',
- duration: 2000
- });
- }
- }).catch((error) => {
- // 请求失败的处理逻辑
- uni.showToast({
- title: '请求失败',
- icon: 'none',
- duration: 2000
- });
- });
- } else if (resModal.cancel) { // 用户点击了取消按钮
- uni.showToast({
- title: '已取消',
- icon: 'none',
- duration: 1000
- });
- }
- }
+ uni.showModal({
+ title: '确认解绑',
+ content: '您确定要解绑设备吗?',
+ success: (resModal) => {
+ if (resModal.confirm) {
+ this.$u.delete(`/app/device/mch/unbind/${this.id}`).then((res) => {
+ if (res.code == 200) {
+ uni.showToast({
+ title: '解除成功',
+ icon: 'none',
+ duration: 2000
+ });
+ uni.navigateBack({
+ delta: 2 // 返回上级页面
+ });
+ } else if (res.code == 500) {
+ uni.showToast({
+ title: res.msg,
+ icon: 'none',
+ duration: 2000
+ });
+ }
+ }).catch((error) => {
+ // 请求失败的处理逻辑
+ uni.showToast({
+ title: '请求失败',
+ icon: 'none',
+ duration: 2000
+ });
+ });
+ } else if (resModal.cancel) { // 用户点击了取消按钮
+ uni.showToast({
+ title: '已取消',
+ icon: 'none',
+ duration: 1000
+ });
+ }
+ }
});
},
confirm(e) {
@@ -754,14 +764,13 @@
this.getDevice()
uni.showToast({
title: '修改成功',
- icon: 'none',
+ icon: 'success',
duration: 2000
- });
-
+ })
}
})
},
- sremakemc(){
+ sremakemc() {
console.log(1);
this.showmc = true
this.xgname = this.listobj.deviceName
@@ -778,17 +787,17 @@
this.showpeice = false
this.showremake = false
this.showpopup = false
- this.showmc = false
+ this.showmc = false
},
getDevice(id) {
this.$u.get("/app/device/" + this.id).then((res) => {
// this.$forceUpdate()
if (res.code == 200) {
this.deviceInfo = res.data
- this.storeId = res.data.storeId
+ this.storeId = res.data.storeId
this.price = this.deviceInfo.price
this.remake = this.deviceInfo.remark
- this.qrResult = 'CTKG-' + res.data.mac
+ this.qrResult = 'CTKG-' + res.data.mac
}
});
@@ -809,13 +818,13 @@
this.$u.get("/app/device/" + id).then((res) => {
if (res.code == 200) {
this.listobj = res.data
- if(res.data.customPicture){
+ if (res.data.customPicture) {
this.userImgs = res.data.customPicture
}
}
})
},
-
+
funListenDeviceMsgEvent: function(options) {
switch (options.type) {
case xBlufi.XBLUFI_TYPE.TYPE_RECIEVE_MY_DATA:
@@ -824,9 +833,9 @@
// console.log("文件读取中", options.data);
break;
case xBlufi.XBLUFI_TYPE.TYPE_RECIEVE_CUSTON_DATA:
- let ver_data = this.parseCustomData(options.data)
+ let ver_data = this.parseCustomData(options.data)
this.setMode = Math.floor(ver_data.setMode / 60)
- console.log("1收到设备发来的自定义数据结果:", ver_data,this.setMode)
+ console.log("1收到设备发来的自定义数据结果:", ver_data, this.setMode)
break;
case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS:
if (options.result) {
@@ -873,10 +882,10 @@
case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS_START:
if (!options.result) {
- setTimeout(()=>{
+ setTimeout(() => {
uni.hideLoading()
this.bluetoothflag = false
- },3000)
+ }, 3000)
console.log("蓝牙未开启", options);
// uni.showToast({
// title: '蓝牙未开启',
@@ -934,7 +943,7 @@
parseCustomData(data) {
// 将字符串按照 "@" 分割成数组
const dataArray = data.split('@');
-
+
// 根据约定,解析各个字段的值
const voltage = parseFloat(dataArray[0].substring(1)); // 去除前缀 "V",并将字符串转换为浮点数
const switchState = dataArray[1].substring(1); // 去除前缀 "S"
@@ -942,7 +951,7 @@
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,
@@ -958,27 +967,31 @@