首頁 > php教程 > php手册 > WeMall微信商城簽到插件Sign的主要源碼

WeMall微信商城簽到插件Sign的主要源碼

WBOY
發布: 2016-10-11 14:01:52
原創
1825 人瀏覽過

WeMall微信商城源碼簽到插件Sign,用於商城的簽到系統,分享了部分比較重要的代碼,供技術員學習參考
WeMall微信商城源碼簽到插件Sign,用於商城的簽到系統,分享了部分比較重要的代碼,供技術員學習參考

AdminController.class.php<?php <?php<br /> <br> namespace AddonsSignController;<br> <br> class AdminController extends InitController<br> {<br> <br> <br>     public function __construct()<br>     {<br>         parent::__construct();<br>     }<br> <br>     public function index()<br>     {<br>         $config = M("AddonSignConfig")->find();<br>         $this->assign("config", $config);<br> <br>         $record = D(’Addons://Sign/AddonSignRecord’); // 實例化User物件<br> <br>         $count = $record->count();// 查詢符合要求的總記錄數<br>         $Page = new ThinkPage($count, 12);// 實例化分頁類別 傳入總記錄數與每頁顯示的記錄數(25)<br> $Page->setConfig('theme', "<div><ul> <li>%FIRST%</li> <li>%UP_PAGE%</li> <li>%LINK_PAGE%</li> <li>%DOWN_PAGE%</li> <li>%LINK_PAGE%</li> <li>%DOWN_PAGE%5%<a>% %TOTAL_PAGE % 頁</a> </li> </ul></div>");<br>         $show = $Page->show();// 分頁顯示輸出<br>         // 進行分頁資料查詢 注意limit方法的參數要使用Page類別的屬性<br>         $record = $record->limit($Page->firstRow . ’,’ . $Page->listRows)->order("id desc")->relation(truePage->listRows)->order("id desc")->relation(true)->se(); <br>         $this->assign("record", $record);// 賦值資料集<br>         $this->assign(’page’, $show);// 賦值分頁輸出<br> <br>         $this->display();<br>     }<br> <br>     public function addConfig()<br>     {<br>         M("AddonSignConfig")->where(array("id" => "1"))->save($_POST);<br>         $this->success(’修改成功’, ’Admin/Admin/index/addon/Sign’);<br>     }<br> }<br> IndexController.class.php namespace AddonsSignController;<?php <br /> <br> class IndexController extends InitController<br> {<br>     public $appUrl = "";<br>     public function __construct()<br>     {<br>         parent::__construct();<br>         $this->appUrl = "http://" . I("server.HTTP_HOST");<br>     }<br> <br>     public function init()<br>     {<br>         return R("App/Common/init");<br>     }<br> <br>     public function oauthRegister($wxuser)<br>     {<br>         return R("App/Common/oauthRegister", array($w​​xuser));<br>     }<br> <br>     public function index()<br>     {<br> <br>         $user = R("App/Public/oauthLogin");<br> <br>         // $user = M("User")->where(array("uid" => session("userUid")))->find();<br>         $contact = M("Contact")->where(array("user_id" => $user["id"]))->find();<br>         if ($contact) {<br>             $this->assign("contact", $contact);<br>         }<br>         $config = M("Config")->find();<br>         $this->assign("config", $config);<br>         $this->assign("user", $user);<br> <br>         $product = M("addonScore")->select();<br>         $this->assign("product", $product);<br>         $this->display();<br>     }<br> <br>     public function addOrder()<br>     {<br>         // $user = M("User")->where(array("uid" => session("userUid")))->find();<br>         $user = M("User")->where(array("id" => session("userId")))->find();<br>         $score = floatval($user["score"]) - floatval($_POST["score"]);<br>         if ($score >= 0) {<br>             M("User")->where(array("id" => $user["id"]))->save(array("score" => $score));<br>         } else {<br>             return;<br>         }<br> <br>         $userHas = M("Contact")->where(array("user_id" => session("userId")))->find();<br>         if ($userHas) {<br>            $contact [“id”] = $userHas [“id”];<br>             $contact [“user_id”] = session(“userId”);<br>             $contact [「姓名」] = $_POST [「姓名」];<br>             $contact [「電話」] = $_POST [「電話」];<br>             $contact [「地址」] = $_POST [「地址」];<br>             M("聯絡人")->儲存($contact);<br>         } 另外 {<br>             $contact [“user_id”] = session(“userId”);<br>             $contact [「姓名」] = $_POST [「姓名」];<br>             $contact ["城市"] = "";<br>             $contact ["區域"] = "";<br>             $contact [「電話」] = $_POST [「電話」];<br>             $contact [「地址」] = $_POST [「地址」];<br>             M("聯絡人")->add($contact);<br>         }<br>         $userHas = M("聯絡人")->where(array("user_id" => session("userId")))->find();<br>         $contact_id = $userHas["id"];<br> <br>         $data[“user_id”]=session(“userId”);<br>         $data [“contact_id”] = $contact_id;<br>         $data[“orderid”]=date(“ymdhis”)。 mt_rand(1, 9);<br>         $data [「總分」] = $_POST[「得分」];<br>         $data [「狀態」] = 0;<br>         $data [「註釋」] = $_POST [「註釋」];<br>         $data["時間"]=日期("年月日H:i:s");<br>         $data ["score_id"] = $_POST ["id"];<br>         $結果 = M("AddonScoreOrder")->add($data);<br>         如果($結果){<br>             $this->ajaxReturn($結果);<br>         }<br>     }<br>     公用函數sign(){<br>         $今天 = 日期("Y-m-d");<br>         $where["time"] = array("like", $today ."%");<br>         $where["user_id"] = session("userId");<br>         $record = D("Addons://Sign/AddonSignRecord")->where($where)->find();<br>         如果($記錄){<br>             $this->ajaxReturn(array("status" => 0));<br>             返回;<br>         }<br> <br>         $user = M("User")->where(array("id" => session("userId")))->find();<br> <br>         $計數 = 0;<br>         做{<br>             $count++;<br>             $昨天 = date("Y-m-d", strtotime("-$count day"));<br>             $where["time"] = array("like", $yesterday."%");<br>            $record = D("AddonSignRecord")->where($where)->find();<br>         } 同時($記錄);<br>         $continue_sign = $count-1;<br> <br>         $config = M("AddonSignConfig")->find();<br>         如果($config){<br>             $addScore = floatval($continue_sign) * floatval($config["continue_sign"]) + floatval($config["first_sign"]);<br>             M("AddonSignRecord")->add(array("user_id" => session("userId"), "score" => $addScore));<br> <br>             $score = floatval($user["score"]) + $addScore;<br>             M("User")->where(array("id" => $user["id"]))->save(array("score" => $score));<br>             $this->ajaxReturn(array("status" => 1, "score" => $addScore));<br>         }<br>     }<br> <br> }<b>Index_index.html</b><code class="prettyprint linenums lang-php">nbsp;html><br> <br> <br>     <meta> <br>     <meta> <br>     <meta> <br>     <title>簽到系統</title> <br>     <meta> <br>     <meta> <br>     <!-- apple devices fullscreen --><br>     <meta> <br>     <meta> <br>     <link> <br>     <link> <br>     <link> <br>     <link> <br>     <link> <br> <br> <br> <div> <br>     <div> <br>         <div> <br>             <div> <br>                 <div><img alt="WeMall微信商城簽到插件Sign的主要源碼" ></div> <br>                 <div> <br>                     <span>{$user.使用者名稱}</span><br>                     <span>會員ID:{$user.id}</span><br>                 </div> <br>             </div> <br>             <div> <br>                 <a>積分<span>{$user.score}</span></a><br>                 <a><span><span class="btn btn-default" onclick="signIn(this)"></span>                                                   style="color: #fff;background-color: transparent;border-color: #fff;">今日簽至</span></a><br>             </div> <br>         </div> <br>     </div> <br>     <div> <br>         <div> <br>             <ul> <br>                 <volist><br>                     <li> <br>                         <div> <br>                             <div> <br>                                 <h5>{$產品.                             </h5> <br>                             </div> <br>                                 <div> <br>                             <img alt="WeMall微信商城簽到插件Sign的主要源碼" ><br>                             </div> <br>                                 <div>點數<br>{..                                 <div><a>                                  的 style="color: black;">立即兌換</a></div>                                 <br><div>                             <a></a>                         <br><br>                     <br>                 <br>             <br>         </div> <br>     </div> <br>     <div></div> <br>     <div class="tc_c2" id="join_box"></div>          style="left:0px;bottom:0px;z-index:3000;position:fixed;display:none;width:100%;"><br>         <div> <br>             <div> <br>                 <div><img alt="WeMall微信商城簽到插件Sign的主要源碼" ></div> <br>             </div> <br>             <div> <br>                 <ul> <br>                     <li> <br>                         <div>姓名</div> <br>                         <div> <br>                             <input><br>                         </div> <br>                     </li> <br>                     <li> <br>                         <div>手機</div> <br>                         <div> <br>                             <input><br>                         </div> <br>                     </li> <br>                     <li> <br>                         <div>地址</div> <br>                         <div> <br>                             <input><br>                         </div> <br>                     </li> <br>                     <li> <br>                         <div>備註</div> <br>                         <div> <br>                             <input><br>                         </div> <br>                     </li> <br>                 </ul> <br>             </div> <br> <br>             <div> <br>                 <a title="返回" class="fanHui" href="javascript:void(0);" onclick="_joinBox._prev()"></a>v()"v()"<br>v()"<br>v()"<div>v()"<br>v()"<input>v()"<br>v()"<a></a>v()"v()"<br>v()"</div>v()"<br>v()"</div>v()"<br>v()"<br>v()"</div>v()"<br>v()"</div>v()"<br>v()"<br>v()"<div>v()"<br>v()"<div>v()"</div>v()"                    樣式=「顯示:無;」><br><div> </div>                 <br><div>                     <input id="input_submit" class="blueBtn" type="submit" value="我要報名」<button id=" alert_button_ok>                            style="顯示:無;寬度:100%;">                     <a style="寬度:100%;" class="blueBtnfont02" href="javascript:void(0);">);                        onclick="submitOrder()">提交<br><div>                 </div> <br>             </a> </div> <br> </div>         🎜🎜     🎜🎜 🎜     🎜🎜         🎜溫馨提示🎜🎜         🎜🎜🎜         🎜🎜知道了🎜🎜🎜         🎜🎜🎜     🎜🎜 🎜<br> <script></script><br> <script></script><br> <script><br /> var id = 0;<br /> var score = 0;<br /> function hidePop(){<br /> $("#join_box").hide();<br /> $("#cover2").hide();<br /> }<br /> function showPop(){<br /> $("#join_box").show();<br /> $("#cover2").show();<br /> }<br /> function doCart(obj , scoreIn ,idIn){<br /> if(parseFloat(scoreIn) > parseFloat($(’#myscore’).html())){<br /> alert("积分不足!");<br /> return;<br /> }<br /> id = idIn;<br /> score = scoreIn;<br /> showPop();<br /> }<br /> <br /> var signFlag = true;<br /> function signIn(obj){<br /> $.ajax({<br /> type: "post",<br /> url: "{:u_addons(’Sign://Index/sign’)}",<br /> data: {<br /> <br /> },<br /> success: function (data) {<br /> if(data){<br /> var json = eval(data)<br /> $("#alert").show();<br /> if (typeof json.score != "undefined") {<br /> $("#alert_text").html("恭喜您获得"+json.score+"积分");<br /> }else{<br /> $("#alert_text").html("对不起,您已签到!");<br /> }<br /> <br /> }<br /> },<br /> beforeSend: function () {<br /> <br /> },<br /> complete: function () {<br /> }<br /> <br /> });<br /> <br /> // $("#alert").show();<br /> }<br /> function hideAlert(){<br /> $("#alert").hide();<br /> location.reload();<br /> }<br /> var submitFlag = true;<br /> function submitOrder(){<br /> if (submitFlag == false) {<br /> alert("请不要重复操作!");<br /> return;<br /> };<br /> var name = $(’#name’).val();<br /> var phone = $(’#phone’).val();<br /> var address = $(’#address’).val();<br /> var note = $(’#note’).val();<br /> <br /> if (name.length == 0 || phone.length == 0 || address.length == 0) {<br /> alert("请核对输入的信息!");<br /> return;<br /> };<br /> submitFlag = false;<br /> <br /> $.ajax({<br /> type: "post",<br /> url: "{:u_addons(’Sign://Index/addOrder’)}",<br /> data: {<br /> name: name,<br /> phone: phone,<br /> id: id,<br /> score: score,<br /> address: address,<br /> note: note<br /> },<br /> success: function (data) {<br /> if(data){<br /> hidePop();<br /> alert("商品兑换成功!");<br /> location.reload();<br /> }<br /> },<br /> beforeSend: function () {<br /> <br /> },<br /> complete: function () {<br /> }<br /> <br /> });<br /> }<br /> </script><br> <br> <b> Admin_index.html</b><br> <br> <code class="prettyprint linenums lang-php"><section><br>     <h1> <br>         簽至管理<br>         <small></small><br>     </h1> <br> </section><br> <!-- Main content --><br> <section><br>     <div> <br>         <!-- /.col --><br>         <div> <br>             <div> <br>                 <div> <br>                     <h3>籤至管理</h3> <br>                     <!-- /.box-tools --><br>                 </div> <br>                 <!-- /.box-header --><br>                 <div> <br>                     <div> <br>                         <ul> <br>                             <li> <br>                                 <a>                             <i></i>                             <span></span>                                 </a><br>                             </li> <br>                         <li> <br>                     <a><br>                     <div> <br>                         <div> <br>                             <!-- <h3>簽至設定</h3> --><br> <br>                             <p><br>                             </p> <form></form> <br>                                  地 <div>                                  地                                                                                                          地                                 <br><label>                                 </label><br>                                  地 <br>                                  地                                  的                                                                       地<br>                                 </div> <br>                                 <div> <br>                                  地 <label>                                  地                                                                     的="text"></label>                                  地                                 <br><br>                                <!--  <div class="col-md-7"><br />                                  地🎠 <input class="form-control" placeholder=""<br />                                  地                                  的                                                                     地                                 <br /> --><br>                                 <div> <br>                                  地 <label>                                  地                                                                          Admin/index’)}’)"</label>                                                                       地                                  地                                  地                                 <br><br>                             <div> <br>                             <button></button><br>                         <br><br>                         <div> <br>                             <!-- <h3>簽至記錄中記錄</h3> --><br> <br>                             <p><br> <br>                             </p> <div> <br>                                 <table> <br>                                  地                                  地                                                                          <thead> <br><th>                                  地                                  地                                                                        地                                  地                                                                        地                                  地                                                                        地                                  地                                                                       地                                  地                                  地                                     <volist></volist> </th> </thead> </table> </div> </div> </div> </div> </div> </div> </div></a> </li> </ul> </div> </div> </div> </div> </div></section>

相關標籤:
來源:php.cn
上一篇:PHP流程控制结构之分支结构 下一篇:基於THINKPHP5 多微信開發框架,讓微信開發飛起來
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
作者最新文章
最新問題
關於CSS心智圖的課件在哪? 課件
來自於 2024-04-16 10:10:18
0
0
1779
相關專題
更多>
熱門推薦
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板