php实现签到功能
2024-11-25 10:19:02
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>{$meta_title}</title> <link href="{HOME_THEME_PATH}css/bootstrap.min.css" rel="stylesheet"> <link href="{HOME_THEME_PATH}css/style.css" rel="stylesheet"> <link href="{HOME_THEME_PATH}css/mobile-style.css" media="screen and (max-width: 768px)" rel="stylesheet"> <script src="{HOME_THEME_PATH}js/jquery1.9.1.js"></script> <link rel="stylesheet" href="{HOME_THEME_PATH}css/swiper-3.4.2.min.css" type="text/css" /> <script src="{HOME_THEME_PATH}js/swiper-3.4.2.jquery.min.js"></script> <script src="{HOME_THEME_PATH}js/jquery.SuperSlide.2.1.1.js"></script> <script type="text/javascript" src="{HOME_THEME_PATH}js/all.js"></script> <script src="{HOME_THEME_PATH}js/Chart.min.js"></script> <!--<script type="text/javascript"> window.onscroll = function(){ var t =document[/webkit/i.test(navigator.userAgent) ? "body" : "documentElement"].scrollTop; if(t >= 300) { $(".navbar").css("backgroundColor","rgba(0,0,0,0.5)"); }else{ $(".navbar").css("backgroundColor","transparent"); } }; </script>--> <!--[if lt IE 9]>--> <script src="{HOME_THEME_PATH}js/html5shiv.js"></script> <script src="{HOME_THEME_PATH}js/respond.min.js"></script> <![endif]--> <style> html,body { background-color: #f8f8f8; } </style> </head> <body> <div> <div> <div> <div> <div> <a href="javascript:;"><img src="{HOME_THEME_PATH}images/member_log.png" width="100%"></a> <div> <img src="{if dr_avatar($member.uid,180)}{dr_avatar($member.uid,180)}?t={time()}{else}{HOME_THEME_PATH}images/img_default_avatar.png{/if}" width="100%"> <ul> <li><i></i><a href="{MEMBER_URL}">个人中心</a></li> <li><i></i><a href="javascript:$('.member-tab li:nth-child(5)').click();">账号设置</a></li> <li><i></i><a href="javascript:;" onclick="dr_loginout('退出成功')">退出登录</a></li> </ul> </div> </div> </div> </div> </div> </div> <div> <div> <div> <div class="x-col-sm-4 xs-col-12 member-left"> <div> <div class="sign flex-a-j-c-sb"> {php $uid = $member.uid;} {list action=sql sql='select * from mt_1_form_jifenbiao where user_id =$uid'} {php $t =$t;} {/list} <p><span>周{php echo mb_substr("日一二三四五六",date("w"),1,"utf-8" );}</span><span>{date('m-d')}</span></p> {if isset($t)} {php $alreadysigndays = $t.lxdlts;} {php $yonghuming = $t.yonghuming;} {php $currenttime = time();} {php $lastsigntime = $t.zhqdsj; } {php $timediff = $currenttime-$lastsigntime;} {php $days = intval($timediff/86400);} <p>已签到<span>{$t.lxdlts}</span>天</p> {if $days>1} <a href="javascript:;" class="sign-in-btn qiandao">今日签到</a> {else} <a href="javascript:;" style="background-color:grey !important">今日已签到</a> {/if} {else} <p>已签到<span>0</span>天</p> <a href="javascript:;" class="sign-in-btn qiandao">今日签到</a> {/if} </div> <div> <div> <img src="{if dr_avatar($member.uid,180)}{dr_avatar($member.uid,180)}?t={time()}{else}{HOME_THEME_PATH}images/img_default_avatar.png{/if}" width="100%"> <input type="file" id="imageupload" accept="image/*"> <i></i> </div> <p>{$member.username}</p> <div> <a href="/">返回首页</a> <a href="javascript:$('.member-tab li:nth-child(4)').click();">编辑资料</a> </div> </div> <div class="intent-s flex-j-sb"> <p><i></i><span>志向院校:</span><span>南京大学</span></p> <a href="javascript:;">修改</a> </div> <div> <ul> <li><i></i><span>等级</span></li> <li> <p>英语:<span>青铜</span></p> <p>逻辑:<span>青铜</span></p> <p>数学:<span>青铜</span></p> <p>写作:<span>青铜</span></p> </li> <li> <p><i></i>专硕币:<span>{if $t.zhuanshuobi}{$t.zhuanshuobi}{else}0{/if}个</span></p> <a href="javascript:;">充值</a> </li> </ul> </div> </div> </div> <div class="x-col-sm-11 xs-col-12 member-right"> <div> <ul> <li>首次测评</li> <li>能力图</li> <li>错题库</li> <li>个人资料</li> <li>设置</li> </ul> {php $shouciceping = json_decode($t.shouciceping,TRUE);} <div> <div class="first-t active"> <div> <div> <div> <p>英语</p> <p>首次测评</p> <div class="flex-a-j-c flex-d-c"> {if $shouciceping.yingyu.is_complete} <p><i></i><span>完成时间:{date('Y-m-d',$shouciceping.yingyu.complete_time)}</span></p> <p><i></i><span>得分:</span><span>{$shouciceping.yingyu.score}</span></p> {else} <a href="/?s=tiku&c=generate&m=first&p={base64_encode('yingyu')}">立即测评</a> {/if} </div> </div> </div> <div> <div> <p>数学</p> <p>首次测评</p> <div class="flex-a-j-c flex-d-c"> {if $shouciceping.shuxue.is_complete} <p><i></i><span>完成时间:{date('Y-m-d',$shouciceping.shuxue.complete_time)}</span></p> <p><i></i><span>得分:</span><span>{$shouciceping.shuxue.score}</span></p> {else} <a href="/?s=tiku&c=generate&m=first&p={base64_encode('shuxue')}">立即测评</a> {/if} </div> </div> </div> <div> <div> <p>逻辑</p> <p>首次测评</p> <div class="flex-a-j-c flex-d-c"> {if $shouciceping.luoji.is_complete} <p><i></i><span>完成时间:{date('Y-m-d',$shouciceping.luoji.complete_time)}</span></p> <p><i></i><span>得分:</span><span>{$shouciceping.luoji.score}</span></p> {else} <a href="/?s=tiku&c=generate&m=first&p={base64_encode('luoji')}">立即测评</a> {/if} </div> </div> </div> <div> <div> <p>写作</p> <p>首次测评</p> <div class="flex-a-j-c flex-d-c"> {if $shouciceping.xiezuo.is_complete} <p><i></i><span>完成时间:{date('Y-m-d',$shouciceping.xiezuo.complete_time)}</span></p> <p><i></i><span>得分:</span><span>{$shouciceping.xiezuo.score}</span></p> {else} <a href="/?s=tiku&c=generate&m=first&p={base64_encode('xiezuo')}">立即测评</a> {/if} </div> </div> </div> </div> </div> <div> <div> <div> <div> <canvas id="myChart1" width="200" height="200"></canvas> </div> </div> </div> </div> <div> <div> <div> <div> <ul> <li>英语</li> <li>数学</li> <li>逻辑</li> <li>写作</li> </ul> <div> <p>题目</p> <ul> <li> <p>It is on tnese occasions that we become tense, we feel pressured, overwhelmed, in astate of stress.</p> <a href="javascript:;">查看详情</a> </li> <li> <p>It is on tnese occasions that we become tense, we feel pressured, overwhelmed, in astate of stress.</p> <a href="javascript:;">查看详情</a> </li> </ul> </div> <div> <ul> <li><a href="javascript:;">上一页</a></li> <li><a href="javascript:;">1</a></li> <li><a href="javascript:;">2</a></li> <li><a href="javascript:;">3</a></li> <li><a href="javascript:;">下一页</a></li> </ul> </div> </div> </div> </div> </div> <div> <div> <div> <div> <form method="POST" name="{MEMBER_URL}&c=account&m=userinfo1"> <div> <p>基本信息</p> <input type="submit" value="保存" > <input type="reset" value="取消" > </div> <div> <ul> <li> <label>我的昵称</label> <input type="text" id="nickname" name="nickname" value="{$member.name}"> </li> <li> <label>我的性别</label> <label ><a href="javascript:;" id="nan" {if $member.xingbie==1}{/if}>男生</a></label> <label style="margin-left:5px;"><a href="javascript:;" id="nv" {if $member.xingbie==0}{/if}>女生</a></label> </li> <li> <label>我的简介</label> <textarea id="jianjie" name="jianjie">{$member.jianjie}</textarea> </li> </ul> </div> </form> </div> </div> </div> </div> <script> $('#nan').click(function(){ if($("#nan").hasClass("active")){ $("#nan").removeClass("active"); $("#nv").addClass("active"); }else{ $("#nan").addClass("active"); $("#nv").removeClass("active"); } }); $('#nv').click(function(){ if($("#nv").hasClass("active")){ $("#nv").removeClass("active"); $("#nan").addClass("active"); }else{ $("#nv").addClass("active"); $("#nan").removeClass("active"); } }); $("form").submit(function(e){ var nickname= $("#nickname").val(); if($("#nan").hasClass("active")){ var xingbie =1; }else{ var xingbie =0; } var jianjie = $("#jianjie").val(); $.ajax({ type: "post", data: {"nickname":nickname,"xingbie":xingbie,"jianjie":jianjie}, dataType: "json", url:'/?s=member&c=account&m=userinfo1', success: function(data){ alert(data); return false; }, error:function(data){ alert(data); return false; } }); return false; }); </script> <div> <div> <div> <div> <div> <p>登陆密码</p> </div> <div> <form id="password_form" method="POST" action="{MEMBER_URL}&c=account&m=password"> <ul> <li> <label>原密码</label> <input type="password" name="password"> </li> <li> <label>新密码</label> <input type="password" name="password1"> </li> <li> <label>重输新密码</label> <input type="password" name="password2"> </li> <li> <input type="submit" value="保存"> </li> </ul> </form> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> <div> <div> <i></i> <p>每周累计签到送专硕币</p> <p>本周你已签到</p> <div class="info flex-j-sa"> <a href="javascript:;">1天</a> <a href="javascript:;">2天</a> <a href="javascript:;"> 3天 <span>+5个<br>专硕币</span> </a> <a href="javascript:;">4天</a> <a href="javascript:;"> 5天 <span>+20个<br>专硕币</span> </a> </div> <a href="javascript:qiandao();">立即签到</a> </div> </div> <script> function qiandao(){ var uid = {$member.uid}; var alreadysigndays = "{$alreadysigndays}"; var yonghuming = "{$yonghuming}"; var nowsigndays = 0; switch (alreadysigndays) { case 1: nowsigndays =2; break; case 2: nowsigndays =3; break; case 3: nowsigndays =4; break; case 4: nowsigndays =5; break; default: nowsigndays =1; } $(".lxdlts").text(nowsigndays); $(".qiandao").text('今日已签到'); $(".qiandao").css("background-color","grey"); switch (alreadysigndays) { case 1: $(".day2").css("background-color","#9dc451"); break; case 2: $(".day3").css("background-color","#9dc451"); break; case 3: $(".day4").css("background-color","#9dc451"); break; case 4: $(".day5").css("background-color","#9dc451"); break; default: $(".day1").css("background-color","#9dc451"); } $.ajax({ type: "post", data: {"user_id":uid,"lxdlts":nowsigndays,"yonghuming":yonghuming}, dataType: "json", url:'/?s=member&c=home&m=sign', success: function(data){ alert(data); return false; }, error:function(data){ alert(data); return false; } }); } </script> <script src="https://cdn.bootcss.com/layer/3.1.0/layer.js"></script> <script src="{HOME_THEME_PATH}js/bootstrap.min.js"></script> <script> $(function () { // 个人中心菜单切换 $(".member-tab li").click(function () { var index = $(this).index(); $(this).addClass("active").siblings("li").removeClass("active"); $(".member-list > div").eq(index).addClass("active").siblings("div").removeClass("active") }); // 弹窗开启关闭 $(".sign-in-btn").click(function () { $(".sign-in-layer").show() }); $(".sign-in-layer .close").click(function () { $(".sign-in-layer").hide() }) }) </script> <script src="{HOME_THEME_PATH}js/jquery.iframe-transport.js"></script> <script src="{HOME_THEME_PATH}js/jquery.ui.widget.js"></script> <script src="{HOME_THEME_PATH}js/jquery.fileupload.js"></script> <script> var ctx = document.getElementById("myChart1").getContext('2d'); var myChart = new Chart(ctx, { type: 'radar', data: { labels: ['完形填空', '长短句', '并列结构', '语法','阅读理解', '单词'], datasets: [{ label: "英语", data: [6, 7, 3, 5, 8, 6], fill:true,"backgroundColor":"rgba(157, 196, 81, 0.4)", pointBackgroundColor:"rgba(157, 196, 81)" } ] }, options:{ legend: { display: true, labels: { fontColor: '#666', fontSize:16 } }, scale: { fontColor: '#ffffff', ticks: { display: false, beginAtZero: true, suggestedMax: 10, stepSize: 2 }, gridLines: { color: '#d6d6d6' } } } }); $('#imageupload').change(function(){ var file = $(this)[0].files[0]; if(/image/.test(file.type)){ var reader = new FileReader(); console.log(reader); reader.onload = function(){ avatar_update(reader.result); } reader.readAsDataURL(file); }else{ layer.msg('请上传有效图片文件'); } }); function avatar_update(image){ $.ajax({ url:"/?c=api&m=data2&auth={md5('9d9adddb5d5b7afab0ee58bd2b6b03d5')}¶m=update_avatar", data:{ uid: {$member.uid}, file: image }, dataType:"json", type:"POST", success: function(res) { if(res.code) { layer.msg('上传成功'); setTimeout(function(){ location.reload() },3000); } else { layer.msg('上传失败'); } }, error: function() { layer.msg('网络错误'); } }); } /*jslint unparam: true */ /*global window, $ */ // $(function () { // 'use strict'; // var url = "{MEMBER_URL}&c=account&m=upload"; // $('.fileupload').fileupload({ // url: url, // dataType: 'json', // done: function (e, data) { // $.each(data.result.files, function (index, file) { // $('<p/>').text(file.name).appendTo('#files'); // }); // console.log(data); // }, // progressall: function (e, data) { // var progress = parseInt(data.loaded / data.total * 100, 10); // $('#progress .progress-bar').css( // 'width', // progress + '%' // ); // } // }); // .prop('disabled', !$.support.fileInput) // .parent().addClass($.support.fileInput ? undefined : 'disabled'); // }); </script> <script src="{SITE_URL}statics/js/dayrui.js"></script> <script src="{SITE_URL}statics/js/dialog-plus.js"></script> </body> </html>
<?php if (!defined('BASEPATH')) exit('No direct script access allowed'); /* v3.1.0 */ class Home extends M_Controller { /** * 构造函数 */ public function __construct() { parent::__construct(); } /** * 首页 */ public function index() { // 登录验证 $url = dr_member_url('login/index', array('backurl' => urlencode(dr_now_url()))); !$this->uid && $this->member_msg(fc_lang('会话超时,请重新登录').$this->member_model->logout(), $url); $this->load->library('dip'); $this->template->assign(array( 'indexu' => 1, 'invite' => dr_get_invite($this->uid, 'username'), 'invite_url' => dr_member_url('register/index', array('uid' => $this->uid, 'invite' => $this->member['username'])), )); $this->template->display(IS_AJAX ? 'main.html' : 'index.html'); } public function sign(){ $user_id = $this->input->post('user_id'); //今天签到后的签到次数 $lxdlts = $this->input->post('lxdlts'); $yonghuming = $this->input->post('yonghuming'); $currenttime = time(); //判断是否签到过 $sign_yes_not = $this->db->select('*')->get_where("mt_1_form_jifenbiao",array('user_id' => $user_id))->row_array(); // exit(json_encode($sign_yes_not)); if($sign_yes_not){ //当前专硕币数量 $lishizhuanshuobi = $sign_yes_not['zhuanshuobi']; //根据累计签到次数,计算会员新的专硕币数量 switch ($lxdlts) { case 1: $zhuanshuobi = $lishizhuanshuobi; break; case 2: $zhuanshuobi = $lishizhuanshuobi; break; case 3: $zhuanshuobi = $lishizhuanshuobi+5; break; case 4: $zhuanshuobi = $lishizhuanshuobi; break; default: $zhuanshuobi = $lishizhuanshuobi+15; } $result_sign = $this->db ->set(array( 'lxdlts' => $lxdlts, "zhuanshuobi"=> $zhuanshuobi, "zhqdsj"=>$currenttime )) ->where('user_id',$user_id) ->update('mt_1_form_jifenbiao'); }else{ $data = array( //签到人id "user_id"=>$user_id, //签到人用户名 "yonghuming"=>$yonghuming, //连续签到次数 "lxdlts"=>$lxdlts, //签到时间 "zhqdsj"=>$currenttime, "zhuanshuobi"=> 0 ); $result_sign = $this->db->insert('mt_1_form_jifenbiao', $data); } if($result_sign){ exit(json_encode("恭喜您签到成功")); } } }