66 行
2.1 KiB
PHP
可执行文件
66 行
2.1 KiB
PHP
可执行文件
<?php
|
|
|
|
namespace Main\Controller;
|
|
|
|
use Think\Controller;
|
|
|
|
//[1.4.44]
|
|
class ContactController extends BaseController
|
|
{
|
|
public function index()
|
|
{
|
|
$name = self::$TEMPLATE;
|
|
if ($name['templatename']) {
|
|
$pid = session('main_user')['id'];
|
|
$list = M('retail_aboutus')->where("pid=" . $pid)->find();
|
|
$this->assign('list', $list);
|
|
|
|
$contact = M('retail_contact')->where("pid=" . $pid)->order("id desc")->find();
|
|
$this->assign('contact', $contact);
|
|
$data['pid'] = $pid;
|
|
$data['status'] = '1';
|
|
$data['type'] = '4';
|
|
$banner = M('retail_tempbanner')->where($data)->find();
|
|
$this->assign('banner', $banner);
|
|
$logo = session('main_user');
|
|
$this->assign('webinfo', $logo);
|
|
$this->display($name['templatename'] . "/contact");
|
|
}
|
|
}
|
|
|
|
// 添加用户提交信息
|
|
public function adds()
|
|
{
|
|
$data['pid'] = session('main_user')['id'];
|
|
$data['name'] = I('post.name');
|
|
$data['phone'] = I('post.phone');
|
|
$data['email'] = I('post.email');
|
|
$data['content'] = I('post.content');
|
|
if (!verifyName($data['name'])) {
|
|
$res['status'] = 0;
|
|
$res['msg'] = "请输入正确的姓名";
|
|
$this->ajaxReturn($res);
|
|
}
|
|
if (!verifyMobilePhone($data['phone'])) {
|
|
$res['status'] = 0;
|
|
$res['msg'] = "请输入正确的手机号";
|
|
$this->ajaxReturn($res);
|
|
}
|
|
if (!preg_match('/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/', $data['email'])) {
|
|
$res['status'] = 0;
|
|
$res['msg'] = "请输入正确的邮箱";
|
|
$this->ajaxReturn($res);
|
|
}
|
|
|
|
$data['addtime'] = time();
|
|
$list = M('retail_information')->add($data);
|
|
if ($list > 0) {
|
|
$res['status'] = 1;
|
|
$res['msg'] = "添加成功";
|
|
} else {
|
|
$res['status'] = 0;
|
|
$res['msg'] = "添加失败";
|
|
}
|
|
$this->ajaxReturn($res);
|
|
}
|
|
} |