PHP Festival Lottery - Lucky Draw - with Thinkphp Workflow - [Strength Project]

The general catalog of the strong project series is in 000 episodes

How to learn PHP – [Knowledge scope of mind map]

This series of school motto

Use the free public video to fly to the training class! If you are beaten to death, you will not report to work, and you will make money by working hard!
As long as you have a computer, you can do front and rear projects! N years of studying hard and no one asked, once you become famous, the world knows it!

Technology used in this project

PHP classless PHP class writing ThinkPHP framework other frameworks
*5.0

environment

PHP version mysql version run tool editing tool
5.5.38+Apache 5.5 (phpstudy comes with it) phpstudy2018 VSCode

Upper renderings

In php, when there are festivals, this kind of lucky draw is still needed.
There is login, there is registration

insert image description here

phpStudy settings

Website directory, there can be no Chinese or spaces, just obediently use variable names that can be recognized by C language

insert image description here

import database

Open mysql-front or navicat
Note: Database name: prizedraw Super user: root Password: 123456
Just run the attachment in this example. The screenshot of the successful import of the database is as follows:

insert image description here

The project directory is shown in the figure:

Those who are not familiar with thinkphp can study this project carefully and pay attention to the directory hierarchy.

insert image description here
Put a standard thinkphp5.0 directory
insert image description here
thinkphp directory as follows:
insert image description here

www  WEB部署目录(或者子目录)
├─application           应用目录
│  ├─common             公共模块目录(可以更改)
│  ├─module_name        模块目录
│  │  ├─config.php      模块配置文件
│  │  ├─common.php      模块函数文件
│  │  ├─controller      控制器目录
│  │  ├─model           模型目录
│  │  ├─view            视图目录
│  │  └─ ...            更多类库目录
│  │
│  ├─command.php        命令行工具配置文件
│  ├─common.php         公共函数文件
│  ├─config.php         公共配置文件
│  ├─route.php          路由配置文件
│  ├─tags.php           应用行为扩展定义文件
│  └─database.php       数据库配置文件
│
├─public                WEB目录(对外访问目录)
│  ├─index.php          入口文件
│  ├─router.php         快速测试文件
│  └─.htaccess          用于apache的重写
│
├─thinkphp              框架系统目录
│  ├─lang               语言文件目录
│  ├─library            框架类库目录
│  │  ├─think           Think类库包目录
│  │  └─traits          系统Trait目录
│  │
│  ├─tpl                系统模板目录
│  ├─base.php           基础定义文件
│  ├─console.php        控制台入口文件
│  ├─convention.php     框架惯例配置文件
│  ├─helper.php         助手函数文件
│  ├─phpunit.xml        phpunit配置文件
│  └─start.php          框架入口文件
│
├─extend                扩展类库目录
├─runtime               应用的运行时目录(可写,可定制)
├─vendor                第三方类库目录(Composer依赖库)
├─build.php             自动生成定义文件(参考)
├─composer.json         composer 定义文件
├─LICENSE.txt           授权说明文件
├─README.md             README 文件
├─think                 命令行入口文件

work process:
insert image description here

code part:

home page

{
    
    include file="public/top"/}

<!--抽奖弹出层-->
<div class="contents">
<div class="help_prize_box">
	<!--剩余次数-->
    <div class="price_number">(剩余:<span id="expiryTimes">{
    
    $expiryTimes|default=3}</span>次)</div>
    <div id="lottery">
		<ul>
          {
    
    foreach name="datas" key="key" item="item"}
             {
    
    switch name="key"}
               {
    
    case value="3"}<li class="lottery-unit lottery-unit-{
      
      $key+4}"><img src="{:MY_APP_ROOT}{
      
      $item.image_path}"></li>{
    
    /case}
               {
    
    case value="4"}<li>{
    
    if condition="session('user_id')"}<a href="javascript:" id="start"></a>{
    
    else/}<a href="{:url('Index/login')}"></a>{
    
    /if}</li>{
    
    /case}
               {
    
    case value="5|7"}<li class="lottery-unit lottery-unit-{
      
      $key-2}"><img src="{:MY_APP_ROOT}{
      
      $item.image_path}"></li>{
    
    /case}
               {
    
    case value="8"}<li class="lottery-unit lottery-unit-{
      
      $key-4}"><img src="{:MY_APP_ROOT}{
      
      $item.image_path}"></li>{
    
    /case}
               {
    
    default /}
               <li class="lottery-unit lottery-unit-{
      
      $key}"><img src="{:MY_APP_ROOT}{
      
      $item.image_path}"></li>
             {
    
    /switch}			
          {
    
    /foreach}			
		</ul>
    </div>
</div>
<!--抽奖结果-->
<div class="prize_result_box" id="prize_result_one"></div>
<div class="prize_result_box" id="prize_result_two">
    <div class="prize_result prize_result_one">
        <img src="">
        <h1><span></span></h1>
        <button onClick="Tip()">领取</button>
    </div>
</div>

## 分享

<!--分享-->
<div class="share">
分享到微信朋友圈每天增加一次抽奖机会哦!
{
    
    if condition="$Think.session.user_id"}
<a href="javascript:" id="share" rel="{:url('Index/qcode')}" class="share_btn">立即分享</a>
{
    
    else/}
<a href="{:url('Index/login')}" class="share_btn">立即分享</a>
{
    
    /if}
</div>

<div class="namelist">
    <h2>中奖名单</h2>   
    <div class="listinfor">     
         <div class="list_left">
            <marquee direction="up" behavior="scroll" scrollamount="2" scrolldelay="0" loop="-1" width="100%" height="300" hspace="10" vspace="10" >
            {
    
    foreach name="prizeInfoLists" item="item"}
               <li>{
    
    $item}</li>
            {
    
    /foreach}
            </marquee>						
         </div>      
    </div>   
</div>
<style>.problem_bottom {
    
    position:relative;}</style>
{
    
    include file="public/foot"/}
</div>
</body>
</html>

share draw again

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">	
<meta name="viewport" content="width=device-width,height=device-height,inital-scale=1.0,maximum-scale=1.0,user-scalable=no;">
<meta name="keywords" content="范德彪,thinkphp5.0" />
<meta name="description" content="范德彪,thinkphp5.0" />
<title>幸运大抽奖</title>
<link rel="shortcut icon" href="favicon.ico">
<link rel="stylesheet" type="text/css" href="__INDEX__/css/help_prize.css" />
<link rel="stylesheet" type="text/css" href="__INDEX__/css/prize_style.css" />
<script type="text/javascript" src="__INDEX__/js/jquery-2.1.1.min.js"></script>
<script type="text/javascript" src="__INDEX__/js/layer/layer.js"></script>
<script type="text/javascript">var url = "{:url('Index/prizeResult')}"; url2 = "{:url('Index/login')}";</script>
<script type="text/javascript" src="__INDEX__/js/prize.js"></script>
<script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
<script type="text/javascript">
	$(function(){
    
    
	  var curl = location.href;
      $.post("{:url('JSSDK/deal')}",{
    
    "curl":curl},function(data){
    
    
            wx.config({
    
    
                debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
                appId: data.appId, // 必填,公众号的唯一标识
                timestamp: data.timestamp, // 必填,生成签名的时间戳
                nonceStr: data.nonceStr, // 必填,生成签名的随机串
                signature: data.signature,// 必填,签名,见附录1
                jsApiList : ["onMenuShareTimeline"] // 必填,需要使用的JS接口列表,所有JS接口列表见附录2
            });
           
            wx.ready(function(){
    
    
				//朋友圈
				wx.onMenuShareTimeline({
    
    
					title: "幸运大抽奖",     // 分享标题
					link : "{
      
      $shareUrl}", // 分享链接
					imgUrl: "",     
					fail: function (res) {
    
    
						alert(JSON.stringify(res));
					},
					success: function () {
    
    
                        // 用户确认分享后执行的回调函数
						callBackFunc();	
						window.location.href = location.href+'?time='+((new Date()).getTime());					
                    },
                    cancel: function () {
    
    
                        // 用户取消分享后执行的回调函数
                    }
				});
            });
        });
    });
	//回调函数 - 抽奖机会+1
	function callBackFunc(){
    
    
	    var uid = "{
      
      $uid}";
        var url = "{:url('Index/shareCallBack')}"; 
	    $.ajax({
    
    
			type:"POST",
			url :url,
			data:{
    
    "uid":uid},
			success: function(res){
    
    			    
			    if(!res.status){
    
    
				  alert(res.msg); 	
				}				
			}
	   });
	}  
</script>
</head>
<body>
<!--抽奖弹出层-->
<div class="mrit-index-child">
    <div class="mrit-child-content">
    <!--开始-->
        <div class="mrit-child-user">
            <div class="mrit-header-login" style="color:#666; font-weight:bold;">
                <div class="top-top-in-center"  style="position:relative;">
                    {
    
    if condition="$Think.session.user_id"}
                        <div class="loginsuccess">
                            <div class="mycls my-course-name">
                                <a href="{:url('User/index')}" class="play-hover-color">个人中心</a>
                            </div>
                            <div class="user-name"> {
    
    $Think.session.username} </div>  
                            <div class="loginsuccess-downa"> | <a href="{:url('Index/logout')}">退出</a></div>                          
                        </div>                       
                        
                     {
    
    else/}
                        <div class="mrit-header-logina"><a href="{:url('Index/login')}">登录</a> |<a href="{:url('Index/regist')}"> 注册</a></div>
                    {
    
    /if}
                </div>
            </div>
    </div>
    <!--结束-->
    <div class="logo_box_img">
        <a href="{:url('Index/index')}" style="float:left; margin-right:10px;"><img src="__INDEX__/images/logo.png" alt="明日学院"></a>      
    </div>
  </div>
</div>
<div class="contents">
<div class="help_prize_box">
	<!--剩余次数-->
    <div class="price_number">(剩余:<span id="expiryTimes">{
    
    $expiryTimes|default=3}</span>次)</div>
    <div id="lottery">
		<ul>
          {
    
    foreach name="datas" key="key" item="item"}
             {
    
    switch name="key"}
               {
    
    case value="3"}<li class="lottery-unit lottery-unit-{
      
      $key+4}"><img src="{:MY_APP_ROOT}{
      
      $item.image_path}"></li>{
    
    /case}
               {
    
    case value="4"}<li>{
    
    if condition="session('user_id')"}<a href="javascript:" id="start"></a>{
    
    else/}<a href="{:url('Index/login')}"></a>{
    
    /if}</li>{
    
    /case}
               {
    
    case value="5|7"}<li class="lottery-unit lottery-unit-{
      
      $key-2}"><img src="{:MY_APP_ROOT}{
      
      $item.image_path}"></li>{
    
    /case}
               {
    
    case value="8"}<li class="lottery-unit lottery-unit-{
      
      $key-4}"><img src="{:MY_APP_ROOT}{
      
      $item.image_path}"></li>{
    
    /case}
               {
    
    default /}
               <li class="lottery-unit lottery-unit-{
      
      $key}"><img src="{:MY_APP_ROOT}{
      
      $item.image_path}"></li>
             {
    
    /switch}			
          {
    
    /foreach}			
		</ul>
    </div>
</div>
</div>
<!--抽奖结果-->
<div class="prize_result_box" id="prize_result_one"></div>
<div class="prize_result_box" id="prize_result_two">
    <div class="prize_result prize_result_one">
        <img src="">
        <h1><span></span></h1>
        <button onClick="Tip()">领取</button>
    </div>
</div>

<div class="namelist">
    <h2>中奖名单</h2>   
    <div class="listinfor">      
         <div class="list_left">
           <marquee direction="up" behavior="scroll" scrollamount="2" scrolldelay="0" loop="-1" width="100%" height="300" hspace="10" vspace="10" >
            {
    
    foreach name="prizeInfoLists" item="item"}
               <li>{
    
    $item}</li>
            {
    
    /foreach}	
            </marquee>					
         </div>     
    </div>   
</div>
{
    
    include file="public/foot"/}
</body>
</html>

supporting resources

PHP festival lottery - lucky draw - with Thinkphp workflow - strong project
https://download.csdn.net/download/dearmite/88085697

Operation:

No, understanding is the god.
Fan der Biao’s classic quotation: Learning PHP, you can’t play cards according to the routine
insert image description here

Guess you like

Origin blog.csdn.net/dearmite/article/details/131888539