|
@@ -4,16 +4,21 @@
|
|
|
|
|
|
<view class="wrapper">
|
|
|
<h2>手机号注册</h2>
|
|
|
- <view style='width:100%;margin-top:50px;border-bottom:1px solid #E8E9ED;padding:10px;' class="flex">
|
|
|
+ <view style='width:100%;margin-top:50px;border-bottom:1px solid #E8E9ED;padding:10px;position:relative;' class="flex">
|
|
|
<view style='width:15%;border-right:1px solid #E8E9ED;'>+86</view>
|
|
|
<view style='width:85%;'><input maxlength="11" v-model='phone' @input='phoneinput' style='padding-left:10px;' placeholder="请输入手机号码" type="text"></view>
|
|
|
+ <image v-if='phone!=""' @click='phone=""' class='close' src='../../static/img/login/guanbi@2x.png'></image>
|
|
|
</view>
|
|
|
<view style='width:100%;border-bottom:1px solid #E8E9ED;position:relative;padding:10px;' class="flex">
|
|
|
- <view style='width:85%;'><input v-model='verifyCode' placeholder="请输入验证码" type="text"></view>
|
|
|
- <button :class='codestatus?"active":""' @click='getcode' class='getcode'>{{sendText}}</button>
|
|
|
+ <view style='width:70%;position:relative;'>
|
|
|
+ <input v-model='verifyCode' placeholder="请输入验证码" type="text">
|
|
|
+ <image v-if='verifyCode!=""' @click='verifyCode=""' class='close1' src='../../static/img/login/guanbi@2x.png'></image>
|
|
|
+ </view>
|
|
|
+ <button :class='codestatus&&!sendDisabled?"active":""' @click='getcode' class='getcode'>{{sendText}}</button>
|
|
|
</view>
|
|
|
<view style='border-bottom:1px solid #E8E9ED;padding:10px;position:relative;'>
|
|
|
<input maxlength='16' class='password' style='height:30px;' v-model='password' placeholder="请输入密码,6-16位字符" :type="type">
|
|
|
+ <image v-if='password!=""' @click='password=""' class='close2' src='../../static/img/login/guanbi@2x.png'></image>
|
|
|
<view @click='switchover' style='position:absolute;right:0;top:38%;z-index:10;cursor:pointer;' class="iconfont " :class='type=="password"?"icon-yanjing-biyan":"icon-yanjing-zhengyan"'></view>
|
|
|
</view>
|
|
|
<button :class='phone!=""&&verifyCode!=""&&password!=""?"active":""' @click='register' class='verificationCode'>注册</button>
|
|
@@ -57,7 +62,7 @@
|
|
|
},
|
|
|
consentStatus:false,
|
|
|
codestatus:false,
|
|
|
- type:'password',
|
|
|
+ type:'text',
|
|
|
inputStatus:'none',
|
|
|
verifyCode:null,
|
|
|
sendText:'获取验证码',
|
|
@@ -93,25 +98,61 @@
|
|
|
})
|
|
|
},
|
|
|
methods: {
|
|
|
+ // 随机数
|
|
|
+ randomAccess(min,max){
|
|
|
+ return Math.floor(Math.random() * (min - max) + max)
|
|
|
+ },
|
|
|
+ // 解码
|
|
|
+ decodeUnicode(str) {
|
|
|
+ //Unicode显示方式是\u4e00
|
|
|
+ str = "\\u"+str
|
|
|
+ str = str.replace(/\\/g, "%");
|
|
|
+ //转换中文
|
|
|
+ str = unescape(str);
|
|
|
+ //将其他受影响的转换回原来
|
|
|
+ str = str.replace(/%/g, "\\");
|
|
|
+ return str;
|
|
|
+ },
|
|
|
+ /*
|
|
|
+ *@param Number NameLength 要获取的名字长度
|
|
|
+ */
|
|
|
+ getRandomName(NameLength){
|
|
|
+ let name = ""
|
|
|
+ for(let i = 0;i<NameLength;i++){
|
|
|
+ let unicodeNum = ""
|
|
|
+ unicodeNum = this.randomAccess(0x4e00,0x9fa5).toString(16)
|
|
|
+ name += this.decodeUnicode(unicodeNum)
|
|
|
+ }
|
|
|
+ return name
|
|
|
+ },
|
|
|
phoneinput(e){
|
|
|
if(e.detail.value.length==11){
|
|
|
this.codestatus=true
|
|
|
}
|
|
|
},
|
|
|
getcode(){
|
|
|
- console.log(/^0?1[3|4|5|6|7|8][0-9]\d{8}$/.test(this.phone))
|
|
|
+ var that = this
|
|
|
if(/^0?1[3|4|5|6|7|8][0-9]\d{8}$/.test(this.phone)){
|
|
|
- // this.$api.doRequest('get','/commonUser/sendVerifyCode',{phone:this.phone}).then(res => {
|
|
|
- // // 获得数据
|
|
|
- // console.log(res);
|
|
|
- // })
|
|
|
- // .catch(res => {
|
|
|
- uni.showToast({
|
|
|
- title: res.errmsg,
|
|
|
- icon:'none',
|
|
|
- duration: 2000
|
|
|
+ this.$api.doRequest('get','/commonUser/sendVerifyCode',{phone:this.phone}).then(res => {
|
|
|
+ that.sendDisabled = true
|
|
|
+ let sec = 60
|
|
|
+ let interval = setInterval(() => {
|
|
|
+ sec--;
|
|
|
+ that.sendText = sec + 's后重发'
|
|
|
+ if (sec <= 0) {
|
|
|
+ that.sendDisabled = false
|
|
|
+ that.sendText = "获取验证码"
|
|
|
+ clearInterval(interval)
|
|
|
+ }
|
|
|
+ }, 1000)
|
|
|
})
|
|
|
- // });
|
|
|
+ .catch(res => {
|
|
|
+ uni.showToast({
|
|
|
+ title: res.errmsg,
|
|
|
+ icon:'none',
|
|
|
+ duration: 2000
|
|
|
+ })
|
|
|
+ });
|
|
|
}else{
|
|
|
uni.showToast({
|
|
|
title: '请输入正确的手机号',
|
|
@@ -122,9 +163,67 @@
|
|
|
|
|
|
},
|
|
|
register(){
|
|
|
- this.$api.doRequest('post','/commonUser/register',{phone:this.phone,password:this.password,verifyCode:this.verifyCode}).then(res => {
|
|
|
- // 获得数据
|
|
|
- console.log(res);
|
|
|
+ var that = this
|
|
|
+ if(!this.consentStatus){
|
|
|
+ uni.showToast({
|
|
|
+ title: '请勾选协议',
|
|
|
+ icon:'none',
|
|
|
+ duration: 2000
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if(this.verifyCode.length>6){
|
|
|
+ uni.showToast({
|
|
|
+ title: '验证码错误',
|
|
|
+ icon:'none',
|
|
|
+ duration: 2000
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if(this.password.length<6){
|
|
|
+ uni.showToast({
|
|
|
+ title: '请输入正确的密码格式',
|
|
|
+ icon:'none',
|
|
|
+ duration: 2000
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var username=this.getRandomName(3)
|
|
|
+ this.$api.doRequest('post','/commonUser/register',{phone:this.phone,password:this.password,verifyCode:this.verifyCode,userName:username}).then(res => {
|
|
|
+ if(res.data.code=='11002'){
|
|
|
+ uni.showToast({
|
|
|
+ title: '验证码错误或过期,请重新获取',
|
|
|
+ icon:'none',
|
|
|
+ duration: 2000
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }else if(res.data.code=='11004'){
|
|
|
+ uni.showToast({
|
|
|
+ title: '该手机号已注册,可直接登录',
|
|
|
+ icon:'none',
|
|
|
+ duration: 2000
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ uni.showLoading({
|
|
|
+ title: '登录中',
|
|
|
+ mask:true
|
|
|
+ })
|
|
|
+ this.$api.doRequest('get','/commonUser/login',{phone:this.phone,password:this.password}).then(res => {
|
|
|
+ // 获得数据
|
|
|
+ uni.setStorageSync('userInfo', res.data)
|
|
|
+ that.$store.commit('login', res.data)
|
|
|
+ that.liangxinLogin()
|
|
|
+ uni.switchTab({
|
|
|
+ url: '/pages/sale/information'
|
|
|
+ });
|
|
|
+ uni.hideLoading()
|
|
|
+ })
|
|
|
+ .catch(res => {
|
|
|
+ console.log(res);
|
|
|
+ });
|
|
|
+ }
|
|
|
})
|
|
|
.catch(res => {
|
|
|
console.log(res);
|
|
@@ -891,7 +990,23 @@
|
|
|
background: url('../../static/img/login/bg.png');
|
|
|
background-size:100%;
|
|
|
}
|
|
|
-
|
|
|
+ .close{
|
|
|
+ width:20px;height:20px;position:absolute;
|
|
|
+ right:0px;
|
|
|
+ }
|
|
|
+ .close1{
|
|
|
+ width:20px;height:20px;position:absolute;
|
|
|
+ right:10px;
|
|
|
+ top:0;
|
|
|
+ }
|
|
|
+ .close2{
|
|
|
+ width: 15px;
|
|
|
+ height: 15px;
|
|
|
+ position: absolute;
|
|
|
+ right: 19px;
|
|
|
+ top: 50%;
|
|
|
+ transform: translateY(-45%);
|
|
|
+ }
|
|
|
.wrapper {
|
|
|
position: relative;
|
|
|
z-index: 90;
|