Authored by xuqi

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

framework @ 119c247f
Subproject commit 75bbc3b075de19f239532f60c5995d06c5f814e2
Subproject commit 119c247f5cf929aa1e059e40609bb16dd6b58f05
... ...
... ... @@ -18,17 +18,18 @@ class Yohobuy
{
// /* 正式环境 */
const API_URL = 'http://api2.open.yohobuy.com/';
const API_URL2 = 'http://api.open.yohobuy.com/';
const SERVICE_URL = 'http://service.api.yohobuy.com/';
const YOHOBUY_URL = 'http://www.yohobuy.com/';
const API_URL = 'http://api2.open.yohobuy.com/';
const API_URL2 = 'http://api.open.yohobuy.com/';
const SERVICE_URL = 'http://service.api.yohobuy.com/';
const YOHOBUY_URL = 'http://www.yohobuy.com/';
/* 测试环境 */
// const API_URL = 'http://test2.open.yohobuy.com/';
// const SERVICE_URL = 'http://test.service.api.yohobuy.com/';
// const YOHOBUY_URL = 'http://www.yohobuy.com/';
// const API_URL_MYCENTER = 'http://192.168.102.213:8080/api-gateway-web/'; // 我的个人中心接口URL
// const API_URL_SHOPINGCART = 'http://192.168.102.213:8080/api-gateway-web/'; // 我的购物车接口URL
// const API_URL = 'http://test2.open.yohobuy.com/';
// const SERVICE_URL = 'http://test.service.api.yohobuy.com/';
// const YOHOBUY_URL = 'http://www.yohobuy.com/';
// const API_URL_MYCENTER = 'http://192.168.102.213:8080/api-gateway-web/'; // 我的个人中心接口URL
// const API_URL_SHOPINGCART = 'http://192.168.102.213:8080/api-gateway-web/'; // 我的购物车接口URL
/**
* 私钥列表
... ...
... ... @@ -106,6 +106,136 @@ class Images
return $domain;
}
/**
* 图片上传
* @param string $name 文件表单name, 即用于$_FILES[$name]
*/
public static function saveImage($name)
{
if (empty($_FILES[$name]))
{
return array();
}
$files = $_FILES[$name];
$images = array();
if (is_array($files['tmp_name']))
{
foreach ($files['tmp_name'] as $k => $tmp_name)
{
if(!empty($tmp_name))
{
$images[$files['name'][$k]] = $tmp_name;
}
}
}
else
{
$images[$files['name']] = $files['tmp_name'];
}
if($_SERVER['HTTP_HOST'] != 'test.service.api.yohobuy.com') //代理转接
{
return self::agentCurlImage($images);
}
else
{
return self::uploadStreamImage($images);
}
}
/**
* 上传图片[图片上传域名限制于http://test.service.api.yohobuy.com]
*
* @param string | array(filename => absolute file path) $file
* url:http://upload.static.yohobuy.com?project=sns&fileData=xxx
* @return mixed
*/
public static function uploadStreamImage($file)
{
$end ="\r\n";
$twoHyphens ="--";
$boundary = "*****";
$stream = '';
$files = is_array($file) ? $file : array($file);
foreach($files as $name => $filename)
{
if(!file_exists($filename))
{
continue;
}
$name = is_numeric($name) ? name.'.jpg' : $name;
$stream .= $twoHyphens.$boundary.$end;
$stream .="Content-Disposition: form-data; "."name=\"fileData\";filename=\"".$name ."\"".$end; // form file element name :fileData
$stream .= $end;
$stream .= file_get_contents($filename);
$stream .= $end;
}
if(empty($stream))
{
return false;
}
$stream .= $twoHyphens.$boundary.$end;
$stream .="Content-Disposition: form-data; "."name=\"project\"".$end;
$stream .= $end;
$stream .= "sns";//project sns
$stream .= $end;
$stream .= $twoHyphens .$boundary .$twoHyphens .$end;
$opts = array(
'http' => array(
'method' => 'POST',
'header' => 'content-type:multipart/form-data;boundary='.$boundary,
'content' => $stream
)
);
$context = stream_context_create($opts);
$result = json_decode(file_get_contents('http://upload.static.yohobuy.com', false, $context), true);
if(!empty($result['data']['imagesList']))
{
return count($file) == 1 || !is_array($file) ? current($result['data']['imagesList']) : $result['data']['imagesList'] ;
}
else
{
return false;
}
}
/**
* 代理上传图片
*
* @param array|string $files
* @return array
*/
private static function agentCurlImage($file)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible;)");
curl_setopt($ch, CURLOPT_URL, 'http://test.service.api.yohobuy.com/sns/ajax/uploadimg');
curl_setopt($ch, CURLOPT_POST, true);
$params = array();
$files = is_array($file) ? $file : array($file);
foreach($files as $key => $name)
{
$key = is_numeric($key) ? $key.'.jpg' : $key;
$filename = dirname($name).'/'.$key;
rename($name, $filename);
if (@class_exists('\CURLFile'))
{
$params["images[$key]"] = new \CURLFile(realpath($filename));
}
else
{
$params["images[$key]"] = '@' . realpath($filename);
}
}
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
$response = json_decode(curl_exec($ch), true);
return $response['data'];
}
/**
* 获取模板的图片地址
* @param $fileName
... ...
... ... @@ -12,20 +12,16 @@ var $ = require('jquery'),
require('./jquery.uploadifive');
$('#upload-img').uploadifive({
'auto': false,
'buttonClass': 'nav-btn',
'formData': {
},
'fileType': 'image/*',
'uploadScript': 'url',
'fileObjName': 'imgName',
'fileSizeLimit': 1024,
'onAddQueueItem': function (file) {
auto: true,
buttonClass: 'nav-btn',
fileType: 'image/*',
uploadScript: '/home/suggestimgUpload',
fileObjName: 'fileData',
fileSizeLimit: 1024,
onAddQueueItem: function (file) {
console.log(file);
alert(1);
},
'onQueueComplete': function (file) {
onQueueComplete: function (file) {
console.log(file);
}
});
\ No newline at end of file
... ...
... ... @@ -11,7 +11,8 @@ var page = 1,
navSwiper,
notab = 0,
sort = '',
id = '';
id = '',
noResult = '<p class="no-result">未找到相关搜索结果</p>';
function hotrank(page, sort, tabId, notab) {
loading.showLoadingMask();
... ... @@ -28,7 +29,11 @@ function hotrank(page, sort, tabId, notab) {
if (page === 1) {
$('.rank-main').remove();
}
$('#hotRank').append(data);
if (data === ' ') {
$('#hotRank').html(noResult);
} else {
$('#hotRank').append(data);
}
lazyLoad($('img.lazy'));
$('.rank-main ul li:gt(2)').find('.item-content i').removeClass('top');
winH = $(window).height();
... ...
... ... @@ -45,9 +45,8 @@
p{
width: 55.517241%;
height: auto;
padding: 0 5% 10em / $pxConvertRem;;
padding: 0 5% 18em / $pxConvertRem;;
float: left;
font-size: 44em / $pxConvertRem;
&:first-of-type{
padding-top:30em / $pxConvertRem;
font-size: 60em / $pxConvertRem;
... ...
... ... @@ -184,9 +184,12 @@ $fav: sprite-map("me/fav/*.png",$spacing: 5px);
.fav-brand-swiper {
.swiper-header {
height: pxToRem(60px);
height: pxToRem(100px);
padding: pxToRem(20px) pxToRem(30px);
display: inline-block;
position: relative;
width: 100%;
@include box-sizing();
.swiper-logo {
height: 100%;
... ... @@ -229,6 +232,19 @@ $fav: sprite-map("me/fav/*.png",$spacing: 5px);
}
}
}
.fav-more {
$width: pxToRem(image_width(sprite-file($fav, fav-more)));
$height: pxToRem(image_height(sprite-file($fav, fav-more)));
@include rem-sprite($fav, fav-more);
width: $width;
height: $height;
position: absolute;
top: 50%;
right: pxToRem(30px);
margin-top: -$height / 2;
}
}
.swiper-container {
height: pxToRem(300px);
... ...
... ... @@ -5,19 +5,20 @@
position: relative;
padding: 0 pxToRem(30px);
color: #fff;
background: #ccc;
font-size: pxToRem(34px);
line-height: pxToRem(164px);
height: pxToRem(164px);
line-height: pxToRem(168px);
height: pxToRem(168px);
background: image-url("me/index/header-bg.jpg");
background-size: cover;
.user-avatar {
float: left;
position: relative;
top: pxToRem(8px);
width: pxToRem(132px);
height: pxToRem(132px);
top: pxToRem(16px);
width: pxToRem(126px);
height: pxToRem(126px);
border-radius: 50%;
border: pxToRem(8px) solid #a7a8a9;
border: pxToRem(6px) solid #a7a8a9;
}
.username {
... ...
... ... @@ -36,13 +36,14 @@
}
.price {
position: relative;
margin-top: pxToRem(20px);
font-size: pxToRem(20px);
line-height: 1;
span {
// chrome 最小支持12px
transform: scale(0.875);
// chrome 最小支持12px, 设计图是 10px ,用CSS3变换
@include transform(scale(0.875));
}
.sale-price {
... ... @@ -50,7 +51,9 @@
}
.old-price {
float: right;
position: absolute;
top: 0;
right: 0;
color: #ededed;
}
... ...
... ... @@ -3,18 +3,25 @@
<span class="active">未使用</span>
<span>已使用</span>
</div>
{{# couponsUrl}}
<div class="employ-list">
{{# unused}}
<div class="employ-main">
<span>50</span>
<p>【summer sale】下装满¥399减¥50券</p>
<p>有效期:2014.07.28 - 2014.09.15</p>
</div>
{{/ unused}}
</div>
<div class="employ-list not none">
{{# used}}
<div class="employ-main">
<span>60</span>
<p>【summer sale】下装满¥399减¥60券</p>
<p>有效期:2014.07.28 - 2014.09.15</p>
<span>{{ money }}</span>
<p>{{ coupon_name }}</p>
<p>{{ couponValidity }}</p>
</div>
{{/ used}}
</div>
{{/ couponsUrl}}
{{> layout/footer}}
\ No newline at end of file
... ...
... ... @@ -66,7 +66,7 @@
{{/ discount}}
</div>
</div>
<a href="{{link}}"></a>
<a class="fav-more" href="{{link}}"></a>
</div>
<div id="swiper-container-{{id}}" class="swiper-container" data-id="{{id}}">
<ul class="swiper-wrapper swiper-wrapper-{{id}}">
... ...
... ... @@ -50,7 +50,7 @@
<a class="list-item" href="/home/address">
<span class="iconfont icon">&#xe637;</span>
地址管理
<span class="iconfont num">3 &#xe604;</span>
<span class="iconfont num">{{address_num}} &#xe604;</span>
</a>
</div>
<div class="group-list">
... ...
{{> layout/header}}
<div class="yoho-suggest-sub-page yoho-page">
{{# suggestSub}}
<div class="suggest-sub-form">
<div class="suggest-sub-form"
data-version="{{param.app_version}}"
data-type="{{param.client_type}}"
data-os-version="{{param.os_version}}"
data-screen-size="{{param.screen_size}}"
data-v="{{param.v}}"
data-project="{{param.project}}"
data-client-secret="{{param.client_secret}}">
<textarea name="" id="suggest-textarea" placeholder="请输入意见反馈,我们会以消息形式回复您的建议或意见,改进产品体验,谢谢!"></textarea>
<div class="img-form">
<span class="img-add">
... ...
... ... @@ -7,8 +7,8 @@
<li class="swiper-slider">
<img class="img-box" src="{{thumb}}">
<div class="price">
<span class="sale-price"{{salePrice}}</span>
<span class="old-price"{{price}}</span>
<span class="sale-price {{^price}}no-price{{/price}}"{{salePrice}}</span>
{{#price}}<span class="old-price"{{.}}</span>{{/price}}
</div>
</li>
{{/recommendList}}
... ...
... ... @@ -30,7 +30,7 @@ class HomeController extends AbstractAction
$uid = 8826435;
$data = \Index\UserModel::getUserProfileData($uid);
$data += \Index\UserModel::getInfoNumData($uid);
// 优选新品数据
$channel = Helpers::getChannelByCookie();
$data['recommendForYou'] = \Index\UserModel::getPreferenceData($channel);
... ... @@ -157,6 +157,15 @@ class HomeController extends AbstractAction
));
}
/**
* 用户收藏的商品-删除
*/
public function favoriteDelAction() {
//$this->echoJson();
}
/**
* 用户收藏的品牌
*/
... ... @@ -212,8 +221,6 @@ class HomeController extends AbstractAction
'couponsUrl' => \Index\UserModel::getCouponData($uid, $status),
'couponsPage' => true
);
print_r($coupons);
$this->_view->display('coupons', $coupons);
}
... ... @@ -361,26 +368,43 @@ class HomeController extends AbstractAction
}
/**
* 意见反馈-提交表单
* 意见反馈-提交表单页面
*/
public function suggest_subAction() {
$udid = $this->getUdid();
$page = $this->get('page', 1);
$limit = $this->get('limit', 30);
public function suggestSubAction() {
// 设置网站标题
$this->setTitle('反馈问题');
$param = \Api\Yohobuy::param();
unset($param['private_key']);
$param['project'] = 'suggest';
$param['client_secret'] = 'e7807a9522ab99af8b8fd926e1ebbd9a';
$data = array(
'suggestPage' => true, //加载js
'pageHeader' => array(
'navBack' => true,
'navTitle' => '反馈问题',
'navBtn' => '提交'
),
'param' => $param,
'suggestSub' => true,
'pageFooter' => true
);
//print_r($data);
$this->_view->display('suggest_sub', $data);
}
$suggest = \Index\UserModel::getSuggestData($udid, $page, $limit);
/**
* 异步上传图片
*/
public function suggestimgUploadAction() {
if ($this->isAjax()) {
$filename = $this->get('filename', '');
$result = \Plugin\Images::saveImage($filename);
//print_r($suggest);
$this->_view->display('suggest_sub', array(
'suggestPage' => true, //加载js
'pageHeader' => array(
'navBack' => true,
'navTitle' => '反馈问题',
'navBtn' => '提交'
),
'suggestSub' => true,
'pageFooter' => true
));
$this->echoJson($result);
}
}
/**
... ...