application/app/controller/Sms.php

(完整代码) 1KB

<?php
/**
 * 易想会员管理营销系统
 * =========================================================
 * 天津市华易动力信息科技有限公司 , 保留所有权利。
 * ----------------------------------------------
 * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
 * 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
 * =========================================================
 * @author : hy_team
 * @date : 2019-08-10
 */
namespace app\app\controller;

use think\Controller;
use app\common\service\Sms as SmsService;

class Sms extends Controller{
	/**
	 * [发送短信]
	 */
	public function send(){
		
		if ($this->request->isAjax()){

			$sign = input("param.sign");
			$mobile = input('param.mobile');

			
			if (!$mobile) return json_encode(['errcode'=>1,'errmsg'=>'手机号为必填']);
			if(empty($sign)) return json_encode(['errcode'=>1,'errmsg'=>'参数错误']);

			//使用提供的阿里云短信服务
			$expire = 120;
			$smslast = session('smslast' . $sign);

			if ((time() - $smslast) < 120) return json_encode(['errcode'=>1,'errmsg'=>'请稍候再获取验证码']);

			$code = rand(100000,999999);
			$item = com_get_config('sms','sys');
			$TemplateContent = $item['TemplateContent'];       
			$sdf = (new SmsService)->sendSms($mobile,$code,$TemplateContent);

			if($sdf === true){//发送成功
				session('smslast_' . $sign,time());
				session('smscode_' . $sign,$code);
				session('smsmobile_' . $sign,$mobile);

				$result = ['expire'=>$expire,'errcode'=>0,'errmsg'=>'短信发送成功'];
			}else{
				//发送失败
				$result = ['errcode'=>1,'errmsg'=>'短信发送失败'];
			}
			return json_encode($result);
		}
			
	}
}

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。