diff --git a/app.json b/app.json index f7318f0..2af6d8a 100644 --- a/app.json +++ b/app.json @@ -3,7 +3,6 @@ "pages/start/start", "pages/login/login", "pages/login/bind/bind", - "pages/login/code/code", "pages/login/verification/verification", "pages/home/home" ] diff --git a/pages/login/bind/bind.acss b/pages/login/bind/bind.acss index fcdccfa..71e3cd1 100644 --- a/pages/login/bind/bind.acss +++ b/pages/login/bind/bind.acss @@ -1,42 +1,53 @@ input::-webkit-input-placeholder, textarea::-webkit-input-placeholder{ - color: #dedede; + color: #dedede; } -.phone-txt{ - padding: 1.2rem .4rem 0; - border-top: .02rem solid #FAFAFA; +.verification{ + background-color: #f1f4f7; +} +.phone-bg{ + padding: 0 .4rem; + background-color: #FFFFFF; + border-top: .2rem solid #f1f4f7; } .phone-title{ font-size: .4rem; line-height: 1.5; } -.phone-txt input{ - width: 100%; - height: .9rem; - line-height: .9rem; - font-size: .32rem; - border-bottom: .02rem solid #e2e4e6; -} .flex{ display: flex; justify-content: space-between; - flex-wrap: wrap; + align-items: center; + border-bottom: .02rem solid #e2e4e6; } -.flex .span-02{ - width: 100%; +.flex>text{ font-size: .3rem; - line-height: 1.5; - margin-top: .2rem; + width: 1.6rem; } -.flex .span-01{ - width: auto; - font-size: .3rem; - line-height: 1.5; - margin-top: .2rem; - color: #348bff; +.flex>input{ + width: calc(100% - 1.6rem); + height: .9rem; + line-height: .9rem; + font-size: .3rem; } +.flex-02{ + border-bottom: 0; +} +.flex-02>view{ + width: 2rem; + color: #333fc9; + font-size: .28rem; + text-align: right; +} +.flex-02>input{ + width: calc(100% - 3.6rem); +} + + + .login-btns{ - margin-top: 1rem; + width: 6.8rem; + margin: .5rem auto 0; } .login-btns>view{ display: flex; diff --git a/pages/login/bind/bind.axml b/pages/login/bind/bind.axml index 8bb71aa..fdac464 100644 --- a/pages/login/bind/bind.axml +++ b/pages/login/bind/bind.axml @@ -1,13 +1,21 @@ - 手机号 - - + + + 手机号 + + + + 验证码 + + 获取验证码 + {{count}}s后可再获取 + + 确认 + diff --git a/pages/login/bind/bind.js b/pages/login/bind/bind.js index c545c1b..65cea41 100644 --- a/pages/login/bind/bind.js +++ b/pages/login/bind/bind.js @@ -4,7 +4,13 @@ Page({ openPhoneTips: false, //验证手机号弹出框 tipsMsg: '', toastText: '', - phoneNumber: '' + phoneNumber: '', + + show: true, //显示获取验证码 + count: "", //剩余时间 + timer: null, + code: '', + value: '' }, onLoad() { @@ -19,11 +25,45 @@ Page({ this.setData({ phoneNumber: e.detail.value, }); + console.log(this.data.phoneNumber,111) + }, + + // 获取输入验证码 + bindKeyCode(e) { + this.setData({ + value: e.detail.value, + }); + console.log(this.data.value,222) }, - // 手机号登录 - // 验证手机号是否存在 - checkPhone(){ + // 倒计时 + timeEV(){ + if (!this.data.timer) { + this.setData({ + count: 60, + show: false + }) + let that = this; + const countDown = setInterval(() => { + if(that.data.count <= 1){ + that.setData({ + count:60, + show: true + }) + clearInterval(countDown) + return + } + that.data.count -- + that.setData({ + count: that.data.count, + show: false + }) + },1000); + } + }, + + // 获取验证码 + changeCode(){ console.log(this.data.phoneNumber,123) let reg_tel = /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/; if (this.data.phoneNumber == "") { @@ -51,11 +91,13 @@ Page({ } let params = { phone: this.data.phoneNumber - } + } + // 验证手机号是否存在 dd.$http.post('/api/user/has-phone-user',params).then(res=>{ console.log(res,'登录认证数据') if(res.data.registered == 0){ - this.bindPhone(); + this.timeEV(); + this.sendCode(); }else if(res.data.registered == 1){ this.setData({ openPhoneTips: true, @@ -64,21 +106,51 @@ Page({ } }) }, - // 手机号绑定 - bindPhone() { + + // 发送验证码 + sendCode() { let params = { phone: this.data.phoneNumber, type: "bind", } dd.$http.post('/api/common/send-sms-captcha',params).then(res=>{ console.log(res,'验证码数据') - // 跳转页面 - dd.navigateTo ({ - url: '/pages/logins/code/code?phone='+this.data.phoneNumber+'&code='+res.data.code + this.setData({ + code: res.data.code }) }) }, + // 绑定手机号 + bindPhone(){ + if(this.data.code == this.data.value){ + let params = { + phone: this.data.phoneNumber, + sms_code: this.data.value, + } + dd.$http.post('/api/user/bind-phone',params).then(res=>{ + console.log(res,'绑定数据') + if (res.code == 0) { + // 跳转页面 + dd.redirectTo ({ + url: '/pages/home/home' + }) + } + }) + }else{ + this.setData({ + value: '', + toastText: '验证码错误', + isToast: true + }); + setTimeout(()=> { + this.setData({ + isToast: false + }) + }, 1000) + } + }, + // 关闭弹窗 clearPhone(){ this.setData({ diff --git a/pages/login/code/code.acss b/pages/login/code/code.acss deleted file mode 100644 index d4e5a69..0000000 --- a/pages/login/code/code.acss +++ /dev/null @@ -1,97 +0,0 @@ -input::-webkit-input-placeholder, -textarea::-webkit-input-placeholder{ - color: #dedede; -} -/* 手机验证码 */ -.verification-txt{ - padding: 1.2rem .4rem 0; - border-top: .02rem solid #FAFAFA; -} -.verification-txt>.p{ - font-size: .4rem; - line-height: 1.5; -} -.verification-txt>.span{ - display: block; - font-size: .26rem; - line-height: 1.5; - color: #999999; - margin-top: .2rem; -} -/* 输入验证码 */ -.security-code-wrap { - overflow: hidden; - padding: .2rem 0; - position: relative; -} -.security-code-container { - display: flex; - justify-content: space-between; - width: 5.32rem; -} -.field-wrap { - list-style: none; - display: block; - width: .72rem; - height: 1rem; - line-height: 1rem; - font-size: .64rem; - background-color: #fff; - border-bottom: .02rem solid #e0e2e4; -} -.char-field { - display: block; - width: 100%; - text-align: center; - font-style: normal; -} -.input-code { - position: absolute; - left: 0; - top: 0; - width: 5.32rem; - height: 1rem; - opacity: 0; - overflow: visible; - z-index: 1; -} - -/* 重获验证码 */ -.getCode{ - display: flex; - justify-content: center; - align-items: center; - width: 100%; - height: .8rem; - margin-top: .4rem; - background-color: #348bff; - border-radius: .16rem; - font-size: .32rem; - color: #FFFFFF; -} - -/* 提示框 */ -.toast{ - width: 3rem; - padding: .2rem .25rem; - background-color: rgba(255,255,255,.8); - color: #333333; - border-radius: .1rem; - font-size: .28rem; - line-height: 1.4; - text-align: center; - position: fixed; - left: 50%; - top: 50%; - transform: translate(-50%,-50%); - z-index: 999; -} -.addr-select-bg{ - width: 100vw; - height: 100%; - background-color: rgba(0,0,0,.5); - position: fixed; - top: 0; - left: 0; - z-index: 998; -} \ No newline at end of file diff --git a/pages/login/code/code.axml b/pages/login/code/code.axml deleted file mode 100644 index 101e85e..0000000 --- a/pages/login/code/code.axml +++ /dev/null @@ -1,27 +0,0 @@ - - - - 输入验证码 - 验证码已发送至 +86 {{ phoneData }} - - - - - - {{ value[index] || placeholder }} - - - - - - - {{count}}秒后可重新获取验证码 - 获取验证码 - - - - - - {{toastText}} - - \ No newline at end of file diff --git a/pages/login/code/code.js b/pages/login/code/code.js deleted file mode 100644 index 9681caf..0000000 --- a/pages/login/code/code.js +++ /dev/null @@ -1,94 +0,0 @@ -Page({ - data: { - phoneData: "", //手机号 - verification: "", //验证码 - value: "", - show: false, //显示获取验证码 - count: "", //剩余时间 - timer: null, - userType: 0, - placeholder:'-', - number:6, - code:'', - isToast: false, - - }, - onLoad(options) { - this.setData({ - phoneData: options.phone, - code: options.code, - }) - - dd.setNavigationBar({ - title: '手机验证码', - backgroundColor: '#FFFFFF', - }); - - if (!this.data.timer) { - this.setData({ - count: 60, - show: true - }) - let that = this; - const countDown = setInterval(() => { - if(that.data.count <= 1){ - that.setData({ - count:60, - show: false - }) - clearInterval(countDown) - return - } - that.data.count -- - that.setData({ - count: that.data.count, - show: true - }) - },1000); - } - }, - // 获取验证码 - bindValueInput(e){ - this.setData({ - value: e.detail.value, - }); - }, - - // 输入完成获取数据 - handleInput() { - console.log(this.data.code,this.data.value,25252525) - - if(this.data.code == this.data.value){ - this.hideKeyboard(); - }else{ - this.setData({ - value: '', - toastText: '验证码错误', - isToast: true - }); - setTimeout(()=> { - this.setData({ - isToast: false - }) - }, 1000) - } - }, - - // 登录 - hideKeyboard() { - let params = { - phone: this.data.phoneData, - sms_code: this.data.value, - } - dd.$http.post('/api/user/bind-phone',params).then(res=>{ - console.log(res,'绑定数据') - if (res.code == 0) { - // 跳转页面 - dd.redirectTo ({ - url: '/pages/home/home' - }) - } - - }) - }, -}); diff --git a/pages/login/code/code.json b/pages/login/code/code.json deleted file mode 100644 index a97367d..0000000 --- a/pages/login/code/code.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "usingComponents": {} -} diff --git a/pages/start/start.acss b/pages/start/start.acss index 3ae4a17..10ded05 100644 --- a/pages/start/start.acss +++ b/pages/start/start.acss @@ -21,5 +21,5 @@ background-color: #3f5ee0; position: fixed; left: .24rem; - top: 1.14rem; + top: .5rem; } \ No newline at end of file diff --git a/static/start.jpg b/static/start.jpg index e6f0c78..874eefb 100644 Binary files a/static/start.jpg and b/static/start.jpg differ