| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- <?php
- class CommonController extends Controller
- {
- /**
- * 发送验证码
- */
- public function actionSendCode()
- {
- $phone = Helper::getPostString('phone', '');
- if (!Helper::isPhone($phone)) {
- Helper::error('手机号码格式错误');
- }
- // 验证码发送限制
- Helper::dealCommonResult(Helper::limitSmsSend(10, $phone, 5), false);
- if (!DB::getScalerWithCriteria('useradmin', DbCriteria::simpleCompare(['phone' => $phone])->setSelect('id'))) {
- Helper::error('该手机号用户不存在');
- }
- $code = (string)random_int(100000,999999);
- RedisInstance::getInstance()->set('user_code:'.$phone, $code, 600);
- // 发送短信
- Helper::dealCommonResult(SMS::getInstance()->send($phone, '2094847', [$code]));
- }
- /**
- * 找回密码
- */
- public function actionSetPassword()
- {
- $phone = Helper::getPostString('phone');
- $code = Helper::getPostString('code');
- $password = Helper::getPostString('password');
- if (!Helper::isPhone($phone)) {
- Helper::error('手机号码格式错误');
- }
- if (!$code || !$password) {
- Helper::error('参数错误');
- }
- if (RedisInstance::getInstance()->get('user_code:'.$phone) != $code) {
- Helper::error('验证码错误');
- }
- $id = DB::getScalerWithCriteria('useradmin', DbCriteria::simpleCompare(['phone' => $phone])->setSelect('id'));
- if (!$id) {
- Helper::error('该手机号用户不存在');
- }
- DB::updateById('useradmin', ['password' => md5($password)], $id);
- Helper::ok();
- }
- /**
- * 图片上传
- */
- public function actionUploadImg()
- {
- Helper::ok();
- }
- /******************************* 测试相关代码 ***************************************/
- public function actionPhp()
- {
- (new DBTable(Helper::getGetString('t1')))->echoEditHtml();
- }
- public function actionTs()
- {
- echo (new DBTable(Helper::getGetString('t1')))->getTsInterFace();
- }
- public function actionForm()
- {
- (new DBTable(Helper::getGetString('t1')))->editVue();
- }
- public function actionTable()
- {
- echo (new DBTable(Helper::getGetString('t1')))->getTableHtml();
- }
- public function actionInfo()
- {
- echo (new DBTable(Helper::getGetString('t1')))->getDetailHtml();
- }
- }
|