Authored by hf

Merge branch 'beta/wap' of http://git.dev.yoho.cn/web/yohobuy into beta/wap

... ... @@ -42,6 +42,13 @@ class HuodongAction extends Controller_Abstract
protected $_data;
/**
* 是否是应用访问标志位
*
* @var boolean
*/
protected $_isApp;
/**
* 初始化
*/
public function init()
... ... @@ -58,6 +65,9 @@ class HuodongAction extends Controller_Abstract
if (isset($config->css->url)) {
$this->_view->assign('imgUrl', $config->img->url);
}
// 判断是否是应用访问, 拼接APP需要的URL参数
$this->_isApp = (null !== $this->get('app_version') || null !== $this->get('uid'));
}
/**
... ... @@ -196,7 +206,7 @@ class HuodongAction extends Controller_Abstract
* @param string $name cookie的名字
* @param string $value cookie的值
* @param integer $expire cookie过期时间
* @param integer $path cookie可用的路径
* @param string $path cookie可用的路径
* @param string $domain cookie可用域名
*/
protected function setCookie($name, $value, $expire = 0, $path = '/', $domain = '.yohobuy.com')
... ...
... ... @@ -24,17 +24,17 @@ class Yohobuy
// const YOHOBUY_URL = 'http://www.yohobuy.com/';
//java API
const API_URL = 'http://apih5.yoho.cn/';
const API_URL2 = 'http://apih5.yoho.cn/';
const SERVICE_URL = 'http://serviceh5.yoho.cn/';
const YOHOBUY_URL = 'http://www.yohobuy.com/';
const API_OLD = 'http://api2.open.yohobuy.com/';
/* 测试环境 */
// const API_URL = 'http://testapi.yoho.cn:28078/'; // 'http://192.168.102.205:8080/gateway/'
// const SERVICE_URL = 'http://testservice.yoho.cn:28077/';
// const API_URL = 'http://apih5.yoho.cn/';
// const API_URL2 = 'http://apih5.yoho.cn/';
// const SERVICE_URL = 'http://serviceh5.yoho.cn/';
// const YOHOBUY_URL = 'http://www.yohobuy.com/';
// const API_OLD = 'http://test2.open.yohobuy.com/';
// const API_OLD = 'http://api2.open.yohobuy.com/';
/* 测试环境 */
const API_URL = 'http://testapi.yoho.cn:28078/'; // 'http://192.168.102.205:8080/gateway/'
const SERVICE_URL = 'http://testservice.yoho.cn:28077/';
const YOHOBUY_URL = 'http://www.yohobuy.com/';
const API_OLD = 'http://test2.open.yohobuy.com/';
/* 预览环境 */
// const API_URL = 'http://preapi.yoho.cn/';
... ...
... ... @@ -20,6 +20,8 @@ class ActivityData
const URI_GET_NAMED_COUPON = 'event/api/v1/activity/getCoupon';
const URI_GET_ALL_COUPON = 'event/api/v1/activity/getCoupon';
const URI_SEND_MESSAGE = 'inbox/service/v1/inbox';
const URI_YUANXIAO_CHOUQIAN = 'union/ActivityRest/draw';
const URI_YUANXIAO_CHOUQIAN_SHARE = 'union/ActivityRest/getDrawInfo';
/**
* 用户获取某个活动指定的单个优惠券
... ... @@ -69,9 +71,51 @@ class ActivityData
}
/**
* 获取元宵抽签的结果
*
* @param int $uid 用户UID
* @param string $nickName 用户昵称
* @param string $birthday 用户生日
* @param int $gender 用户性别
* @return mixed 抽签的结果
*/
public static function getYuanxiaoInfo($uid, $nickName, $birthday, $gender)
{
$param = array();
$param['method'] = 'wap.activity.draw';
$param['uid'] = $uid;
$param['nickname'] = $nickName;
$param['birthday'] = $birthday;
$param['gender'] = $gender;
return Yohobuy::jsonPost(Yohobuy::SERVICE_URL . self::URI_YUANXIAO_CHOUQIAN, $param);
}
/**
* 获取分享结果页元宵抽签的结果
*
* @param int $uid 用户UID
* @return mixed 抽签的结果
*/
public static function getYuanxiaoShareInfo($uid)
{
$param = array();
$param['method'] = 'wap.activity.draw';
$param['uid'] = $uid;
return Yohobuy::jsonPost(Yohobuy::SERVICE_URL . self::URI_YUANXIAO_CHOUQIAN_SHARE, $param);
}
/**
* 发送站内信
*
* @param int $activityId 活动ID
*
* @param int $uid
* @param string $title
* @param int $content
* @param int $type
* @param string $verify_key
* @param int $send_uid
* @param string $call_back
* @return array
*/
public static function message($uid, $title, $content, $type = 1, $verify_key = '', $send_uid = 0, $call_back = '')
... ...
... ... @@ -21,7 +21,6 @@ class UserData
* 个人详情数据
*
* @param int $uid 用户ID
* @param int $udid 客户端唯一标识
* @return array 个人详情接口返回的数据
*/
public static function userData($uid)
... ...
... ... @@ -120,6 +120,8 @@ class RegData
public static function sendCodeToMobile($area, $mobile)
{
$param = Yohobuy::param();
$param['client_type'] = 'h5'; // 2016/02/18 hf: 根据JAVA邓新飞的发短信内容需要调整
$param['private_key'] = Yohobuy::$privateKeyList['android']; // H5默认使用Android的私钥
$param['method'] = 'app.register.sendRegCodeToMobile';
$param['area'] = $area;
$param['mobile'] = $mobile;
... ...
... ... @@ -5496,6 +5496,32 @@ function setEditModeWithSknId(sknId, isThisGoodSelected) {
isSelected = isThisGoodSelected;
}
function preventDefault(e) {
console.log(e);
if (e.target.localName === 'ul') return;
e = e || window.event;
if (e.preventDefault)
e.preventDefault();
e.returnValue = false;
}
function disableScroll(e) {
if (window.addEventListener) // older FF
window.addEventListener('DOMMouseScroll', preventDefault, false);
window.onwheel = preventDefault; // modern standard
window.onmousewheel = document.onmousewheel = preventDefault; // older browsers, IE
window.ontouchmove = preventDefault; // mobile
}
function enableScroll() {
if (window.removeEventListener)
window.removeEventListener('DOMMouseScroll', preventDefault, false);
window.onmousewheel = document.onmousewheel = null;
window.onwheel = null;
window.ontouchmove = null;
document.onkeydown = null;
}
//删除面板
function removePannel() {
var $pannel = $('.chose-panel'),
... ... @@ -5537,9 +5563,7 @@ function disableNumEdit() {
function show(html, cb) {
var $html = $('html, body');
/*var scrollPosition = [
var scrollPosition = [
document.documentElement.scrollLeft || document.body.scrollLeft,
document.documentElement.scrollTop || document.body.scrollTop
],
... ... @@ -5549,7 +5573,7 @@ function show(html, cb) {
$html.data('previous-overflow', $html.css('overflow'));
$html.css('overflow', 'hidden');
$html.css('height', '100%');
window.scrollTo(scrollPosition[0], scrollPosition[1]);*/
window.scrollTo(scrollPosition[0], scrollPosition[1]);
if (html) {
$chosePanel.html(html);
... ... @@ -5561,20 +5585,22 @@ function show(html, cb) {
$('.chose-panel').show();
$num = $('#good-num');
cbFn = cb;
disableScroll();
}
//隐藏当前Panel
function hide() {
$html = $('html, body');
/*var $html = $('html, body'),
var $html = $('html, body'),
scrollPosition = $html.data('scroll-position');
// un-lock scroll position
$html.css('overflow', $html.data('previous-overflow'));
$html.css('height', 'auto');
window.scrollTo(scrollPosition[0], scrollPosition[1]);*/
window.scrollTo(scrollPosition[0], scrollPosition[1]);
$('.chose-panel').hide();
enableScroll();
}
//修改加入购物车的文字和背景
... ... @@ -5656,6 +5682,7 @@ function changeColorChosed(newColorIndex) {
init();
$yohoPage.on('touchstart', '.chose-panel', function(e) {
var $cur = $(e.target);
... ... @@ -5666,6 +5693,8 @@ $yohoPage.on('touchstart', '.chose-panel', function(e) {
//点击蒙版消失
hide();
enableScroll();
return false;
});
... ... @@ -9574,7 +9603,7 @@ $('.down').on('touchend', function() {
});
});
define("js/cart/gift-advance", ["jquery","lazyload","hammer"], function(require, exports, module){
define("js/cart/gift-advance", ["jquery","mlellipsis","lazyload","hammer"], function(require, exports, module){
/**
* 赠品/加价购
* @author: xuqi<qi.xu@yoho.cn>
... ... @@ -9582,6 +9611,7 @@ define("js/cart/gift-advance", ["jquery","lazyload","hammer"], function(require,
*/
var $ = require("jquery"),
ellipsis = require("mlellipsis"),
lazyLoad = require("lazyload"),
Hammer = require("hammer"),
tip = require("js/plugin/tip"),
... ... @@ -9594,6 +9624,7 @@ var $page = $('.gift-advance-page'),
require("js/common");
lazyLoad($('.lazy'));
ellipsis.init();
function getProductInfo(skn, promotionId) {
loading.showLoadingMask();
... ... @@ -9627,13 +9658,11 @@ $page.find('.chose').each(function(i, elem) {
});
});
// $page.on('touchend', '.chose', function() {
// var $this = $(this),
// id = $this.closest('.gift-advance-good').data('id'),
// promotionId = $this.closest('.advance-block').data('promotion-id');
//
// getProductInfo(id, promotionId);
// });
setTimeout(function() {
$('.gift-advance-good .name').each(function() {
this.mlellipsis(2);
});
}, 0);
});
define("js/cart/order-ensure", ["jquery","lazyload","hammer","handlebars","source-map"], function(require, exports, module){
... ...
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
... ... @@ -71,6 +71,32 @@ function setEditModeWithSknId(sknId, isThisGoodSelected) {
isSelected = isThisGoodSelected;
}
function preventDefault(e) {
console.log(e);
if (e.target.localName === 'ul') return;
e = e || window.event;
if (e.preventDefault)
e.preventDefault();
e.returnValue = false;
}
function disableScroll(e) {
if (window.addEventListener) // older FF
window.addEventListener('DOMMouseScroll', preventDefault, false);
window.onwheel = preventDefault; // modern standard
window.onmousewheel = document.onmousewheel = preventDefault; // older browsers, IE
window.ontouchmove = preventDefault; // mobile
}
function enableScroll() {
if (window.removeEventListener)
window.removeEventListener('DOMMouseScroll', preventDefault, false);
window.onmousewheel = document.onmousewheel = null;
window.onwheel = null;
window.ontouchmove = null;
document.onkeydown = null;
}
//删除面板
function removePannel() {
var $pannel = $('.chose-panel'),
... ... @@ -112,9 +138,7 @@ function disableNumEdit() {
function show(html, cb) {
var $html = $('html, body');
/*var scrollPosition = [
var scrollPosition = [
document.documentElement.scrollLeft || document.body.scrollLeft,
document.documentElement.scrollTop || document.body.scrollTop
],
... ... @@ -124,7 +148,7 @@ function show(html, cb) {
$html.data('previous-overflow', $html.css('overflow'));
$html.css('overflow', 'hidden');
$html.css('height', '100%');
window.scrollTo(scrollPosition[0], scrollPosition[1]);*/
window.scrollTo(scrollPosition[0], scrollPosition[1]);
if (html) {
$chosePanel.html(html);
... ... @@ -136,20 +160,22 @@ function show(html, cb) {
$('.chose-panel').show();
$num = $('#good-num');
cbFn = cb;
disableScroll();
}
//隐藏当前Panel
function hide() {
$html = $('html, body');
/*var $html = $('html, body'),
var $html = $('html, body'),
scrollPosition = $html.data('scroll-position');
// un-lock scroll position
$html.css('overflow', $html.data('previous-overflow'));
$html.css('height', 'auto');
window.scrollTo(scrollPosition[0], scrollPosition[1]);*/
window.scrollTo(scrollPosition[0], scrollPosition[1]);
$('.chose-panel').hide();
enableScroll();
}
//修改加入购物车的文字和背景
... ... @@ -231,6 +257,7 @@ function changeColorChosed(newColorIndex) {
init();
$yohoPage.on('touchstart', '.chose-panel', function(e) {
var $cur = $(e.target);
... ... @@ -241,6 +268,8 @@ $yohoPage.on('touchstart', '.chose-panel', function(e) {
//点击蒙版消失
hide();
enableScroll();
return false;
});
... ...
... ... @@ -5,6 +5,7 @@
*/
var $ = require('jquery'),
ellipsis = require('mlellipsis'),
lazyLoad = require('yoho.lazyload'),
Hammer = require('yoho.hammer'),
tip = require('../plugin/tip'),
... ... @@ -17,6 +18,7 @@ var $page = $('.gift-advance-page'),
require('../common');
lazyLoad($('.lazy'));
ellipsis.init();
function getProductInfo(skn, promotionId) {
loading.showLoadingMask();
... ... @@ -50,10 +52,8 @@ $page.find('.chose').each(function(i, elem) {
});
});
// $page.on('touchend', '.chose', function() {
// var $this = $(this),
// id = $this.closest('.gift-advance-good').data('id'),
// promotionId = $this.closest('.advance-block').data('promotion-id');
//
// getProductInfo(id, promotionId);
// });
setTimeout(function() {
$('.gift-advance-good .name').each(function() {
this.mlellipsis(2);
});
}, 0);
... ...
... ... @@ -22,10 +22,10 @@ function getInstance() {
'{{# hasFooter}}' +
'<div class="dialog-footer">' +
'{{# leftBtnText}}' +
'<span class="dialog-left-btn">{{.}}</span>' +
'<span class="dialog-left-btn tap-hightlight">{{.}}</span>' +
'{{/ leftBtnText}}' +
'{{# rightBtnText}}' +
'<span class="dialog-right-btn">{{.}}</span>' +
'<span class="dialog-right-btn tap-hightlight">{{.}}</span>' +
'{{/ rightBtnText}}' +
'</div>' +
'{{/ hasFooter}}' +
... ...
... ... @@ -55,7 +55,10 @@
.del-icon {
position: absolute;
right: 0.75rem;
bottom: 0.25rem;
width: 60rem / $pxConvertRem;
height: 60rem / $pxConvertRem;
line-height: 60rem / $pxConvertRem;
text-align: center;
color: #999;
}
}
... ...
... ... @@ -320,5 +320,9 @@ $suggest: sprite-map("me/suggest/*.png",$spacing: 5px);
color: #ee0011;
}
}
> span:active {
background-color: #ccc;
}
}
}
... ...
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<title>{{staticTitle}}</title>
<!-- <meta name="apple-mobile-web-app-title" content="SUMMER SALE"> -->
<meta name="format-detection" content="telephone=no">
<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no,minimal-ui">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="grey">
<script>
(function(d,c){var e=d.documentElement,a="orientationchange" in window?"orientationchange":"resize",b=function(){var f=e.clientWidth;if(!f){return}if(f>=640){e.style.fontSize="80px"}else{e.style.fontSize=80*(f/640)+"px"}};if(!d.addEventListener){return}b();c.addEventListener(a,b,false);d.addEventListener("DOMContentLoaded",b,false)})(document,window);
</script>
</head>
<body>
<div class="main-wrap">
元宵节抽签
{{> cuxiao/yuanxiao/header}}
<div class="main-wrap home">
<div class="header"></div>
<div class="people">
<div class="flower flower-l"></div>
<div class="flower flower-r"></div>
</div>
<a class="start" href="/cuxiao/yuanxiao/info"></a>
<div class="footer">
<a class="arrow animated infinite pulse" href="/cuxiao/yuanxiao/info"></a>
<div class="yohobuy"></div>
</div>
</div>
</body>
{{> cuxiao/yuanxiao/footer}}
... ...
{{> cuxiao/yuanxiao/header}}
<div class="main-wrap info">
<div class="header">
<span class="title chao">潮</span>
<span class="title liu">流</span>
<div class="sub-title">&nbsp;开运测试</div>
</div>
<form class="user" method="POST">
<div class="user-info nick">
<div class="title">
昵称
</div>
<input type="text" name="nick" placeholder="请输入您帅气的名字!" value="" maxlength="5">
</div>
<div class="user-info birthday">
<div class="title">
生日
</div>
<input type="date" name="birthday" value="{{birthday}}" min="1900-01-01" max="2016-01-01">
</div>
<div class="gender">
<div class="title">
性<br>别
</div>
<div class="icon boy">
<span class="check {{#if gender}}checked{{/if}}" data-gender="{{#if gender}}1{{/if}}"></span>
</div>
<div class="icon girl">
<span class="check {{#unless gender}}checked{{/if}}" data-gender="{{#if gender}}2{{/if}}"></span>
</div>
<input type="hidden" name="gender" id="gender" value="{{gender}}">
</div>
</form>
<div class="footer">
<div class="submit">
开始测试
</div>
</div>
<div class="mask hide">
<div class="modal">
<div class="icon close"></div>
<div class="text">
你还没有<br>完善信息哦
</div>
<div class="btn close">
现在就完善
</div>
</div>
</div>
</div>
{{> cuxiao/yuanxiao/footer}}
... ...
{{> cuxiao/yuanxiao/header}}
<div class="main-wrap result">
<div class="flower flower-l"></div>
<div class="flower flower-r"></div>
<div class="title">
<p>
{{result.name}}
</p>
2016年的潮流运势是
</div>
<div class="hr">
</div>
<div class="type {{result.type}}" data-type="{{result.type}}">
</div>
<div class="footer">
<div class="share">
分享2016年潮流运势
</div>
</div>
</div>
{{> cuxiao/yuanxiao/type}}
{{> cuxiao/yuanxiao/footer}}
... ...
{{> cuxiao/yuanxiao/header}}
<div class="main-wrap share">
<div class="header"></div>
<div class="flower flower-l"></div>
<div class="flower flower-r"></div>
<div class="title">
<p>
{{result.name}}
</p>
2016年的潮流运势是
</div>
<div class="type {{result.type}}" data-type="{{result.type}}">
</div>
<div class="count">
已有{{count}}人参与
</div>
<div class="footer">
<a class="entry" href="/cuxiao/yuanxiao/index">
我也要测
</a>
</div>
</div>
{{> cuxiao/yuanxiao/type}}
{{> cuxiao/yuanxiao/footer}}
... ...
{{> cuxiao/yuanxiao/header}}
<div class="main-wrap wait">
<div class="flower flower-l"></div>
<div class="flower flower-r"></div>
<div class="tip">
正在分析你的<br>潮流运势<br>…
</div>
<div class="loading animated infinite rotateIn">
</div>
<div class="hat">
</div>
<div class="footer">
</div>
</div>
<script type="text/javascript">
setTimeout(function (){
location.href = "/cuxiao/yuanxiao/result";
}, 2000);
</script>
{{> cuxiao/yuanxiao/footer}}
... ...
<script type="text/javascript" src="{{staticFile}}/js/libs.js"></script>
{{#staticJS}}
<script type="text/javascript" src="{{../staticFile}}/js/{{.}}"></script>
{{/staticJS}}
</body>
... ...
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<title>{{staticTitle}}</title>
<!-- <meta name="apple-mobile-web-app-title" content="SUMMER SALE"> -->
<meta name="format-detection" content="telephone=no">
<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no,minimal-ui">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="grey">
<script type="text/javascript">
(function(d,c){var e=d.documentElement,a="orientationchange" in window?"orientationchange":"resize",b=function(){var f=e.clientWidth;if(!f){return}if(f>=640){e.style.fontSize="40px"}else{e.style.fontSize=40*(f/640)+"px"}};if(!d.addEventListener){return}b();c.addEventListener(a,b,false);d.addEventListener("DOMContentLoaded",b,false)})(document,window);
</script>
<link rel="stylesheet" href="{{staticFile}}/css/style.css">
</head>
<body>
... ...
<script type="text/tmpl" id="P1">
<div class="bg-guang"></div>
<div class="bg-yuan"></div>
<div class="title">成为一个大写加粗的</div>
<div class="chaoren animated infinite pulse"></div>
</script>
<script type="text/tmpl" id="P2">
<div class="bg-bige animated zoomIn"></div>
<div class="bg-manzai animated zoomIn"></div>
<div class="bg-ren"></div>
<div class="title animated infinite pulse"></div>
<div class="yzbb animated slideInDown"></div>
</script>
<script type="text/tmpl" id="P3">
<div class="bg-yunqi animated zoomIn"></div>
<div class="shoes animated infinite swing"></div>
<div class="yeezy animated slideInDown"></div>
</script>
<script type="text/tmpl" id="P4">
<div class="bg-car"></div>
<div class="hands animated infinite swing"></div>
<div class="wanghong animated slideInRight"></div>
</script>
<script type="text/tmpl" id="M1">
<div class="bg-majia"></div>
<div class="bg-yifei animated slideInUp"></div>
<div class="flyman flyIn "></div>
</script>
<script type="text/tmpl" id="M2">
<div class="bg-bamei animated slideInRight"></div>
<div class="meizi animated infinite swing"></div>
<div class="shoes"></div>
</script>
<script type="text/tmpl" id="M3">
<div class="bg-cloud1 animated slideInRight"></div>
<div class="bg-chuanzhe animated slideInLeft"></div>
<div class="shan"></div>
<div class="rensheng"></div>
<div class="cloud2 animated slideInRight"></div>
<div class="shoes animated infinite swing"></div>
</script>
<script type="text/tmpl" id="M4">
<div class="bg-guang"></div>
<div class="bg-jin1 animated slideInright"></div>
<div class="ren"></div>
<div class="jin2 animated slideInDown"></div>
<div class="jin3 animated slideInDown"></div>
<div class="shuaiqi animated slideInDown"></div>
</script>
<script type="text/tmpl" id="F1">
<div class="bg-hezi1 animated slideInLeft"></div>
<div class="bg-hezi2 animated slideInDown"></div>
<div class="bg-hezi3 animated slideInRight"></div>
<div class="sun animated infinite zoomIn"></div>
<div class="kuaidi animated slideInDown"></div>
</script>
<script type="text/tmpl" id="F2">
<div class="bg-love1 animated infinite zoomIn"></div>
<div class="bg-love2"></div>
<div class="boy animated slideInRight"></div>
<div class="girl animated slideInLeft"></div>
<div class="bidong animated slideInRight"></div>
</script>
<script type="text/tmpl" id="F3">
<div class="bg-bra animated infinite pulse"></div>
<div class="xiongda animated zoomIn"></div>
</script>
<script type="text/tmpl" id="F4">
<div class="bg-guang animated infinite zoomIn"></div>
<div class="bg-shoes1 animated slideInLeft"></div>
<div class="bg-shoes2 animated slideInRight"></div>
<div class="bg-shoes3 animated slideInDown"></div>
<div class="style animated slideInUp"></div>
</script>
... ...
<?php
namespace Cuxiao;
use LibModels\Wap\Cuxiao\ActivityData;
use LibModels\Wap\Home\UserData;
/**
* Created by PhpStorm.
* User: Gtskk
* Date: 2016/2/18
* Time: 16:26
*
* @name YuanxiaoModel
* @package models/Cuxiao
* @author Gtskk(tttt6399998@126.com)
*/
class YuanxiaoModel
{
/**
* 处理用户详情数据
*
* @param int $uid 用户ID
* @return array|mixed 处理之后的个人详情数据
*/
public static function getUserProfileData($uid)
{
$result = array(
'birthday' => '2000-01-01',
'gender' => 2
);
// 调用接口获取个人详情
$userData = UserData::userData($uid);
// 处理个人详情数
if (isset($userData['data']) && !empty($userData['data'])) {
$result['birthday'] = $userData['data']['birthday'] ?: '2000-01-01';
$result['gender'] = $userData['data']['gender'];
}
return $result;
}
/**
* @param int $uid 用户UID
* @param sring $nickName 用户昵称
* @param string $birthday 用户生日
* @param int $gender 用户性别
* @return array 处理之后抽签的结果
*/
public static function getChouqianInfo($uid, $nickName, $birthday, $gender)
{
$result = array('code' => 400, 'message' => '出错啦~');
do {
if (empty($uid)) {
break;
}
if (empty($nickName)) {
$result['message'] = '昵称不能为空';
break;
}
if (empty($birthday)) {
$result['message'] = '生日不能为空';
break;
}
if (empty($gender)) {
$result['message'] = '性别不能为空';
break;
}
$chouqian = ActivityData::getYuanxiaoInfo($uid, $nickName, $birthday, $gender);
if ($chouqian) {
$result = $chouqian;
}
} while (false);
return $result;
}
/**
* @param int $uid 用户UID
* @return array|mixed 抽奖的结果
*/
public static function getChoujiangShareInfo($uid)
{
$result = array('code' => 400, 'message' => '出错啦~');
do {
if (empty($uid)) {
break;
}
$chouqian = ActivityData::getYuanxiaoShareInfo($uid);
if (isset($chouqian['data'])) {
$result = array(
'name' => $chouqian['data']['nickname'],
'type' => $chouqian['data']['randomCode'],
'total' => $chouqian['data']['total']
);
}
} while (false);
return $result;
}
}
\ No newline at end of file
... ...
... ... @@ -11,7 +11,7 @@ use LibModels\Wap\Cuxiao\ActivityData;
class ChristmasController extends HuodongAction
{
private $_isApp = false;
// private $_isApp = false;
/**
* 备注:2015年12月11号上线
... ...
<?php
use Action\HuodongAction;
use Cuxiao\YuanxiaoModel;
use Plugin\Helpers;
use LibModels\Wap\Cuxiao\ActivityData;
use Api\Yohobuy;
/**
* 元宵抽签活动
*/
class YuanxiaoController extends HuodongAction
{
// const STATIC_FILE = 'http://localhost:2222/assets/1.0.2';
const STATIC_FILE = 'http://cdn.yoho.cn/huodong/2016yuanxiao/1.0.2';
const ENCRYPT_KEY = 'iamgtskkwhoareyou';
/**
* 通过当前用户审判是否跳到登录页
*
*/
private function auditJumpLogin()
{
$uid = $this->getLoggedUid();
if (!$uid || !is_numeric($uid)) {
$this->go(Helpers::url('/signin.html', array('refer' => Helpers::url('/cuxiao/yuanxiao/info')), 'default'));
}
}
/**
* 元宵抽签
*/
public function indexAction()
{
// 该变量用来控制和显示页面的弹出提示
$showPopupFlag = '0';
$this->_view->display('index', array(
'staticTitle' => '元宵抽签'
'staticTitle' => '元宵抽签',
'staticFile' => self::STATIC_FILE,
'staticJS' => array(
'home.js'
)
));
}
/**
* 元宵抽签 信息
*/
public function infoAction()
{
// 审判跳转登录页
$this->auditJumpLogin();
$uid = $this->getUid();
// POST提交请求
$posts = $this->post();
if (!empty($posts)) {
$nickName = $this->post('nick', '');
$birthday = $this->post('birthday', '');
$gender = $this->post('gender', 1);
// 调用接口
$result = YuanxiaoModel::getChouqianInfo($uid, $nickName, $birthday, $gender);
if ($result['code'] === 200) { // 处理成功就跳转到等待页
// 将返回的结果存入cookeie中15分钟
$cookieData = array(
'name' => $nickName,
'type' => $result['data']['randomCode']
);
$this->setCookie('yuanxiaochouqian', json_encode($cookieData), time() + 15*60);
$this->go(Helpers::url('/cuxiao/yuanxiao/wait'));
} else { // 不成功就显示返回的错误信息
$this->_view->display('info', array(
'staticTitle' => '元宵抽签',
'staticFile' => self::STATIC_FILE,
'staticJS' => array(
'info.js'
),
'birthday' => $birthday,
'gender' => $gender,
'message' => $result['message']
));
}
} else {
$userData = YuanxiaoModel::getUserProfileData($uid);
$this->_view->display('info', array(
'staticTitle' => '元宵抽签',
'staticFile' => self::STATIC_FILE,
'staticJS' => array(
'info.js'
),
'birthday' => $userData['birthday'],
'gender' => $userData['gender'],
));
}
}
/**
* 元宵抽签 等待
*/
public function waitAction()
{
// 审判跳转登录页
$this->auditJumpLogin();
$this->_view->display('wait', array(
'staticTitle' => '元宵抽签',
'staticFile' => self::STATIC_FILE,
'staticJS' => array(
'wait.js'
),
));
}
/**
* 元宵抽签 结果
*/
public function resultAction()
{
// 审判跳转登录页
$this->auditJumpLogin();
$result = $this->getCookie('yuanxiaochouqian', null);
// if (empty($result)) { // 未取到信息就重新测试
// $this->go(Helpers::url('/cuxiao/yuanxiao/info'));
// }
// cookie中存的结果
$result = json_decode($result, true);
$shareUrl = Helpers::url('/cuxiao/yuanxiao/share', array(
'hash' => $this->encrypt($this->getUid())
));
$this->_view->display('result', array(
'staticTitle' => '元宵抽签',
'weixinShare' => $this->_isApp ? false : true, // 是否需要微信分享
'staticFile' => self::STATIC_FILE,
'result' => $result,
'shareUrl' => $shareUrl,
'staticJS' => array(
'result.js'
)
));
}
/**
* 元宵抽签 分享
*/
public function shareAction()
{
// 用户UID
$uid = $this->decrypt($this->get('hash', ''));
if (empty($uid)) {
$this->go(Helpers::url('/cuxiao/yuanxiao/index'));
}
// 调用接口获取type和count
$result = YuanxiaoModel::getChoujiangShareInfo($uid);
$this->_view->display('share', array(
'staticTitle' => '元宵抽签',
'staticFile' => self::STATIC_FILE,
'result' => array(
'name' => $result['name'],
'type' => $result['type']
),
'count' => $result['total'],
'staticJS' => array(
'share.js'
)
));
}
/**
* 检测登录状态
*
* @return int
*/
private function getLoggedUid()
{
if ($this->_isApp) {
$uid = $this->get('uid');
} else {
$uid = $this->getUid();
}
return $uid;
}
/**
* 加密字符串
*
* @param string $data 需要加密的字符串
* @return string 加密之后的字符串
*/
private function encrypt($data)
{
$data = strval($data);
$key = md5(self::ENCRYPT_KEY);
$x = 0;
$len = strlen($data);
$l = strlen($key);
$char = '';
$str = '';
for ($i = 0; $i < $len; $i++) {
if ($x == $l)
{
$x = 0;
}
$char .= $key{$x};
$x++;
}
for ($i = 0; $i < $len; $i++) {
$str .= chr(ord($data{$i}) + (ord($char{$i})) % 256);
}
return base64_encode($str);
}
/**
* 解密字符串
*
* @param string $data 需要解密的字符串
* @return string 解密之后的字符串
*/
private function decrypt($data)
{
$key = md5(self::ENCRYPT_KEY);
$x = 0;
$data = base64_decode($data);
$len = strlen($data);
$l = strlen($key);
$char = '';
$str = '';
for ($i = 0; $i < $len; $i++) {
if ($x == $l)
{
$x = 0;
}
$char .= substr($key, $x, 1);
$x++;
}
for ($i = 0; $i < $len; $i++) {
if (ord(substr($data, $i, 1)) < ord(substr($char, $i, 1))) {
$str .= chr((ord(substr($data, $i, 1)) + 256) - ord(substr($char, $i, 1)));
} else {
$str .= chr(ord(substr($data, $i, 1)) - ord(substr($char, $i, 1)));
}
}
return $str;
}
}
... ...