diff --git a/pages/home/me/indexx.js b/pages/home/me/indexx.js index 0510c15..a6effe3 100644 --- a/pages/home/me/indexx.js +++ b/pages/home/me/indexx.js @@ -12,15 +12,64 @@ Page({ isCxHq:false, bdsjhVisible:false, avatar:"", + countdown:60, userInfo:{ avatar:"", nick:"", isChatVip:false,//是否会员 - phone:'', + phone:'123', hasPhone:false - + }, + phone:'', + phoneVerificationCode:'' + }, + // 手机号码校验 + getPhone(e){ + const phone = e.detail.value; + if (!/^1[3456789]\d{9}$/.test(phone)) { + wx.showToast({ + title: '手机号码格式不正确', + icon: 'none' + }); + return; + } + }, + getVerificationCode(e){ + const VerificationCode = e.detail.value; + if (VerificationCode.length !== 6) { + wx.showToast({ + title: '验证码格式不正确', + icon: 'none' + }); + return; + } + }, + getCode(){ + console.log(this.data.phone); + if(this.data.countdown === 60 || this.data.countdown === '重新获取'){ + req.postRequest('/api/user/send-authentication-code',{phone:this.data.phone}).then((res)=>{ + console.log(res); + if (res.data.code !== 200) { + return wx.showToast({ + title: res.data.msg, + icon: 'none' + }); + } + if (this.data.countdown === '重新获取') { + this.setData({countdown: 60}) + } + // 验证码倒计时 + this.setData({isCxHq:true}) + const timerId = setInterval(()=>{ + this.setData({countdown:this.data.countdown-1}) + if (this.data.countdown === 0) { + clearTimeout(timerId); + this.setData({countdown:'重新获取'}) + } + },1000) + console.log('获取验证码'); + }) } - }, doBdsjh(){ console.log('绑定手机号') @@ -30,7 +79,30 @@ Page({ this.setData({bdsjhVisible:false}) }, doEXecSjh(){ - this.setData({bdsjhVisible:false}) + req.patchRequest('/api/user/curt',{ + phone:this.data.phone, + phoneVerificationCode:this.data.phoneVerificationCode + }).then((res)=>{ + console.log(res); + if(res.data.code !== 200){ + wx.showToast({ + title:res.data.msg, + icon:'none' + }) + return + }else { + this.setData({bdsjhVisible:false}) + this.getUserInfo() + wx.showToast({ + title:'绑定成功', + icon:'none' + }) + } + }) + this.setData({ + phoneVerificationCode:'', + isCxHq:false + }) }, go2Grzl(){ wx.navigateTo({ @@ -91,7 +163,10 @@ Page({ getUserInfo(){ req.getRequest('/api/user/curt',{}).then((res)=>{ if(res.data.code==200){ - this.setData({userInfo:res.data.data}) + this.setData({ + userInfo:res.data.data, + phone:res.data.data.phone + }) } console.log(this.userInfo); }).catch((err)=>{ diff --git a/pages/home/me/indexx.wxml b/pages/home/me/indexx.wxml index 86da8ac..45c1005 100644 --- a/pages/home/me/indexx.wxml +++ b/pages/home/me/indexx.wxml @@ -24,31 +24,31 @@ - + 绑定手机号 {{userInfo.phone}} - + 意见反馈 - + + 小程序版本 @@ -71,14 +71,14 @@ 手机号码 验证码 - + - + - {{isCxHq?'重新获取':'立即获取'}} + {{isCxHq?countdown:'立即获取'}} 取消 完成 diff --git a/pages/home/me/yjfk/yjfk.js b/pages/home/me/yjfk/yjfk.js index 4063133..2fe02ca 100644 --- a/pages/home/me/yjfk/yjfk.js +++ b/pages/home/me/yjfk/yjfk.js @@ -18,6 +18,14 @@ Page({ wx.navigateBack({ changed: true }); }, doExecYjfk(e){ + const contactWay = e.detail.value.contactWay; + if (!/^1[3456789]\d{9}$/.test(contactWay)) { + wx.showToast({ + title: '手机号码格式不正确', + icon: 'none' + }); + return; + } let form = e.detail.value req.postRequest('/api/v1/opinion',form).then((res)=>{ console.log(res) diff --git a/pages/home/me/yjfk/yjfk.wxml b/pages/home/me/yjfk/yjfk.wxml index eefb207..a0d005d 100644 --- a/pages/home/me/yjfk/yjfk.wxml +++ b/pages/home/me/yjfk/yjfk.wxml @@ -7,13 +7,8 @@ 建议描述 联系方式 -
- - - - - - - + + + +
- diff --git a/pages/home/me/yjfk/yjfk.wxss b/pages/home/me/yjfk/yjfk.wxss index a761362..9e4f3cc 100644 --- a/pages/home/me/yjfk/yjfk.wxss +++ b/pages/home/me/yjfk/yjfk.wxss @@ -83,6 +83,7 @@ font-size: 32rpx; text-align: center; font-family: SourceHanSansSC-medium; + z-index: 999; } .lxfs{ position: absolute; @@ -98,10 +99,10 @@ .jymsk{ position: absolute; - left: 23px; - top: 251px; - width: 330px; - height: 207px; + left: 46rpx; + top: 502rpx; + width: 660rpx; + height: 414rpx; line-height: 20px; border-radius: 15px; background-color: rgba(239, 239, 239, 1); @@ -113,10 +114,10 @@ .lxfsk{ position: absolute; - left: 23px; - top: 532px; - width: 330px; - height: 56px; + left: 46rpx; + top: 1064rpx; + width: 660rpx; + height: 112rpx; line-height: 20px; border-radius: 15px; background-color: rgba(239, 239, 239, 1); diff --git a/project.private.config.json b/project.private.config.json index 344f243..c0eb7a7 100644 --- a/project.private.config.json +++ b/project.private.config.json @@ -21,6 +21,13 @@ "query": "", "launchMode": "default", "scene": null + }, + { + "name": "", + "pathName": "pages/home/me/indexx", + "query": "", + "launchMode": "default", + "scene": null } ] } diff --git a/utils/request.js b/utils/request.js index dec2747..171c4f4 100644 --- a/utils/request.js +++ b/utils/request.js @@ -41,7 +41,7 @@ class request { } /** - * POST类型的网络请求 + * patch类型的网络请求 */ patchRequest(url, data, header = this._header) { return this.requestAll(url, data, header, 'PATCH')