From 03a1b6994b23e5565b211e926b27d80b03f3609b Mon Sep 17 00:00:00 2001 From: "3321822538@qq.com" <3321822538@qq.com> Date: Tue, 22 Oct 2024 18:01:20 +0800 Subject: [PATCH] 111 --- page_user/lanya.vue | 14 +-- page_user/opinion.vue | 34 ++--- page_user/photo.vue | 68 +++++----- page_user/photoxq.vue | 6 +- page_user/yinsixq.vue | 18 ++- pages/index/index.vue | 245 +++++++++++++++++++++++++++---------- pages/login/denglu.vue | 27 +++- pages/login/wjpassword.vue | 82 +++++++++++-- pages/login/zhuce.vue | 44 +++++-- pages/my.vue | 13 +- 10 files changed, 384 insertions(+), 167 deletions(-) diff --git a/page_user/lanya.vue b/page_user/lanya.vue index 610413a..20eac89 100644 --- a/page_user/lanya.vue +++ b/page_user/lanya.vue @@ -88,7 +88,7 @@ onLoad() { let that = this xBlufi.initXBlufi(1); - xBlufi.listenDeviceMsgEvent(true, that.funListenDeviceMsgEvent); + xBlufi.listenDeviceMsgEvent(true, that.funListenDeviceMsgEvent) xBlufi.notifyStartDiscoverBle({ 'isStart': true }) @@ -113,7 +113,7 @@ this.flag = false let that = this xBlufi.initXBlufi(1); - xBlufi.listenDeviceMsgEvent(true, that.funListenDeviceMsgEvent); + xBlufi.listenDeviceMsgEvent(true, that.funListenDeviceMsgEvent) xBlufi.notifyStartDiscoverBle({ 'isStart': true }) @@ -190,14 +190,14 @@ break; case xBlufi.XBLUFI_TYPE.TYPE_RECIEVE_CUSTON_DATA: this.ver_data = this.parseCustomData(options.data) - console.log("1收到设备发来的自定义数据结果:", this.ver_data); + console.log("1收到设备发来的自定义数据结果:", this.ver_data) 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, 5) === "WATER"); + let uniqueDevicesList = Array.from(new Set(this.devicesList)) + let filteredDevices = uniqueDevicesList.filter(device => device.name.substring(0, 5) === "WATER") // 将过滤后的数组重新赋值给 this.devicesList - this.devicesList = filteredDevices; + this.devicesList = filteredDevices } break; case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS_START: @@ -233,7 +233,7 @@ power, remainingPower, setMode - }; + } }, } } diff --git a/page_user/opinion.vue b/page_user/opinion.vue index 524274e..0fc57be 100644 --- a/page_user/opinion.vue +++ b/page_user/opinion.vue @@ -40,14 +40,12 @@ 上传图片 - - 上传问题图片可以让问题快速解决哦! @@ -58,15 +56,6 @@ - - - - - - 联系方式 - - - 提交 @@ -85,7 +74,6 @@ imglist: [], token: '', contact: '', - stause:false, picdomain:'' } }, @@ -109,21 +97,19 @@ } }, onLoad() { - - this.getQiniuToken() - // this.getstause() + this.getQiniuToken() }, methods: { hidePlaceholder() { - this.placeholderVisible = false; + this.placeholderVisible = false }, showPlaceholder() { if (!this.textValue) { - this.placeholderVisible = true; + this.placeholderVisible = true } }, updateWordCount() { - this.currentCount = this.textValue.trim().replace(/\s+/g, '').length; + this.currentCount = this.textValue.trim().replace(/\s+/g, '').length }, sub() { if (this.cutidx == -1) { @@ -131,21 +117,21 @@ title: '请选择反馈类型', icon: 'none', duration: 2000 - }); + }) } else if (this.textValue == '') { uni.showToast({ title: '请输入问题描述', icon: 'none', duration: 2000 - }); + }) } else if (this.contact == '') { uni.showToast({ title: '请输入联系方式', icon: 'none', duration: 2000 - }); + }) } else { - var imgString = this.imglist.join(','); + var imgString = this.imglist.join(',') let data = { type: this.cutidx, issueDescription: this.textValue, @@ -163,7 +149,7 @@ uni.navigateBack() },1500) } - }); + }) } }, btn() { @@ -183,7 +169,7 @@ key: 'smartmeter/img/' + math }, success: function(res) { - console.log(res, 'resres'); + console.log(res, 'resres') let str = JSON.parse(res.data) _this.userImgs = _this.picdomain + '/' + str.key console.log(_this.userImgs) diff --git a/page_user/photo.vue b/page_user/photo.vue index bdbfbe1..f20b12f 100644 --- a/page_user/photo.vue +++ b/page_user/photo.vue @@ -92,12 +92,12 @@ // 点击拍照 photo() { let that = this - const cameraContext = uni.createCameraContext(); + const cameraContext = uni.createCameraContext() cameraContext.takePhoto({ quality: 'high', success: (res) => { - console.log(res); - const tempFilePath = res.tempImagePath; + console.log(res) + const tempFilePath = res.tempImagePath that.maskpic = res.tempImagePath that.tempFilePathpic = res.tempImagePath uni.showLoading({ @@ -121,22 +121,22 @@ userId:that.userid } that.$u.get(`/app/plant/identify`,data).then((res) => { - if (res.code == 200) { - that.zwlist = res.data - uni.hideLoading() - // 跳转到植物列表 - uni.navigateTo({ - url: '/page_user/photolist?list=' + JSON.stringify(that.zwlist) + '&cart=' + JSON.stringify(that.tempFilePathpic) - }) - } else { - uni.showToast({ - title: '网络波动异常,请重新识别', - icon: 'none', - duration: 1000 - }) - } - }) - } + if (res.code == 200) { + that.zwlist = res.data + uni.hideLoading() + // 跳转到植物列表 + uni.navigateTo({ + url: '/page_user/photolist?list=' + JSON.stringify(that.zwlist) + '&cart=' + JSON.stringify(that.tempFilePathpic) + }) + } else { + uni.showToast({ + title: '网络波动异常,请重新识别', + icon: 'none', + duration: 1000 + }) + } + }) + } }) } }) @@ -180,21 +180,21 @@ userId:that.userid } that.$u.get(`/app/plant/identify`,data).then((res) => { - if (res.code == 200) { - that.zwlist = res.data - uni.hideLoading() - // 跳转到植物列表 - uni.navigateTo({ - url: '/page_user/photolist?list=' + JSON.stringify(that.zwlist) + '&cart=' + JSON.stringify(that.tempFilePathpic) - }) - } else { - uni.showToast({ - title: '网络波动异常,请重新识别', - icon: 'none', - duration: 1000 - }) - } - }) + if (res.code == 200) { + that.zwlist = res.data + uni.hideLoading() + // 跳转到植物列表 + uni.navigateTo({ + url: '/page_user/photolist?list=' + JSON.stringify(that.zwlist) + '&cart=' + JSON.stringify(that.tempFilePathpic) + }) + } else { + uni.showToast({ + title: '网络波动异常,请重新识别', + icon: 'none', + duration: 1000 + }) + } + }) } }) } diff --git a/page_user/photoxq.vue b/page_user/photoxq.vue index 655c5c4..866c88f 100644 --- a/page_user/photoxq.vue +++ b/page_user/photoxq.vue @@ -121,14 +121,14 @@ }, parseData(text) { // 根据换行符分割文本为数组 - const items = text.split('\n'); + const items = text.split('\n') // 遍历每个条目,并添加序号 items.forEach((item, index) => { // 去除条目前后的空白字符 - const trimmedItem = item.trim(); + const trimmedItem = item.trim() // 如果条目不为空,则添加到格式化列表中,并添加序号 if (trimmedItem) { - this.formattedList.push(`${trimmedItem}`); + this.formattedList.push(`${trimmedItem}`) } }) }, diff --git a/page_user/yinsixq.vue b/page_user/yinsixq.vue index e46797a..a8c5e52 100644 --- a/page_user/yinsixq.vue +++ b/page_user/yinsixq.vue @@ -3,7 +3,9 @@ - + + + @@ -15,7 +17,9 @@ bgc: { backgroundColor: "#fff", }, - tit:'' + tit:'', + id:'', + cont:'' } }, // 分享到好友(会话) @@ -36,9 +40,17 @@ }, onLoad(option) { this.tit = option.tit + this.id = option.id + this.getxq() }, methods:{ - + getxq() { + this.$u.get(`/app/article/${this.id}`).then((res) => { + if (res.code == 200) { + this.cont = res.data.content + } + }) + }, } } diff --git a/pages/index/index.vue b/pages/index/index.vue index 31780af..b4c20e7 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -76,18 +76,22 @@ + - 雨水感应 + 雨水感应 + + - 儿童锁 + 儿童锁 + @@ -175,8 +179,12 @@ }, data() { return { - yschecked: true, - etchecked: true, + one:false, + ones:true, + two:false, + twos:true, + yschecked: '', + etchecked: '', kgflag: false, activeshu: 0, xuanzeflag: false, @@ -221,8 +229,8 @@ }, onLoad() { let that = this - xBlufi.initXBlufi(1); - xBlufi.listenDeviceMsgEvent(true, that.funListenDeviceMsgEvent); + xBlufi.initXBlufi(1) + xBlufi.listenDeviceMsgEvent(true, that.funListenDeviceMsgEvent) xBlufi.notifyStartDiscoverBle({ 'isStart': true }) @@ -246,57 +254,148 @@ }, methods: { + kq(){ + uni.getNetworkType({ + success(res) { + if (res.networkType !== 'none') { + uni.getConnectedBluetoothDevices({ + success(res) { + setTimeout(()=> { + xBlufi.notifySendCustomData({ + customData:'11open' + }) + },1500) + }, + fail(err) { + console.error('获取已连接蓝牙设备信息失败:',err) + } + }) + } else { + console.log('手机未连接网络') + } + } + }) + }, + gb(){ + uni.getNetworkType({ + success(res) { + if (res.networkType !== 'none') { + uni.getConnectedBluetoothDevices({ + success(res) { + setTimeout(()=> { + xBlufi.notifySendCustomData({ + customData:'11close' + }) + },1500) + }, + fail(err) { + console.error('获取已连接蓝牙设备信息失败:',err) + } + }) + } else { + console.log('手机未连接网络') + } + } + }) + }, // 雨水感应 btnyushui(){ - if(this.yschecked == true){ - let that = this - uni.getNetworkType({ - success(res) { - if (res.networkType !== 'none') { - uni.getConnectedBluetoothDevices({ - success(res) { - setTimeout(()=> { - xBlufi.notifySendCustomData({ - customData:'qlose' - }) - that.yschecked = false - },1500) - }, - fail(err) { - console.error('获取已连接蓝牙设备信息失败:',err) - } - }) - } else { - console.log('手机未连接网络') - } + let that = this + uni.getNetworkType({ + success(res) { + if (res.networkType !== 'none') { + uni.getConnectedBluetoothDevices({ + success(res) { + setTimeout(()=> { + that.yschecked = false + xBlufi.notifySendCustomData({ + customData:'11yudi' + }) + },1500) + }, + fail(err) { + console.error('获取已连接蓝牙设备信息失败:',err) + } + }) + } else { + console.log('手机未连接网络') } - }) - }else{ - console.log(11); - let that = this - uni.getNetworkType({ - success(res) { - if (res.networkType !== 'none') { - uni.getConnectedBluetoothDevices({ - success(res) { - setTimeout(()=> { - xBlufi.notifySendCustomData({ - customData:'qpen' - }) - that.yschecked = true - },1500) - }, - fail(err) { - console.error('获取已连接蓝牙设备信息失败:',err) - } - }) - } else { - console.log('手机未连接网络') - } - } - }) - } + } + }) }, + btnyushuis(){ + let that = this + uni.getNetworkType({ + success(res) { + if (res.networkType !== 'none') { + uni.getConnectedBluetoothDevices({ + success(res) { + setTimeout(()=> { + that.yschecked = true + xBlufi.notifySendCustomData({ + customData:'11unyudi' + }) + },1500) + }, + fail(err) { + console.error('获取已连接蓝牙设备信息失败:',err) + } + }) + } else { + console.log('手机未连接网络') + } + } + }) + }, + // 点击儿童锁 + btnertong(){ + let that = this + uni.getNetworkType({ + success(res) { + if (res.networkType !== 'none') { + uni.getConnectedBluetoothDevices({ + success(res) { + setTimeout(()=> { + that.etchecked = false + xBlufi.notifySendCustomData({ + customData:'11lock' + }) + },1500) + }, + fail(err) { + console.error('获取已连接蓝牙设备信息失败:',err) + } + }) + } else { + console.log('手机未连接网络') + } + } + }) + }, + btnertongs(){ + let that = this + uni.getNetworkType({ + success(res) { + if (res.networkType !== 'none') { + uni.getConnectedBluetoothDevices({ + success(res) { + setTimeout(()=> { + that.etchecked = true + xBlufi.notifySendCustomData({ + customData:'11unlock' + }) + },1500) + }, + fail(err) { + console.error('获取已连接蓝牙设备信息失败:',err) + } + }) + } else { + console.log('手机未连接网络') + } + } + }) + }, // 点击添加设备 btnaddsb(){ @@ -434,22 +533,40 @@ case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS: if (options.result) { let devicesarr = options.data - console.log(devicesarr,'111'); + console.log(devicesarr,'111') devicesarr.forEach(device => { - const mac = device.name.substring(4); + const mac = device.name.substring(4) if (device.name.slice(5, 17) == this.mac) { this.deviceId = device.deviceId this.name = device.name // console.log(device.name,this.mac,'222'); - this.devicesList.push(device); - let uniqueDevicesList = Array.from(new Set(this.devicesList)); + this.devicesList.push(device) + let uniqueDevicesList = Array.from(new Set(this.devicesList)) this.devicesList = uniqueDevicesList; } }) } break; case xBlufi.XBLUFI_TYPE.TYPE_CONNECTED: - console.log("连接回调:" + JSON.stringify(options)); + console.log("连接回调:" + JSON.stringify(options)) + uni.getNetworkType({ + success(res) { + if (res.networkType !== 'none') { + uni.getConnectedBluetoothDevices({ + success(res) { + setTimeout(()=> { + xBlufi.notifySendCustomData({ + customData: "11unlock" + }) + },1500) + }, + fail(err) { + console.error('获取已连接蓝牙设备信息失败:',err) + } + }) + } + } + }) uni.setStorageSync('device_key', 'true') if (options.result) { { @@ -464,15 +581,15 @@ } break; case xBlufi.XBLUFI_TYPE.TYPE_RECIEVE_CUSTON_DATA: - console.log("1收到设备发来的自定义数据结果:", options.data); + console.log("1收到设备发来的自定义数据结果:", options.data) this.ver_data = this.parseCustomData(options.data) break; case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS_STOP: if (options.result) { - let uniqueDevicesList = Array.from(new Set(this.devicesList)); + let uniqueDevicesList = Array.from(new Set(this.devicesList)) let filteredDevices = uniqueDevicesList.filter(device => device.name.substring(0, 5) === "WATER") // 将过滤后的数组重新赋值给 this.devicesList - this.devicesList = filteredDevices; + this.devicesList = filteredDevices } break; case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS_START: @@ -483,12 +600,10 @@ duration: 3000 }) return - } else { - } break - } - }, + } + }, // 从蓝牙拿到数据进行解析 parseCustomData(data) { diff --git a/pages/login/denglu.vue b/pages/login/denglu.vue index cc89424..efd5856 100644 --- a/pages/login/denglu.vue +++ b/pages/login/denglu.vue @@ -29,7 +29,7 @@ 忘记密码 - + 登录 @@ -79,6 +79,29 @@ }, methods:{ + // 点击登录 + btndl(){ + let data = { + phone:this.tel, + // phoneCode:this.yzm, + // uuid:this.uuid, + password:this.password + } + this.$u.post(`/appCodeLogin`,data).then((res) => { + if (res.code == 200) { + wx.setStorageSync('token', res.token) + uni.switchTab({ + url:'/pages/index/index' + }) + }else{ + uni.showToast({ + title: res.msg, + icon: 'none', + duration: 2000 + }) + } + }) + }, // 点击微信一键登录 getPhoneNumber(e) { this.jsCode = e.detail.code @@ -107,7 +130,7 @@ wxLoginAsync().then(async (data) => { this.$u.post(`/wxlogin?mobileCode=${this.jsCode}&jsCode=${this.mobileCode}`, data).then((res) => { if (res.code == 200) { - wx.setStorageSync('token', res.token); + wx.setStorageSync('token', res.token) uni.switchTab({ url:'/pages/index/index' }) diff --git a/pages/login/wjpassword.vue b/pages/login/wjpassword.vue index ccc7a26..33e8d5c 100644 --- a/pages/login/wjpassword.vue +++ b/pages/login/wjpassword.vue @@ -49,7 +49,7 @@ - + 确定 @@ -70,7 +70,8 @@ tel:'', yzm:'', countdown: 60, - timer: null + timer: null, + uuid:'' } }, // 分享到好友(会话) @@ -94,9 +95,69 @@ }, onUnload() { // 页面卸载时清除定时器,防止内存泄漏 - clearInterval(this.timer); + clearInterval(this.timer) }, methods:{ + // 点击确定忘记密码 + btnwj(){ + if(this.tel == ''){ + uni.showToast({ + title: '手机号不能为空', + icon: 'none', + duration: 2000 + }) + }else if(this.yzm == ''){ + uni.showToast({ + title: '验证码不能为空', + icon: 'none', + duration: 2000 + }) + }else if(this.password == ''){ + uni.showToast({ + title: '新密码不能为空', + icon: 'none', + duration: 2000 + }) + }else if(this.passwords == ''){ + uni.showToast({ + title: '确认新密码不能为空', + icon: 'none', + duration: 2000 + }) + }else if(this.password != this.passwords){ + uni.showToast({ + title: '两次密码不一致', + icon: 'none', + duration: 2000 + }) + }else{ + let data = { + phone:this.tel, + phoneCode:this.yzm, + uuid:this.uuid, + password:this.password + } + this.$u.put(`/forgetAppPwd?phone=${this.tel}&phoneCode=${this.yzm}&newPassword=${this.password}&uuid=${this.uuid}`,data).then((res) => { + if (res.code == 200) { + uni.showToast({ + title: '操作成功', + icon: 'none', + duration: 2000 + }) + setTimeout(()=>{ + uni.navigateBack() + },1500) + }else{ + uni.showToast({ + title: res.msg, + icon: 'none', + duration: 2000 + }) + } + }) + } + }, + btn(num){ if(num == 1){ this.txt = 'txt' @@ -121,25 +182,24 @@ if (this.countdown > 0) { this.countdown-- } else { - clearInterval(this.timer); // 倒计时结束,清除定时器 + clearInterval(this.timer) // 倒计时结束,清除定时器 this.countdown = 60 } - }, 1000); // 每秒更新一次 + }, 1000) // 每秒更新一次 }, // 如果需要在其他地方停止倒计时,可以添加这个方法 stopCountdown() { - clearInterval(this.timer); - this.countdown = 0; // 可选:将倒计时重置为0 + clearInterval(this.timer) + this.countdown = 0 // 可选:将倒计时重置为0 }, // 点击获取验证码 btnhuoqu(){ this.startCountdown() + this.$u.get(`appCaptcha?phone=${this.tel}&type=2`).then(res => { + this.uuid = res.uuid + }) }, - // 点击确认忘记密码 - btnqr(){ - console.log(1); - } } } diff --git a/pages/login/zhuce.vue b/pages/login/zhuce.vue index 955f1f9..c51d1c8 100644 --- a/pages/login/zhuce.vue +++ b/pages/login/zhuce.vue @@ -43,7 +43,7 @@ - 我已阅读并同意 用户协议隐私政策 + 我已阅读并同意 用户协议隐私政策 注册并登录 @@ -78,7 +78,8 @@ tel:'', yzm:'', countdown: 60, - timer: null + timer: null, + uuid:'' } }, // 分享到好友(会话) @@ -102,7 +103,7 @@ }, onUnload() { // 页面卸载时清除定时器,防止内存泄漏 - clearInterval(this.timer); + clearInterval(this.timer) }, methods:{ // 注册并登录 @@ -132,7 +133,26 @@ duration: 2000 }) }else{ - + let data = { + phone:this.tel, + phoneCode:this.yzm, + uuid:this.uuid, + password:this.password + } + this.$u.post(`/appCodeLogin`,data).then((res) => { + if (res.code == 200) { + wx.setStorageSync('token', res.token) + uni.switchTab({ + url:'/pages/index/index' + }) + }else{ + uni.showToast({ + title: res.msg, + icon: 'none', + duration: 2000 + }) + } + }) } }, @@ -164,7 +184,7 @@ wxLoginAsync().then(async (data) => { this.$u.post(`/wxlogin?mobileCode=${this.jsCode}&jsCode=${this.mobileCode}`, data).then((res) => { if (res.code == 200) { - wx.setStorageSync('token', res.token); + wx.setStorageSync('token', res.token) uni.switchTab({ url:'/pages/index/index' }) @@ -192,21 +212,23 @@ if (this.countdown > 0) { this.countdown-- } else { - clearInterval(this.timer); // 倒计时结束,清除定时器 + clearInterval(this.timer) // 倒计时结束,清除定时器 this.countdown = 60 } }, 1000); // 每秒更新一次 }, // 如果需要在其他地方停止倒计时,可以添加这个方法 stopCountdown() { - clearInterval(this.timer); - this.countdown = 0; // 可选:将倒计时重置为0 + clearInterval(this.timer) + this.countdown = 0 // 可选:将倒计时重置为0 }, // 点击获取验证码 btnhuoqu(){ this.startCountdown() - this.$u.get(`appCaptcha?phone=${this.tel}&type=2`).then(res => {}) + this.$u.get(`appCaptcha?phone=${this.tel}&type=2`).then(res => { + this.uuid = res.uuid + }) }, // 点击跳转到立即登录页 btnljdl(){ @@ -218,11 +240,11 @@ btnyh(num){ if(num == 1){ uni.navigateTo({ - url:'/page_user/yinsixq?tit=' + '用户协议' + url:'/page_user/yinsixq?tit=' + '用户协议' + '&id=' + 1 }) }else{ uni.navigateTo({ - url:'/page_user/yinsixq?tit=' + '隐私政策' + url:'/page_user/yinsixq?tit=' + '隐私政策' + '&id=' + 2 }) } } diff --git a/pages/my.vue b/pages/my.vue index e3d1863..96470be 100644 --- a/pages/my.vue +++ b/pages/my.vue @@ -65,7 +65,6 @@ imageSrc:'', token:'', picdomain:'' - } }, // 分享到好友(会话) @@ -91,7 +90,7 @@ methods: { // 获取用户信息 getinfo() { - this.$u.get(`//appVerify/profile`).then((res) => { + this.$u.get(`/appVerify/profile`).then((res) => { if (res.code == 200) { this.userobj = res.data this.imageSrc = res.data.avatar @@ -148,15 +147,15 @@ btnxq(num){ if(num == 1){ uni.navigateTo({ - url:'/page_user/yinsixq?tit=' + '隐私政策' + url:'/page_user/yinsixq?tit=' + '隐私政策' + '&id=' + 2 }) }else if(num == 2){ uni.navigateTo({ - url:'/page_user/yinsixq?tit=' + '用户协议' + url:'/page_user/yinsixq?tit=' + '用户协议' + '&id=' + 1 }) }else if(num == 3){ uni.navigateTo({ - url:'/page_user/yinsixq?tit=' + '关于我们' + url:'/page_user/yinsixq?tit=' + '关于我们' + '&id=' + 3 }) }else if(num == 4){ uni.showModal({ @@ -166,10 +165,10 @@ if (res.confirm) { uni.clearStorage().then(() => { // 成功清空所有本地存储 - console.log('所有本地存储数据已清空'); + console.log('所有本地存储数据已清空') }).catch((error) => { // 处理错误 - console.error('清空本地存储失败', error); + console.error('清空本地存储失败', error) }) uni.reLaunch({ url:'/pages/login/login'