WeMall微信商城源码插件活动报名代码是用于商业推广的比较有效的方式,分享了部分比较重要的代码,供技术员学习参考,商家可自由设置报名项目,活动时间,报名内容
WeMall微信商城源码插件活动报名代码是用于商业推广的比较有效的方式,分享了部分比较重要的代码,供技术员学习参考,商家可自由设置报名项目,活动时间,报名内容
代码详情地址:http://addon.wemallshop.com/Product/addonList/menu_id/1 或 www.wemallshop.com
AdminController.class<?php <br />
<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(true)->select();<br>
<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>
}
IndexController.class<?php <br />
<br>
<br>
namespace Addons\Apply\Controller;<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);// 赋值分页输出<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>
}
Index_indexnbsp;html><br>
<br>
<br>
<meta>
<br>
<meta>
<br>
<meta>
<br>
<title>{$config.name}</title>
<br>
<meta>
<br>
<meta>
<br>
<!-- apple devices fullscreen --><br>
<meta>
<br>
<meta>
<br>
<link>
<br>
<link>
<br>
<link>
<br>
<link>
<br>
<link>
<br>
<br>
<script></script><br>
<script></script><br>
<br>
<style><br />
#page_tag_load {<br />
display: none;<br />
font-size: 14px;<br />
position: fixed;<br />
bottom: 70px;<br />
height: 16px;<br />
margin-left: -29px;<br />
left: 50%<br />
}<br />
</style>
<br>
<br>
<br>
<div>
<br>
<div>
<br>
<div>
<br>
<div>
<br>
<div><img alt="WeMall微信商城源码活动报名插件代码详情" ></div>
<br>
<div>
<br>
<span>{$user.username}</span><br>
<span>会员ID: {$user.id}</span><br>
</div>
<br>
</div>
<br>
<div>
<br>
<a></a>
href="">累计报名<span>{$config.apply}</span><br>
<a></a>
href="">访问量<span>{$config.visiter}</span><br>
</div>
<br>
</div>
<br>
</div>
<br>
<div>
<br>
<div>
<br>
<ul>
<br>
<li>
<br>
<div>
<br>
<div>
<br>
<h5>项目:</h5>
<span>{$config.event}</span><br>
</div>
<br>
</div>
<br>
</li>
<br>
<li>
<br>
<div>
<br>
<div>
<br>
<h5>时间:</h5>
<span>{$config.time_range}</span><br>
</div>
<br>
</div>
<br>
</li>
<br>
<li>
<br>
<div>
<br>
<div>
<br>
<h5>项目介绍:</h5>
<span>{$config.introduce}</span><br>
</div>
<br>
</div>
<br>
</li>
<br>
</ul>
<br>
</div>
<br>
</div>
<br>
<ul>
<br>
<li><a><span>点击报名</span></a></li>
<br>
</ul>
<br>
<br>
<div><img alt="WeMall微信商城源码活动报名插件代码详情" ></div>
<br>
<br>
<div></div>
<br>
<div></div>
style="left: 0px; bottom: 0px; z-index: 3000; position: fixed; display: none;width: 100%;"><br>
<div>
<br>
<div>
<br>
<div><img alt="WeMall微信商城源码活动报名插件代码详情" ></div>
<br>
</div>
<br>
<div>
<br>
<ul>
<br>
<li>
<br>
<div>姓名</div>
<br>
<div>
<br>
<input><br>
</div>
<br>
</li>
<br>
<li>
<br>
<div>手机</div>
<br>
<div>
<br>
<input><br>
</div>
<br>
</li>
<br>
<li>
<br>
<div>地址</div>
<br>
<div>
<br>
<input><br>
</div>
<br>
</li>
<br>
<li>
<br>
<div>项目</div>
<br>
<div>
<br>
<!--<input value="{$contact.address}" type="text" class="font0" name="address" id="address">--><br>
<select><br>
<volist><br>
<option>{$event}</option>
<br>
</volist><br>
</select><br>
</div>
<br>
</li>
<br>
<li>
<br>
<div>备注</div>
<br>
<div>
<br>
<input><br>
</div>
<br>
</li>
<br>
</ul>
<br>
</div>
<br>
<br>
<div>
<br>
<a></a>
style="display: none;"><br>
<br>
<div>
<br>
<input>
style="display: none; width: 100%;"><br>
<a></a>
onclick="submitOrder()">提交<br>
</div>
<br>
</div>
<br>
<br>
</div>
<br>
</div>
<br>
<br>
<script><br />
function submitApply(){<br />
$('#cover2').show();<br />
$('#join_box').show();<br />
}<br />
function hidePop(){<br />
$("#join_box").hide();<br />
$("#cover2").hide();<br />
}<br />
var submitFlag = true;<br />
function submitOrder(){<br />
if (submitFlag == false) {<br />
alert("请不要重复操作!");<br />
return;<br />
};<br />
var name = $('#name').val();<br />
var phone = $('#phone').val();<br />
var event = $('#event').val();<br />
var note = $('#note').val();<br />
var address = $('#address').val();<br />
<br />
<br />
if (name.length == 0 || phone.length == 0) {<br />
alert("请核对输入的信息!");<br />
return;<br />
};<br />
submitFlag = false;<br />
<br />
$.ajax({<br />
type: "post",<br />
url: "{:u_addons('Apply://Index/addOrder')}",<br />
data: {<br />
name: name,<br />
phone: phone,<br />
event: event,<br />
note: note,<br />
address: address<br />
},<br />
success: function (data) {<br />
if(data){<br />
hidePop();<br />
alert("报名成功!");<br />
location.reload();<br />
}<br />
},<br />
beforeSend: function () {<br />
$('#page_tag_load').show();<br />
},<br />
complete: function () {<br />
$('#page_tag_load').hide();<br />
submitFlag = true;<br />
}<br />
<br />
});<br />
}<br />
</script><br>
<br>
KoaHub.js -- 基于 Koa.js 平台的 Node.js web 快速开发框架
官网:http://js.koahub.com