WeMall微信商城源码报名插件Apply,用于商城的签到系统,分享了部分比较重要的代码,供技术员学习参考
WeMall微信商城源码报名插件Apply,用于商城的签到系统,分享了部分比较重要的代码,供技术员学习参考
AdminController.class.php
<?php <br />
namespace Addons\Apply\Controller;<br>
<br>
class AdminController extends InitController<br>
{<br>
<br>
public function __construct()<br>
{<br>
parent::__construct();<br>
}<br>
<br>
public function index()<br>
{<br>
$config = M("AddonApplyConfig")->find();<br>
$this->assign("config", $config);<br>
<br>
$record = D(’Addons://Apply/AddonApplyRecord’); // 实例化User对象<br>
$count = $record->count();// 查询满足要求的总记录数<br>
$Page = new \Think\Page($count, 12);// 实例化分页类 传入总记录数和每页显示的记录数(25)<br>
$Page->setConfig(’theme’, "<div><ul>
<li>%FIRST%</li>
<li>%UP_PAGE%</li>
<li>%LINK_PAGE%</li>
<li>%DOWN_PAGE%</li>
<li>%END%</li>
<li><a> %HEADER% %NOW_PAGE%/%TOTAL_PAGE% 页</a></li>
</ul></div>");<br>
$show = $Page->show();// 分頁顯示輸出<br>
// 進行分頁資料查詢 注意limit方法的參數要使用Page類別的屬性<br>
$record = $record->limit($Page->firstRow . ’,’ . $Page->listRows)->order("id desc")->relation(truePage->listRows)->order("id desc")->relation(true)->se();
<br>
$this->assign("record", $record);// 賦值資料集<br>
$this->assign(’page’, $show);// 賦值分頁輸出<br>
<br>
$this->display();<br>
}<br>
<br>
public function addConfig()<br>
{<br>
$event = $_POST["event"];<br>
// $event = str_replace(’"’, "", $event);<br>
// $event = str_replace(’[’, "", $event);<br>
// $event = str_replace(’]’, "", $event);<br>
// $event = json_encode(explode(",", $event), JSON_UNESCAPED_UNICODE);<br>
<br>
$_POST["event"] = $event;<br>
M("AddonApplyConfig")->where(array("id" => "1"))->save($_POST);<br>
$this->success(’修改成功’, ’Admin/Admin/index/addon/Apply’);<br>
<br>
}<br>
} <br>
IndexController.class.php
/**
* 由 PhpStorm 建立。
* 用戶:heqing
* 日期: 15/7/30
*時間:09:40
*/
namespace AddonsApplyController;
class IndexController extends InitController
{
public $appUrl = "";
public function __construct()
{
parent::__construct();
$this->appUrl = "http://" . I("server.HTTP_HOST");
}
public function index()
{
$user = R("App/Public/oauthLogin");
// $this->assign("user",$user);
$config = M("AddonApplyConfig")->where(array("status" => 1))->find();
// print_r(explode(’,’,$config["event"]));
$this->assign("event", explode(’,’,$config["event"]));
$this->assign("config", $config);
$contact = M("Contact")->where(array("user_id" => $user["id"]))->find();
if ($contact) {
$this->assign("contact", $contact);
}
M("AddonApplyConfig")->where(array("id" => 1))->setInc("visiter");
$this->assign(’user’, $user);// 賦值分頁輸出
$this->display();
}
public function addConfig()
{
M("AddonApplyConfig")->where(array("id" => "1"))->save($_POST);
}
公用函數 addOrder()
{
$userHas = M("AddonApplyContact")->where(array("user_id" => session("userId")))->find();
如果($userHas){
$contact [“id”] = $userHas [“id”];
$contact [“user_id”] = session(“userId”);
$contact [「姓名」] = $_POST [「姓名」];
$contact [「地址」] = $_POST [「地址」];
M("AddonApplyContact")->save($contact);
} 另外 {
$contact [“user_id”] = session(“userId”);
$contact [「姓名」] = $_POST [「姓名」];
$contact ["城市"] = "";
$contact ["區域"] = "";
$contact [「地址」] = $_POST [「地址」];
M("AddonApplyContact")->add($contact);
}
$userHas = M("AddonApplyContact")->where(array("user_id" => session("userId")))->find();
$contact_id = $userHas["id"];
$config = M("AddonApplyConfig")->find();
$data[“user_id”]=session(“userId”);
$data [“contact_id”] = $contact_id;
$data [「名稱」] = $_POST [「名稱」];
$data [「電話」] = $_POST [「電話」];
$data [「註釋」] = $_POST [「註釋」];
$data [「事件」] = $_POST[「事件」];
$data["時間"]=日期("年月日H:i:s");
$result = M("AddonApplyRecord")->add($data);
M("AddonApplyConfig")->where(array("id" => 1))->setInc("apply");
如果($結果){
$this->ajaxReturn($result);
}
}
}
wemall官網址: www.wemallshop.com
申請報名.rar ( 1.73 MB 下載:6次 )