diff --git a/plugs/think-plugs-cms/src/controller/api/auth/Bind.php b/plugs/think-plugs-cms/src/controller/api/auth/Bind.php new file mode 100644 index 0000000..9b3e612 --- /dev/null +++ b/plugs/think-plugs-cms/src/controller/api/auth/Bind.php @@ -0,0 +1,33 @@ + '用户登录验证', + ]; + public function send() + { + $data = $this->_vali([ + 'phone.mobile' => '手机号错误', + 'phone.require' => '手机号为空', + ]); + Library::$sapp->cache->set(static::genCacheKey($data['phone']), ['code' => 123456, 'time' => time() + 300], 600); + $this->success("测试验证码123456"); + } + + private static function genCacheKey(string $phone, string $scene = self::tLogin): string + { + if (isset(array_change_key_case(static::$scenes)[strtolower($scene)])) { + return md5(strtolower("sms-{$scene}-{$phone}")); + } else { + throw new Exception("未定义的业务"); + } + } +} \ No newline at end of file