|
- <?php
- header("Content-type:text/html; charset=utf-8");
- require_once '../Common/Config.php';
- require_once '../Common/Function.php';
- require_once "jssdk.php";
- $pdo = new PDO("sqlsrv:Server=".HOST.";Database=".DB, USER, PASSWORD);//5.6版本pdo连接sqlsrv
- if ($_POST){
- $openid= htmlspecialchars($_POST['openid']);
- $fromOpenid=htmlspecialchars($_POST['fromOpenid']);
- $tel=htmlspecialchars($_POST['tel']);
- /* $openid="oCVcbv1udkL4iZm-t1h8YMrMDSyU2";
- $tel="13025822222";
- $fromOpenid=''; */
- $sql="SELECT id FROM lottery_user WHERE openId='".$openid."'";
-
- $result=$pdo->query($sql);
- $rowset = $result->fetchAll(PDO::FETCH_ASSOC);
- $errinfo=$pdo->errorInfo();
- if (!$rowset){
- $sql="SELECT TOP 1 id,lotteryCode FROM lottery_code";
- $result=$pdo->query($sql);
- $rowset = $result->fetchAll(PDO::FETCH_ASSOC);
- $errinfo=$pdo->errorInfo();
- if ($errinfo[0] =="00000"){
- $lotteryCode=$rowset[0]['lotteryCode'];
- $id=$rowset[0]['id'];
- //$id=2;
- $sql="INSERT INTO lottery_user(openId,tel,createtime) VALUES('".$openid."','".$tel."','".date("Y-m-d H:i:s",time())."')";
- $result=$pdo->exec($sql);
- $sql="INSERT INTO lottery_friends(openId,friendsOpenId,lotteryCode,createtime) VALUES('".$openid."','".$fromOpenid."',".$lotteryCode.",'".date("Y-m-d H:i:s",time())."')";
-
- $result=$pdo->exec($sql);
- $sql="DELETE FROM lottery_code WHERE id=".$id;
- $result1=$pdo->exec($sql);
- if ($result && $result1 !==false){
- echo json_encode(array("errorcode"=>0,"errorinfo"=>"报名成功"));
- if ($fromOpenid !=''){
- $fsql="SELECT id FROM lottery_user WHERE openId='".$fromOpenid."'";
- $fresult=$pdo->query($fsql);
- $frowset = $fresult->fetchAll(PDO::FETCH_ASSOC);
- $errinfo=$pdo->errorInfo();
- if ($frowset){
- $icodesql="SELECT TOP 1 id,lotteryCode FROM lottery_code";
- $icoderesult=$pdo->query($icodesql);
- $icoderowset = $icoderesult->fetchAll(PDO::FETCH_ASSOC);
- //$icodeerrinfo=$pdo->errorInfo();
- if ($icoderowset){
- $iid=$icoderowset[0]['id'];
- $icode=$icoderowset[0]['lotteryCode'];
- $isql="INSERT INTO lottery_friends(openId,lotteryCode,createtime) VALUES('".$fromOpenid."',".$icode.",'".date("Y-m-d H:i:s",time())."')";
- $iresult=$pdo->exec($isql);
- $dsql="DELETE FROM lottery_code WHERE id=".$iid;
- $iresult=$pdo->exec($dsql);
- }
-
- }
- }
- exit;
- }else{
- echo json_encode(array("errorcode"=>1,"errorinfo"=>"报名失败"));exit;
- }
- }else{
- echo json_encode(array("errorcode"=>2,"errorinfo"=>"抽奖码已发完"));exit;
- }
- }else{
- echo json_encode(array("errorcode"=>3,"errorinfo"=>"微信号已经报名"));exit;
- }
- }
- if (isset($_GET['openId'])){
- $openId=$_GET['openId'];
- //$openId="oCVcbv1udkL4iZm-t1h8YMrMDSyU";
- $sql="SELECT id,tel,sharTimeLine,lotteryCode FROM lottery_user WHERE openId='{$openId}'";
-
- //$pdo=new PDO("mysql:host=".HOST.";dbname=".DB,USER,PASSWORD); //7.0版本pdo连接mysql
- $result=$pdo->query($sql);
- $rowset = $result->fetchAll(PDO::FETCH_ASSOC);
- $errinfo=$pdo->errorInfo();
- if($rowset){
- $htmlTel=$rowset[0]['tel'];
-
- $codeSql="SELECT lotteryCode FROM lottery_friends WHERE openId='{$openId}'";
-
- //$pdo=new PDO("mysql:host=".HOST.";dbname=".DB,USER,PASSWORD); //7.0版本pdo连接mysql
- $codeResult=$pdo->query($codeSql);
- $codeRowset = $codeResult->fetchAll(PDO::FETCH_ASSOC);
- if ($codeRowset){
- $htmlCode="";
- foreach ($codeRowset as $v){
- $htmlCode.=$v['lotteryCode'].",";
- }
- $htmlCode=rtrim($htmlCode,",");
- }
- //$htmlCode=$rowset[0]['lotteryCode'];
- $sharTimeLine=$rowset[0]['sharTimeLine'];
- $updateId=$rowset[0]['id'];
- $jssdk = new JSSDK(APPID, APPSECRET);
- $signPackage = $jssdk->GetSignPackage();
-
- $news = array(
- "Title" =>"【免费巴士自由行】千岛湖、普陀山共10名额 蜘蛛出行请你玩",
- "Description"=>"【蜘蛛出行微信上线啦~】千岛湖、普陀山巴士自由行各5个免单名额相送!关注我们预定安全舒适便捷的巴士出行 : D",
- "PicUrl" =>'https://mmbiz.qlogo.cn/mmbiz/xVqMASLIx1nE5XSsicXcM1znAqdS9rBA8W1GgS55lnu0fRR1AgsyzRiaTb5ANLVhrtdQ6FFEjFpypPVuylpH1kVQ/0?wx_fmt=jpeg',
- "Url" =>'http://xmwxc.zhizhuchuxing.cn/wechat/jssdk/activity.php');
- $sharfriendArr=array("url"=>'http://xmwxc.zhizhuchuxing.cn/wechat/jssdk/activity.php?fromOpenId='.$openId);
- }else {
- $infoUrl="http://".$_SERVER['HTTP_HOST']."/wechat/jssdk/activity.php?openId=".$openId;
- Header("Location: $infoUrl");
- exit();
- }
-
- }else if(!isset($_GET['code'])){
- $selfUrl=urlencode("http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
- $getCodeUrl="https://open.weixin.qq.com/connect/oauth2/authorize?appid=".APPID."&redirect_uri=".$selfUrl."&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect";
- Header("Location: $getCodeUrl");
- exit();
- }else{
- $code=$_GET['code'];
- $getOpenidUrl="https://api.weixin.qq.com/sns/oauth2/access_token?appid=".APPID."&secret=".APPSECRET."&code=".$code."&grant_type=authorization_code";
- $response=http_request($getOpenidUrl);
- $openIdObj=json_decode($response);
- $openId=$openIdObj->openid;
- $url="http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']."&openId=".$openId;
- Header("Location: $url");
- exit;
- }
- ?>
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="UTF-8">
- <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport" />
- <title></title>
- <style>
- *{margin:0px;padding: 0px;font-family: "黑体";}
- .tishi2{width:100%;text-align: center;font-size:18px;line-height: 30px;margin-bottom:20px;}
- .page2moblie,.page2choujiang{width:100%;text-align: center;margin-bottom:5px;}
- .page2moblie span,.page2choujiang span{font-size: 16px;}
- .kjtime{width:100%;text-align: center;font-size: 18px;margin-top:20px;}
- .kjtime2{width:100%;text-align: center;font-size: 18px;margin-top:5px;margin-bottom: 10px;}
- .anniu2{width:90%;margin:auto;text-align: center;height: 35px;line-height: 35px;font-size: 18px;color: #FFFFFF;background: #33d6b0;margin-bottom: 10px;margin-top:15px;}
- .tishi3{margin-left:5%;font-weight: bold;text-align: left;margin-top:17px;}
- .tishi4{width:90%;margin:auto;font-size: 14px;margin-top:10px;line-height: 22px;}
- .zhizhulogo{width:100%;height: 136px;}
- .black{position: absolute;top:0;left: 0;background: #000000;opacity: 0.4;width:100%;}
- .tishi5{position: absolute;top:175px;left: 0;right: 0;margin:auto;background: #FFFFFF;width:66%;border-radius:5px;padding: 10px;padding-top:30px;padding-bottom:30px;font-size:15px;display: none;}
- .x{position: absolute;top:5px;right:5px; height: 20px;width:20px;text-align: center;line-height: 21px;font-size: 21px;background:#FF7E00;color:#FFFFFF;border-radius:2px;}
- .erweima{width:180px;margin-top:10px;}
- </style>
- </head>
- <body id="body">
- <div style="position: relative;">
- <div class="page2" id="page2">
- <div class="tishi2">
- <div style="margin-bottom:5px;width:90%;margin:auto;padding-top:85px;">您已成功参与蜘蛛出行免单活动!</div>
- <div style="text-align: center; font-size:15px;"><a href="http://mp.weixin.qq.com/s?__biz=MzIwNjI0MDAwOQ==&mid=502857775&idx=2&sn=1d04e2f10383af14cdd1a8481353e9ef&scene=1&srcid=05187fCeBZFiQD8IUOgrRN1R#rd" style="color: #33d6b0;">点击选择奖品>></a></div>
-
- <!--<div>免费千岛湖巴士自由行共5名额</div>
- <div style="font-size: 14px;">上海出发 不含住宿及门票</div>
- <div>免费普陀山巴士自由行共5名额</div>
- <div style="font-size: 14px;">上海出发 不含住宿及门票</div>-->
- <!--<a href="http://mp.weixin.qq.com/s?__biz=MzIwNjI0MDAwOQ==&mid=502857775&idx=2&sn=1d04e2f10383af14cdd1a8481353e9ef&scene=0&previewkey=m65GKbcndwwmEE8v%2FfjGRcwqSljwj2bfCUaCyDofEow%3D#wechat_redirect">
- <img style="height: 277px;width:100%;" src="img/lotop.png"/>
- </a>-->
- </div>
- <div class="page2moblie" style="margin-bottom:63px;">
- <span>手机号:</span>
- <span id="moblienum2"><?php echo $htmlTel; ?></span>
- </div>
- <div id="cjm">
-
- <div class="page2choujiang">
- <div style="margin-bottom:20px;">你的抽奖码:</div>
- <div id="choujiangma" style="width:90%;margin-left:5%;padding-right:5%; word-wrap: break-word; word-break: break-all;"><?php echo $htmlCode;?></div>
- </div>
- <?php
- /* foreach ($codeRowset as $v){
- echo "<div class='page2choujiang'><span>抽奖码:</span><span>".$v['lotteryCode']."</span></div>";
- } */
- ?>
- </div>
- <div class="anniu2" id="anniu2">多要一个抽奖码</div>
- <!--<div class="anniu2" id="anniu3">再拿一个大红包</div>-->
- <div class="tishi3" style="margin-top:30px;">开奖时间:</div>
- <div class="tishi4" >2016年5月23日 周一 18:00</div>
- <div class="tishi3">温馨提示:</div>
- <div class="tishi4" >长按下方二维码关注我们,获取中奖提醒;若开奖时未关注蜘蛛出行,中奖视为无效。</div>
- <!-- <div class="tishi4" >2.点击上方[再拿一个大红包],成功邀请2位好友参与,奖励一个大红包!红包数量有限,先到先得哦!</div>-->
- <div style="margin:0 auto;text-align: center;">
- <img class="erweima" src="../Public/images/erweima.jpg" alt="" />
- <img class="zhizhulogo" style="width:300px;" src="../Public/images/zhizhulogo.png" alt="" />
- </div>
- </div>
- <div class="black" id="black"></div>
- <div class="tishi5" id="tishi5">
- <div class="x" id="x">×</div>
- <div id="content"></div>
- </div>
- </div>
- </body>
- <script>
- var anniu3=document.getElementById("anniu3");
- var anniu2=document.getElementById("anniu2");
- var tishi5=document.getElementById("tishi5");
- var black=document.getElementById("black");
- var body=document.getElementById("body");
- var x=document.getElementById("x");
- var content=document.getElementById("content");
- var H=document.documentElement.clientHeight;
-
- black.style.height=H+"px";
- black.style.display="none";
- var banmove=function(ev){ev.preventDefault();}
- anniu2.onclick=function(){
- window.scrollTo(0,0);
- body.addEventListener("touchmove",banmove);
- body.style.height=H+'px';
- body.style.overflow="hidden";
- black.style.display="block";
- tishi5.style.display="block";
- content.innerHTML="点击右上角【···】,选择【分享朋友圈】,分享成功,您即多获得一个抽奖码;<br>选择【发送给朋友】每邀请一位好友报名成功,再额外获得一个抽奖码!"
- }
- /* anniu3.onclick=function(){
- body.style.overflow="hidden";
- black.style.display="block";
- tishi5.style.display="block";
- content.innerHTML="点击右上角【···】,选择【发送给朋友】邀请两位好友报名成功,您即可领取红包!共190份红包,先到先得!"
- } */
- x.onclick=function(){
- body.removeEventListener("touchmove",banmove);
- tishi5.style.display="none";
- black.style.display="none";
- body.style.overflow="scroll";
- }
- </script>
-
- <script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
- <script src="../Public/js/jquery-1.12.3.min.js"></script>
- <script>
- /*
- * 注意:
- * 1. 所有的JS接口只能在公众号绑定的域名下调用,公众号开发者需要先登录微信公众平台进入“公众号设置”的“功能设置”里填写“JS接口安全域名”。
- * 2. 如果发现在 Android 不能分享自定义内容,请到官网下载最新的包覆盖安装,Android 自定义分享接口需升级至 6.0.2.58 版本及以上。
- * 3. 常见问题及完整 JS-SDK 文档地址:http://mp.weixin.qq.com/wiki/7/aaa137b55fb2e0456bf8dd9148dd613f.html
- *
- * 开发中遇到问题详见文档“附录5-常见错误及解决办法”解决,如仍未能解决可通过以下渠道反馈:
- * 邮箱地址:weixin-open@qq.com
- * 邮件主题:【微信JS-SDK反馈】具体问题
- * 邮件内容说明:用简明的语言描述问题所在,并交代清楚遇到该问题的场景,可附上截屏图片,微信团队会尽快处理你的反馈。
- */
- wx.config({
- debug: false,
- appId: '<?php echo $signPackage["appId"];?>',
- timestamp: <?php echo $signPackage["timestamp"];?>,
- nonceStr: '<?php echo $signPackage["nonceStr"];?>',
- signature: '<?php echo $signPackage["signature"];?>',
- jsApiList: [
- // 所有要调用的 API 都要加到这个列表中
- //'checkJsApi',
- 'onMenuShareTimeline',
- 'onMenuShareAppMessage'
- ]
- });
- wx.ready(function () {
-
- //检查是否支持jsApi
- /* wx.checkJsApi({
- jsApiList: [
- 'onMenuShareTimeline',
- 'onMenuShareAppMessage'
-
-
- ],
- success: function (res) {
- //alert(1);
- alert(JSON.stringify(res));
- }
- }); */
-
-
- // 在这里调用 API
-
- wx.onMenuShareTimeline({ //分享到朋友圈
- title: '<?php echo $news['Title'];?>',
- link: '<?php echo $news['Url'];?>',
- imgUrl: '<?php echo $news['PicUrl'];?>',
- trigger: function (res) {
- // 不要尝试在trigger中使用ajax异步请求修改本次分享的内容,因为客户端分享操作是一个同步操作,这时候使用ajax的回包会还没有返回
- // alert('用户点击分享到朋友圈');
-
- },
- success: function (res) {
- alert("分享成功");
- var url="http://xmwxc.zhizhuchuxing.cn/wechat/jssdk/lottery.php";
- $.ajax({
- type:'post',
- async:false,
- cache:false,
- data:{
- method:"shareTimeLine",
- sharTimeLine:<?php echo $sharTimeLine;?>,
- updateId:<?php echo $updateId;?>,
- openId:'<?php echo $openId;?>'
- },
- url : url,
- success : function(data) {
- window.location.href = "http://xmwxc.zhizhuchuxing.cn/wechat/jssdk/lotteryinfo.php?openId=<?php echo $openId;?>";
- },
- error : function() {
- alert('fail');
- }
- });
- },
- cancel: function (res) {
- alert('已取消');
- },
- fail: function (res) {
- // alert(JSON.stringify(res));
- }
- });
-
-
-
- wx.onMenuShareAppMessage({ //分享给朋友
- title: '<?php echo $news['Title'];?>',
- desc: '<?php echo $news['Description'];?>',
- link: '<?php echo $sharfriendArr['url']?>',
- imgUrl: '<?php echo $news['PicUrl'];?>',
- trigger: function (res) {
- // 不要尝试在trigger中使用ajax异步请求修改本次分享的内容,因为客户端分享操作是一个同步操作,这时候使用ajax的回包会还没有返回
- // alert('用户点击发送给朋友');
- },
- success: function (res) {
- alert('已分享');
- //alert(JSON.stringify(res));
- },
- cancel: function (res) {
- // alert('已取消');
- },
- fail: function (res) {
- // alert(JSON.stringify(res));
- }
- });
- /* wx.hideMenuItems({
-
- menuList: [
- 'menuItem:share:appMessage',
- 'menuItem:share:timeline',
- 'menuItem:copyUrl'
- ] // 要隐藏的菜单项,只能隐藏“传播类”和“保护类”按钮,所有menu项见附录3
-
- }); */
-
- });
-
-
- </script>
- </html>
|