kitchendDevice/pageTwo/login/forgetPassword.vue

307 lines
6.4 KiB
Vue
Raw Normal View History

2025-03-25 10:17:30 +08:00
<template>
<view class="content">
<!-- <view class="bg"></view> -->
<view class="login">
<view class="editem">
<view class="item">
2025-12-27 15:47:56 +08:00
<view class="text">{{$t("infoEmail")}}</view>
2025-03-25 10:17:30 +08:00
<view class="input">
2025-12-22 09:34:09 +08:00
<input v-model="phone" type="text" />
2025-03-25 10:17:30 +08:00
</view>
</view>
<view class="item ">
2025-12-22 09:34:09 +08:00
<view class="text">{{$t("titleCode")}}</view>
2025-03-25 10:17:30 +08:00
<view class="input yanzhengma">
<input class="uni-input" v-model="code" />
<button class="code" type="none" @click="handleCode" v-model="code"
2025-12-22 09:34:09 +08:00
:disabled="disabled">{{second<60 ? second+$t("titleSendCodeRetry"):$t("titleSendCode")}}
2025-03-25 10:17:30 +08:00
</button>
</view>
</view>
<view class="item">
2025-12-22 09:34:09 +08:00
<view class="text">{{$t("titlePassword")}}</view>
2025-03-25 10:17:30 +08:00
<view class="input">
<input class="uni-input" v-model="password" />
</view>
</view>
<view class="item">
2025-12-22 09:34:09 +08:00
<view class="text">{{$t("titleConfirmPassword")}}</view>
2025-03-25 10:17:30 +08:00
<view class="input">
<input class="uni-input" v-model="password2" />
</view>
</view>
</view>
<!-- <view class="xieyi">
<checkbox-group @change="checkboxChange" class="group">
<label>
<checkbox :value="1" style="transform:scale(0.7)" />{{$t("login.agreement")}}
<text @click="handlexieyi" @click.stop>{{$t("login.agreementContnt")}}</text>
</label>
</checkbox-group>
</view> -->
2025-12-22 09:34:09 +08:00
<view class="btnlogin" @click="handleTelLogin">{{$t("titleRegister")}}</view>
2025-03-25 10:17:30 +08:00
</view>
</view>
</template>
<script>
export default {
data() {
return {
phone: "",
code: "",
password: "",
password2: "",
disabled: false,
second: 60,
value: 1,
type: ""
}
},
onLoad(options) {
2025-12-22 09:34:09 +08:00
let that = this
uni.setNavigationBarTitle({
title: that.$t('titleLogin')
})
2025-03-25 10:17:30 +08:00
this.type = options.type //1
},
methods: {
checkboxChange(e) {
this.value = e.detail.value.length ? e.detail.value[0] : "0"
},
// 登录、
handleTelLogin() {
let that = this
if (that.value == 0) {
2025-12-22 09:34:09 +08:00
that.$tools.msg(that.$t("verifyAgreement"))
2025-03-25 10:17:30 +08:00
return
}
2025-12-27 15:47:56 +08:00
if (!(/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/.test(that.phone))) {
2025-12-22 09:34:09 +08:00
that.$tools.msg(that.$t("verifyEmailCorrect"))
2025-03-25 10:17:30 +08:00
return
}
if (!that.code) {
2025-12-22 09:34:09 +08:00
that.$tools.msg(that.$t("verifyCode"))
2025-03-25 10:17:30 +08:00
return
}
if (!that.password) {
2025-12-22 09:34:09 +08:00
that.$tools.msg(that.$t("verifyPassword"))
2025-03-25 10:17:30 +08:00
return
}
if (!that.password2) {
2025-12-22 09:34:09 +08:00
that.$tools.msg(that.$t("verifyPassword"))
2025-03-25 10:17:30 +08:00
return
}
if (that.password2 != that.password) {
2025-12-22 09:34:09 +08:00
that.$tools.msg(that.$t("verifyPasswordCorrect"))
2025-03-25 10:17:30 +08:00
return
}
let account = {
data: that.phone,
password: that.password,
2025-12-27 15:47:56 +08:00
confirm_password: that.password2,
code: that.code,
language: uni.getStorageSync('language')
2025-03-25 10:17:30 +08:00
}
let https = that.type == 'register' ? that.$model.getregister(account) : that.$model.getResetPassword(
account)
return https.then(res => {
console.log("注册", res)
if (res.code != 0) {
that.$tools.msg(res.msg)
return
}
uni.setStorageSync('token', res.data.token)
uni.setStorageSync('aan_id', res.data.aan_id)
2025-12-27 15:47:56 +08:00
that.$store.dispatch("getHomeConfig")
2025-12-22 09:34:09 +08:00
that.$tools.msg(that.$t("msgSetPasswordSuccess"))
2025-03-25 10:17:30 +08:00
setTimeout(function() {
uni.reLaunch({
url: "/pages/index/index"
})
}, 1000)
}).catch(err => {})
},
// 获取验证码
handleCode() {
let that = this
2025-12-27 15:47:56 +08:00
if (!(/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/.test(that.phone))) {
2025-12-22 09:34:09 +08:00
that.$tools.msg(that.$t("verifyEmailCorrect"))
2025-03-25 10:17:30 +08:00
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 => {})
},
handlexieyi() {}
}
}
</script>
<style scoped lang="scss">
.content {
width: 100%;
height: 100vh;
background: #fff;
// display: flex;
// flex-direction: column;
// align-items: center;
// justify-content: center;
}
.bg {
position: absolute;
top: 0;
width: 100%;
height: 50vh;
z-index: 9;
// background: $maincolor;
}
.login {
2025-11-25 14:21:22 +08:00
width: calc(100% - 60rpx);
2025-03-25 10:17:30 +08:00
height: auto;
background: #fff;
2025-11-25 14:21:22 +08:00
border-radius: 20rpx;
padding: 30rpx;
2025-03-25 10:17:30 +08:00
background-color: #fff;
z-index: 99;
// position: relative;
2025-11-25 14:21:22 +08:00
// margin-left: calc(10% - 80rpx);
2025-03-25 10:17:30 +08:00
// box-shadow: 0px 1px 5px 2px #dfe2e1fc;
.title {
text-align: left;
color: #333;
2025-12-22 09:34:09 +08:00
font-size: 40rpx;
2025-03-25 10:17:30 +08:00
font-weight: bold;
2025-11-25 14:21:22 +08:00
margin-bottom: 30rpx;
2025-03-25 10:17:30 +08:00
}
.editem {
position: relative;
display: flex;
align-items: center;
font-size: 32rpx;
justify-content: space-between;
flex-wrap: wrap;
.item {
width: 100%;
display: flex;
align-items: center;
justify-content: space-between;
2025-11-25 14:21:22 +08:00
margin-bottom: 30rpx;
2025-03-25 10:17:30 +08:00
.text {
width: 240rpx;
2025-11-25 14:21:22 +08:00
height: 80rpx;
line-height: 80rpx;
2025-03-25 10:17:30 +08:00
font-size: 32rpx;
}
.input {
width: calc(100% - 240rpx);
height: 35px;
line-height: 35px;
display: flex;
position: relative;
border: #dfdfdf 1px solid;
border-radius: 5px;
2025-11-25 14:21:22 +08:00
padding: 0 20rpx;
2025-03-25 10:17:30 +08:00
background-color: #f7f7f7;
}
input {
2025-11-25 14:21:22 +08:00
height: 80rpx;
line-height: 80rpx;
2025-03-25 10:17:30 +08:00
position: absolute;
2025-11-25 14:21:22 +08:00
left: 20rpx;
2025-03-25 10:17:30 +08:00
right: 0px;
z-index: 88;
2025-12-22 09:34:09 +08:00
font-size: 28rpx;
2025-03-25 10:17:30 +08:00
}
.yanzhengma {
input {
right: 220rpx;
2025-12-22 09:34:09 +08:00
font-size: 28rpx;
2025-03-25 10:17:30 +08:00
}
}
}
.code {
width: 220rpx;
background: #dfdfdf;
font-size: 28rpx;
margin: 0;
2025-11-25 14:21:22 +08:00
line-height: 80rpx;
2025-03-25 10:17:30 +08:00
border-radius: 5px;
text-align: center;
position: absolute;
right: 0px;
top: 0px;
bottom: 0;
z-index: 99;
}
.forget {
width: 80px;
background: #fff;
color: $textcolor;
}
}
.btngroup {
width: 100%;
height: 35px;
line-height: 35px;
display: flex;
justify-content: center;
text {
display: block;
color: $textcolor;
}
}
.btnlogin {
width: 100%;
2025-11-25 14:21:22 +08:00
margin: 30rpx 0;
2025-03-25 10:17:30 +08:00
height: 42px;
line-height: 42px;
background: $btncolor;
font-weight: 700;
2025-11-25 14:21:22 +08:00
border-radius: 30rpx;
2025-03-25 10:17:30 +08:00
text-align: center;
color: #fff !important;
}
}
.xieyi {
font-size: 32rpx;
color: $textcolor;
text {
border-bottom: 1px solid $textcolor;
}
}
</style>