可设置发送聊天前必须设置昵称
This commit is contained in:
parent
75ac1e9770
commit
a20222747d
@ -144,6 +144,14 @@ class DialogController extends AbstractController
|
||||
{
|
||||
$user = User::auth();
|
||||
//
|
||||
$chat_nickname = Base::settingFind('system', 'chat_nickname');
|
||||
if ($chat_nickname == 'required') {
|
||||
$nickname = User::select(['nickname as nickname_original'])->whereUserid($user->userid)->value('nickname_original');
|
||||
if (empty($nickname)) {
|
||||
return Base::retError('请设置昵称', [], -2);
|
||||
}
|
||||
}
|
||||
//
|
||||
$dialog_id = intval(Request::input('dialog_id'));
|
||||
$text = trim(Request::input('text'));
|
||||
//
|
||||
|
@ -24,7 +24,7 @@ class SystemController extends AbstractController
|
||||
*
|
||||
* @apiParam {String} type
|
||||
* - get: 获取(默认)
|
||||
* - save: 保存设置(参数:reg、login_code、password_policy)
|
||||
* - save: 保存设置(参数:reg、login_code、password_policy、chat_nickname)
|
||||
|
||||
* @apiSuccess {Number} ret 返回状态码(1正确、0错误)
|
||||
* @apiSuccess {String} msg 返回信息(错误描述)
|
||||
@ -40,7 +40,7 @@ class SystemController extends AbstractController
|
||||
User::auth('admin');
|
||||
$all = Request::input();
|
||||
foreach ($all AS $key => $value) {
|
||||
if (!in_array($key, ['reg', 'login_code', 'password_policy'])) {
|
||||
if (!in_array($key, ['reg', 'login_code', 'password_policy', 'chat_nickname'])) {
|
||||
unset($all[$key]);
|
||||
}
|
||||
}
|
||||
@ -52,6 +52,7 @@ class SystemController extends AbstractController
|
||||
$setting['reg'] = $setting['reg'] ?: 'open';
|
||||
$setting['login_code'] = $setting['login_code'] ?: 'auto';
|
||||
$setting['password_policy'] = $setting['password_policy'] ?: 'simple';
|
||||
$setting['chat_nickname'] = $setting['chat_nickname'] ?: 'optional';
|
||||
//
|
||||
return Base::retSuccess('success', $setting ?: json_decode('{}'));
|
||||
}
|
||||
|
9
resources/assets/js/functions/web.js
vendored
9
resources/assets/js/functions/web.js
vendored
@ -54,7 +54,6 @@
|
||||
})
|
||||
])
|
||||
},
|
||||
loading: true,
|
||||
onOk: () => {
|
||||
if (typeof config.onOk === "function") {
|
||||
if (config.onOk(config.value, () => {
|
||||
@ -66,6 +65,14 @@
|
||||
$A.Modal.remove();
|
||||
}
|
||||
},
|
||||
onCancel: () => {
|
||||
if (typeof config.onCancel === "function") {
|
||||
config.onCancel();
|
||||
}
|
||||
},
|
||||
loading: true,
|
||||
okText: $A.L(config.okText || '确定'),
|
||||
cancelText: $A.L(config.cancelText || '取消'),
|
||||
});
|
||||
setTimeout(() => {
|
||||
document.getElementById(inputId) && document.getElementById(inputId).focus();
|
||||
|
@ -13,6 +13,7 @@
|
||||
<Radio label="open">{{$L('开启')}}</Radio>
|
||||
<Radio label="close">{{$L('关闭')}}</Radio>
|
||||
</RadioGroup>
|
||||
<div v-if="formDatum.login_code == 'auto'" class="form-tip">{{$L('自动:密码输入错误后必须添加验证码。')}}</div>
|
||||
</FormItem>
|
||||
<FormItem :label="$L('密码策略')" prop="passwordPolicy">
|
||||
<RadioGroup v-model="formDatum.password_policy">
|
||||
@ -22,6 +23,13 @@
|
||||
<div v-if="formDatum.password_policy == 'simple'" class="form-tip">{{$L('简单:大于或等于6个字符。')}}</div>
|
||||
<div v-else-if="formDatum.password_policy == 'complex'" class="form-tip">{{$L('复杂:大于或等于6个字符,包含数字、字母大小写或者特殊字符。')}}</div>
|
||||
</FormItem>
|
||||
<FormItem :label="$L('聊天昵称')" prop="chatNickname">
|
||||
<RadioGroup v-model="formDatum.chat_nickname">
|
||||
<Radio label="optional">{{$L('可选')}}</Radio>
|
||||
<Radio label="required">{{$L('必填')}}</Radio>
|
||||
</RadioGroup>
|
||||
<div v-if="formDatum.chat_nickname == 'required'" class="form-tip">{{$L('必填:发送聊天内容前必须设置昵称。')}}</div>
|
||||
</FormItem>
|
||||
</Form>
|
||||
<div class="setting-footer">
|
||||
<Button :loading="loadIng > 0" type="primary" @click="submitForm">{{$L('提交')}}</Button>
|
||||
|
66
resources/assets/js/store/actions.js
vendored
66
resources/assets/js/store/actions.js
vendored
@ -18,24 +18,21 @@ export default {
|
||||
params.header['token'] = state.userToken;
|
||||
params.header['fd'] = state.method.getStorageString("userWsFd");
|
||||
//
|
||||
const cloneParams = state.method.cloneJSON(params);
|
||||
return new Promise(function (resolve, reject) {
|
||||
if (params.spinner === true) {
|
||||
const spinner = document.getElementById("common-spinner");
|
||||
if (spinner) {
|
||||
const beforeCall = params.before;
|
||||
params.before = () => {
|
||||
state.ajaxLoadNum++;
|
||||
spinner.style.display = "block"
|
||||
typeof beforeCall == "function" && beforeCall();
|
||||
};
|
||||
//
|
||||
const completeCall = params.complete;
|
||||
params.complete = () => {
|
||||
state.ajaxLoadNum--;
|
||||
if (state.ajaxLoadNum <= 0) {
|
||||
spinner.style.display = "none"
|
||||
}
|
||||
typeof completeCall == "function" && completeCall();
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -57,6 +54,17 @@ export default {
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (ret === -2 && params.checkNick !== false) {
|
||||
// 需要昵称
|
||||
dispatch("userNickNameInput").then(() => {
|
||||
dispatch("call", Object.assign(cloneParams, {
|
||||
checkNick: false
|
||||
})).then(resolve).catch(reject);
|
||||
}).catch(() => {
|
||||
reject({data, msg: $A.L('请设置昵称!')})
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (ret === 1) {
|
||||
resolve({data, msg});
|
||||
} else {
|
||||
@ -307,6 +315,56 @@ export default {
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 设置用户昵称
|
||||
* @param dispatch
|
||||
* @returns {Promise<unknown>}
|
||||
*/
|
||||
userNickNameInput({dispatch}) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
let callback = (cb, success) => {
|
||||
if (typeof cb === "function") {
|
||||
cb();
|
||||
}
|
||||
if (success === true) {
|
||||
setTimeout(resolve, 301)
|
||||
} else {
|
||||
setTimeout(reject, 301)
|
||||
}
|
||||
}
|
||||
$A.modalInput({
|
||||
title: "设置昵称",
|
||||
placeholder: "请输入昵称",
|
||||
okText: "保存",
|
||||
onOk: (value, cb) => {
|
||||
if (value) {
|
||||
dispatch("call", {
|
||||
url: 'users/editdata',
|
||||
data: {
|
||||
nickname: value,
|
||||
},
|
||||
checkNick: false,
|
||||
}).then(() => {
|
||||
dispatch('getUserInfo').then(() => {
|
||||
callback(cb, true);
|
||||
}).catch(() => {
|
||||
callback(cb, false);
|
||||
});
|
||||
}).catch(({msg}) => {
|
||||
$A.modalError(msg, 301);
|
||||
callback(cb, false);
|
||||
});
|
||||
} else {
|
||||
callback(cb, false);
|
||||
}
|
||||
},
|
||||
onCancel: () => {
|
||||
callback(null, false);
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 登出(打开登录页面)
|
||||
* @param state
|
||||
|
Loading…
x
Reference in New Issue
Block a user