1.设置新增邮箱绑定和密码重置

2024.3.11 sws
master
sws 2024-03-11 18:20:44 +08:00
parent 838f64ff71
commit b88c331e6e
5 changed files with 276 additions and 47 deletions

View File

@ -306,6 +306,13 @@
"enablePullDownRefresh": false,
"navigationBarTitleText": ""
}
},
{
"path": "pages/password/password",
"style": {
"enablePullDownRefresh": true,
"navigationBarTitleText": ""
}
}
],
"subPackages": [{

View File

@ -37,6 +37,25 @@
</view>
</form>
</view>
<view v-if="current_opt_form == 'bind_email'" class="form-content">
<form @submit="formBindEmail">
<view class="tc">
<image class="icon circle auto dis-block margin-bottom-xxl br" :src="(user.avatar || null) == null ? '/static/images/default-user.png' : user.avatar" mode="widthFix"></image>
<view v-if="(user.nickname || null) != null" class="cr-base">{{ user.nickname }}</view>
</view>
<view class="margin-top-xxxl padding-top-xxxl">
<input type="text" :placeholder="$t('login.login.db1rf4')" maxlength="60" name="accounts" @input="form_input_email_event" key="login_email_1" class="form-item margin-vertical-xl wh-auto" />
<view class="code pr margin-vertical-main">
<input type="number" :placeholder="$t('login.login.t3951j')" name="verify" maxlength="4" />
<button :class="'verify-submit pa round br text-size-sm cr-base ' + (verify_disabled ? 'sub-disabled' : '')" type="default" hover-class="none" size="mini" :loading="verify_loading" :disabled="verify_disabled" @tap="verify_send_event">{{ verify_submit_text }}</button>
</view>
<button class="bg-main br-main cr-white round text-size margin-top-xxxl" form-type="submit" type="default" hover-class="none" :loading="form_submit_loading" :disabled="form_submit_loading">{{ $t('login.login.tfl656') }}</button>
</view>
<view class="margin-top-xxxl padding-top-xxxl padding-horizontal-main padding-bottom-xxxl tc">
<text class="cr-blue" data-value="bind" @tap="opt_form_event">{{ $t('login.login.483nho') }}</text>
</view>
</form>
</view>
<!-- 存在用户信息 -->
<block v-if="user != null">
@ -71,7 +90,7 @@
</block>
<!-- 站点logo -->
<image v-if="(home_site_logo_square || null) != null && current_opt_form != 'bind' && current_opt_form != 'bind_verify' && current_opt_form != 'success'" class="icon circle auto dis-block br" :src="home_site_logo_square" mode="widthFix"></image>
<image v-if="(home_site_logo_square || null) != null && current_opt_form != 'bind' && current_opt_form != 'bind_verify' && current_opt_form != 'bind_email' && current_opt_form != 'success'" class="icon circle auto dis-block br" :src="home_site_logo_square" mode="widthFix"></image>
<!-- 非登录成功则需要展示的数据 -->
<block v-if="current_opt_form != 'success'">
@ -461,7 +480,7 @@
// #ifdef APP
// app
this.provider_action()
this.provider_action();
//#endif
//
@ -537,7 +556,7 @@
reg_email: this.$t('login.login.jc0w0o'),
forget: this.$t('login.login.8tmyuc'),
success: this.$t('login.login.5p23c6'),
}
},
});
},
@ -633,9 +652,9 @@
// #ifdef APP
// app
var thirdpartylogin = this.plugins_thirdpartylogin_data || {};
if(Object.keys(thirdpartylogin).length) {
if (Object.keys(thirdpartylogin).length) {
var temp_thirdpartylogin = Object.keys(thirdpartylogin).reduce((pre, cur) => {
if(this.app_login_provider_list.includes(cur)) {
if (this.app_login_provider_list.includes(cur)) {
pre[cur] = thirdpartylogin[cur];
}
return pre;
@ -788,7 +807,7 @@
}
}
//
if (this.current_opt_type == 'login_email' || this.current_opt_type == 'reg_email') {
if (this.current_opt_type == 'login_email' || this.current_opt_type == 'reg_email' || this.current_opt_type == 'bind_email') {
if ((this.form_input_email_value || null) == null) {
app.globalData.showToast(this.$t('login.login.xak8g1'));
return false;
@ -800,7 +819,7 @@
return false;
}
// 使
if (this.current_opt_form != 'bind' && this.current_opt_form != 'bind_verify') {
if (this.current_opt_form != 'bind' && this.current_opt_form != 'bind_verify' && this.current_opt_form != 'bind_email') {
if (this.common_img_verify_state == 1) {
this.setData({
popup_image_verify_status: true,
@ -816,7 +835,7 @@
//
verify_send_handle() {
//
if (this.current_opt_form != 'bind' && this.current_opt_form != 'bind_verify') {
if (this.current_opt_form != 'bind' && this.current_opt_form != 'bind_verify' && this.current_opt_form != 'bind_email') {
if (this.common_img_verify_state == 1) {
if ((this.form_input_image_verify_value || null) == null || this.form_input_image_verify_value.length < 4) {
app.globalData.showToast(this.$t('login.login.7r5h37'));
@ -828,15 +847,26 @@
//
var action = '';
var image_verify_type = '';
if (this.current_opt_form == 'bind' || this.current_opt_form == 'bind_verify') {
action = 'appmobilebindverifysend';
if (this.current_opt_form == 'bind' || this.current_opt_form == 'bind_email' || this.current_opt_form == 'bind_verify') {
image_verify_type = 'user_bind';
var post_data = {
mobile: this.form_input_mobile_value || '',
};
if ((post_data.mobile || null) == null) {
app.globalData.showToast(this.$t('login.login.4c5n8o'));
return false;
if (this.current_opt_form == 'bind_email') {
action = 'appemailbindverifysend';
var post_data = {
email: this.form_input_email_value || '',
};
if ((post_data.email || null) == null) {
app.globalData.showToast(this.$t('login.login.xak8g1'));
return false;
}
} else if (this.current_opt_form == 'bind_verify') {
action = 'appmobilebindverifysend';
var post_data = {
mobile: this.form_input_mobile_value || '',
};
if ((post_data.mobile || null) == null) {
app.globalData.showToast(this.$t('login.login.4c5n8o'));
return false;
}
}
} else {
if (this.current_opt_form == 'login') {
@ -929,9 +959,25 @@
},
});
},
formBindMobile(e) {
//
var validation = [
{ fields: 'mobile', msg: this.$t('login.login.4c5n8o') },
{ fields: 'verify', msg: this.$t('login.login.01xmab') },
];
this.formBind(e, validation, app.globalData.get_request_url('appmobilebind', 'user'));
},
//
formBind(e) {
formBindEmail(e) {
//
var validation = [
{ fields: 'email', msg: this.$t('login.login.xak8g1') },
{ fields: 'verify', msg: this.$t('login.login.01xmab') },
];
this.formBind(e, validation, app.globalData.get_request_url('appemailbind', 'user'));
},
//
formBind(e, validation, url) {
//
var client_type = app.globalData.application_client_type();
var user = this.user || this.plugins_thirdpartylogin_user || app.globalData.get_login_cache_info() || {};
@ -967,7 +1013,7 @@
//
uni.request({
url: app.globalData.get_request_url('appmobilebind', 'user'),
url: url,
method: 'POST',
data: e.detail.value,
dataType: 'json',
@ -1465,20 +1511,26 @@
// #ifdef APP
let self = this;
switch(type) {
switch (type) {
// QQ
case 'weixin' :
case 'qq' :
case 'google' :
case 'weixin':
case 'qq':
case 'google':
uni.login({
provider: type,
success: function(res) {
success: function (res) {
let auth_result = res.authResult;
self.app_login_bind_handle({...auth_result, ...{
platform: type,
openid: auth_result.openid,
access_token: auth_result.access_token,
}}, auth_result);
self.app_login_bind_handle(
{
...auth_result,
...{
platform: type,
openid: auth_result.openid,
access_token: auth_result.access_token,
},
},
auth_result
);
},
fail: function (error) {
app.globalData.showToast(error.errMsg || this.$t('login.login.4835p5'));
@ -1487,16 +1539,22 @@
break;
//
case 'apple' :
case 'apple':
uni.login({
provider: type,
success: function(res) {
success: function (res) {
let auth_result = res.appleInfo || res.userInfo;
self.app_login_bind_handle({...auth_result, ...{
platform: type,
openid: auth_result.openId || auth_result.user,
access_token: auth_result.access_token || ''
}}, auth_result);
self.app_login_bind_handle(
{
...auth_result,
...{
platform: type,
openid: auth_result.openId || auth_result.user,
access_token: auth_result.access_token || '',
},
},
auth_result
);
},
fail: function (error) {
app.globalData.showToast(error.errMsg || this.$t('login.login.4835p5'));
@ -1504,8 +1562,8 @@
});
break;
default :
app.globalData.showToast(type+this.$t('login.login.li9573'));
default:
app.globalData.showToast(type + this.$t('login.login.li9573'));
}
// #endif
},
@ -1523,16 +1581,16 @@
success: (res) => {
uni.hideLoading();
if (res.data.code == 0) {
var user = {...auth_result, ...res.data.data};
var user = { ...auth_result, ...res.data.data };
//
this.setData({
plugins_thirdpartylogin_user: user
plugins_thirdpartylogin_user: user,
});
//
if ((user.is_force_bind_user || 0) != 1) {
this.setData({
user: user
user: user,
});
//
@ -1631,7 +1689,7 @@
popup_login_status: false,
});
},
// app
provider_action() {
uni.getProvider({
@ -1641,9 +1699,9 @@
app_login_provider_list: result.provider || [],
});
},
fail: (error) => {}
fail: (error) => {},
});
}
},
},
};
</script>

View File

@ -0,0 +1,18 @@
.password {
height: 100vh;
background: #fff;
}
.password .form-item {
height: 100rpx;
line-height: 100rpx;
background: #F9F9F9;
border-radius: 50rpx;
border: 0;
}
.password .form-item ::v-deep .input-placeholder,
.password .form-item ::v-deep .uni-input-input {
padding: 0 36rpx;
font-size: 30rpx;
}

137
pages/password/password.vue Normal file
View File

@ -0,0 +1,137 @@
<template>
<view :class="theme_view">
<!-- 主体内容 -->
<block v-if="data_list_loding_status == 3">
<view class="password">
<view class="padding-main">
<form @submit="formBindPwd">
<view class="margin-top-xxxl">
<input type="text" placeholder="请输入当前密码" minlength="6" maxlength="18" name="pwd_old" password="true" class="form-item wh-auto margin-bottom-main" />
<input type="text" placeholder="请输入新密码" minlength="6" maxlength="18" name="pwd_new" password="true" class="form-item wh-auto margin-bottom-main" />
<input type="text" placeholder="请确认新密码" minlength="6" maxlength="18" name="pwd_renew" password="true" class="form-item wh-auto margin-bottom-main" />
</view>
<view class="margin-top-xxxxl tc">
<button class="bg-main br-main cr-white round text-size" form-type="submit" type="default" hover-class="none" :loading="form_submit_loading" :disabled="form_submit_loading">确认修改</button>
</view>
</form>
</view>
</view>
</block>
<block v-else>
<!-- 错误提示 -->
<component-no-data :propStatus="data_list_loding_status" :propMsg="data_list_loding_msg"></component-no-data>
</block>
</view>
</template>
<script>
const app = getApp();
import componentNoData from '../../components/no-data/no-data';
export default {
data() {
return {
theme_view: app.globalData.get_theme_value_view(),
data_list_loding_status: 1,
data_list_loding_msg: '',
form_submit_loading: false,
};
},
onLoad(params) {
//
app.globalData.page_event_onload_handle(params);
},
onShow() {
//
app.globalData.page_event_onshow_handle();
//
this.init();
},
methods: {
init() {
var user = app.globalData.get_user_info(this, 'init');
if (user != false) {
//
if (app.globalData.user_is_need_login(user)) {
uni.redirectTo({
url: '/pages/login/login?event_callback=init',
});
this.setData({
data_list_loding_status: 0,
data_list_loding_msg: this.$t('setup.setup.07o10b'),
});
return false;
} else {
this.setData({
data_list_loding_status: 3,
user: user,
});
}
} else {
this.setData({
data_list_loding_status: 0,
data_list_loding_msg: this.$t('setup.setup.nwt4o1'),
});
}
},
formBindPwd() {
//
// #ifdef MP
var field_openid = client_type + '_openid';
var field_unionid = client_type + '_unionid';
e.detail.value[field_openid] = user[field_openid] || '';
e.detail.value[field_unionid] = user[field_unionid] || '';
// #endif
//
var validation = [
{ fields: 'pwd_old', msg: '请输入密码' },
{ fields: 'pwd_new', msg: '请输入新密码' },
{ fields: 'pwd_renew', msg: '确认新密码' },
];
// #ifdef MP
validation.push({ fields: field_openid, msg: this.$t('login.login.prqvf1') });
// #endif
if (app.globalData.fields_check(e.detail.value, validation)) {
uni.showLoading({
title: this.$t('common.processing_in_text'),
});
this.setData({
form_submit_loading: true,
});
//
uni.request({
url: app.globalData.get_request_url('apppwdbind', 'user'),
method: 'POST',
data: e.detail.value,
dataType: 'json',
success: (res) => {
uni.hideLoading();
this.setData({
form_submit_loading: false,
});
app.globalData.showToast(res.data.msg);
if (res.data.code == 0 && (res.data.data || null) != null) {
//
uni.navigateBack();
}
},
fail: () => {
uni.hideLoading();
this.setData({
form_submit_loading: false,
});
app.globalData.showToast(this.$t('common.internet_error_tips'));
},
});
}
},
},
};
</script>
<style>
@import './password.css';
</style>

View File

@ -14,6 +14,14 @@
<text>{{ $t('setup.setup.x81v6d') }}</text>
<text class="fr cr-grey">{{ user.mobile_security || '' }} {{ $t('setup.setup.j6skqh') }}</text>
</view>
<view class="padding-top-xxl padding-bottom-xxl padding-right-xxxl arrow-right br-t" data-value="/pages/password/password" @tap="url_event">
<text>更换密码</text>
<text class="fr cr-grey">{{ $t('setup.setup.j6skqh') }}</text>
</view>
<view class="padding-top-xxl padding-bottom-xxl padding-right-xxxl arrow-right br-t" data-value="/pages/login/login?opt_type=bind_email&opt_form=bind_email" @tap="url_event">
<text>更换邮箱</text>
<text class="fr cr-grey">{{ user.email_security || '' }} {{ $t('setup.setup.j6skqh') }}</text>
</view>
<view v-if="home_use_multilingual_status == 1" class="padding-top-xxl padding-bottom-xxl padding-right-xxxl arrow-right br-t" data-value="/pages/login/login?opt_form=bind_verify" @tap="open_language_event">
<text>{{ $t('setup.setup.r7jz13') }}</text>
<text class="fr cr-grey">{{ language }}</text>
@ -70,9 +78,10 @@
</view>
</component-popup>
</block>
<!-- 错误提示 -->
<component-no-data :propStatus="data_list_loding_status" :propMsg="data_list_loding_msg"></component-no-data>
<block v-else>
<!-- 错误提示 -->
<component-no-data :propStatus="data_list_loding_status" :propMsg="data_list_loding_msg"></component-no-data>
</block>
</view>
</view>
</template>