124 lines
4.5 KiB
PHP
124 lines
4.5 KiB
PHP
<?php
|
|
defined('BASEPATH') or exit('No direct script access allowed');
|
|
require_once COMMPATH . 'third_party/phpqrcode/phpqrcode.php';
|
|
|
|
class Enter extends CI_Controller
|
|
{
|
|
const ENROLL_SIGN_KEY = 'sytopic_enroll_code_'; //报名验证码key
|
|
const SIGN_TOP_KEY = 'topic_id'; //报名验证码key
|
|
private $a_id, $skey;
|
|
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
|
|
$this->load->library('hd_exception');
|
|
$this->load->library('MyEncryption');
|
|
|
|
$this->load->model('market/market_sylive_activity_model');
|
|
$this->load->model('market/Market_sytopic_model', 'topic_model');
|
|
$this->load->model('market/Market_sytopic_module_option_model', 'module_option_model');
|
|
$this->load->model('market/Market_sytopic_enroll_model', 'sytopic_enroll_model');
|
|
$this->load->model('market/market_sylive_organization_model', 'organization_model');
|
|
$this->load->library('qiniu');
|
|
|
|
$this->skey = $this->input->get_post('skey');
|
|
$param = $this->myencryption->base64url_decode($this->skey);
|
|
$this->a_id = intval($param[self::SIGN_TOP_KEY]);//活动id
|
|
if (!$this->a_id) {
|
|
throw new Hd_exception("参数错误", 400);
|
|
}
|
|
$this->data['skey'] = $this->skey;
|
|
|
|
if($this->skey == 'dG9waWNfaWQ9Ng' || $this->skey == 'dG9waWNfaWQ9OQ'){
|
|
debug_log("params:". json_encode($this->input->get()), 'auto1.txt');
|
|
}
|
|
|
|
if($this->skey == 'dG9waWNfaWQ9OA'){
|
|
debug_log("params:". json_encode($this->input->get()), 'auto2.txt');
|
|
}
|
|
}
|
|
|
|
public function index()
|
|
{
|
|
$row = $this->topic_model->get(['id' => $this->a_id]);
|
|
if (!$row) {
|
|
throw new Hd_exception('参数错误', 400);
|
|
}
|
|
|
|
$jsonData = json_decode($row['jsondata'], true);
|
|
$info = [
|
|
'id' => $row['id'],
|
|
'title' => $row['title'],
|
|
'banner' => $jsonData['banner'] ? build_qiniu_image_url($jsonData['banner']) : '',
|
|
'bgColor' => $jsonData['bg_color'] ?: '',
|
|
'buttonType' => $jsonData['button_type'] ? (int)$jsonData['button_type'] : '',
|
|
'bottom_img' => $jsonData['bottom_img'] ? build_qiniu_image_url($jsonData['bottom_img']) : '',
|
|
];
|
|
$moduleLists = $this->module_option_model->getTopicModelOptionsList($this->a_id);
|
|
$this->data['modules'] = array_values($moduleLists);
|
|
$this->data['logoList'] = $this->module_option_model->getTypeEnrollBannerList($this->a_id);
|
|
|
|
$info['biz'] = [];
|
|
$this->data['info'] = $info;
|
|
$this->data['_title'] = $row['title'];
|
|
|
|
$this->load->view('h5/market/sylive2/header', $this->data);
|
|
$this->load->view('h5/market/sytopic/index2');
|
|
$this->load->view('h5/market/sylive2/footer');
|
|
}
|
|
|
|
//报名
|
|
public function enroll()
|
|
{
|
|
$redis = &load_cache();
|
|
$optionId = intval($this->input->post('optionId'));
|
|
$topicId = intval($this->input->post('topicId'));
|
|
if (!$topicId) {
|
|
$this->show_json('', 400, '参数错误');
|
|
}
|
|
$info = $this->input->post('info');
|
|
$name = $info['name'];
|
|
$mobile = $info['phone'];
|
|
$code = $info['code'];
|
|
if (!$name) {
|
|
$name = '客户';
|
|
//$this->show_json('', 400, '请输入姓名');
|
|
}
|
|
$key = self::ENROLL_SIGN_KEY . $mobile;
|
|
if (!$code || $code != $redis->get($key)) {
|
|
$this->show_json('', 400, '请输入正确的验证码');
|
|
}
|
|
$result = $this->sytopic_enroll_model->enroll($topicId, $optionId, 0, $name, $mobile);
|
|
if (!$result['code']) {
|
|
$this->show_json('', 400, $result['msg']);
|
|
}
|
|
$this->show_json('', 200, '提交成功');
|
|
}
|
|
|
|
//获取报名验证码
|
|
public function get_code()
|
|
{
|
|
$mobile = $this->input->post('mobile');
|
|
if (!mobile_valid($mobile)) {
|
|
$this->show_json('', 400, '请输入正确的手机号码');
|
|
}
|
|
$redis = &load_cache();
|
|
$key = self::ENROLL_SIGN_KEY . $mobile;
|
|
$code = $redis->get($key);
|
|
if ($code) {
|
|
$this->show_json('', 200, '验证码已发送');
|
|
}
|
|
if (!$code) {
|
|
$this->load->helper('string');
|
|
$code = random_string('numeric', 4);
|
|
$redis->save($key, $code, 60 * 5);
|
|
}
|
|
$content = "【之家车卖场】您的验证码为: {$code},五分钟之内有效,请勿泄露于他人!";
|
|
b2m_send_sms($mobile, $content);
|
|
$this->show_json('', 200, '验证码已发送');
|
|
}
|
|
|
|
|
|
}
|