question_uniapp/pages/Setting/setPasswork.vue

174 lines
5.3 KiB
Vue
Raw Permalink Normal View History

2025-06-06 03:08:19 +08:00
<template>
<view class="page">
2025-06-10 00:51:49 +08:00
<uni-nav-bar @clickLeft="goto(1, 1)" left-icon="back" :border="false" :shadow="false" :fixed="true"
2025-06-10 17:10:40 +08:00
:title="$t('setPasswork.title')" backgroundColor="#fff" :statusBar="true"></uni-nav-bar>
2025-06-10 00:51:49 +08:00
<view style="width: 94%; margin: 20rpx auto; padding: 30rpx 10rpx;">
<uni-forms label-position="top" label-width="180rpx" :model="model" :rules="rules" ref="model">
2025-06-07 21:01:16 +08:00
<uni-forms-item :label="$t('setPasswork.text1')" name="email" label-width="400rpx">
<uni-easyinput type="text" v-model="model.email" placeholder=""></uni-easyinput>
2025-06-06 03:08:19 +08:00
</uni-forms-item>
2025-06-07 21:01:16 +08:00
<uni-forms-item :label="$t('setPasswork.text3')" name="code" label-width="400rpx">
2025-06-10 00:51:49 +08:00
<uni-easyinput type="number" v-model="model.code" :placeholder="$t('setPasswork.text12')">
2025-06-06 03:08:19 +08:00
<template #right>
<button type="primary"
:disabled="isSend"
@click="sendCode()"
2025-06-10 00:51:49 +08:00
style="font-size: 28rpx; padding: auto 20rpx; width: 220rpx;">{{sendText}}</button>
2025-06-06 03:08:19 +08:00
</template>
</uni-easyinput>
</uni-forms-item>
2025-06-09 00:34:46 +08:00
<uni-forms-item :label="$t('setPasswork.text4')" name="password">
2025-06-07 21:01:16 +08:00
<uni-easyinput type="password" :passwordIcon="true" v-model="model.password" :placeholder="$t('setPasswork.text5')" />
2025-06-06 03:08:19 +08:00
</uni-forms-item>
2025-06-09 00:34:46 +08:00
<uni-forms-item :label="$t('setPasswork.text6')" name="cpassword" labelWidth="400rpx">
2025-06-07 21:01:16 +08:00
<uni-easyinput type="password" :passwordIcon="true" v-model="model.cpassword" :placeholder="$t('setPasswork.text7')" />
2025-06-06 03:08:19 +08:00
</uni-forms-item>
</uni-forms>
</view>
2025-06-10 00:51:49 +08:00
<view style="bottom: 0rpx; position: absolute; width:100vw; height: 120rpx;">
2025-06-06 03:08:19 +08:00
<view class="cell_list">
2025-06-07 21:01:16 +08:00
<button type="primary" round style="width: 100%;" @click="submit">{{$t('buttonSubmit')}}</button>
2025-06-06 03:08:19 +08:00
</view>
</view>
</view>
</template>
<script>
import {
mapState,
mapMutations
} from 'vuex';
export default {
data() {
return {
2025-06-07 21:08:06 +08:00
sendText: this.$t('setPasswork.text8'),
2025-06-06 03:08:19 +08:00
isSend: false,
model: {
email: '',
password: '',
cpassword: '',
code: ''
},
rules: {
2025-06-07 21:08:06 +08:00
email: {rules:[{required: true,errorMessage: this.$t('setPasswork.text9')}]},
password: {rules:[{required: true,errorMessage: this.$t('setPasswork.text10')}]},
cpassword: {rules:[{required: true,errorMessage: this.$t('setPasswork.text11')}]},
code: {rules:[{required: true,errorMessage: this.$t('setPasswork.text12')}]},
2025-06-06 03:08:19 +08:00
}
};
},
computed: {
...mapState(['userInfo'])
},
//第一次加载
onLoad(e) {
},
//页面显示
onShow() {},
//方法
methods: {
onPageJump(url) {
uni.navigateTo({
url: url
});
},
2025-06-10 00:51:49 +08:00
goto(url, type) {
if (type == 2) {
return uni.switchTab({ url: url })
}
if (type == 1) {
return uni.navigateBack({ delta: url });
}
uni.navigateTo({
url: url
})
},
2025-06-06 03:08:19 +08:00
sendCode(){
this.isSend = true;
if (!this.$base.mailRegular.test(this.model.email)) {
2025-06-15 22:12:30 +08:00
uni.showToast({title: this.$t('setPasswork.text13'), icon:'none'});
2025-06-06 03:08:19 +08:00
return;
}
let s = 120;
let data = {
type: "email",
event: "resetpwd",
email: this.model.email,
lang: this.$i18n.locale
}
this.$http.post('/api/common/captcha', data).then(res => {
if(res.code == 0){
2025-06-07 21:08:06 +08:00
uni.showToast({title: this.$t('setPasswork.text14')});
this.sendText = this.$t('setPasswork.text15', {par: s});
2025-06-06 03:08:19 +08:00
let intervalId = setInterval(() => {
s = s-1;
if (s == 0) {
clearInterval(intervalId);
this.isSend = false;
2025-06-07 21:08:06 +08:00
this.sendText = this.$t('setPasswork.text8');
2025-06-06 03:08:19 +08:00
}
else{
2025-06-07 21:08:06 +08:00
this.sendText = this.$t('setPasswork.text15', {par: s});
2025-06-06 03:08:19 +08:00
}
}, 1000);
}
});
},
submit(){
this.$refs.model.validate().then(res=>{
if (!this.$base.mailRegular.test(this.model.email)) {
2025-06-15 22:12:30 +08:00
uni.showToast({title: this.$t('setPasswork.text13'), icon:'none'});
2025-06-06 03:08:19 +08:00
return;
}
if (!this.$base.passwordRegular.test(this.model.password)) {
2025-06-15 22:12:30 +08:00
uni.showToast({title: this.$t('setPasswork.text16'), icon:'none'});
2025-06-06 03:08:19 +08:00
return;
}
if (this.model.cpassword !== this.model.password) {
2025-06-15 22:12:30 +08:00
uni.showToast({title: this.$t('setPasswork.text17'), icon:'none'});
2025-06-06 03:08:19 +08:00
return;
}
this.$http.post('/api/common/resetpwd', {email: this.model.email, newpassword: this.model.password, code: this.model.code}).then(res => {
if(res.code == 0){
uni.showToast({title: res.data.mes});
setTimeout(() => {
uni.navigateBack();
}, 1000);
}
});
});
}
},
//页面隐藏
onHide() {},
//页面卸载
onUnload() {},
//页面下来刷新
onPullDownRefresh() {},
//页面上拉触底
onReachBottom() {},
//用户点击分享
onShareAppMessage(e) {
return this.wxShare();
}
};
</script>
<style lang="scss" scoped>
@import '@/style/mixin.scss';
body{background-color: #fff;}
.page{min-height: 95vh;position: relative;}
.rechargeTitle{
2025-06-10 00:51:49 +08:00
font-weight: 400;font-size: 32rpx;color: #999999;line-height: 46rpx; text-align: center; margin-top: 60rpx;
2025-06-06 03:08:19 +08:00
}
.rechargeNet{
2025-06-10 00:51:49 +08:00
font-weight: 600;font-size: 40rpx;color: #333;line-height: 46rpx; text-align: center; margin-top: 40rpx;
2025-06-06 03:08:19 +08:00
}
.txt{
2025-06-10 00:51:49 +08:00
font-size: 28rpx; color:#999; font-weight: 500;
2025-06-06 03:08:19 +08:00
}
.cell_right{
2025-06-10 00:51:49 +08:00
font-size: 28rpx; color:#333; font-weight: 500;
2025-06-06 03:08:19 +08:00
}
</style>