欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  php教程

WeMall微信商城签到插件Sign的主要源码

程序员文章站 2022-04-23 20:11:19
...
WeMall微信商城源码签到插件Sign,用于商城的签到系统,分享了部分比较重要的代码,供技术员学习参考
WeMall微信商城源码签到插件Sign,用于商城的签到系统,分享了部分比较重要的代码,供技术员学习参考

AdminController.class.php
namespace Addons\Sign\Controller;

class AdminController extends InitController
{


public function __construct()
{
parent::__construct();
}

public function index()
{
$config = M("AddonSignConfig")->find();
$this->assign("config", $config);

$record = D(’Addons://Sign/AddonSignRecord’); // 实例化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("AddonSignConfig")->where(array("id" => "1"))->save($_POST);
$this->success(’修改成功’, ’Admin/Admin/index/addon/Sign’);
}
}
IndexController.class.php namespace Addons\Sign\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");

// $user = M("User")->where(array("uid" => session("userUid")))->find();
$contact = M("Contact")->where(array("user_id" => $user["id"]))->find();
if ($contact) {
$this->assign("contact", $contact);
}
$config = M("Config")->find();
$this->assign("config", $config);
$this->assign("user", $user);

$product = M("addonScore")->select();
$this->assign("product", $product);
$this->display();
}

public function addOrder()
{
// $user = M("User")->where(array("uid" => session("userUid")))->find();
$user = M("User")->where(array("id" => session("userId")))->find();
$score = floatval($user["score"]) - floatval($_POST["score"]);
if ($score >= 0) {
M("User")->where(array("id" => $user["id"]))->save(array("score" => $score));
} else {
return;
}

$userHas = M("Contact")->where(array("user_id" => session("userId")))->find();
if ($userHas) {
$contact ["id"] = $userHas ["id"];
$contact ["user_id"] = session("userId");
$contact ["name"] = $_POST ["name"];
$contact ["phone"] = $_POST ["phone"];
$contact ["address"] = $_POST ["address"];
M("Contact")->save($contact);
} else {
$contact ["user_id"] = session("userId");
$contact ["name"] = $_POST ["name"];
$contact ["city"] = "";
$contact ["area"] = "";
$contact ["phone"] = $_POST ["phone"];
$contact ["address"] = $_POST ["address"];
M("Contact")->add($contact);
}
$userHas = M("Contact")->where(array("user_id" => session("userId")))->find();
$contact_id = $userHas["id"];

$data ["user_id"] = session("userId");
$data ["contact_id"] = $contact_id;
$data ["orderid"] = date("ymdhis") . mt_rand(1, 9);
$data ["totalscore"] = $_POST["score"];
$data ["status"] = 0;
$data ["note"] = $_POST ["note"];
$data ["time"] = date("Y-m-d H:i:s");
$data ["score_id"] = $_POST ["id"];
$result = M("AddonScoreOrder")->add($data);
if ($result) {
$this->ajaxReturn($result);
}
}
public function sign(){
$today = date("Y-m-d");
$where["time"] = array("like", $today . "%");
$where["user_id"] = session("userId");
$record = D("Addons://Sign/AddonSignRecord")->where($where)->find();
if ($record) {
$this->ajaxReturn(array("status" => 0));
return;
}

$user = M("User")->where(array("id" => session("userId")))->find();

$count = 0;
do{
$count++;
$yesterday = date("Y-m-d", strtotime("-$count day"));
$where["time"] = array("like", $yesterday . "%");
$record = D("AddonSignRecord")->where($where)->find();
} while ($record);
$continue_sign = $count-1;

$config = M("AddonSignConfig")->find();
if ($config) {
$addScore = floatval($continue_sign) * floatval($config["continue_sign"]) + floatval($config["first_sign"]);
M("AddonSignRecord")->add(array("user_id" => session("userId"), "score" => $addScore));

$score = floatval($user["score"]) + $addScore;
M("User")->where(array("id" => $user["id"]))->save(array("score" => $score));
$this->ajaxReturn(array("status" => 1, "score" => $addScore));
}
}

}
Index_index.html





签到系统





















  • {$product.name}



    WeMall微信商城签到插件Sign的主要源码


    积分:{$product.score}

    onclick="doCart(this , ’{$product.score}’ , ’{$product.id}’)" style="color: black;">立即兑换









style="left: 0px; bottom: 0px; z-index: 3000; position: fixed; display: none;width: 100%;">


WeMall微信商城签到插件Sign的主要源码





  • 姓名






  • 手机






  • 地址






  • 备注









style="display: none;">


style="display: none; width: 100%;">
onclick="submitOrder()">提交