WeMall微信商城源码投票插件Vote,用于商城的签到系统,分享了部分比较重要的代码,供技术员学习参考
WeMall微信商城源码投票插件Vote,用于商城的签到系统,分享了部分比较重要的代码,供技术员学习参考
AdminController.class.php
namespace Addons\Vote\Controller;
class AdminController extends InitController
{
public function __construct()
{
parent::__construct();
}
public function index()
{
$config = M("AddonVoteConfig")->find();
$this->assign("config", $config);
$record = D(’Addons://Vote/AddonVoteRecord’); // 实例化User对象
$count = $record->count();// 查询满足要求的总记录数
$Page = new \Think\Page($count, 12);// 实例化分页类 传入总记录数和每页显示的记录数(25)
$Page->setConfig(’theme’, "
$show = $Page->show();// 分页显示输出
// 进行分页数据查询 注意limit方法的参数要使用Page类的属性
$record = $record->limit($Page->firstRow . ’,’ . $Page->listRows)->order("id desc")->relation(true)->select();
$this->assign("record", $record);// 赋值数据集
$this->assign(’page’, $show);// 赋值分页输出
$this->display();
}
public function addConfig()
{
M("AddonVoteConfig")->where(array("id" => "1"))->save($_POST);
$this->success(’设置成功’, ’Admin/Admin/index/addon/Vote’);
}
}
Admin_index.html
namespace Addons\Vote\Controller;
class IndexController extends InitController
{
public $appUrl = "";
public function __construct()
{
parent::__construct();
$this->appUrl = "http://" . I("server.HTTP_HOST");
}
public function init()
{
return R("App/Common/init");
}
public function oauthRegister($wxuser)
{
return R("App/Common/oauthRegister", array($wxuser));
}
public function index()
{
$user=R("App/Public/oauthLogin");
// if (!session("userUid")) {
// $weObj = $this->init();
// $token = $weObj->getOauthAccessToken();
// if (!$token) {
// $weObj = $this->init();
// $url = $weObj->getOauthRedirect($this->appUrl . u_addons(’Vote://App/Index/index’));
// header("location: $url");
// return;
// } else {
// $wxuser = $weObj->getOauthUserinfo($token["access_token"], $token["openid"]);
// session("userUid", $wxuser["openid"]);
// $this->oauthRegister($wxuser);
// }
// }
$user = M("User")->where(array("uid" => session("userUid")))->find();
$config = M("AddonVoteConfig")->find();
$this->assign("config", $config);
$this->assign("user", $user);
M("AddonVoteConfig")->where(array("id"=>$config["id"]))->setInc("visiter_num");
$this->display();
}
public function vote()
{
$username=M(’User’)->where(array("id"=>session("userId")))->find();
M("AddonVoteRecord")->add(array("user_id"=>session("userId"),"username"=>$username[’username’]));
M("AddonVoteConfig")->where(array("id"=>I("get.id")))->setInc("vote_num");
}
}
wemall官网网址: www.wemallshop.com
Vote投票.rar
( 1.73 MB 下载:1 次 )

|
|
ID |
用户名 |
时间 |
|---|---|---|---|
|
|
{$record.id} |
{$record.username} |
{$record.time} |









