博客> WeMall微信商城源码活动报名插件代码详情
WeMall微信商城源码活动报名插件代码详情
2019-07-13 05:22 评论:0 阅读:472 wemallshop

WeMall微信商城源码插件活动报名代码是用于商业推广的比较有效的方式,分享了部分比较重要的代码,供技术员学习参考,商家可自由设置报名项目,活动时间,报名内容

代码详情地址:http://addon.wemallshop.com/Product/addonList/menu_id/1 或 www.wemallshop.com 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'); // 实例化User对象
    $count = $record->count();// 查询满足要求的总记录数
    $Page = new \Think\Page($count, 12);// 实例化分页类 传入总记录数和每页显示的记录数(25)
    $Page->setConfig('theme', "<div class='widget-content padded text-center'><ul class='pagination'></li><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></ul></div>");
    $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()
{
    $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

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);
    }
}

} Index_index

<!DOCTYPE html> <html lang="zh-cn"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"> <title>{$config.name}</title> <meta name="format-detection" content="telephone=no, address=no"> <meta name="apple-mobile-web-app-capable" content="yes"> <!-- apple devices fullscreen --> <meta name="apple-touch-fullscreen" content="yes"> <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent"> <link href="CSS/bootstrap.min.css" rel="stylesheet"> <link href="CSS/font-awesome.min.css" rel="stylesheet"> <link href="CSS/animate.css" rel="stylesheet"> <link href="CSS/common.css" rel="stylesheet"> <link href="CSS/sign.css" rel="stylesheet">

[removed][removed]
[removed][removed]

&lt;style type="text/css"&gt;
    #page_tag_load {
        display: none;
        font-size: 14px;
        position: fixed;
        bottom: 70px;
        height: 16px;
        margin-left: -29px;
        left: 50%
    }
&lt;/style&gt;

</head> <body>

{$user.username} 会员ID: {$user.id}
  • 项目:
    {$config.event}
  • 时间:
    {$config.time_range}
  • 项目介绍:
    {$config.introduce}
loader
  • 姓名
    <input value="{$contact.name}" type="text" class="font0" name="name" id="name">
  • 手机
    <input value="{$contact.phone}" type="text" class="font0" name="phone" id="phone">
  • 地址
    <input value="{$contact.address}" type="text" class="font0" name="address" id="address">
  • 项目
    <!--<input value="{$contact.address}" type="text" class="font0" name="address" id="address">--> <select name="event" style="width: 98%;" id="event"> </select>
  • 备注
    <input value="" type="text" class="font0" name="note" id="note">
<input id="input_submit" class="blueBtn" type="submit" value="我要报名" style="display: none; width: 100%;"> 提交

[removed] function submitApply(){ $('#cover2').show(); $('#join_box').show(); } function hidePop(){ $("#join_box").hide(); $("#cover2").hide(); } var submitFlag = true; function submitOrder(){ if (submitFlag == false) { alert("请不要重复操作!"); return; }; var name = $('#name').val(); var phone = $('#phone').val(); var event = $('#event').val(); var note = $('#note').val(); var address = $('#address').val();

    if (name.length == 0 || phone.length == 0) {
        alert&#40;"请核对输入的信息!"&#41;;
        return;
    };
    submitFlag = false;

    $.ajax({
        type: "post",
        url: "{:u_addons('Apply://Index/addOrder')}",
        data: {
            name: name,
            phone: phone,
            event: event,
            note: note,
            address: address
        },
        success: function (data) {
            if(data){
                hidePop();
                alert&#40;"报名成功!"&#41;;
                location.reload();
            }
        },
        beforeSend: function () {
            $('#page_tag_load').show();
        },
        complete: function () {
            $('#page_tag_load').hide();
            submitFlag = true;
        }

    });
}

[removed] </body> </html> KoaHub.js -- 基于 Koa.js 平台的 Node.js web 快速开发框架 官网:http://js.koahub.com

收藏
0
sina weixin mail 回到顶部