active.php 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545
  1. <link href="/css/active/hdx.min.css?version=<?= $this->context->version ?>" rel="stylesheet" type="text/css">
  2. <style type="text/css">
  3. #event_content img {
  4. max-width: 100% !important;
  5. height: auto !important;
  6. }
  7. .navbar-fixed-bottom {
  8. border-top: 1px solid #bcbcbc;
  9. box-sizing: border-box;
  10. height: 50px;
  11. z-index:90;
  12. }
  13. .navbar-bottom-small {
  14. background: #fff;
  15. }
  16. .navbar-bottom-small a.btn {
  17. padding-top: 5px;
  18. height: 50px;
  19. color: #999999
  20. }
  21. .navbar-bottom-small a.btn span {
  22. margin-right: 0px;
  23. }
  24. #reg_event_btn_enabled {
  25. height: 50px;
  26. line-height: 50px;
  27. padding: 0;
  28. }
  29. .open-app-img {
  30. width: 20px;
  31. }
  32. .navbar-bottom-small:nth-of-type(1) {
  33. border-right: 1px solid #bcbcbc;
  34. }
  35. @media all and (max-width:400px) {
  36. .modal.pay-complete.in .modal-dialog {
  37. width: 100% !important;
  38. }
  39. }
  40. @media all and (max-width:320px) {
  41. .modal.pay-complete.in .go-ticket {
  42. padding-top: 220px !important;
  43. }
  44. }
  45. @media all and (min-width:350px) and (max-width:400px) {
  46. .modal.pay-complete.in .modal-dialog {
  47. width: 350px !important;
  48. }
  49. }
  50. @media all and (min-width:401px) and (max-width:450px) {
  51. .modal.pay-complete.in .modal-dialog {
  52. width: 85% !important;
  53. }
  54. }
  55. .activeContent {
  56. position: relative;
  57. margin-top: 15px;
  58. z-index:1;
  59. }
  60. .activeContent img{
  61. width:100%;
  62. }
  63. </style>
  64. <div name="activeBeCenterMask" class="xhMask" ></div>
  65. <div name="activeBeCenter" class="xhBeCenterBox" style="border-radius:3px;z-index:1040">
  66. <div class="lay-body" id="J_MainBody" style="padding-top:0px;">
  67. <div style="text-align:right;" id="close"><img src="/images/close.png" style="margin-right:10px;margin-top:8px;" /></div>
  68. <div class="reg">
  69. <div class="reg-form" style="padding-top:3px;">
  70. <form action="" method="post">
  71. <div class="m-form reg-name">
  72. <input type="text" class="m-full-txt " id="J_name" name="activeName" placeholder="姓名">
  73. </div>
  74. <div class="m-form reg-phone">
  75. <input type="text" name="activeMobile" class="m-full-txt reg-phone-number J_Phone" placeholder="手机号">
  76. </div>
  77. <div class="m-form reg-msg">
  78. <input type="text" class="m-full-txt reg-msg-code" name="activeCode" id="J_mcode" placeholder="短信验证码">
  79. <button type="button" class="reg-phone-sure J_Code" getmobilemsgstatus="yes" name="activeCreateCode">
  80. <span name="getActiveCodeText">获取验证码</span>
  81. <span style="display:none;" name="reGetActiveCode"><i style="color:white;font-size:12px;">120</i>秒后重新获取</span>
  82. </button>
  83. </div>
  84. <div style="margin:0 5%;font-size:12px;color:red;" name="activeHint"></div>
  85. <div class="login-btn clearfix"><button type="button" onclick="registerInfo()" style="border-radius:3px;">确认报名</button></div>
  86. </form>
  87. </div>
  88. </div>
  89. </div>
  90. </div>
  91. <section class="event-details event-details2" id="event-details">
  92. <h1><?= $active['title'] ?></h1>
  93. <div class="org-name">
  94. <div style="clear: both;"></div>
  95. </div>
  96. <div class="text-right" style="padding: 8px 0 0;">
  97. <span>报名人数:<?= $active['applyNum'] ?></span>
  98. <!-- <span>报名:0</span> -->
  99. </div>
  100. <div class="event-info">
  101. <div>
  102. <span><span class="icon-time"></span>时间</span>
  103. <?php if(date("m月d日",$active['startTime']) == date("m月d日",$active['endTime'])){
  104. echo date("m月d日 H:i",$active['startTime']).' - '.date("H:i",$active['endTime']);
  105. }else{
  106. echo date("m月d日 H:i",$active['startTime']).' - '.date("m月d日 H:i",$active['endTime']);
  107. } ?>
  108. </div>
  109. <div class="place">
  110. <span><span class="icon-place"></span>地点</span><a href="http://api.map.baidu.com/geocoder?address=<?= $active['address'] ?>&output=html"><?= $active['address'] ?></a>
  111. <div class="icon-gps"></div>
  112. </div>
  113. <div style="border-bottom: 0;">
  114. <span><span class="icon-ticket"></span>票价</span> <span class="text-warning"><?php if($ticketClass['price'] > 0){ echo $ticketClass['price'].'元'; }else{ echo'免费'; }?></span>
  115. </div>
  116. </div>
  117. <div class="activeContent">
  118. <?= $active['content'] ?>
  119. </div>
  120. <section>
  121. <div id="event_content">
  122. <div id="home_event_description" class="home_event_summary">
  123. </div>
  124. </div>
  125. <div style="padding-bottom:45px;"></div>
  126. </section>
  127. <div id="event_register_step1">
  128. <div class="navbar-fixed-bottom btn-signup-lg">
  129. <div class="col-3 navbar-bottom-small">
  130. <a class="btn" href="<?= $this->context->frontUrl ?>/mobile/index?account=<?= $this->context->merchant['id'] ?>"> <img src="/images/active/openApp.png" class="open-app-img">
  131. <p style="font-size:12px;">首页</p>
  132. </a>
  133. </div>
  134. <div class="col-3 navbar-bottom-small">
  135. <?php if($this->context->merchant['id'] == 16063078666){ ?>
  136. <a href="http://www.fjglhs.com/" class="btn" name="eventFollowSpan">
  137. <?php }else{ ?>
  138. <a href="<?= $this->context->frontUrl ?>/mobile/index?account=<?= $this->context->merchant['id'] ?>" class="btn" name="eventFollowSpan">
  139. <?php } ?>
  140. <span class="icon-like-before" id="b_like"></span>
  141. <p style="font-size:12px;">关于我们</p>
  142. </a>
  143. </div>
  144. <?php if($this->context->isLogin){ ?>
  145. <!-- 还未报名 -->
  146. <?php if(empty($apply)){ ?>
  147. <!-- 没有手机号 -->
  148. <?php if(empty($user['mobile'])){ ?>
  149. <div id="fillUserInfo" class="col-6">
  150. <a href="javascript:void(0)" class="btn btn-primary" data-toggle="modal" style="padding:14px 0">我要报名</a>
  151. </div>
  152. <!-- 可以报名 -->
  153. <?php }else{ ?>
  154. <div id="activeApply" class="col-6">
  155. <a href="javascript:void(0)" class="btn btn-primary" data-toggle="modal" style="padding:14px 0">我要报名</a>
  156. </div>
  157. <?php } ?>
  158. <!-- 已经报过名 -->
  159. <?php }else{ ?>
  160. <div class="col-6">
  161. <a href="javascript:void(0)" class="btn btn-primary" data-toggle="modal" style="padding:14px 0">已经报名</a>
  162. </div>
  163. <?php } ?>
  164. <!-- 没有登陆 -->
  165. <?php }else{ ?>
  166. <div class="col-6" onclick="goToLogin('<?= $_SERVER['REQUEST_URI'].'&wantLogin=yes' ?>')">
  167. <a href="javascript:void(0)" class="btn btn-primary" data-toggle="modal" style="padding:14px 0">我要报名</a>
  168. </div>
  169. <?php } ?>
  170. </div>
  171. <div class="modal fade ticket-modal ticket-modal-bottom in" id="ticket-modal" data-scroll="true" aria-hidden="false" style="display:none; transform-origin: 0px 0px 0px; opacity: 1; transform: scale(1, 1);">
  172. <div class="modal-dialog">
  173. <div class="modal-content">
  174. <h3 class="modal-header">
  175. 活动信息
  176. <div class="close" name="activeClose" data-dismiss="modal"><span class="icon-close-bubble"></span></div>
  177. </h3>
  178. <div class="media">
  179. <img class="pull-left" src="/images/active/cover2.jpg" alt="">
  180. <div class="media-body">
  181. <h4><?= $active['title'] ?></h4>
  182. <div><?= $active['address'] ?></div>
  183. <div><?= date("m月d日 H:i",$active['startTime']) ?></div>
  184. </div>
  185. </div>
  186. <div class="modal-body">
  187. <div id="">
  188. <div class="popover-box" id="event_tickets_area">
  189. <ul name="event_tickets_thumbs">
  190. <?php if($ticketClass['price'] > 0){ ?>
  191. <li class="class info active" style="padding-top:2px;padding-bottom:2px;"><div><div class="title">报名费</div><span class="text-primary"><?= floatval($ticketClass['price']) ?>元</span><p id="event_ticket_tips_0" style="display: block;"></p></div><b class="round-top"></b><b class="round-bottom"></b><b class="round-left"></b><b class="round-right"></b></li>
  192. <?php }else{ ?>
  193. <li class="class info active" style="padding-top:2px;padding-bottom:2px;"><div><div class="title">免费票</div><span class="text-primary">免费</span><p id="event_ticket_tips_0" style="display: block;"></p></div><b class="round-top"></b><b class="round-bottom"></b><b class="round-left"></b><b class="round-right"></b></li>
  194. <?php } ?>
  195. </ul>
  196. </div>
  197. <div class="clearfix" style="padding-top: 10px;">
  198. <div class="col-6" style="padding-right: 10px; display: none;" id="event_ticket_order_number">
  199. <select id="event_ticket_order_number_sel" class="simpleinput"><option value="1">1 张</option></select>
  200. </div>
  201. <div class="" id="event_ticket_order_btn">
  202. <button class="btn btn-primary btn-block" onclick="applyActive()">确认报名</button>
  203. </div>
  204. </div>
  205. </div>
  206. </div>
  207. </div>
  208. </div>
  209. </div>
  210. </div>
  211. </section>
  212. <script>
  213. <?php if($this->context->isWeixin){ ?>
  214. //微信分享
  215. var shareTitle = '<?= $active['title'] ?>';
  216. var descContent = '<?= $active['title'] ?>';
  217. var lineLink = '<?= Yii::$app->params['frontUrl'] ?>/pay/active?id=<?= $active['id'] ?>&account=<?= $this->context->merchant['id'] ?>&weixinShare=yes';
  218. var imgUrl = '<?= Yii::$app->params['imgUrl'].$this->context->merchant['logo'] ?>';
  219. wx.config({
  220. debug:false,
  221. appId: '<?= $this->context->signPackage['appId'] ?>',
  222. timestamp: <?= $this->context->signPackage['timestamp'] ?>,
  223. nonceStr: '<?= $this->context->signPackage['nonceStr'] ?>',
  224. signature: '<?= $this->context->signPackage['signature'] ?>',
  225. jsApiList: [
  226. 'checkJsApi',
  227. 'onMenuShareTimeline',
  228. 'onMenuShareAppMessage',
  229. 'onMenuShareQQ',
  230. 'onMenuShareWeibo',
  231. ]
  232. });
  233. wx.ready(function () {
  234. var shareData = {
  235. title: shareTitle,
  236. link: lineLink,
  237. imgUrl: imgUrl,
  238. desc:descContent,
  239. };
  240. wx.onMenuShareAppMessage(shareData);
  241. wx.onMenuShareTimeline({
  242. title: shareTitle,
  243. link: lineLink,
  244. imgUrl: imgUrl,
  245. desc:descContent,
  246. success: function () {
  247. //分享成功后的操作
  248. },
  249. cancel: function () {
  250. // 用户取消分享后执行的回调函数
  251. }
  252. });
  253. wx.onMenuShareQQ({
  254. title: shareTitle,
  255. link: lineLink,
  256. imgUrl: imgUrl,
  257. desc:descContent,
  258. success: function () {
  259. //分享成功后的操作
  260. },
  261. cancel: function () {
  262. // 用户取消分享后执行的回调函数
  263. }
  264. });
  265. wx.onMenuShareWeibo(shareData);
  266. });
  267. <?php } ?>
  268. var activeBeCenter = $("div[name=activeBeCenter]");
  269. var activeBeCenterMask = $("div[name=activeBeCenterMask]");
  270. var activeHeight = activeBeCenter.outerHeight();//取div标签的高宽
  271. var activeWidth = activeBeCenter.outerWidth();//取浏览器高宽
  272. var wWidth = $(window).width();
  273. var wHeight = $(window).height();
  274. var _scrollHeight = $(document).scrollTop();//获取当前窗口距离页面顶部高度
  275. var rH = (wHeight - activeHeight) / 2 + _scrollHeight;
  276. var rW = (wWidth - activeWidth) /2;
  277. activeBeCenter.css({"z-index":998,"position":"absolute","left":rW,"top":rH,});
  278. //验证流程
  279. var activeName = $("input[name=activeName]");
  280. var activeMobile = $("input[name=activeMobile]");
  281. var activeCode = $("input[name=activeCode]");
  282. var needValidate = [activeName,activeMobile,activeCode];
  283. setStats(activeName, '请填写姓名', function(val, mess){
  284. var info=[false, mess];
  285. if(val.length <= 0){
  286. info[1] = '请填写姓名';
  287. }else if(getLength(val) >=0 && getLength(val) <=40){
  288. info[0] = true;
  289. info[1] = '填写正确';
  290. }else{
  291. info[0] = false;
  292. info[1] = '填写错误';
  293. }
  294. return info;
  295. });
  296. setStats(activeMobile,'请填写手机号',function(val,msg){
  297. var info = [false,msg];
  298. val = $.trim(val);
  299. if(val.length <= 0){
  300. info[1] = '请填写手机号';
  301. }else if((/^1[0-9]\d{9}$/.test(val)) == false){
  302. info[1] = '手机号填写不正确';
  303. }else{
  304. $.ajax({type:"GET",url:"/active/mobile-not-use?account=<?= $this->context->merchant['id'] ?>&mobile="+val,dataType:'json',async:false,success:function(data){
  305. if(data.code == 'A0001'){
  306. info[0] = true;
  307. }else{
  308. info[1] = data.msg;
  309. }
  310. }});
  311. }
  312. return info;
  313. });
  314. setStats(activeCode, '请填写验证码', function(val, mess){
  315. var info=[false, mess];
  316. if(getLength(val) > 0){
  317. $.ajax({type:"GET",url:"/active/check-auth-code?account=<?= $this->context->merchant['id'] ?>&code="+val,dataType:'json',async:false,success:function(data){
  318. if(data.code == 'A0001'){
  319. info[0] = true;
  320. }else{
  321. info[1] = data.msg;
  322. }
  323. }});
  324. }else{
  325. info[1] = '请填写验证码';
  326. }
  327. return info;
  328. });
  329. function registerInfo()
  330. {
  331. var verifyStatus = true;
  332. for(var m=0;m<needValidate.length;m++){
  333. var singleObj = needValidate[m];
  334. if(singleObj.attr('activeinputstatus') == undefined){
  335. singleObj.blur();
  336. }
  337. if(singleObj.attr('activeinputstatus') == 'no'){
  338. verifyStatus = false;
  339. singleObj.blur();
  340. break;
  341. }
  342. }
  343. if(verifyStatus == false){
  344. return;
  345. }
  346. var data = "_csrf=<?= Yii::$app->request->csrfToken ?>&mobile="+activeMobile.val()+"&realName="+activeName.val()+"&code="+activeCode.val();
  347. $.ajax({
  348. type:"POST",
  349. url:'/active/register-info?account=<?= $this->context->merchant['id'] ?>',
  350. data:data,
  351. dataType:'json',
  352. async:false,
  353. success:function(data){
  354. if(data.code =='A0001'){
  355. applyActive();
  356. }
  357. }
  358. });
  359. }
  360. function setStats(obj,mess,check)
  361. {
  362. obj.focus(function(){
  363. $("div[name=activeHint]").html('');
  364. });
  365. obj.blur(function(){
  366. var objVal = obj.val();
  367. var info = check(objVal,mess);
  368. if(info[0]){
  369. $(this).attr('activeinputstatus','yes');
  370. $("div[name=activeHint]").html('');
  371. }else{
  372. $(this).attr('activeinputstatus','no');
  373. $("div[name=activeHint]").html(info[1]).css('color','red');
  374. }
  375. });
  376. }
  377. var activeCreateCode = $("button[name=activeCreateCode]");
  378. var getActiveCodeText = $("span[name=getActiveCodeText]");
  379. var reGetActiveCode = $("span[name=reGetActiveCode]");
  380. activeCreateCode.click(function(){//获取手机验证码
  381. var mobileVal = activeMobile.val();
  382. if(mobileVal.length <= 0){
  383. $("div[name=activeHint]").html('请填写手机号').css("color","red");
  384. }
  385. if(activeMobile.attr('activeinputstatus') == undefined){//手机未验证
  386. return;
  387. }
  388. if(activeMobile.attr('activeinputstatus') == 'no'){//手机验证未通过
  389. return;
  390. }
  391. //防止连续点击
  392. if(activeCreateCode.attr('clicked') == 'yes'){
  393. xhPopMsg('请稍候…',1600);
  394. return;
  395. }
  396. activeCreateCode.attr('clicked','yes');
  397. setTimeout(function(){
  398. activeCreateCode.attr('clicked','no');
  399. },3000);
  400. $("p[name=authCodeHint]").html('');
  401. if(activeCreateCode.attr('getMobileMsgStatus') == 'yes'){
  402. $.ajax({type:"GET",url:"/active/generate-auth-code?account=<?= $this->context->merchant['id']?>&mobile="+mobileVal,dataType:'json',async:false,success:function(data){
  403. if(data.code == 'A0001'){
  404. activeCreateCode.attr('getMobileMsgStatus','no');
  405. getActiveCodeText.css("display","none");
  406. reGetActiveCode.css("display","block").parent().css("background-color","#CCCCCC").css("border-color","#CCCCCC");
  407. var timeSupport = reGetActiveCode.find('i');
  408. var beginTimeNum = timeSupport.text();//记录一开始时间
  409. var timeNumDecrease = parseInt(beginTimeNum);//用于减少的时间
  410. var setInt = setInterval(function(){
  411. timeNumDecrease--;
  412. timeSupport.text(timeNumDecrease);
  413. if(timeNumDecrease == 0){
  414. clearInterval(setInt);
  415. getActiveCodeText.css('display','block').parent().css("background-color","#18a8df").css("border-color","#1590be");
  416. reGetActiveCode.css('display','none');
  417. timeSupport.text(beginTimeNum);
  418. activeCreateCode.attr('getMobileMsgStatus','yes');
  419. }
  420. },1200);
  421. }else{
  422. activeMobile.siblings('p').css("color","red").html(data.msg);
  423. }
  424. }});
  425. }
  426. });
  427. $("#apply").click(function(){
  428. activeBeCenter.css('display','block');
  429. activeBeCenterMask.css('display','block');
  430. });
  431. $("#close").click(function(){
  432. activeBeCenter.css('display','none');
  433. activeBeCenterMask.css('display','none');
  434. $('html').removeClass('noscroll');//去除浮层允许底部滚动
  435. });
  436. $("#activeApply").click(function(){
  437. $("#ticket-modal").css('display','block');
  438. activeBeCenterMask.css('display','block');
  439. $('html').addClass('noscroll');//有浮层不允许底部滚动
  440. });
  441. $("#fillUserInfo").click(function(){
  442. activeBeCenter.css('display','block');
  443. activeBeCenterMask.css('display','block');
  444. $('html').addClass('noscroll');//有浮层不允许底部滚动
  445. });
  446. $("div[name=activeClose]").click(function(){
  447. $("#ticket-modal").css('display','none');
  448. activeBeCenterMask.css('display','none');
  449. $('html').removeClass('noscroll');//允许底部滚动
  450. });
  451. <?php if($this->context->isWeixin){?>
  452. var appId,nonceStr,package,paySign,signType,timeStamp,orderId;
  453. //确定并开始走报名流程
  454. function applyActive()
  455. {
  456. var data = 'activeId=<?= $active['id'] ?>&_csrf=<?= Yii::$app->request->csrfToken ?>&classId=<?= $ticketClass['id'] ?>';
  457. $.ajax({type:"POST",url:'/active/apply?account=<?= $this->context->merchant['id'] ?>',data:data,dataType:'json',async:false,success:function(data){
  458. if(data.code == 'A0001'){
  459. if(data.data.fee == 'free'){
  460. xhPopMsg(data.msg);
  461. setTimeout(function(){
  462. window.location.href='<?= Yii::$app->params['frontUrl'] ?>/active/result?status=success&orderId='+data.data.orderId+'&account=<?= $this->context->merchant['id'] ?>';
  463. },1800);
  464. }else{
  465. appId = data.data.appId;
  466. nonceStr = data.data.nonceStr;
  467. package = data.data.package;
  468. paySign = data.data.paySign;
  469. signType = data.data.signType;
  470. timeStamp = data.data.timeStamp;
  471. orderId = data.data.orderId;
  472. if (typeof WeixinJSBridge == "undefined"){
  473. if( document.addEventListener ){
  474. document.addEventListener('WeixinJSBridgeReady', jsApiCall, false);
  475. }else if (document.attachEvent){
  476. document.attachEvent('WeixinJSBridgeReady', jsApiCall);
  477. document.attachEvent('onWeixinJSBridgeReady', jsApiCall);
  478. }
  479. }else{
  480. jsApiCall();
  481. }
  482. }
  483. }else{
  484. xhPopMsg(data.msg,2000);
  485. }
  486. }});
  487. }
  488. //调用微信JS api 支付
  489. function jsApiCall()
  490. {
  491. WeixinJSBridge.invoke(
  492. 'getBrandWCPayRequest', {
  493. "appId":appId, //公众号名称,由商户传入
  494. "timeStamp":timeStamp, //时间戳,自1970年以来的秒数
  495. "nonceStr" : nonceStr, //随机串
  496. "package" : package,
  497. "signType" : signType, //微信签名方式:
  498. "paySign" : paySign //微信签名
  499. },
  500. function(res){
  501. WeixinJSBridge.log(res.err_msg);
  502. //alert(res.err_code+'|'+res.err_desc+'|'+res.err_msg);
  503. if(res.err_msg == 'get_brand_wcpay_request:ok'){
  504. window.location.href='<?= Yii::$app->params['frontUrl'] ?>/active/result?status=success&orderId='+orderId+'&account=<?= $this->context->merchant['id'] ?>';
  505. }
  506. }
  507. );
  508. }
  509. <?php } ?>
  510. </script>