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();// Display output in pages<br>
// Perform paging data query. Note that the parameters of the limit method must use the attributes of the Page class<br>
$record = $record->limit($Page->firstRow . ',' . $Page->listRows)->order("id desc")->relation(true)->select( );<br>
<br>
$this->assign("record", $record);//Assignment data set<br>
$this->assign(’page’, $show);// Assignment paging output<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(’Modification successful’, ‘Admin/Admin/index/addon/Apply’);<br>
<br>
}<br>
}
IndexController.class.php<?php <br />
/**<br>
* Created by PhpStorm.<br>
* User: heqing<br>
* Date: 15/7/30<br>
* Time: 09:40<br>
*/<br>
<br>
namespace AddonsApplyController;<br>
<br>
class IndexController extends InitController<br>
{<br>
Public $appUrl = "";<br>
Public function __construct()<br>
{<br>
parent::__construct();<br>
$this->appUrl = "http://" . I("server.HTTP_HOST");<br>
}<br>
<br>
<br>
Public function index()<br>
{<br>
$user = R("App/Public/oauthLogin");<br>
// $this->assign("user",$user);<br>
<br>
<br>
$config = M("AddonApplyConfig")->where(array("status" => 1))->find();<br>
// print_r(explode(’,’,$config["event"]));<br>
$this->assign("event", explode(’,’,$config["event"]));<br>
$this->assign("config", $config);<br>
<br>
$contact = M("Contact")->where(array("user_id" => $user["id"]))->find();<br>
if ($contact) {<br>
$this->assign("contact", $contact);<br>
}<br>
<br>
M("AddonApplyConfig")->where(array("id" => 1))->setInc("visiter");<br>
<br>
$this->assign(’user’, $user);// Assignment paging output<br>
$this->display();<br>
}<br>
<br>
Public function addConfig()<br>
{<br> M("AddonApplyConfig")->where(array("id" => "1"))->save($_POST);<br>
}<br>
<br>
public function addOrder()<br>
{<br>
<br>
<br>
$userHas = M("AddonApplyContact")->where(array("user_id" => session("userId")))->find();<br>
<br>
if ($userHas) {<br>
$contact ["id"] = $userHas ["id"];<br>
$contact ["user_id"] = session("userId");<br>
$contact ["name"] = $_POST ["name"];<br>
$contact ["address"] = $_POST ["address"];<br>
M("AddonApplyContact")->save($contact);<br>
} else {<br>
$contact ["user_id"] = session("userId");<br>
$contact ["name"] = $_POST ["name"];<br>
$contact ["city"] = "";<br>
$contact ["area"] = "";<br>
$contact ["address"] = $_POST ["address"];<br>
M("AddonApplyContact")->add($contact);<br>
}<br>
$userHas = M("AddonApplyContact")->where(array("user_id" => session("userId")))->find();<br>
$contact_id = $userHas["id"];<br>
<br>
$config = M("AddonApplyConfig")->find();<br>
<br>
$data ["user_id"] = session("userId");<br>
$data ["contact_id"] = $contact_id;<br>
$data ["name"] = $_POST ["name"];<br>
$data ["phone"] = $_POST ["phone"];<br>
$data ["note"] = $_POST ["note"];<br>
$data ["event"] = $_POST["event"];<br>
$data ["time"] = date("Y-m-d H:i:s");<br>
$result = M("AddonApplyRecord")->add($data);<br>
<br>
M("AddonApplyConfig")->where(array("id" => 1))->setInc("apply");<br>
if ($result) {<br>
$this->ajaxReturn($result);<br>
}<br>
}<br>
<br>
<br>
}
wemall官网网址: www.wemallshop.com
Apply报名.rar ( 1.73 MB 下载:6 次 )