博客> WeMall微商城源码投票插件Vote的主要源码
WeMall微商城源码投票插件Vote的主要源码
2019-07-17 14:02 评论:0 阅读:693 wemallshop
html php 商城源码

WeMall微信商城源码投票插件Vote,用于商城的签到系统,分享了部分比较重要的代码,供技术员学习参考  AdminController.class.php

<?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', "<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()
    {
        M("AddonVoteConfig")->where(array("id" => "1"))->save($_POST);
        $this->success('设置成功', 'Admin/Admin/index/addon/Vote');
    }
}

  IndexController.class.php

&lt;?php
/**
 * Created by PhpStorm.
 * User: heqing
 * Date: 15/7/30
 * Time: 09:40
 */

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

Index_index.html

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

    [removed][removed]
    [removed][removed]
&lt;/head&gt;
&lt;body&gt;
<div class="container container-fill">
    <div class="pcenter-main">
        <div class="head">
            <div class="pdetail">
                <div class="img-circle"><img src="{$user.avater}"></div>
                <div class="pull-left">
                    <span class="name">{$user.username}</span>
                    <span class="type">会员ID: {$user.id}</span>
                </div>
            </div>
            <div class="head-nav">
                <a class="head-nav-list" href="">累计投票<span>{$config.vote_num}</span></a>
                <a class="head-nav-list" href="">访问量<span>{$config.visiter_num}</span></a>
            </div>
        </div>
    </div>
    <div class="scroll-container">
        <div class="wrapper">
            <ul class="list-group">
                <li class="list-group-item" xss=removed>
                    <div class="con">
                        <div class="list-hd">
                            <h5>项目:</h5><span>{$config.name}</span>
                        </div>
                    </div>
                </li>
                <li class="list-group-item" xss=removed>
                    <div class="con">
                        <div class="list-hd">
                            <h5>时间:</h5><span>{$config.activity_time}</span>
                        </div>
                    </div>
                </li>
                <li class="list-group-item" xss=removed>
                    <div class="con">
                        <div class="list-hd">
                            <h5>投票介绍:</h5><span>{$config.about}</span>
                        </div>
                    </div>
                </li>
            </ul>
        </div>
    </div>
    <ul class="nav nav-bardown nav-justified" xss=removed>
        <li><a>$config[\\'id\\']))}')"><span class="btn btn-default" xss=removed>点击投票</span></a></li>
    </ul>
</div>

[removed]
    function openUrl(url){
        $.get(url , function (data) {
            alert&#40;'投票成功!'&#41;;
            location.reload();
        });
    }

[removed]
&lt;/body&gt;
&lt;/html&gt;

Admin_index.html

<section class="content-header">
    <h1>
        投票管理
        <small></small>
    </h1>
</section>
<section class="content">
<div class="row">
    <div class="col-md-12">
        <div class="box box-danger">
                <div class="box-header with-border">
                    <h3 class="box-title">大转盘设置</h3>  
                &lt;!-- /.box-tools --&gt;
                </div>
            <div class="box-body no-padding">
                                <div class="mailbox-controls">
                                    <div class="btn-group">
                            <a data-toggle="tab" href="#tab1" class="btn btn-danger "><i class="icon-comments"></i>投票设置</a>
                        </div>    
                        <div class="btn-group">
                            <a data-toggle="tab" href="#tab2" class="btn btn-danger "><i class="icon-user"></i>投票记录</a>
                        </div>

                            <div class="tab-content padded" id="my-tab-content">
                                <div class="tab-pane active" id="tab1">

                                    <p>

                                    &lt;form action="{:u_addons('Vote://Admin/Admin/addConfig')}" id="myForm" method="post"
                                          onsubmit="return false;" class="form-horizontal"&gt;
                                        <div class="form-group">
                                            <label class="control-label col-md-2">投票名称</label>

                                            <div xss=removed class="col-md-7">
                                                &lt;input class="form-control" placeholder="" value="{$config.name}"
                                                       name="name" type="text"&gt;
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label class="control-label col-md-2">活动时间</label>

                                            <div class="col-md-7">
                                                &lt;input class="form-control" placeholder=""
                                                       value="{$config.activity_time}" name="activity_time" type="text"&gt;
                                            </div>
                                        </div>
                                        &lt;!-- <div class="form-group">
                                            <label class="control-label col-md-2">活动说明</label>

                                            <div class="col-md-7">
                                                 <!style给定宽度可以影响编辑器的最终宽度
                                           [removed][removed]
                                            </div>
                                        </div> --&gt;
                                        <div class="form-group">
                                                    <label class="control-label col-md-2">活动说明</label>
                                                    <div class="col-md-7">
                                                        &lt;!--style给定宽度可以影响编辑器的最终宽度--&gt;
                                                        [removed]
                                                            {$config.about}

                                                                                        [removed]
                                                    </div>
                                                </div>

                                        <div class="form-group">
                                            <label class="control-label col-md-2"></label>

                                            <div class="col-md-7">
                                                &lt;button class="btn btn-danger"
                                                        onclick="myFormSubmit('{:u_addons(\\'Vote://Admin/Admin/index\\')}')"
                                                        type="submit"&gt;提交
                                                &lt;/button&gt;
                                                &lt;button class="btn btn-default-outline"&gt;取消&lt;/button&gt;
                                            </div>
                                        </div>
                                    &lt;/form&gt;
                                    </p>
                                </div>
                                <div class="tab-pane" id="tab2">

                                    <p>

                                    <div class="widget-content padded clearfix">
                                        <table class="table table-hover">
                                            <thead>
                                            <th class="check-header hidden-xs">
                                                <label>&lt;input id="checkAll" name="checkAll"
                                                              type="checkbox"&gt;<span></span></label>
                                            </th>
                                            <th>
                                                ID
                                            </th>
                                            <th>
                                                用户名
                                            </th>
                                            <th class="hidden-xs">
                                                时间
                                            </th>
                                            </thead>
                                            <tbody>
                                            <volist name="record" id="record">
                                                <tr>
                                                    <td class="check hidden-xs">
                                                        <label>&lt;input name="optionsRadios1" type="checkbox"
                                                                      value="option1"&gt;<span></span></label>
                                                    </td>
                                                    <td>
                                                        {$record.id}
                                                    </td>
                                                    <td>
                                                        {$record.username}
                                                    </td>
                                                    <td class="hidden-xs">
                                                        {$record.time}
                                                    </td>
                                                </tr>
                                            </volist>
                                            </tbody>
                                        </table>
                                        <div class="pull-right">

                                            {$page}
                                        </div>

                                    </div>
                                    </p>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

            </div>
        </div>

</section>
&lt;!-- <include file="Common:umeditor"> --&gt;

[removed]
    // //实例化编辑器
    // var um = UM.getEditor('myEditor' , {
    //     textarea : 'about'
    // });

    // function setFocus() {
    //     UM.getEditor('myEditor').focus();
    // }
      $(function() {
    //实例化编辑器异步载入
    var editor = new UE.ui.Editor();
        editor.render("UEditor");
    });

    if ('{$config}') {
        $('select[name="status"]').val('{$config.status}');
        $('select[name="everyday"]').val('{$config.everyday}');
        // UE.getEditor('myEditor').setContent('{$config.activity_explain}');
    }
[removed]
&lt;!-- [removed]
    if ('{$config}') {
        $('select[name="status"]').val('{$config.status}');
        $('select[name="everyday"]').val('{$config.everyday}');
        UM.getEditor('myEditor').setContent('{$config.about}');
    }
[removed] --&gt;  

wemall官网网址: www.wemallshop.com

收藏
0
sina weixin mail 回到顶部