diff --git a/page_user/dingshi.vue b/page_user/dingshi.vue index e1c08e2..b4f5da3 100644 --- a/page_user/dingshi.vue +++ b/page_user/dingshi.vue @@ -4,52 +4,56 @@ id="navbar"> - - - - {{ formattedTime(values[0], values[1]) }} - P{{ index + 1 }} {{ formatTime(values[2]) }} - - - - - - - - - - - 设置浇水 - - - 距离下次浇水时间还有{{xctime}} - - - {{hour}}时 {{minutekq}}分 - - - 浇水时长 - - - {{minute}}分 {{second}}秒 - - - - 取消 - - - 确定 - - + + + + + {{ formattedTime(values[0], values[1]) }} + P{{ index + 1 }} {{ formatTime(values[2]) }} + + + + + + + + + + + 设置浇水 + + + 距离下次浇水时间还有{{xctime}} + + + {{hour}}时 {{minutekq}}分 + + + 浇水时长 + + + {{minute}}分 {{second}}秒 + + + + 取消 + + + 确定 + + + + + + + + + + + + + 设备未连接 - - - - - - - - @@ -65,7 +69,7 @@ flag:false, checked:false, timeflag:false, - + show: false, params: { year: false, diff --git a/page_user/photo.vue b/page_user/photo.vue index f20b12f..d35b24c 100644 --- a/page_user/photo.vue +++ b/page_user/photo.vue @@ -83,7 +83,7 @@ } }) }, - + // 返回首页 btnback() { uni.switchTab({ url: '/pages/index/index' @@ -130,10 +130,11 @@ }) } else { uni.showToast({ - title: '网络波动异常,请重新识别', + title: '识别失败,请重新识别', icon: 'none', duration: 1000 }) + that.maskpic = '' } }) } @@ -141,13 +142,13 @@ } }) }, - + // 处理相机错误情况 handleCameraError(e) { console.error('相机出错:', e.detail); - // 处理相机错误情况 }, + // 切换摄像头位置 switchCamera() { - this.cameraPosition = this.cameraPosition == 'back' ? 'front' : 'back'; // 切换摄像头位置 + this.cameraPosition = this.cameraPosition == 'back' ? 'front' : 'back'; }, // 从相册选择图 uploadPictrue() { @@ -189,7 +190,7 @@ }) } else { uni.showToast({ - title: '网络波动异常,请重新识别', + title: '识别失败,请重新识别', icon: 'none', duration: 1000 }) diff --git a/page_user/photolist.vue b/page_user/photolist.vue index 0c0cdd1..bdfa216 100644 --- a/page_user/photolist.vue +++ b/page_user/photolist.vue @@ -8,20 +8,18 @@ - + {{item.name}} {{Number(item.score * 100).toFixed(1) + '%'}} - {{item.msg == null ? '暂无简介' : item.msg}} + {{ item.introduce == null ? '暂无简介' : (item.introduce.length > 20 ? item.introduce.substring(0, 20) + '...' : item.introduce) }} - - @@ -55,16 +53,24 @@ } }, onLoad(option) { - this.cartpic = JSON.parse(option.cart) - this.zwlist = JSON.parse(option.list) + this.cartpic = JSON.parse(option.cart) //植物图片 + this.zwlist = JSON.parse(option.list) //植物信息 }, methods:{ + // 点击请求植物详情跳转到详情页 btnxq(plantId){ - uni.navigateTo({ - url:'/page_user/photoxq?plantId=' + plantId - }) + if(plantId == null || plantId == ''){ + uni.showToast({ + title: '无该非植物信息', + icon: 'none', + duration: 2000 + }) + }else{ + uni.navigateTo({ + url:'/page_user/photoxq?plantId=' + plantId + }) + } } - } } @@ -101,6 +107,7 @@ width: 140rpx; height: 140rpx; margin-right: 18rpx; + border-radius: 10rpx; } } .rt{ diff --git a/page_user/photoxq.vue b/page_user/photoxq.vue index 866c88f..07cd14f 100644 --- a/page_user/photoxq.vue +++ b/page_user/photoxq.vue @@ -31,7 +31,7 @@ - + diff --git a/page_user/upload.vue b/page_user/upload.vue index a928cff..9c292a7 100644 --- a/page_user/upload.vue +++ b/page_user/upload.vue @@ -6,7 +6,7 @@ - + {{user.deviceName == undefined ? '--' : user.deviceName}} @@ -18,20 +18,17 @@ WIFI - ChangteA-5G + ChangteA-5G 息屏 - {{xptxt}} + {{xptxt}} 固件更新 - {{gjtxt}} + {{gjtxt}} @@ -43,7 +40,7 @@ 修改名称 - + 取消 @@ -93,7 +90,8 @@ label: 'v2.1.3' }], deviceid:'', - user:{} + user:{}, + namesb:'' } }, // 分享到好友(会话) @@ -103,7 +101,6 @@ path: '/pages/index/index' } }, - // 分享到朋友圈 onShareTimeline: function() { return { @@ -125,7 +122,11 @@ } }) }, - + // 点击显示修改名称弹框 + btnxianshi(){ + this.nameflag = true + this.namesb = this.user.deviceName + }, // 选择息屏时间 xpconfirm(e){ this.xptxt = e[0].label @@ -140,9 +141,24 @@ }, // 点击确定修改设备名称 btnqd(){ - this.nameflag = false - } - + this.$u.put(`/app/editDeviceName?deviceId=${this.deviceid}&deviceName=${this.namesb}`).then(res => { + if(res.code == 200){ + this.nameflag = false + this.user.deviceName = this.namesb + uni.showToast({ + title: '修改成功', + icon: 'success', + duration:2000 + }) + }else{ + uni.showToast({ + title: res.msg, + icon: 'none', + duration:2000 + }) + } + }) + }, } } @@ -151,7 +167,6 @@ /deep/ .u-title { margin-bottom: 22rpx; } - /deep/ .uicon-nav-back { margin-bottom: 22rpx; } @@ -223,7 +238,6 @@ height: 332rpx; margin: auto; } - .name { width: 100%; font-weight: 600; @@ -233,14 +247,12 @@ margin-top: 64rpx; justify-content: center; align-items: center; - image { width: 44rpx; height: 44rpx; margin-left: 26rpx; } } - .model { width: 100%; display: flex; @@ -248,13 +260,11 @@ font-size: 32rpx; color: #3D3D3D; margin-top: 48rpx; - .one { margin-left: 74rpx; margin-right: 144rpx; } } - .wifi { width: 678rpx; height: 104rpx; @@ -270,11 +280,9 @@ justify-content: space-between; padding: 0 42rpx; box-sizing: border-box; - .flex { display: flex; align-items: center; - image { width: 40rpx; height: 40rpx; diff --git a/page_user/yinsixq.vue b/page_user/yinsixq.vue index a8c5e52..923de9e 100644 --- a/page_user/yinsixq.vue +++ b/page_user/yinsixq.vue @@ -44,6 +44,7 @@ this.getxq() }, methods:{ + // 请求文章详情 getxq() { this.$u.get(`/app/article/${this.id}`).then((res) => { if (res.code == 200) { diff --git a/pages/index/index.vue b/pages/index/index.vue index 471a615..2f50b7c 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -7,14 +7,14 @@ - - + 暂无设备,请先绑定设备 - + 绑定 @@ -310,7 +310,9 @@ devicelist:[], shebid:'', user:{}, - lastChar:'' + lastChar:'', + timer:'', + bjflag:false } }, // 分享到好友(会话) @@ -333,7 +335,9 @@ }, onShow() { + // 请求个人信息 this.getinfo() + // 一进来每分钟发一次上传信息命令 this.getshuju() }, @@ -342,7 +346,7 @@ btnshowjs() { this.showjs = true }, - + // 补零函数 formattedTime(minutes, seconds) { // 将数字转换为字符串并补零 const formattedMinutes = String(minutes).padStart(2, '0'); @@ -388,8 +392,10 @@ content: '未连接成功,是否重新连接,重新连接请确保设备在附近5米范围内', success: function (res) { if (res.confirm) { + uni.hideLoading() that.getinfo() - } else if (res.cancel) { + } else if (res.cancel) { + uni.hideLoading() uni.showToast({ title: '已取消连接', icon: 'none', @@ -454,103 +460,203 @@ }, // 雨水感应开启 btnyushui() { - 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('手机未连接网络') + if(this.datalist == ''){ + let that = this + uni.showModal({ + title: '提示', + content: '设备未连接,是否进行设备连接?', + success: function (res) { + if (res.confirm) { + uni.hideLoading() + that.btnlj() + } else if (res.cancel) { + uni.hideLoading() + uni.showToast({ + title: '已取消连接', + icon: 'none', + duration:2000 + }) + } + } + }) + }else{ + uni.showLoading({ + title: '开启中...' + }) + let that = this + uni.getNetworkType({ + success(res) { + if (res.networkType !== 'none') { + uni.getConnectedBluetoothDevices({ + success(res) { + setTimeout(() => { + that.yschecked = false + xBlufi.notifySendCustomData({ + customData: '11yudi' + }) + uni.hideLoading() + }, 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('手机未连接网络') + if(this.datalist == ''){ + let that = this + uni.showModal({ + title: '提示', + content: '设备未连接,是否进行设备连接?', + success: function (res) { + if (res.confirm) { + uni.hideLoading() + that.btnlj() + } else if (res.cancel) { + uni.hideLoading() + uni.showToast({ + title: '已取消连接', + icon: 'none', + duration:2000 + }) + } + } + }) + }else{ + uni.showLoading({ + title: '开启中...' + }) + let that = this + uni.getNetworkType({ + success(res) { + if (res.networkType !== 'none') { + uni.getConnectedBluetoothDevices({ + success(res) { + setTimeout(() => { + that.yschecked = true + xBlufi.notifySendCustomData({ + customData: '11unyudi' + }) + uni.hideLoading() + }, 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('手机未连接网络') + if(this.datalist == ''){ + let that = this + uni.showModal({ + title: '提示', + content: '设备未连接,是否进行设备连接?', + success: function (res) { + if (res.confirm) { + uni.hideLoading() + that.btnlj() + } else if (res.cancel) { + uni.hideLoading() + uni.showToast({ + title: '已取消连接', + icon: 'none', + duration:2000 + }) + } + } + }) + }else{ + uni.showLoading({ + title: '开启中...' + }) + let that = this + uni.getNetworkType({ + success(res) { + if (res.networkType !== 'none') { + uni.getConnectedBluetoothDevices({ + success(res) { + setTimeout(() => { + that.etchecked = false + xBlufi.notifySendCustomData({ + customData: '11lock' + }) + uni.hideLoading() + }, 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('手机未连接网络') + if(this.datalist == ''){ + let that = this + uni.showModal({ + title: '提示', + content: '设备未连接,是否进行设备连接?', + success: function (res) { + if (res.confirm) { + uni.hideLoading() + that.btnlj() + } else if (res.cancel) { + uni.hideLoading() + uni.showToast({ + title: '已取消连接', + icon: 'none', + duration:2000 + }) + } + } + }) + }else{ + uni.showLoading({ + title: '开启中...' + }) + let that = this + uni.getNetworkType({ + success(res) { + if (res.networkType !== 'none') { + uni.getConnectedBluetoothDevices({ + success(res) { + setTimeout(() => { + that.etchecked = true + xBlufi.notifySendCustomData({ + customData: '11unlock' + }) + uni.hideLoading() + }, 1500) + }, + fail(err) { + console.error('获取已连接蓝牙设备信息失败:', err) + } + }) + } else { + console.log('手机未连接网络') + } } - } - }) + }) + } }, // 点击添加设备 @@ -577,6 +683,7 @@ url: '/page_user/dingshi?list=' + JSON.stringify(this.ver_data) }) }, + // 点击取消手动浇水 btnqx() { @@ -591,6 +698,9 @@ duration: 3000 }) } else { + uni.showLoading({ + title: '开启中...' + }) let that = this uni.getNetworkType({ success(res) { @@ -601,6 +711,7 @@ xBlufi.notifySendCustomData({ customData: "11time@" + that.jstime + '@' }) + uni.hideLoading() that.startTimer(that.jstime) that.sdjsflag = false that.kgflag = true @@ -619,58 +730,104 @@ }, // 手动浇水定时器 - startTimer(totalSeconds) { - let sdseconds = totalSeconds - console.log(remainingSeconds, '000'); - const timer = setInterval(() => { - // 计算分钟和秒 - const minutes = Math.floor(remainingSeconds / 60).toString() - const secs = (remainingSeconds % 60).toString() - // 格式化秒,确保是两位数 - this.sdseconds = secs.padStart(2, '0') - // 如果分钟大于0,则显示分钟;否则,不显示(只显示秒) - this.sdminutes = minutes.padStart(2, '0') - // 更新剩余秒数 - remainingSeconds--; - // 如果剩余秒数为0,则停止定时器 - if (remainingSeconds <= 0) { - clearInterval(timer) - this.btnkq() - this.sdminutes = '' - this.sdseconds = '' - } - }, 1000) + startTimer(totalSeconds) { + let remainingSeconds = totalSeconds; // 正确初始化 remainingSeconds + const sdminutes = ''; // 如果您打算在组件中使用这些变量,最好在这里声明它们 + const sdseconds = ''; + this.timer = setInterval(() => { + // 计算分钟和秒 + const minutes = Math.floor(remainingSeconds / 60).toString(); + const secs = (remainingSeconds % 60).toString(); + // 格式化秒和分钟,确保是两位数 + this.sdseconds = secs.padStart(2, '0'); + this.sdminutes = (minutes > 0 ? minutes : '').padStart(2, '0'); // 如果分钟为0,则不显示分钟 + // 更新剩余秒数 + remainingSeconds--; + // 如果剩余秒数为0,则停止定时器 + if (remainingSeconds <= 0) { + clearInterval(this.timer); + this.btnkq(); // 确保这个函数是存在的,并且您想要在这里调用它 + this.sdminutes = ''; // 清除分钟显示(可选,根据您的需求) + this.sdseconds = ''; // 清除秒显示(可选,根据您的需求) + } + }, 1000); }, - + // 关闭手动浇水 btnkq() { - let that = this - uni.getNetworkType({ - success(res) { - if (res.networkType !== 'none') { - uni.getConnectedBluetoothDevices({ - success(res) { - setTimeout(() => { - xBlufi.notifySendCustomData({ - customData: "11close" - }) - that.startTimer(0) - that.sdminutes = '' - that.sdseconds = '' - that.kgflag = false - }, 1500) - }, - fail(err) { - console.error('获取已连接蓝牙设备信息失败:', err) - } - }) + if(this.datalist == ''){ + let that = this + uni.showModal({ + title: '提示', + content: '设备未连接,是否进行设备连接?', + success: function (res) { + if (res.confirm) { + uni.hideLoading() + that.btnlj() + } else if (res.cancel) { + uni.hideLoading() + uni.showToast({ + title: '已取消连接', + icon: 'none', + duration:2000 + }) + } + } + }) + }else{ + uni.showLoading({ + title: '关闭中...' + }) + let that = this + uni.getNetworkType({ + success(res) { + if (res.networkType !== 'none') { + uni.getConnectedBluetoothDevices({ + success(res) { + setTimeout(() => { + xBlufi.notifySendCustomData({ + customData: "11close" + }) + // that.startTimer(0) + clearInterval(that.timer) + that.sdminutes = '' + that.sdseconds = '' + that.kgflag = false + uni.hideLoading() + }, 1500) + }, + fail(err) { + console.error('获取已连接蓝牙设备信息失败:', err) + } + }) + } } - } - }) + }) + } }, // 开启手动浇水 btngb() { - this.sdjsflag = true + if(this.datalist == ''){ + uni.showModal({ + title: '提示', + content: '设备未连接,是否进行设备连接?', + success: function (res) { + if (res.confirm) { + uni.hideLoading() + that.btnlj() + } else if (res.cancel) { + uni.hideLoading() + uni.showToast({ + title: '已取消连接', + icon: 'none', + duration:2000 + }) + } + } + }) + }else{ + this.sdjsflag = true + } }, // 跳转到设置 @@ -699,6 +856,8 @@ this.datalist = '' this.mac = '' this.ver_data = {} + this.name = '' + this.deviceId = '' this.xuanzeflag = false let that = this xBlufi.initXBlufi(1) @@ -744,34 +903,39 @@ getlist(){ this.$u.get(`/app/getDeviceInfoByUser?userId=${this.userobj.userId}`).then((res) => { if (res.code == 200) { - this.devicelist = res.data - this.mac = res.data[0].mac - this.user = res.data[0] - this.shebid = res.data[0].deviceId - if(this.datalist == ''){ - let that = this - xBlufi.initXBlufi(1) - xBlufi.listenDeviceMsgEvent(true, that.funListenDeviceMsgEvent) - xBlufi.notifyStartDiscoverBle({ - 'isStart': true - }) - setTimeout(() => { - xBlufi.notifyStartDiscoverBle({ - 'isStart': false + if(res.data.length > 0 || res.data != ''){ + this.bjflag = false + this.devicelist = res.data + this.mac = res.data[0].mac + this.user = res.data[0] + this.shebid = res.data[0].deviceId + if(this.datalist == ''){ + let that = this + uni.showModal({ + title: '提示', + content: '设备未连接,是否进行设备连接?', + success: function (res) { + if (res.confirm) { + uni.hideLoading() + that.btnlj() + } else if (res.cancel) { + uni.hideLoading() + uni.showToast({ + title: '已取消连接', + icon: 'none', + duration:2000 + }) + } + } }) - if (that.devicesList.length > 0) { - xBlufi.notifyConnectBle({ - isStart: true, - deviceId: that.deviceId, - name: that.name - }) - } - }, 2000) - that.getchao() + } + }else{ + this.bjflag = true } } }) }, + // 点击切换设备 btnksxz() { if (this.xuanzeflag == true) { this.xuanzeflag = false @@ -848,7 +1012,6 @@ xBlufi.notifyInitBleEsp32({ deviceId: this.deviceId }) - this.deviceIds = options.data.deviceId this.name = this.name } } else { @@ -871,32 +1034,34 @@ break; case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS_START: if (!options.result) { - uni.showToast({ - title: '蓝牙未开启', - icon: 'none', - duration: 3000 - }) - // uni.showModal({ - // title: '提示', - // content: '请打开蓝牙和位置信息', - // success: function (res) { - // if (res.confirm) { - // that.getinfo() - // } else if (res.cancel) { - // uni.showToast({ - // title: '已取消连接', - // icon: 'none', - // duration:2000 - // }) - // } - // } + uni.hideLoading() + // uni.showToast({ + // title: '蓝牙未开启', + // icon: 'none', + // duration: 3000 // }) + uni.showModal({ + title: '提示', + content: '请打开蓝牙和位置信息', + success: function (res) { + if (res.confirm) { + uni.hideLoading() + that.btnlj() + } else if (res.cancel) { + uni.hideLoading() + uni.showToast({ + title: '已取消连接', + icon: 'none', + duration:2000 + }) + } + } + }) return } break } }, - // 每隔一分钟发送一次获取数据 getshuju() { let that = this @@ -927,7 +1092,7 @@ }, 60000) }, - // 处理接收数据 + // 处理从设备接收数据 getchuli() { const inputString = this.datalist const pairs = inputString.split(';') @@ -943,7 +1108,6 @@ } }) this.ver_data = pSetObjects //六个浇水时间段 - // this.ver_data.p_set5[3] = this.lastChar console.log(inputString,this.ver_data, '002002002') this.showobj = showObject //雨滴,锁,等是否开启 if (this.showobj.showArray[1] == 1) { @@ -967,7 +1131,7 @@ const [hour, minute,minutes, second, /* other fields */ ] = timeArray const date = new Date() date.setHours(hour, minute,minute, second, 0) // 毫秒设为0 - console.log(date,'11111'); + console.log(date,'11111') return date } function timeDifference(date1, date2) { @@ -989,9 +1153,8 @@ for (const key in ver_Data) { if (ver_Data.hasOwnProperty(key) && ver_Data[key][3] === 1) { const timeArray = ver_Data[key] - console.log(timeArray,'00000'); + console.log(timeArray,'00000') const timeDate = timeArrayToDate(timeArray) - const diff = timeDifference(timeDate, new Date()) if (timeDate > new Date()) { if (!nextTime || (diff.hours * 60 + diff.minutes < (nextTimeDiff.hours || 0) * 60 + ( @@ -1009,16 +1172,11 @@ } } // 输出结果,确保在访问 null 值之前进行检查 - this.xctime = nextTime ? `${nextTimeDiff.hours}时${nextTimeDiff.minutes}分` : '无距离下次浇水时间'; - this.xctimesc = nextWaterDuration || '未知'; - this.sctimejs = prevTime ? prevTime.toTimeString().split(' ')[0].slice(0, -3) : '无上次浇水时间'; - this.xctimesj = nextTime ? nextTime.toTimeString().split(' ')[0].slice(0, -3) : '无下次浇水时间'; + this.xctime = nextTime ? `${nextTimeDiff.hours}时${nextTimeDiff.minutes}分` : '无距离下次浇水时间' + this.xctimesc = nextWaterDuration || '未知' + this.sctimejs = prevTime ? prevTime.toTimeString().split(' ')[0].slice(0, -3) : '无上次浇水时间' + this.xctimesj = nextTime ? nextTime.toTimeString().split(' ')[0].slice(0, -3) : '无下次浇水时间' console.log('下次浇水时间',this.xctimesj,'距离下次浇水时间',this.xctime,'上次浇水时间',this.sctimejs) - // console.log('距离下次最近的时间差:', nextTimeDiff ? `${nextTimeDiff.hours}时${nextTimeDiff.minutes}分` : '无'); - // console.log('下次时间:', nextTime ? nextTime.toTimeString().split(' ')[0] : '无'); - // console.log('下次浇水时长:', nextWaterDuration || '无'); - // console.log('距离上次最近的时间差:', prevTimeDiff ? `${prevTimeDiff.hours}时${prevTimeDiff.minutes}分` : '无'); - // console.log('上次时间:', prevTime ? prevTime.toTimeString().split(' ')[0] : '无') } } } @@ -1171,7 +1329,7 @@ border-radius: 20rpx; margin-top: 40rpx; } - + .sblist { width: 100%; height: 68vh; diff --git a/pages/login/denglu.vue b/pages/login/denglu.vue index efd5856..67aba40 100644 --- a/pages/login/denglu.vue +++ b/pages/login/denglu.vue @@ -21,7 +21,8 @@ 密码 - + + @@ -81,26 +82,40 @@ 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 - }) + if(this.tel == ''){ + uni.showToast({ + title: '手机号不能为空', + icon: 'none', + duration: 2000 + }) + }else if(this.password == ''){ + uni.showToast({ + title: '密码不能为空', + icon: 'none', + 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 + }) + } + }) + } }, // 点击微信一键登录 getPhoneNumber(e) { @@ -141,7 +156,7 @@ }) }, - + // 显示密码可见可不见 btn(num){ if(num == 1){ this.txt = 'txt' diff --git a/pages/login/login.vue b/pages/login/login.vue index 76958d1..63fd68a 100644 --- a/pages/login/login.vue +++ b/pages/login/login.vue @@ -39,11 +39,13 @@ }, methods:{ + // 跳转到注册页 btnzc(){ uni.navigateTo({ url:'/pages/login/zhuce' }) }, + // 跳转到登录页 denglu(){ uni.navigateTo({ url:'/pages/login/denglu' diff --git a/pages/login/wjpassword.vue b/pages/login/wjpassword.vue index 33e8d5c..babe0be 100644 --- a/pages/login/wjpassword.vue +++ b/pages/login/wjpassword.vue @@ -33,7 +33,8 @@ 新密码 - + + @@ -43,7 +44,8 @@ 确认密码 - + + @@ -71,7 +73,8 @@ yzm:'', countdown: 60, timer: null, - uuid:'' + uuid:'', + yzmkg:false } }, // 分享到好友(会话) @@ -157,7 +160,7 @@ }) } }, - + // 切换新密码显示与不显示 btn(num){ if(num == 1){ this.txt = 'txt' @@ -165,6 +168,7 @@ this.txt = 'password' } }, + // 切换确认密码显示与不显示 btns(num){ if(num == 1){ this.txts = 'txt' @@ -195,10 +199,27 @@ // 点击获取验证码 btnhuoqu(){ - this.startCountdown() - this.$u.get(`appCaptcha?phone=${this.tel}&type=2`).then(res => { - this.uuid = res.uuid - }) + if(this.tel == ''){ + uni.showToast({ + title: '手机号不能为空', + icon: 'none', + duration: 2000 + }) + }else{ + if(this.yzmkg == false){ + this.yzmkg = true + this.startCountdown() + this.$u.get(`appCaptcha?phone=${this.tel}&type=2`).then(res => { + this.uuid = res.uuid + }) + }else{ + uni.showToast({ + title: '不要重复点击', + icon: 'none', + duration: 2000 + }) + } + } }, } } diff --git a/pages/login/zhuce.vue b/pages/login/zhuce.vue index c51d1c8..d697257 100644 --- a/pages/login/zhuce.vue +++ b/pages/login/zhuce.vue @@ -36,7 +36,8 @@ 密码 - + + @@ -54,15 +55,11 @@ - + - + @@ -79,7 +76,8 @@ yzm:'', countdown: 60, timer: null, - uuid:'' + uuid:'', + yzmkg:false } }, // 分享到好友(会话) @@ -194,10 +192,10 @@ console.error(err) }) }, - + // 显示密码可见可不见 btn(num){ if(num == 1){ - this.txt = 'txt' + this.txt = 'text' }else if(num == 2){ this.txt = 'password' } @@ -225,10 +223,27 @@ // 点击获取验证码 btnhuoqu(){ - this.startCountdown() - this.$u.get(`appCaptcha?phone=${this.tel}&type=2`).then(res => { - this.uuid = res.uuid - }) + if(this.tel == ''){ + uni.showToast({ + title: '手机号不能为空', + icon: 'none', + duration: 2000 + }) + }else{ + if(this.yzmkg == false){ + this.yzmkg = true + this.startCountdown() + this.$u.get(`appCaptcha?phone=${this.tel}&type=2`).then(res => { + this.uuid = res.uuid + }) + }else{ + uni.showToast({ + title: '不要重复点击', + icon: 'none', + duration: 2000 + }) + } + } }, // 点击跳转到立即登录页 btnljdl(){