Files
liche/api/controllers/wxapp/licheb/Sms.php
T
2021-07-05 09:56:27 +08:00

50 lines
1.4 KiB
PHP

<?php
defined('WXAPP_APP') OR exit('No direct script access allowed');
/**
* Created by Vim
* User: lcc
* Date: 2020/06/23
* Time: 14:08
*/
require_once APPPATH.'controllers/wxapp/Wxapp.php';
class Sms extends Wxapp{
function __construct($inputs, $app_key){
parent::__construct($inputs, $app_key);
$this->login_white = 'all';//登录白名单
$this->check_status = array();//用户状态校验
$this->check_mobile = array();//需要手机号
$this->check_headimg =array();//授权微信信息
}
/**
* 获取验证码
*/
protected function get(){
$mobile = $this->input_param('mobile');
if (!mobile_valid($mobile)) {
throw new Exception('请输入正确的手机号码', ERR_PARAMS_ERROR);
}
$user = $this->app_user_model->get(['mobile'=>$mobile,'status>'=> -1]);
if(!$user){
throw new Exception('用户不存在', API_CODE_FAIL);
}
$mc = &load_cache();
$key = "licheb_login_code_".$mobile;
if(!$code = $mc->get($key)) {
$this->load->helper('string');
$code = random_string('numeric', 6);
$mc->save($key, $code, 600);
}
//send_sms($mobile,$code);
//$msg = '发送成功';
$msg = $code;
throw new Exception($msg, API_CODE_SUCCESS);
}
}