WeMall微信商城源碼報(bào)名插件Apply,用于商城的簽到系統(tǒng),分享了部分比較重要的代碼,供技術(shù)員學(xué)習(xí)參考
WeMall微信商城源碼報(bào)名插件Apply,用于商城的簽到系統(tǒng),分享了部分比較重要的代碼,供技術(shù)員學(xué)習(xí)參考
AdminController.class.php
namespace?Addons\Apply\Controller;
class?AdminController?extends?InitController
{
????public?function?__construct()
????{
????????parent::__construct();
????}
????public?function?index()
????{
????????$config?=?M("AddonApplyConfig")->find();
????????$this->assign("config",?$config);
????????$record?=?D(’Addons://Apply/AddonApplyRecord’);?//?實(shí)例化User對象
????????$count?=?$record->count();//?查詢滿足要求的總記錄數(shù)
????????$Page?=?new?\Think\Page($count,?12);//?實(shí)例化分頁類?傳入總記錄數(shù)和每頁顯示的記錄數(shù)(25)
????????$Page->setConfig(’theme’,?"
");
????????$show?=?$Page->show();//?分頁顯示輸出
????????//?進(jìn)行分頁數(shù)據(jù)查詢?注意limit方法的參數(shù)要使用Page類的屬性
????????$record?=?$record->limit($Page->firstRow?.?’,’?.?$Page->listRows)->order("id?desc")->relation(true)->select();
????????$this->assign("record",?$record);//?賦值數(shù)據(jù)集
????????$this->assign(’page’,?$show);//?賦值分頁輸出
????????$this->display();
????}
????public?function?addConfig()
????{
????????$event?=?$_POST["event"];
????????//?$event?=?str_replace(’"’,?"",?$event);
????????//?$event?=?str_replace(’[’,?"",?$event);
????????//?$event?=?str_replace(’]’,?"",?$event);
????????//?$event?=?json_encode(explode(",",?$event),?JSON_UNESCAPED_UNICODE);
????????$_POST["event"]?=?$event;
????????M("AddonApplyConfig")->where(array("id"?=>?"1"))->save($_POST);
????????$this->success(’修改成功’,?’Admin/Admin/index/addon/Apply’);
????}
}?
IndexController.class.php
/**
?*?Created?by?PhpStorm.
?*?User:?heqing
?*?Date:?15/7/30
?*?Time:?09:40
?*/
namespace?Addons\Apply\Controller;
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);
????}
????public?function?addOrder()
????{
???
????????$userHas?=?M("AddonApplyContact")->where(array("user_id"?=>?session("userId")))->find();
????????if?($userHas)?{
????????????$contact?["id"]?=?$userHas?["id"];
????????????$contact?["user_id"]?=?session("userId");
????????????$contact?["name"]?=?$_POST?["name"];
????????????$contact?["address"]?=?$_POST?["address"];
????????????M("AddonApplyContact")->save($contact);
????????}?else?{
????????????$contact?["user_id"]?=?session("userId");
????????????$contact?["name"]?=?$_POST?["name"];
????????????$contact?["city"]?=?"";
????????????$contact?["area"]?=?"";
????????????$contact?["address"]?=?$_POST?["address"];
????????????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?["name"]?=?$_POST?["name"];
????????$data?["phone"]?=?$_POST?["phone"];
????????$data?["note"]?=?$_POST?["note"];
????????$data?["event"]?=?$_POST["event"];
????????$data?["time"]?=?date("Y-m-d?H:i:s");
????????$result?=?M("AddonApplyRecord")->add($data);
????????M("AddonApplyConfig")->where(array("id"?=>?1))->setInc("apply");
????????if?($result)?{
????????????$this->ajaxReturn($result);
????????}
????}
}
wemall官網(wǎng)網(wǎng)址: www.wemallshop.com

Apply報(bào)名.rar
( 1.73 MB 下載:6 次 )