Commit 5b1320a3 by 庄钊鑫

注册模块代码

parent 4d9b51a7
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" addBOMForNewFiles="with NO BOM" />
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="JavaScriptSettings">
<option name="languageLevel" value="ES6" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/personal.iml" filepath="$PROJECT_DIR$/.idea/personal.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/vendor/aliApiSdk/Dysmsapi" />
<excludeFolder url="file://$MODULE_DIR$/vendor/aliApiSdk/aliyun-php-sdk-core" />
<excludeFolder url="file://$MODULE_DIR$/vendor/jpush/jpush" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="PhpIncludePathManager">
<include_path>
<path value="$PROJECT_DIR$/vendor/jpush/jpush" />
<path value="$PROJECT_DIR$/vendor/aliApiSdk/Dysmsapi" />
<path value="$PROJECT_DIR$/vendor/aliApiSdk/aliyun-php-sdk-core" />
</include_path>
</component>
<component name="PhpProjectSharedConfiguration" php_language_level="5.4.0" />
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="91f66d3c-41ac-41b6-86c7-896c6cbc8e56" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/app/api/controller/v1/app/Send.php" beforeDir="false" afterPath="$PROJECT_DIR$/app/api/controller/v1/app/Send.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/api/controller/v1/app/User.php" beforeDir="false" afterPath="$PROJECT_DIR$/app/api/controller/v1/app/User.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/api/logic/app/UserLogic.php" beforeDir="false" afterPath="$PROJECT_DIR$/app/api/logic/app/UserLogic.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/api/model/Sms.php" beforeDir="false" afterPath="$PROJECT_DIR$/app/api/model/Sms.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/api/model/User.php" beforeDir="false" afterPath="$PROJECT_DIR$/app/api/model/User.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/common/validate/Base.php" beforeDir="false" afterPath="$PROJECT_DIR$/app/common/validate/Base.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/route.php" beforeDir="false" afterPath="$PROJECT_DIR$/app/route.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/runtime/log/201903/11.log" beforeDir="false" afterPath="$PROJECT_DIR$/runtime/log/201903/11.log" afterDir="false" />
</list>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="ComposerSettings" synchronizationState="SYNCHRONIZE">
<pharConfigPath>$PROJECT_DIR$/composer.json</pharConfigPath>
</component>
<component name="FileEditorManager">
<leaf>
<file pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/app/api/controller/v1/app/User.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="517">
<caret line="219" column="48" selection-start-line="219" selection-start-column="48" selection-end-line="219" selection-end-column="48" />
<folding>
<element signature="e#45#72#0#PHP" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/app/api/model/User.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="347">
<caret line="102" column="5" lean-forward="true" selection-start-line="102" selection-start-column="5" selection-end-line="102" selection-end-column="5" />
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/app/common/validate/Validate.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="342">
<caret line="40" column="35" lean-forward="true" selection-start-line="40" selection-start-column="35" selection-end-line="40" selection-end-column="35" />
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/app/api/logic/app/UserLogic.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="261">
<caret line="30" column="27" selection-start-line="30" selection-start-column="27" selection-end-line="30" selection-end-column="27" />
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/app/api/logic/app/SendLogic.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="494">
<caret line="31" column="34" selection-start-line="31" selection-start-column="34" selection-end-line="31" selection-end-column="34" />
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/app/api/model/Sms.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="65">
<caret line="111" column="27" selection-start-line="111" selection-start-column="27" selection-end-line="111" selection-end-column="27" />
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/app/api/controller/v1/app/Send.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="417">
<caret line="83" column="44" selection-start-line="83" selection-start-column="37" selection-end-line="83" selection-end-column="44" />
<folding>
<element signature="e#132#158#0#PHP" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/app/api/controller/Send.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="579">
<caret line="84" column="24" selection-start-line="84" selection-start-column="13" selection-end-line="84" selection-end-column="24" />
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/app/common/validate/Base.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="328">
<caret line="90" column="42" selection-start-line="90" selection-start-column="42" selection-end-line="90" selection-end-column="42" />
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/app/route.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="228">
<caret line="21" column="80" selection-start-line="21" selection-start-column="80" selection-end-line="21" selection-end-column="80" />
</state>
</provider>
</entry>
</file>
</leaf>
</component>
<component name="FindInProjectRecents">
<findStrings>
<find>validate</find>
<find>短信</find>
<find>page_index</find>
<find>alidayu</find>
<find>getEnumRule</find>
<find>password</find>
<find>sms_type</find>
<find>sendSms</find>
</findStrings>
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
<component name="IdeDocumentHistory">
<option name="CHANGED_PATHS">
<list>
<option value="$PROJECT_DIR$/app/database.php" />
<option value="$PROJECT_DIR$/app/api/logic/app/UserLogic.php" />
<option value="$PROJECT_DIR$/app/route.php" />
<option value="$PROJECT_DIR$/app/api/model/User.php" />
<option value="$PROJECT_DIR$/app/api/model/Sms.php" />
<option value="$PROJECT_DIR$/app/api/controller/v1/app/Send.php" />
<option value="$PROJECT_DIR$/app/common/validate/Base.php" />
<option value="$PROJECT_DIR$/app/api/controller/v1/app/User.php" />
</list>
</option>
</component>
<component name="PhpServers">
<servers />
</component>
<component name="PhpWorkspaceProjectConfiguration">
<include_path>
<path value="$PROJECT_DIR$/vendor/jpush/jpush" />
<path value="$PROJECT_DIR$/vendor/aliApiSdk/Dysmsapi" />
<path value="$PROJECT_DIR$/vendor/aliApiSdk/aliyun-php-sdk-core" />
</include_path>
</component>
<component name="ProjectFrameBounds" fullScreen="true">
<option name="width" value="1440" />
<option name="height" value="900" />
</component>
<component name="ProjectView">
<navigator proportions="" version="1">
<foldersAlwaysOnTop value="true" />
</navigator>
<panes>
<pane id="ProjectPane">
<subPane>
<expand>
<path>
<item name="personal" type="b2602c69:ProjectViewProjectNode" />
<item name="personal" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="personal" type="b2602c69:ProjectViewProjectNode" />
<item name="personal" type="462c0819:PsiDirectoryNode" />
<item name="app" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="personal" type="b2602c69:ProjectViewProjectNode" />
<item name="personal" type="462c0819:PsiDirectoryNode" />
<item name="app" type="462c0819:PsiDirectoryNode" />
<item name="api" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="personal" type="b2602c69:ProjectViewProjectNode" />
<item name="personal" type="462c0819:PsiDirectoryNode" />
<item name="app" type="462c0819:PsiDirectoryNode" />
<item name="api" type="462c0819:PsiDirectoryNode" />
<item name="controller" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="personal" type="b2602c69:ProjectViewProjectNode" />
<item name="personal" type="462c0819:PsiDirectoryNode" />
<item name="app" type="462c0819:PsiDirectoryNode" />
<item name="api" type="462c0819:PsiDirectoryNode" />
<item name="controller" type="462c0819:PsiDirectoryNode" />
<item name="v1" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="personal" type="b2602c69:ProjectViewProjectNode" />
<item name="personal" type="462c0819:PsiDirectoryNode" />
<item name="app" type="462c0819:PsiDirectoryNode" />
<item name="api" type="462c0819:PsiDirectoryNode" />
<item name="controller" type="462c0819:PsiDirectoryNode" />
<item name="v1" type="462c0819:PsiDirectoryNode" />
<item name="app" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="personal" type="b2602c69:ProjectViewProjectNode" />
<item name="personal" type="462c0819:PsiDirectoryNode" />
<item name="app" type="462c0819:PsiDirectoryNode" />
<item name="common" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="personal" type="b2602c69:ProjectViewProjectNode" />
<item name="personal" type="462c0819:PsiDirectoryNode" />
<item name="app" type="462c0819:PsiDirectoryNode" />
<item name="common" type="462c0819:PsiDirectoryNode" />
<item name="validate" type="462c0819:PsiDirectoryNode" />
</path>
</expand>
<select />
</subPane>
</pane>
<pane id="Scope" />
</panes>
</component>
<component name="PropertiesComponent">
<property name="WebServerToolWindowFactoryState" value="false" />
<property name="nodejs_interpreter_path.stuck_in_default_project" value="undefined stuck path" />
<property name="nodejs_npm_path_reset_for_default_project" value="true" />
</component>
<component name="RunDashboard">
<option name="ruleStates">
<list>
<RuleState>
<option name="name" value="ConfigurationTypeDashboardGroupingRule" />
</RuleState>
<RuleState>
<option name="name" value="StatusDashboardGroupingRule" />
</RuleState>
</list>
</option>
</component>
<component name="SvnConfiguration">
<configuration />
</component>
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="91f66d3c-41ac-41b6-86c7-896c6cbc8e56" name="Default Changelist" comment="" />
<created>1552287639374</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1552287639374</updated>
<workItem from="1552287640754" duration="11594000" />
</task>
<servers />
</component>
<component name="TimeTrackingManager">
<option name="totallyTimeSpent" value="11594000" />
</component>
<component name="ToolWindowManager">
<frame x="0" y="0" width="1440" height="900" extended-state="0" />
<editor active="true" />
<layout>
<window_info id="Favorites" side_tool="true" />
<window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.24964234" />
<window_info id="Structure" order="1" side_tool="true" weight="0.25" />
<window_info anchor="bottom" id="Docker" show_stripe_button="false" />
<window_info anchor="bottom" id="Database Changes" />
<window_info anchor="bottom" id="Version Control" />
<window_info anchor="bottom" id="Terminal" />
<window_info anchor="bottom" id="Event Log" side_tool="true" />
<window_info anchor="bottom" id="Message" order="0" />
<window_info anchor="bottom" id="Find" order="1" />
<window_info anchor="bottom" id="Run" order="2" />
<window_info anchor="bottom" id="Debug" order="3" weight="0.4" />
<window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
<window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
<window_info anchor="bottom" id="TODO" order="6" />
<window_info anchor="right" id="Database" />
<window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
<window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
<window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
</layout>
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="1" />
</component>
<component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/app/tags.php">
<provider selected="true" editor-type-id="text-editor" />
</entry>
<entry file="file://$PROJECT_DIR$/thinkphp/library/think/Controller.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-15">
<caret line="187" column="23" selection-start-line="187" selection-start-column="23" selection-end-line="187" selection-end-column="23" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/app/api/controller/Api.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="261">
<caret line="152" column="23" selection-start-line="152" selection-start-column="23" selection-end-line="152" selection-end-column="23" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/app/config.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-2781" />
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/thinkphp/helper.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="158">
<caret line="98" column="38" selection-start-line="98" selection-start-column="38" selection-end-line="98" selection-end-column="38" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/app/database.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="133">
<caret line="15" column="37" selection-start-line="15" selection-start-column="26" selection-end-line="15" selection-end-column="37" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/app/route.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="228">
<caret line="21" column="80" selection-start-line="21" selection-start-column="80" selection-end-line="21" selection-end-column="80" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/app/api/model/User.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="347">
<caret line="102" column="5" lean-forward="true" selection-start-line="102" selection-start-column="5" selection-end-line="102" selection-end-column="5" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/app/api/controller/Send.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="579">
<caret line="84" column="24" selection-start-line="84" selection-start-column="13" selection-end-line="84" selection-end-column="24" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/app/api/logic/app/UserLogic.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="261">
<caret line="30" column="27" selection-start-line="30" selection-start-column="27" selection-end-line="30" selection-end-column="27" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/app/api/model/Sms.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="65">
<caret line="111" column="27" selection-start-line="111" selection-start-column="27" selection-end-line="111" selection-end-column="27" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/app/api/logic/app/SendLogic.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="494">
<caret line="31" column="34" selection-start-line="31" selection-start-column="34" selection-end-line="31" selection-end-column="34" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/app/common/validate/Validate.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="342">
<caret line="40" column="35" lean-forward="true" selection-start-line="40" selection-start-column="35" selection-end-line="40" selection-end-column="35" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/app/common/validate/Base.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="328">
<caret line="90" column="42" selection-start-line="90" selection-start-column="42" selection-end-line="90" selection-end-column="42" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/app/api/controller/v1/app/Send.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="417">
<caret line="83" column="44" selection-start-line="83" selection-start-column="37" selection-end-line="83" selection-end-column="44" />
<folding>
<element signature="e#132#158#0#PHP" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/app/api/controller/v1/app/User.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="517">
<caret line="219" column="48" selection-start-line="219" selection-start-column="48" selection-end-line="219" selection-end-column="48" />
<folding>
<element signature="e#45#72#0#PHP" expanded="true" />
</folding>
</state>
</provider>
</entry>
</component>
</project>
\ No newline at end of file
......@@ -84,8 +84,8 @@ class Send extends Base
$this->check($request, 'Base.sendSms');
if ($request['sms_type'] != 'login' and $request['sms_type'] != 'bind') {
$bool = UserLogic::checkUser($request['mobile']);
if(empty($bool)){
$this->returnmsg(403, [], [],"", [], "该手机号注册");
if(!empty($bool)){
$this->returnmsg(403, [], [],"", [], "该手机号注册");
}
}
......@@ -93,6 +93,6 @@ class Send extends Base
if ($info === false) {
$this->returnmsg(403, [], [], "", [], "验证码错误");
}
$this->render("验证成功",200);
$this->render(200,['success'=>'验证码正确']);
}
}
......@@ -157,4 +157,71 @@ class User extends Base
$data !== false ? $this->render($data) : $this->returnmsg(403,"","","","","登录失败");
}
/**
* @author:
* @time: 2019年3月
* description 手机号验证
*/
public function validateMobile()
{
$requestData = $this->selectParam(['mobile','sms_type' => 'bind']);
$this->check($requestData, 'Base.sendSms');
$this->render(200,['success'=>'手机号码验证成功']);
}
/**
* @author:
* @time: 2019年3月
* description 发送验证码
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function sendCode()
{
$request = $this->selectParam(['mobile', 'sms_type' => 'pass']);
$request['sendPartnerSms'] = $request['sms_type'];
$this->check($request, 'Base.sendSms');
if ($request['sms_type'] == 'pass') {
$bool = UserLogic::checkUser($request['mobile']);
if(!empty($bool)){
$this->returnmsg(403, [], [],"", [], "该手机号已注册");
}
}
//$info = true;
$info = SendLogic::SendSms($request['mobile'], $request['sms_type']);
if ($info === false) {
$this->returnmsg(403, [], [],"", [], "信息发送出现了一点小问题哟~");
}
//发送成功
$this->render(200,['success'=>'验证码发送成功']);
}
/**
* @author:
* @time: 2019年3月
* description 注册
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function register()
{
$request = $this->selectParam(['mobile', 'password','password2']);
$this->check($request, 'Base.register');
$bool = UserLogic::checkUser($request['mobile']);
if(!empty($bool)){
$this->returnmsg(403, [], [],"", [], "该手机号已注册");
}
$result = UserModel::build()->register($request);
if ($result) {
$this->render(200,['success'=>'注册成功!']);
} else {
$this->returnmsg(403, $data = [], $header = [], $type = "", "Login error", $message = "注册失败");
}
}
}
......@@ -30,7 +30,7 @@ class UserLogic
*/
public static function checkUser($mobile)
{
$bool = User::build()->where(['mobile' => $mobile, 'is_banned' => 0])->find();
$bool = User::build()->where(['mobile' => $mobile])->find();
return empty($bool) ? false : true;
}
......
......@@ -54,6 +54,8 @@ class Sms extends Model
{
// 调用sdk发送短信
$aliConfig = config('alidayu');
$aliConfig['AccessKey'] = 'LTAIHsoQGZrGjIxs';
$aliConfig['SecretKey'] = 'BkrK54Rm2fbSwhW7Ig4dOuSMBsMJHs';
// 加载区域结点配置
// 初始化用户Profile实例
$profile = \DefaultProfile::getProfile("cn-hangzhou", $aliConfig['AccessKey'], $aliConfig['SecretKey']);
......@@ -66,9 +68,9 @@ class Sms extends Model
// 必填,设置雉短信接收号码
$request->setPhoneNumbers($mobile);
// 必填,设置签名名称
$request->setSignName($aliConfig['smsType'][$smsType]['signName']);
$request->setSignName('庄钊鑫');
// 必填,设置模板CODE
$request->setTemplateCode($aliConfig['smsType'][$smsType]['templateCode']);
$request->setTemplateCode('SMS_139239868');
$params = array(
'code' => $code,
);
......@@ -80,7 +82,7 @@ class Sms extends Model
date_default_timezone_set("Asia/Shanghai");//短信SDK强行转换了时区导致PHP无法识别使用了默认时区,这里需要强制转换回上海时区
//修改其它验证码的有效性
self::build()->update(['is_effected' => 0], ['mobile' => $mobile, 'sms_type' => $smsType]);
self::build()->update(['is_effected' => 0,'update_time' => timeToDate(time())], ['mobile' => $mobile, 'sms_type' => $smsType]);
// 写入数据库
$bool = self::build()->insert([
'uuid' => uuid(),
......@@ -91,7 +93,7 @@ class Sms extends Model
'create_time' => timeToDate(time()),
'update_time' => timeToDate(time()),
]);
return $bool;
return true;
}
......
......@@ -91,4 +91,30 @@ class User extends Model
}
/**
* @author:
* @time: 2019年3月
* description 注册
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function register($request)
{
Db::startTrans();
//创建新用户
$user['uuid'] = uuid();
$user['mobile'] = $request['mobile'];
$user['name'] = replaceToStar($request['mobile']);
$user['create_time'] = timeToDate(time());
$result = self::build()->insert($user);
if (!$result) {
Db::rollback();
return false;
}
Db::commit();
return true;
}
}
\ No newline at end of file
......@@ -20,10 +20,11 @@ class Base extends Validate
'id' => 'require|number|gt:0',
'content' => 'require|max:255',
'mobile' => 'require|number|length:11|regex:mobile',
'sms_type' => 'require|in:login,bind,pay_password',
'sms_type' => 'require|in:login,bind,pay_password,pass',
'partner_sms_type' => 'require|in:pass,set_pay,bind_card',
'code' => 'require|max:6',
'password' => 'require|min:6',
'password' => 'require|min:6|confirm:password2',
'password2' => 'require',
'message_type' => 'require|in:con,chat,system',
'province' => 'chsAlpha',
'school_name' => 'chsAlpha',
......@@ -61,6 +62,7 @@ class Base extends Validate
'code' => '验证码格式错误',
'password.require' => '密码必须',
'password.min' => '密码过短',
'password.confirm' => '两次密码输入不一致',
'message_type' => '消息类型错误',
'province' => '省份设置错误',
'city.json' => '城市设置错误',
......@@ -86,7 +88,7 @@ class Base extends Validate
'id' => ['id'],
'uuid' => ['uuid'],
'sendSms' => ['mobile', 'sms_type'],
'register' => ['mobile','password','password2'],
'sendPartnerSms' => ['mobile', 'sms_type_partner'],
'validatePartnerCode' => ['mobile', 'sms_type_partner', 'code'],
......
......@@ -17,11 +17,14 @@ Route::resource(':version/app/User', 'api/:version.app.User');//用户 //注册
//restful方法中另外一个方法等。。。
Route::rule(':version/app/User/login', 'api/:version.app.User/login');//用户登录
Route::rule(':version/app/User/validateMobile', 'api/:version.app.User/validateMobile');//验证用户手机号
Route::rule(':version/app/User/sendCode', 'api/:version.app.User/sendCode');//发送验证码
Route::rule(':version/app/User/register', 'api/:version.app.User/register');//注册
Route::rule(':version/app/User/updateToken', 'api/:version.app.User/updateToken');//更新token
Route::rule(':version/app/User/publicLogin', 'api/:version.app.User/publicLogin');//公众号授权
Route::rule(':version/app/User/pointDeal', 'api/:version.app.User/pointDeal');//积分明细
Route::rule(':version/app/User/getShareSign', 'api/:version.app.User/getShareSign');
Route::rule(':version/app/Send/validate', 'api/:version.app.Send/validate');//验证
Route::rule(':version/app/Send/validate', 'api/:version.app.Send/validateCode');//验证
Route::miss('Error/index');
......
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment