ReedawFoodApp/body/setting/phone.vue

217 lines
4.1 KiB
Vue

<template>
<view class="content">
<view class="login">
<view class="editem">
<view class="item">
<view class="text">{{$t('infoMobile')}}</view>
<view class="input">
<input v-model="phone" :placeholder="$t('verifyMobile')" />
</view>
</view>
<view class="item ">
<view class="text">{{$t('titleCode')}}</view>
<view class="input yanzhengma">
<input class="uni-input" v-model="code" />
<button class="code" type="none" @click="handleCode" v-model="code"
:disabled="disabled">{{second<60 ? second+$t('titleSendCodeRetry'):$t('titleSendCode')}}
</button>
</view>
</view>
</view>
<view class="btnlogin" @click="handleTelLogin">{{$t('btnSubmit')}}</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
phone: "",
code: "",
disabled: false,
second: 60,
}
},
onLoad() {
let that = this
uni.setNavigationBarTitle({
title: that.$t('titlePhone')
})
},
methods: {
// 登录、
handleTelLogin() {
let that = this
if (!(/^1[3456789]\d{9}$/.test(that.phone))) {
that.$tools.msg(that.$t('verifyMobileCorrect'))
return
}
if (!that.code) {
that.$tools.msg(that.$t('verifyCode'))
return
}
that.$model.getAccountMsg({
data: that.phone,
code: that.code,
}).then(res => {
if (res.code != 0) {
that.$tools.msg(res.msg)
return
} else {
that.$tools.msg(that.$t('msgSetSuccess'))
that.$store.commit('changeAccountNumber', {
my_tel: that.phone
})
setTimeout(function() {
uni.redirectTo({
url: "/body/setting/setting"
})
}, 1000)
}
}).catch(err => {})
},
// 获取验证码
handleCode() {
let that = this
if (!that.phone) {
that.$tools.msg(that.$t('verifyMobile'))
return
}
if (!(/^1[3456789]\d{9}$/.test(that.phone))) {
that.$tools.msg(that.$t('verifyMobileCorrect'))
return
}
//
that.$model.getSendCode({
data: that.phone,
}).then(res => {
console.log(res)
if (res.code != 0) {
that.$tools.msg(res.msg)
return
}
that.disabled = true
let interval = setInterval(() => {
--that.second
}, 1000)
setTimeout(() => {
clearInterval(interval)
that.disabled = false
that.second = 60
}, 60000)
}).catch(err => {})
},
}
}
</script>
<style scoped lang="scss">
.content {
width: 100%;
height: 100vh;
background: #fff;
}
.login {
width: calc(100% - 30px);
height: auto;
background: #fff;
border-radius: 10px;
padding: 15px;
background-color: #fff;
z-index: 99;
.title {
text-align: left;
color: #333;
font-size: 40rpx;
font-weight: bold;
margin-bottom: 15px;
}
.editem {
position: relative;
display: flex;
align-items: center;
font-size: 28rpx;
justify-content: space-between;
flex-wrap: wrap;
.item {
width: 100%;
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 15px;
.text {
width: 80px;
height: 40px;
line-height: 40px;
font-size: 28rpx;
}
.input {
width: calc(100% - 100px);
height: 35px;
line-height: 35px;
display: flex;
position: relative;
border: #dfdfdf 1px solid;
border-radius: 5px;
padding: 0 10px;
background-color: #f7f7f7;
}
input {
height: 40px;
line-height: 40px;
position: absolute;
left: 10px;
right: 0px;
z-index: 88;
font-size: 28rpx;
}
.yanzhengma {
input {
right: 120px;
font-size: 32rpx;
}
}
}
.code {
width: 110px;
background: #dfdfdf;
font-size: 32rpx;
margin: 0;
line-height: 40px;
border-radius: 5px;
text-align: center;
position: absolute;
right: 0px;
top: 0px;
bottom: 0;
z-index: 99;
}
}
.btnlogin {
width: 100%;
margin: 15px 0;
height: 42px;
line-height: 42px;
background: $btncolor;
font-weight: 700;
border-radius: 15px;
text-align: center;
color: #fff !important;
}
}
</style>