From 06d58bbdf34f073bb9a4641918b92a1c863d35c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A7=9A=E4=BA=9A=E7=94=B7?= Date: Thu, 28 Oct 2021 11:08:01 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=86=E7=A0=81=E6=A1=86=E7=A6=81=E6=AD=A2?= =?UTF-8?q?=E7=B2=98=E8=B4=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/forgetPassword/forgetPassword.js | 83 +++++++++++++- pages/forgetPassword/forgetPassword.wxml | 4 +- pages/phonePassword/phonePassword.js | 41 +++++++ pages/phonePassword/phonePassword.wxml | 2 +- pages/setPassword/setPassword.js | 84 +++++++++++++- pages/setPassword/setPassword.wxml | 4 +- pages/upDateInfo/upDateInfo.js | 135 +++++++++++++++++++++-- pages/upDateInfo/upDateInfo.wxml | 6 +- 8 files changed, 342 insertions(+), 17 deletions(-) diff --git a/pages/forgetPassword/forgetPassword.js b/pages/forgetPassword/forgetPassword.js index 31c65a1..ffcb768 100644 --- a/pages/forgetPassword/forgetPassword.js +++ b/pages/forgetPassword/forgetPassword.js @@ -13,6 +13,8 @@ Page({ showGetCaptcha: true, show: true, // 默认显示的是闭眼睛 showVerify: true, + vals:[], + valsVerify: [] }, bindInputPhone(e) { @@ -84,7 +86,86 @@ Page({ }, 1000) // 倒计时 end }, - + clearrepeatval(){ + this.data.vals = [] + wx.showToast({ + title: '禁止复制粘贴请手动输入', + icon: 'none', + duration: 2000 + }) + this.setData({ + password: '' + }) + return + }, + clearrepeatvalVerify(){ + this.data.valsVerify = [] + wx.showToast({ + title: '禁止复制粘贴请手动输入', + icon: 'none', + duration: 2000 + }) + this.setData({ + verifyPassword: '' + }) + return + }, + // 新密码的输入 + handlePasswordInput(e) { //禁止输入中复制粘贴 + // 获取当前数组 + const vals = this.data.vals + // 获取当前输入的值 + const currentval = e.detail.value.replace(/\s+/g, "") + if(currentval){ // 如果值存在追加到vals中 + vals.push(currentval) + } + if(vals.length == 1 ){ + const v = vals[vals.length-1].length + if(v > 1){ // 如果第一个的长度就大于1 说明是粘贴过来的 + this.clearrepeatval() + } + } + if(vals.length > 1){ + // 如果值数组大于1 就获取最后一个值长度和倒数第二个值长度 + // 比较值长度差如果大于1 则粘贴的 + const lastv = vals[vals.length-1].length // 获取最后一个值的长度 + const secondv = vals[vals.length-2].length // 获取倒数第二个值得长度 + const dis = lastv - secondv + if(dis>1){ + this.clearrepeatval() + } + } + // 最后赋值 + this.data['password'] = currentval + }, + // 确认新密码的输入 + handleVerifyPasswordInput(e) { //禁止输入中复制粘贴 + // 获取当前数组 + const vals = this.data.valsVerify + // 获取当前输入的值 + const currentval = e.detail.value.replace(/\s+/g, "") + if(currentval){ // 如果值存在追加到vals中 + vals.push(currentval) + } + if(vals.length == 1 ){ + const v = vals[vals.length-1].length + if(v > 1){ // 如果第一个的长度就大于1 说明是粘贴过来的 + this.clearrepeatvalVerify() + } + } + if(vals.length > 1){ + // 如果值数组大于1 就获取最后一个值长度和倒数第二个值长度 + // 比较值长度差如果大于1 则粘贴的 + const lastv = vals[vals.length-1].length // 获取最后一个值的长度 + const secondv = vals[vals.length-2].length // 获取倒数第二个值得长度 + const dis = lastv - secondv + if(dis>1){ + this.clearrepeatvalVerify() + } + } + // 最后赋值 + this.data['verifyPassword'] = currentval + }, // 确认 formSubmit(e) { if(!e.detail.value.phone){ diff --git a/pages/forgetPassword/forgetPassword.wxml b/pages/forgetPassword/forgetPassword.wxml index d69cfdf..710d629 100644 --- a/pages/forgetPassword/forgetPassword.wxml +++ b/pages/forgetPassword/forgetPassword.wxml @@ -17,7 +17,7 @@ 新密码 - + @@ -25,7 +25,7 @@ 确认密码 - + diff --git a/pages/phonePassword/phonePassword.js b/pages/phonePassword/phonePassword.js index 7068e1a..2fa6889 100644 --- a/pages/phonePassword/phonePassword.js +++ b/pages/phonePassword/phonePassword.js @@ -15,6 +15,8 @@ Page({ requestCodeSuccess: true, randCodeImage: '' // 验证码 }, + vals: [], // 禁止密码粘贴用到的数组 + password: '', // 密码 rsaPublicKey: '', // 公钥 flag: false }, @@ -48,6 +50,45 @@ Page({ }) }) }, + clearrepeatval(){ + this.data.vals = [] + wx.showToast({ + title: '禁止复制粘贴请手动输入', + icon: 'none', + duration: 2000 + }) + this.setData({ + password: '' + }) + return + }, + handlePasswordInput(e) { //禁止输入中复制粘贴 + // 获取当前数组 + const vals = this.data.vals + // 获取当前输入的值 + const currentval = e.detail.value.replace(/\s+/g, "") + if(currentval){ // 如果值存在追加到vals中 + vals.push(currentval) + } + if(vals.length == 1 ){ + const v = vals[vals.length-1].length + if(v > 1){ // 如果第一个的长度就大于1 说明是粘贴过来的 + this.clearrepeatval() + } + } + if(vals.length > 1){ + // 如果值数组大于1 就获取最后一个值长度和倒数第二个值长度 + // 比较值长度差如果大于1 则粘贴的 + const lastv = vals[vals.length-1].length // 获取最后一个值的长度 + const secondv = vals[vals.length-2].length // 获取倒数第二个值得长度 + const dis = lastv - secondv + if(dis>1){ + this.clearrepeatval() + } + } + // 最后赋值 + this.data['password'] = currentval + }, // 提交 formSubmit(e) { if(!e.detail.value.phone){ diff --git a/pages/phonePassword/phonePassword.wxml b/pages/phonePassword/phonePassword.wxml index 3b97e84..0e6a5e0 100644 --- a/pages/phonePassword/phonePassword.wxml +++ b/pages/phonePassword/phonePassword.wxml @@ -10,7 +10,7 @@ 密码 - + diff --git a/pages/setPassword/setPassword.js b/pages/setPassword/setPassword.js index 4d2cf5d..97cff3a 100644 --- a/pages/setPassword/setPassword.js +++ b/pages/setPassword/setPassword.js @@ -10,6 +10,8 @@ Page({ password: '', // token newPassword: '', // 密码 verifyPassword: '', // 确认密码 + valsNew: [], + valsVerify: [], rsaPublicKey: '', flag: false, show: true, // 默认显示的是闭眼睛 @@ -25,6 +27,86 @@ Page({ showVerify: !this.data.showVerify }) }, + clearrepeatval(){ + this.data.valsNew = [] + wx.showToast({ + title: '禁止复制粘贴请手动输入', + icon: 'none', + duration: 2000 + }) + this.setData({ + newPassword: '' + }) + return + }, + clearrepeatvalVerify(){ + this.data.valsVerify = [] + wx.showToast({ + title: '禁止复制粘贴请手动输入', + icon: 'none', + duration: 2000 + }) + this.setData({ + verifyPassword: '' + }) + return + }, + // 新密码的输入 + handlePasswordInput(e) { //禁止输入中复制粘贴 + // 获取当前数组 + const vals = this.data.valsNew + // 获取当前输入的值 + const currentval = e.detail.value.replace(/\s+/g, "") + if(currentval){ // 如果值存在追加到vals中 + vals.push(currentval) + } + if(vals.length == 1 ){ + const v = vals[vals.length-1].length + if(v > 1){ // 如果第一个的长度就大于1 说明是粘贴过来的 + this.clearrepeatval() + } + } + if(vals.length > 1){ + // 如果值数组大于1 就获取最后一个值长度和倒数第二个值长度 + // 比较值长度差如果大于1 则粘贴的 + const lastv = vals[vals.length-1].length // 获取最后一个值的长度 + const secondv = vals[vals.length-2].length // 获取倒数第二个值得长度 + const dis = lastv - secondv + if(dis>1){ + this.clearrepeatval() + } + } + // 最后赋值 + this.data['newPassword'] = currentval + }, + // 确认新密码的输入 + handleVerifyPasswordInput(e) { //禁止输入中复制粘贴 + // 获取当前数组 + const vals = this.data.valsVerify + // 获取当前输入的值 + const currentval = e.detail.value.replace(/\s+/g, "") + if(currentval){ // 如果值存在追加到vals中 + vals.push(currentval) + } + if(vals.length == 1 ){ + const v = vals[vals.length-1].length + if(v > 1){ // 如果第一个的长度就大于1 说明是粘贴过来的 + this.clearrepeatvalVerify() + } + } + if(vals.length > 1){ + // 如果值数组大于1 就获取最后一个值长度和倒数第二个值长度 + // 比较值长度差如果大于1 则粘贴的 + const lastv = vals[vals.length-1].length // 获取最后一个值的长度 + const secondv = vals[vals.length-2].length // 获取倒数第二个值得长度 + const dis = lastv - secondv + if(dis>1){ + this.clearrepeatvalVerify() + } + } + // 最后赋值 + this.data['verifyPassword'] = currentval + }, // 登录 formSubmit(e) { const that = this @@ -125,7 +207,7 @@ Page({ }) }, onLoad(options){ - this.data.userInfo = JSON.parse(options.userInfo) + // this.data.userInfo = JSON.parse(options.userInfo) }, /** * 生命周期函数--监听页面显示 diff --git a/pages/setPassword/setPassword.wxml b/pages/setPassword/setPassword.wxml index 0bf413d..924b9b0 100644 --- a/pages/setPassword/setPassword.wxml +++ b/pages/setPassword/setPassword.wxml @@ -5,7 +5,7 @@ 密码 - + @@ -13,7 +13,7 @@ 确认密码 - + diff --git a/pages/upDateInfo/upDateInfo.js b/pages/upDateInfo/upDateInfo.js index 2bf095c..95154fb 100644 --- a/pages/upDateInfo/upDateInfo.js +++ b/pages/upDateInfo/upDateInfo.js @@ -9,12 +9,13 @@ Page({ * 页面的初始数据 */ data: { - form: { - oldpassword: '', // 旧密码 - password: '', // 新密码 - confirmpassword: '', // 确认新密码 - rsaPublicKey: '', // 公钥 - }, + oldpassword: '', // 旧密码 + password: '', // 新密码 + confirmpassword: '', // 确认新密码 + rsaPublicKey: '', // 公钥 + valsOld: [], + valsNew: [], + valsVerify: [], showOld: true, show: true, // 默认显示的是闭眼睛 showVerify: true, @@ -31,9 +32,129 @@ Page({ }, showPasswordVerify(){ this.setData({ - showVerify: !this.data.showVerify + 'showVerify': !this.data.showVerify }) }, + clearrepeatvalOld(){ + this.data.valsOld = [] + wx.showToast({ + title: '禁止复制粘贴请手动输入', + icon: 'none', + duration: 2000 + }) + this.setData({ + oldpassword: '' + }) + return + }, + clearrepeatval(){ + this.data.valsNew = [] + wx.showToast({ + title: '禁止复制粘贴请手动输入', + icon: 'none', + duration: 2000 + }) + this.setData({ + password: '' + }) + return + }, + clearrepeatvalVerify(){ + this.data.valsVerify = [] + wx.showToast({ + title: '禁止复制粘贴请手动输入', + icon: 'none', + duration: 2000 + }) + this.setData({ + confirmpassword: '' + }) + return + }, + // 旧密码的输入 + handleOldPasswordInput(e) { //禁止输入中复制粘贴 + // 获取当前数组 + const vals = this.data.valsOld + // 获取当前输入的值 + const currentval = e.detail.value.replace(/\s+/g, "") + if(currentval){ // 如果值存在追加到vals中 + vals.push(currentval) + } + if(vals.length == 1 ){ + const v = vals[vals.length-1].length + if(v > 1){ // 如果第一个的长度就大于1 说明是粘贴过来的 + this.clearrepeatvalOld() + } + } + if(vals.length > 1){ + // 如果值数组大于1 就获取最后一个值长度和倒数第二个值长度 + // 比较值长度差如果大于1 则粘贴的 + const lastv = vals[vals.length-1].length // 获取最后一个值的长度 + const secondv = vals[vals.length-2].length // 获取倒数第二个值得长度 + const dis = lastv - secondv + if(dis>1){ + this.clearrepeatvalOld() + } + } + // 最后赋值 + this.data['oldpassword'] = currentval + }, + // 新密码的输入 + handlePasswordInput(e) { //禁止输入中复制粘贴 + // 获取当前数组 + const vals = this.data.valsNew + // 获取当前输入的值 + const currentval = e.detail.value.replace(/\s+/g, "") + if(currentval){ // 如果值存在追加到vals中 + vals.push(currentval) + } + if(vals.length == 1 ){ + const v = vals[vals.length-1].length + if(v > 1){ // 如果第一个的长度就大于1 说明是粘贴过来的 + this.clearrepeatval() + } + } + if(vals.length > 1){ + // 如果值数组大于1 就获取最后一个值长度和倒数第二个值长度 + // 比较值长度差如果大于1 则粘贴的 + const lastv = vals[vals.length-1].length // 获取最后一个值的长度 + const secondv = vals[vals.length-2].length // 获取倒数第二个值得长度 + const dis = lastv - secondv + if(dis>1){ + this.clearrepeatval() + } + } + // 最后赋值 + this.data['password'] = currentval + }, + // 确认新密码的输入 + handleVerifyPasswordInput(e) { //禁止输入中复制粘贴 + // 获取当前数组 + const vals = this.data.valsVerify + // 获取当前输入的值 + const currentval = e.detail.value.replace(/\s+/g, "") + if(currentval){ // 如果值存在追加到vals中 + vals.push(currentval) + } + if(vals.length == 1 ){ + const v = vals[vals.length-1].length + if(v > 1){ // 如果第一个的长度就大于1 说明是粘贴过来的 + this.clearrepeatvalVerify() + } + } + if(vals.length > 1){ + // 如果值数组大于1 就获取最后一个值长度和倒数第二个值长度 + // 比较值长度差如果大于1 则粘贴的 + const lastv = vals[vals.length-1].length // 获取最后一个值的长度 + const secondv = vals[vals.length-2].length // 获取倒数第二个值得长度 + const dis = lastv - secondv + if(dis>1){ + this.clearrepeatvalVerify() + } + } + // 最后赋值 + this.data['form.confirmpassword'] = currentval + }, // 提交 formSubmit(e) { if(!e.detail.value.oldpassword){ diff --git a/pages/upDateInfo/upDateInfo.wxml b/pages/upDateInfo/upDateInfo.wxml index 528ae15..1bdb7c8 100644 --- a/pages/upDateInfo/upDateInfo.wxml +++ b/pages/upDateInfo/upDateInfo.wxml @@ -4,7 +4,7 @@ 旧密码 - + @@ -12,7 +12,7 @@ 新密码 - + @@ -20,7 +20,7 @@ 确认新密码 - +