调整代码

This commit is contained in:
kuaifan 2022-07-13 20:34:42 +08:00
parent 64d34deb6b
commit cda9be878b
8 changed files with 104 additions and 99 deletions

View File

@ -753,24 +753,4 @@ class SystemController extends AbstractController
} }
return $array; return $array;
} }
/**
* @api {get} api/system/get/regverify 18. 获取是否开启邮箱验证
*
* @apiDescription 获取邮箱配置是否开启注册邮箱验证
* @apiVersion 1.0.0
* @apiGroup system
* @apiName get__regverify
*
* @apiSuccess {Number} ret 返回状态码1正确、0错误
* @apiSuccess {String} msg 返回信息(错误描述)
* @apiSuccess {Object} data 返回数据
*/
public function get__regverify()
{
User::auth();
$isRegVerify = Base::settingFind('emailSetting', 'reg_verify') === 'open';
return Base::retSuccess('success', $isRegVerify ? 1 : 0);
}
} }

View File

@ -986,12 +986,12 @@ class UsersController extends AbstractController
} }
/** /**
* @api {get} api/users/send/email 18. 发送邮箱验证码 * @api {get} api/users/email/send 18. 发送邮箱验证码
* *
* @apiDescription 需要token身份 * @apiDescription 需要token身份
* @apiVersion 1.0.0 * @apiVersion 1.0.0
* @apiGroup users * @apiGroup users
* @apiName send__email * @apiName email__send
* *
* @apiParam {Number} type 邮件类型 * @apiParam {Number} type 邮件类型
* @apiParam {String} email 邮箱地址 * @apiParam {String} email 邮箱地址
@ -1000,11 +1000,12 @@ class UsersController extends AbstractController
* @apiSuccess {String} msg 返回信息(错误描述) * @apiSuccess {String} msg 返回信息(错误描述)
* @apiSuccess {Object} data 返回数据 * @apiSuccess {Object} data 返回数据
*/ */
public function send__email() public function email__send()
{ {
$user = User::auth();
//
$type = Request::input('type', 2); $type = Request::input('type', 2);
$email = Request::input('email'); $email = Request::input('email');
$user = User::auth();
if (!$email) { if (!$email) {
return Base::retError('请输入新邮箱地址'); return Base::retError('请输入新邮箱地址');
} }
@ -1025,7 +1026,7 @@ class UsersController extends AbstractController
} }
/** /**
* @api {get} api/users/edit/email 19. 修改邮箱 * @api {get} api/users/email/edit 19. 修改邮箱
* *
* @apiDescription 需要token身份 * @apiDescription 需要token身份
* @apiVersion 1.0.0 * @apiVersion 1.0.0
@ -1039,9 +1040,10 @@ class UsersController extends AbstractController
* @apiSuccess {String} msg 返回信息(错误描述) * @apiSuccess {String} msg 返回信息(错误描述)
* @apiSuccess {Object} data 返回数据 * @apiSuccess {Object} data 返回数据
*/ */
public function edit__email() public function email__edit()
{ {
$user = User::auth(); $user = User::auth();
//
$user->checkSystem(); $user->checkSystem();
// //
$newEmail = trim(Request::input('newEmail')); $newEmail = trim(Request::input('newEmail'));
@ -1126,8 +1128,6 @@ class UsersController extends AbstractController
return Base::retError('删除失败'); return Base::retError('删除失败');
} }
} }
return Base::retSuccess('success', $user); return Base::retSuccess('success', $user);
} }
} }

View File

@ -16,6 +16,7 @@ use Guanguans\Notify\Messages\EmailMessage;
* @property string|null $code 验证参数 * @property string|null $code 验证参数
* @property string|null $email 电子邮箱 * @property string|null $email 电子邮箱
* @property int|null $status 0-未验证1-已验证 * @property int|null $status 0-未验证1-已验证
* @property int|null $type 邮件类型1-邮箱认证2-修改邮箱
* @property \Illuminate\Support\Carbon|null $created_at * @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at * @property \Illuminate\Support\Carbon|null $updated_at
* @method static \Illuminate\Database\Eloquent\Builder|UserEmailVerification newModelQuery() * @method static \Illuminate\Database\Eloquent\Builder|UserEmailVerification newModelQuery()
@ -26,11 +27,10 @@ use Guanguans\Notify\Messages\EmailMessage;
* @method static \Illuminate\Database\Eloquent\Builder|UserEmailVerification whereEmail($value) * @method static \Illuminate\Database\Eloquent\Builder|UserEmailVerification whereEmail($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserEmailVerification whereId($value) * @method static \Illuminate\Database\Eloquent\Builder|UserEmailVerification whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserEmailVerification whereStatus($value) * @method static \Illuminate\Database\Eloquent\Builder|UserEmailVerification whereStatus($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserEmailVerification whereType($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserEmailVerification whereUpdatedAt($value) * @method static \Illuminate\Database\Eloquent\Builder|UserEmailVerification whereUpdatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserEmailVerification whereUserid($value) * @method static \Illuminate\Database\Eloquent\Builder|UserEmailVerification whereUserid($value)
* @mixin \Eloquent * @mixin \Eloquent
* @property int|null $type 邮件类型1-邮箱认证2-修改邮箱3-删除账号
* @method static \Illuminate\Database\Eloquent\Builder|UserEmailVerification whereType($value)
*/ */
class UserEmailVerification extends AbstractModel class UserEmailVerification extends AbstractModel
{ {

View File

@ -29,7 +29,11 @@
<Radio label="open">{{ $L('开启') }}</Radio> <Radio label="open">{{ $L('开启') }}</Radio>
<Radio label="close">{{ $L('关闭') }}</Radio> <Radio label="close">{{ $L('关闭') }}</Radio>
</RadioGroup> </RadioGroup>
<div v-if="formData.reg_verify == 'open'" class="form-tip">{{$L('开启后帐号需验证通过才可登录')}}</div> <div v-if="formData.reg_verify == 'open'" class="form-tip">
{{$L('开启后:')}}<br/>
{{$L('① 帐号需验证通过才可登录')}}<br/>
{{$L('② 修改邮箱和删除账号需要邮箱验证码')}}
</div>
</FormItem> </FormItem>
<FormItem :label="$L('任务提醒')" prop="notice"> <FormItem :label="$L('任务提醒')" prop="notice">
<RadioGroup v-model="formData.notice"> <RadioGroup v-model="formData.notice">

View File

@ -3,8 +3,10 @@
<Form ref="formDatum" :model="formDatum" :rules="ruleDatum" label-width="auto" @submit.native.prevent> <Form ref="formDatum" :model="formDatum" :rules="ruleDatum" label-width="auto" @submit.native.prevent>
<FormItem :label="$L('账号')" prop="email"> <FormItem :label="$L('账号')" prop="email">
<div class="setting-email"> <div class="setting-email">
<Input v-if="isRegVerify == 1" v-model="formDatum.email" :class="count > 0 ? 'setting-send-input':'setting-input'" search @on-search="sendEmailCode" :enter-button="$L(sendBtnText)" :placeholder="$L('请输入邮箱')" /> <Input v-if="isRegVerify == 1" v-model="formDatum.email"
<Input v-else class="setting-input" v-model="formDatum.email" :placeholder="$L('请输入邮箱账号')"/> :class="count > 0 ? 'setting-send-input':'setting-input'" search @on-search="sendEmailCode"
:enter-button="$L(sendBtnText)" :placeholder="$L('请输入邮箱')"/>
<Input v-else class="setting-input" v-model="formDatum.email" :placeholder="$L('请输入邮箱账号')"/>
</div> </div>
</FormItem> </FormItem>
<FormItem :label="$L('邮箱验证码')" prop="code" v-if="isRegVerify == 1"> <FormItem :label="$L('邮箱验证码')" prop="code" v-if="isRegVerify == 1">
@ -14,7 +16,8 @@
<Input v-model="formDatum.password" type="password" :placeholder="$L('请输入登录密码')"/> <Input v-model="formDatum.password" type="password" :placeholder="$L('请输入登录密码')"/>
</FormItem> </FormItem>
<FormItem :label="$L('删除原因')"> <FormItem :label="$L('删除原因')">
<Input v-model="formDatum.reason" type="textarea" :autosize="{minRows: 4,maxRows: 8}" :placeholder="$L('请输入注销原因')"></Input> <Input v-model="formDatum.reason" type="textarea" :autosize="{minRows: 4,maxRows: 8}"
:placeholder="$L('请输入注销原因')"></Input>
</FormItem> </FormItem>
</Form> </Form>
<div class="setting-footer"> <div class="setting-footer">
@ -23,17 +26,15 @@
</div> </div>
<Modal <Modal
v-model="warningShow" v-model="warningShow"
class="warning-box"> :title="$L(`删除${appTitle}账号`)"
<div slot="header"> class="page-setting-delete-box">
<h3>{{ $L('删除DooTask账号') }}</h3> <div class="big-text">{{ $L('账号删除后,该账号将无法正常登录且无法恢复,账号下的所有数据也将被删除。') }}</div>
<div class="big-text">{{ $L('账号删除后,该账号将无法正常登录且无法恢复,账号下的所有数据也将被删除。') }}</div> <div class="small-text">
<div class="small-text"> <div>{{ $L('注销前,请确认一下事项:') }}</div>
<div>{{ $L('注销前,请确认一下事项:') }}</div> <div>{{ $L('1、您将无法查看该账号内的任何信息包括账号信息、文件记录、聊天记录、项目信息、团队成员信息等。') }}</div>
<div>{{ $L('1、您将无法查看该账号内的任何信息包括账号信息、文件记录、聊天记录、项目信息、团队成员信息等。') }}</div> <div>{{ $L('2、若你是团队的所有者请在注销您的账户前转移所有权。例如该账户所创建的项目可将项目移交他人或删除项目以及文件夹。') }}</div>
<div>{{ $L('2、若你是团队的所有者请在注销您的账户前转移所有权。例如该账户所创建的项目可将项目移交他人或删除项目以及文件夹。') }}</div> <div>{{ $L('3、您将退出所有群聊无法查到过往消息和人员。') }}</div>
<div>{{ $L('3、您将退出所有群聊无法查到过往消息和人员。') }}</div> <div>{{ $L('4、请保证账号未被暂停使用。') }}</div>
<div>{{ $L('4、请保证账号未被暂停使用。') }}</div>
</div>
</div> </div>
<div slot="footer" class="button-box"> <div slot="footer" class="button-box">
<Button type="primary" :loading="loadIng > 0" @click="submitForm('confirm')">{{ $L('已清楚风险确定注销') }} <Button type="primary" :loading="loadIng > 0" @click="submitForm('confirm')">{{ $L('已清楚风险确定注销') }}
@ -44,6 +45,8 @@
</template> </template>
<script> <script>
import {mapState} from "vuex";
export default { export default {
data() { data() {
return { return {
@ -55,22 +58,7 @@ export default {
reason: '', reason: '',
password: '', password: '',
}, },
ruleDatum: {}, ruleDatum: {
count: 0,
isSendButtonShow: true,
codeShow: false,
isRegVerify: 0,
warningShow: false,
sendBtnText: ''
}
},
mounted() {
this.getRegVerify();
},
methods: {
initLanguage() {
this.sendBtnText = this.$L('发送验证码')
this.ruleDatum = {
email: [ email: [
{ {
validator: (rule, value, callback) => { validator: (rule, value, callback) => {
@ -86,18 +74,45 @@ export default {
trigger: 'change' trigger: 'change'
}, },
], ],
}; },
count: 0,
isSendButtonShow: true,
codeShow: false,
isRegVerify: 0,
warningShow: false,
sendBtnText: this.$L('发送验证码')
}
},
mounted() {
this.formDatum.email = this.userInfo.email
this.getRegVerify();
},
computed: {
...mapState(['userInfo']),
appTitle() {
return window.systemInfo.title || "DooTask";
}, },
},
methods: {
sendEmailCode() { sendEmailCode() {
if (this.count > 0) { if (this.count > 0) {
return return
} }
this.$store.dispatch("call", { this.$store.dispatch("call", {
url: 'users/send/email', url: 'users/email/send',
data: {type: 3, email: this.formDatum.email} data: {
}).then(({}) => { type: 3,
email: this.formDatum.email
},
spinner: true
}).then(_ => {
this.isSendButtonShow = false; this.isSendButtonShow = false;
this.count = 120; //120 this.count = 120; //120
this.sendBtnText = this.count + ' 秒';
let times = setInterval(() => { let times = setInterval(() => {
this.count--; // this.count--; //
this.sendBtnText = this.count + ' 秒'; this.sendBtnText = this.count + ' 秒';
@ -110,6 +125,7 @@ export default {
$A.messageError(msg); $A.messageError(msg);
}) })
}, },
submitForm(type) { submitForm(type) {
this.$refs.formDatum.validate((valid) => { this.$refs.formDatum.validate((valid) => {
if (valid) { if (valid) {
@ -143,10 +159,9 @@ export default {
getRegVerify() { getRegVerify() {
this.$store.dispatch("call", { this.$store.dispatch("call", {
url: 'system/get/regverify', url: 'system/setting/email',
}).then(({data}) => { }).then(({data}) => {
this.isRegVerify = data; this.isRegVerify = data.reg_verify === 'open';
}).catch(() => {
}) })
}, },
}, },

View File

@ -3,8 +3,10 @@
<Form ref="formDatum" :model="formDatum" :rules="ruleDatum" label-width="auto" @submit.native.prevent> <Form ref="formDatum" :model="formDatum" :rules="ruleDatum" label-width="auto" @submit.native.prevent>
<FormItem :label="$L('新邮箱地址')" prop="newEmail"> <FormItem :label="$L('新邮箱地址')" prop="newEmail">
<div class="setting-email"> <div class="setting-email">
<Input v-if="isRegVerify == 1" v-model="formDatum.newEmail" :class="count > 0 ? 'setting-send-input':'setting-input'" search @on-search="sendEmailCode" :enter-button="$L(sendBtnText)" :placeholder="$L('输入新邮箱地址')" /> <Input v-if="isRegVerify == 1" v-model="formDatum.newEmail"
<Input v-else class="setting-input" v-model="formDatum.newEmail" :placeholder="$L('输入新邮箱地址')"/> :class="count > 0 ? 'setting-send-input':'setting-input'" search @on-search="sendEmailCode"
:enter-button="$L(sendBtnText)" :placeholder="$L('输入新邮箱地址')"/>
<Input v-else class="setting-input" v-model="formDatum.newEmail" :placeholder="$L('输入新邮箱地址')"/>
</div> </div>
</FormItem> </FormItem>
<FormItem :label="$L('验证码')" prop="code" v-if="isRegVerify == 1"> <FormItem :label="$L('验证码')" prop="code" v-if="isRegVerify == 1">
@ -28,20 +30,7 @@ export default {
newEmail: '', newEmail: '',
code: '', code: '',
}, },
ruleDatum: {}, ruleDatum: {
count: 0,
isSendButtonShow: true,
isRegVerify: 0,
sendBtnText: ''
}
},
mounted() {
this.getRegVerify();
},
methods: {
initLanguage() {
this.sendBtnText = this.$L('发送验证码');
this.ruleDatum = {
newEmail: [ newEmail: [
{ {
validator: (rule, value, callback) => { validator: (rule, value, callback) => {
@ -57,15 +46,31 @@ export default {
trigger: 'change' trigger: 'change'
}, },
], ],
}; },
}, count: 0,
isSendButtonShow: true,
isRegVerify: 0,
sendBtnText: this.$L('发送验证码')
}
},
mounted() {
this.getRegVerify();
},
methods: {
sendEmailCode() { sendEmailCode() {
this.$store.dispatch("call", { this.$store.dispatch("call", {
url: 'users/send/email', url: 'users/email/send',
data: {type: 2, email: this.formDatum.newEmail} data: {
}).then(({}) => { type: 2,
email: this.formDatum.newEmail
},
spinner: true
}).then(_ => {
this.isSendButtonShow = false; this.isSendButtonShow = false;
this.count = 120; //120 this.count = 120; //120
this.sendBtnText = this.count + ' 秒';
let times = setInterval(() => { let times = setInterval(() => {
this.count--; // this.count--; //
this.sendBtnText = this.count + ' 秒'; this.sendBtnText = this.count + ' 秒';
@ -78,12 +83,13 @@ export default {
$A.messageError(msg); $A.messageError(msg);
}) })
}, },
submitForm() { submitForm() {
this.$refs.formDatum.validate((valid) => { this.$refs.formDatum.validate((valid) => {
if (valid) { if (valid) {
this.loadIng++; this.loadIng++;
this.$store.dispatch("call", { this.$store.dispatch("call", {
url: 'users/edit/email', url: 'users/email/edit',
data: this.formDatum, data: this.formDatum,
}).then(({data}) => { }).then(({data}) => {
$A.messageSuccess('修改成功'); $A.messageSuccess('修改成功');
@ -105,10 +111,9 @@ export default {
getRegVerify() { getRegVerify() {
this.$store.dispatch("call", { this.$store.dispatch("call", {
url: 'system/get/regverify', url: 'system/setting/email',
}).then(({data}) => { }).then(({data}) => {
this.isRegVerify = data; this.isRegVerify = data.reg_verify === 'open';
}).catch(() => {
}) })
}, },
}, },

View File

@ -90,12 +90,12 @@ export default {
menu.push(...[ menu.push(...[
{path: 'system', name: '系统设置', divided: true}, {path: 'system', name: '系统设置', divided: true},
{path: 'logout', name: '退出登录'}, {path: 'logout', name: '退出登录'},
{path: 'delete', name: '删除账户'}, {path: 'delete', name: '删除账户', divided: true},
]) ])
} else { } else {
menu.push(...[ menu.push(...[
{path: 'logout', name: '退出登录', divided: true}, {path: 'logout', name: '退出登录', divided: true},
{path: 'delete', name: '删除账户'}, {path: 'delete', name: '删除账户', divided: true},
]) ])
} }
return menu; return menu;

View File

@ -289,17 +289,18 @@
} }
} }
.warning-box { .page-setting-delete-box {
.big-text { .big-text {
margin-top: 10px;
font-size: 16px; font-size: 16px;
font-weight: 500;
color: #f00;
} }
.small-text { .small-text {
margin-top: 15px; margin-top: 15px;
div { > div {
margin-top: 10px; margin: 10px 0;
} }
} }
.button-box { .button-box {