Authored by hf

Merge branch 'gamecoupon' into develop

  1 +<!DOCTYPE html>
  2 +<html>
  3 +<head>
  4 + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  5 + <meta charset="utf-8">
  6 + <title>{{staticTitle}}</title>
  7 + <meta name="apple-mobile-web-app-title" content="SUMMER SALE">
  8 + <meta name="format-detection" content="telephone=no">
  9 + <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no,minimal-ui" media="(device-height: 568px)">
  10 + <meta name="apple-mobile-web-app-capable" content="yes">
  11 + <meta name="apple-mobile-web-app-status-bar-style" content="grey">
  12 + <link rel="stylesheet" href="{{imgUrl}}/cuxiao/css/newyear/index.css">
  13 + <script>
  14 + (function(doc, win) {
  15 + var docEl = doc.documentElement;
  16 + (function() {
  17 + var clientWidth = docEl.clientWidth;
  18 + if (!clientWidth) {
  19 + return;
  20 + }
  21 + docEl.style.fontSize = 20 * (clientWidth / 320) + 'px';
  22 + }());
  23 + })(document, window);
  24 + </script>
  25 +</head>
  26 +<body class="keBody">
  27 +<div class="coupon-container" show="{{showPopupFlag}}">
  28 + <div class="coupon-top">
  29 + <img src="{{imgUrl}}/cuxiao/img/newyear/160105/top-bg.png" alt="">
  30 + <a class="go-check" href="{{myCouponUrl}}"></a>
  31 + <a class="app-btn app1" href="http://a.app.qq.com/o/simple.jsp?pkgname=com.yoho&g_f=995445"></a>
  32 + <a class="app-btn app2" href="http://www.yohoshow.com/about/index/yohoboysqr"></a>
  33 + </div>
  34 + <div class="coupon-bottom">
  35 + <div class="coupon-banner">
  36 + <a href="{{bannerUrl_1}}"></a>
  37 + <a href="{{bannerUrl_2}}"></a>
  38 + <a href="{{bannerUrl_3}}"></a>
  39 + <a href="{{bannerUrl_4}}"></a>
  40 + </div>
  41 + <a class="follow-yoho" href="http://mp.weixin.qq.com/s?__biz=MjM5ODI5MDA4MA==&amp;mid=201849402&amp;idx=1&amp;sn=c0089812f9769d82e0075f69d771f6e1#rd"></a>
  42 + <div class="bottom-btn">
  43 + <a class="play-again" href="javascript:;"></a>
  44 + <a class="share-btn" href="javascript:;"></a>
  45 + </div>
  46 + </div>
  47 + <div class="coupon-ft">
  48 + <img src="{{imgUrl}}/cuxiao/img/newyear/160105/14.png">
  49 + </div>
  50 +</div>
  51 +<div class="modal"></div>
  52 +<div class="dialog-box geted">
  53 + <div class="dialog-inner">
  54 + <img src="{{imgUrl}}/cuxiao/img/newyear/160105/geted.png" alt=""/>
  55 + <span class="dialog-close"></span>
  56 + </div>
  57 +</div>
  58 +
  59 +<div class="dialog-box fail">
  60 + <div class="dialog-inner">
  61 + <img src="{{imgUrl}}/cuxiao/img/newyear/160105/fail.png" alt=""/>
  62 + <span class="refresh-btn"></span>
  63 + </div>
  64 +</div>
  65 +<input id="shareLink" type="hidden" value="{{shareLink}}">
  66 +<input id="shareImg" type="hidden" value="{{shareImg}}">
  67 +<input id="shareTitle" type="hidden" value="{{shareTitle}}">
  68 +<input id="shareDesc" type="hidden" value="{{shareDesc}}">
  69 +<script type="text/javascript" src="{{imgUrl}}/cuxiao/js/jquery.min.js"></script>
  70 +<script>
  71 + //提示分享
  72 + $('.share-btn').click(function () {
  73 + $('.modal').fadeIn();
  74 + });
  75 + //关闭提示分享
  76 + $('.modal').click(function () {
  77 + $(this).fadeOut();
  78 + });
  79 +
  80 + //提示已领过券
  81 + if ($('.coupon-container').attr('show') === '1') {
  82 + $('.dialog-box.geted').show();
  83 + }
  84 + //提示领券失败
  85 + else if ($('.coupon-container').attr('show') === '2') {
  86 + $('.dialog-box.fail').show();
  87 + }
  88 +
  89 + //关闭提示
  90 + $('.dialog-close').click(function(){
  91 + $(this).parents('.dialog-box').fadeOut();
  92 + });
  93 + //刷新页面
  94 + $('.refresh-btn').click(function() {
  95 + location.reload();
  96 + });
  97 +</script>
  98 +{{#if weixinShare}}
  99 +<script type="text/javascript" charset="utf-8" src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
  100 +<script type="text/javascript" charset="utf-8" src="{{jsUrl}}/cuxiao/js/share.weixin.js"></script>
  101 +{{/if}}
  102 +{{> layout/analysis}}
  103 +</body>
  104 +</html>
  1 +<?php
  2 +use Action\HuodongAction;
  3 +use LibModels\Wap\Cuxiao\ActivityData;
  4 +use Plugin\Helpers;
  5 +
  6 +/**
  7 + *
  8 + * @name Newyear
  9 + * @package
  10 + * @copyright yoho.inc
  11 + * @version 1.0 (2015-12-30 20:39:50)
  12 + * @author fei.hong <fei.hong@yoho.cn>
  13 + */
  14 +class NewyearController extends HuodongAction
  15 +{
  16 + /**
  17 + * 利是封领券
  18 + *
  19 + * 备注:2016年1月5号上线
  20 + */
  21 + public function couponAction()
  22 + {
  23 + //获取登录者ID,未登录返回false
  24 + $uid = $this->getLoggedUid();
  25 + if (!$uid || !is_numeric($uid)) {
  26 + //未登录的用户访问,跳转到登录页面。并且在登陆后跳转回本页面
  27 + $this->go(Helpers::url('/signin.html', array('refer' => Helpers::url('/cuxiao/newyear/coupon')), 'default'));
  28 + }
  29 +
  30 + // 该变量用来控制和显示页面的弹出提示
  31 + $showPopupFlag = '0';
  32 +
  33 + //获取跳转到个人中心-我的优惠券链接,并调用接口,完成领券操作
  34 + $myCouponUrl = Helpers::url('/home/coupons', null, 'default') . '?openby:yohobuy={"action":"go.coupon"}';
  35 + $activityId = $this->getActivityId();
  36 + $result = ActivityData::getCouponAll($uid, $activityId);
  37 + if (isset($result['code'])) {
  38 + switch (intval($result['code'])) {
  39 + case 200: // 领取成功, 发送站内信消息
  40 + $showPopupFlag = '0';
  41 + $this->sendMessage($uid, '【优惠券】您有1000元套券', '尊敬的客户:恭喜您成功获得1000元套券 !您可以在个人中心的交易管理中查看‘我的优惠券’。');
  42 + break;
  43 + case 201: // 已领取过, 提示重复领券
  44 + $showPopupFlag = '1';
  45 + break;
  46 + default: // 领取失败, 提示领券失败
  47 + $showPopupFlag = '2';
  48 + break;
  49 + }
  50 + }
  51 +
  52 + $this->_view->display('coupon', array(
  53 + 'staticTitle' => 'YOHO!BUY有货新年寻宝大作战',
  54 + 'weixinShare' => $this->_isApp ? false : true, // 是否需要微信分享
  55 + 'shareLink' => 'http://feature.yoho.cn/2016lishifeng/index.html',
  56 + 'shareTitle' => 'YOHO!BUY有货新年寻宝大作战,千元利是等你赢!',
  57 + 'shareDesc' => 'YOHO!BUY有货,全球800+潮流品牌每日上新!',
  58 + 'shareImg' => 'http://img12.static.yhbimg.com/couponImg/2015/12/30/12/02008a9724b898dee56852de9f1a3978bf.jpg',
  59 + 'showPopupFlag' => $showPopupFlag,
  60 + 'myCouponUrl' => $myCouponUrl,
  61 + 'bannerUrl_1' => 'http://m.yohobuy.com/boys?openby:yohobuy={"action":"go.home","params":{"channel":"1"}}',
  62 + 'bannerUrl_2' => 'http://m.yohobuy.com/girls?openby:yohobuy={"action":"go.home","params":{"channel":"2"}}',
  63 + 'bannerUrl_3' => 'http://m.yohobuy.com/kids?openby:yohobuy={"action":"go.home","params":{"channel":"3"}}',
  64 + 'bannerUrl_4' => 'http://m.yohobuy.com/lifestyle?openby:yohobuy={"action":"go.home","params":{"channel":"4"}}',
  65 + ));
  66 + }
  67 +
  68 + /**
  69 + * 检测登录状态
  70 + *
  71 + * @return int
  72 + */
  73 + private function getLoggedUid()
  74 + {
  75 + // 判断是否是应用访问, 拼接APP需要的URL参数
  76 + $this->_isApp = (null !== $this->get('app_version') || null !== $this->get('uid'));
  77 + $uid = false;
  78 + if ($this->_isApp) {
  79 + $uid = $this->get('uid');
  80 + } else {
  81 + $uid = $this->getUid();
  82 + }
  83 +
  84 + return $uid;
  85 + }
  86 +
  87 + /**
  88 + * 发送站内信
  89 + *
  90 + * @param int $uid 用户ID
  91 + */
  92 + private function sendMessage($uid, $title, $content)
  93 + {
  94 + try {
  95 + ActivityData::message($uid, $title, $content);
  96 + } catch (Exception $e) {
  97 + // do nothing
  98 + }
  99 + }
  100 +
  101 + /**
  102 + * 根据环境来获取活动ID
  103 + *
  104 + * @return int
  105 + */
  106 + private function getActivityId()
  107 + {
  108 + // 设置环境变量
  109 + switch (APPLICATION_ENV) {
  110 + case 'production': // 生产
  111 + return 462;
  112 + case 'preview': // 预览
  113 + case 'testing': // 测试
  114 + case 'develop': // 开发
  115 + default:
  116 + return 88;
  117 + }
  118 + }
  119 +
  120 +}