Authored by yangyang

解决冲突

@@ -18,17 +18,18 @@ class Yohobuy @@ -18,17 +18,18 @@ class Yohobuy
18 { 18 {
19 19
20 // /* 正式环境 */ 20 // /* 正式环境 */
21 - const API_URL = 'http://api2.open.yohobuy.com/';  
22 - const API_URL2 = 'http://api.open.yohobuy.com/';  
23 - const SERVICE_URL = 'http://service.api.yohobuy.com/';  
24 - const YOHOBUY_URL = 'http://www.yohobuy.com/'; 21 + const API_URL = 'http://api2.open.yohobuy.com/';
  22 + const API_URL2 = 'http://api.open.yohobuy.com/';
  23 + const SERVICE_URL = 'http://service.api.yohobuy.com/';
  24 + const YOHOBUY_URL = 'http://www.yohobuy.com/';
25 25
26 /* 测试环境 */ 26 /* 测试环境 */
27 -// const API_URL = 'http://test2.open.yohobuy.com/';  
28 -// const SERVICE_URL = 'http://test.service.api.yohobuy.com/';  
29 -// const YOHOBUY_URL = 'http://www.yohobuy.com/';  
30 -// const API_URL_MYCENTER = 'http://192.168.102.213:8080/api-gateway-web/'; // 我的个人中心接口URL  
31 -// const API_URL_SHOPINGCART = 'http://192.168.102.213:8080/api-gateway-web/'; // 我的购物车接口URL 27 + // const API_URL = 'http://test2.open.yohobuy.com/';
  28 + // const SERVICE_URL = 'http://test.service.api.yohobuy.com/';
  29 + // const YOHOBUY_URL = 'http://www.yohobuy.com/';
  30 + // const API_URL_MYCENTER = 'http://192.168.102.213:8080/api-gateway-web/'; // 我的个人中心接口URL
  31 + // const API_URL_SHOPINGCART = 'http://192.168.102.213:8080/api-gateway-web/'; // 我的购物车接口URL
  32 +
32 33
33 /** 34 /**
34 * 私钥列表 35 * 私钥列表
@@ -106,6 +106,136 @@ class Images @@ -106,6 +106,136 @@ class Images
106 return $domain; 106 return $domain;
107 } 107 }
108 108
  109 +
  110 + /**
  111 + * 图片上传
  112 + * @param string $name 文件表单name, 即用于$_FILES[$name]
  113 + */
  114 + public static function saveImage($name)
  115 + {
  116 + if (empty($_FILES[$name]))
  117 + {
  118 + return array();
  119 + }
  120 + $files = $_FILES[$name];
  121 + $images = array();
  122 + if (is_array($files['tmp_name']))
  123 + {
  124 + foreach ($files['tmp_name'] as $k => $tmp_name)
  125 + {
  126 + if(!empty($tmp_name))
  127 + {
  128 + $images[$files['name'][$k]] = $tmp_name;
  129 + }
  130 + }
  131 + }
  132 + else
  133 + {
  134 + $images[$files['name']] = $files['tmp_name'];
  135 + }
  136 + if($_SERVER['HTTP_HOST'] != 'test.service.api.yohobuy.com') //代理转接
  137 + {
  138 + return self::agentCurlImage($images);
  139 + }
  140 + else
  141 + {
  142 + return self::uploadStreamImage($images);
  143 + }
  144 + }
  145 +
  146 + /**
  147 + * 上传图片[图片上传域名限制于http://test.service.api.yohobuy.com]
  148 + *
  149 + * @param string | array(filename => absolute file path) $file
  150 + * url:http://upload.static.yohobuy.com?project=sns&fileData=xxx
  151 + * @return mixed
  152 + */
  153 + public static function uploadStreamImage($file)
  154 + {
  155 + $end ="\r\n";
  156 + $twoHyphens ="--";
  157 + $boundary = "*****";
  158 + $stream = '';
  159 + $files = is_array($file) ? $file : array($file);
  160 + foreach($files as $name => $filename)
  161 + {
  162 + if(!file_exists($filename))
  163 + {
  164 + continue;
  165 + }
  166 + $name = is_numeric($name) ? name.'.jpg' : $name;
  167 + $stream .= $twoHyphens.$boundary.$end;
  168 + $stream .="Content-Disposition: form-data; "."name=\"fileData\";filename=\"".$name ."\"".$end; // form file element name :fileData
  169 + $stream .= $end;
  170 + $stream .= file_get_contents($filename);
  171 + $stream .= $end;
  172 + }
  173 + if(empty($stream))
  174 + {
  175 + return false;
  176 + }
  177 + $stream .= $twoHyphens.$boundary.$end;
  178 + $stream .="Content-Disposition: form-data; "."name=\"project\"".$end;
  179 + $stream .= $end;
  180 + $stream .= "sns";//project sns
  181 + $stream .= $end;
  182 + $stream .= $twoHyphens .$boundary .$twoHyphens .$end;
  183 + $opts = array(
  184 + 'http' => array(
  185 + 'method' => 'POST',
  186 + 'header' => 'content-type:multipart/form-data;boundary='.$boundary,
  187 + 'content' => $stream
  188 + )
  189 + );
  190 + $context = stream_context_create($opts);
  191 + $result = json_decode(file_get_contents('http://upload.static.yohobuy.com', false, $context), true);
  192 + if(!empty($result['data']['imagesList']))
  193 + {
  194 + return count($file) == 1 || !is_array($file) ? current($result['data']['imagesList']) : $result['data']['imagesList'] ;
  195 + }
  196 + else
  197 + {
  198 + return false;
  199 + }
  200 + }
  201 +
  202 + /**
  203 + * 代理上传图片
  204 + *
  205 + * @param array|string $files
  206 + * @return array
  207 + */
  208 + private static function agentCurlImage($file)
  209 + {
  210 + $ch = curl_init();
  211 + curl_setopt($ch, CURLOPT_HEADER, 0);
  212 + curl_setopt($ch, CURLOPT_VERBOSE, 0);
  213 + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  214 + curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible;)");
  215 + curl_setopt($ch, CURLOPT_URL, 'http://test.service.api.yohobuy.com/sns/ajax/uploadimg');
  216 + curl_setopt($ch, CURLOPT_POST, true);
  217 + $params = array();
  218 + $files = is_array($file) ? $file : array($file);
  219 + foreach($files as $key => $name)
  220 + {
  221 + $key = is_numeric($key) ? $key.'.jpg' : $key;
  222 + $filename = dirname($name).'/'.$key;
  223 + rename($name, $filename);
  224 + if (@class_exists('\CURLFile'))
  225 + {
  226 + $params["images[$key]"] = new \CURLFile(realpath($filename));
  227 + }
  228 + else
  229 + {
  230 + $params["images[$key]"] = '@' . realpath($filename);
  231 + }
  232 + }
  233 + curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
  234 + $response = json_decode(curl_exec($ch), true);
  235 + return $response['data'];
  236 +
  237 + }
  238 +
109 /** 239 /**
110 * 获取模板的图片地址 240 * 获取模板的图片地址
111 * @param $fileName 241 * @param $fileName
@@ -12,20 +12,16 @@ var $ = require('jquery'), @@ -12,20 +12,16 @@ var $ = require('jquery'),
12 require('./jquery.uploadifive'); 12 require('./jquery.uploadifive');
13 13
14 $('#upload-img').uploadifive({ 14 $('#upload-img').uploadifive({
15 - 'auto': false,  
16 - 'buttonClass': 'nav-btn',  
17 - 'formData': {  
18 -  
19 - },  
20 - 'fileType': 'image/*',  
21 - 'uploadScript': 'url',  
22 - 'fileObjName': 'imgName',  
23 - 'fileSizeLimit': 1024,  
24 - 'onAddQueueItem': function (file) { 15 + auto: true,
  16 + buttonClass: 'nav-btn',
  17 + fileType: 'image/*',
  18 + uploadScript: '/home/suggestimgUpload',
  19 + fileObjName: 'fileData',
  20 + fileSizeLimit: 1024,
  21 + onAddQueueItem: function (file) {
25 console.log(file); 22 console.log(file);
26 - alert(1);  
27 }, 23 },
28 - 'onQueueComplete': function (file) {  
29 - 24 + onQueueComplete: function (file) {
  25 + console.log(file);
30 } 26 }
31 }); 27 });
@@ -11,7 +11,8 @@ var page = 1, @@ -11,7 +11,8 @@ var page = 1,
11 navSwiper, 11 navSwiper,
12 notab = 0, 12 notab = 0,
13 sort = '', 13 sort = '',
14 - id = ''; 14 + id = '',
  15 + noResult = '<p class="no-result">未找到相关搜索结果</p>';
15 16
16 function hotrank(page, sort, tabId, notab) { 17 function hotrank(page, sort, tabId, notab) {
17 loading.showLoadingMask(); 18 loading.showLoadingMask();
@@ -28,7 +29,11 @@ function hotrank(page, sort, tabId, notab) { @@ -28,7 +29,11 @@ function hotrank(page, sort, tabId, notab) {
28 if (page === 1) { 29 if (page === 1) {
29 $('.rank-main').remove(); 30 $('.rank-main').remove();
30 } 31 }
31 - $('#hotRank').append(data); 32 + if (data === ' ') {
  33 + $('#hotRank').html(noResult);
  34 + } else {
  35 + $('#hotRank').append(data);
  36 + }
32 lazyLoad($('img.lazy')); 37 lazyLoad($('img.lazy'));
33 $('.rank-main ul li:gt(2)').find('.item-content i').removeClass('top'); 38 $('.rank-main ul li:gt(2)').find('.item-content i').removeClass('top');
34 winH = $(window).height(); 39 winH = $(window).height();
@@ -45,9 +45,8 @@ @@ -45,9 +45,8 @@
45 p{ 45 p{
46 width: 55.517241%; 46 width: 55.517241%;
47 height: auto; 47 height: auto;
48 - padding: 0 5% 10em / $pxConvertRem;; 48 + padding: 0 5% 18em / $pxConvertRem;;
49 float: left; 49 float: left;
50 - font-size: 44em / $pxConvertRem;  
51 &:first-of-type{ 50 &:first-of-type{
52 padding-top:30em / $pxConvertRem; 51 padding-top:30em / $pxConvertRem;
53 font-size: 60em / $pxConvertRem; 52 font-size: 60em / $pxConvertRem;
@@ -184,9 +184,12 @@ $fav: sprite-map("me/fav/*.png",$spacing: 5px); @@ -184,9 +184,12 @@ $fav: sprite-map("me/fav/*.png",$spacing: 5px);
184 .fav-brand-swiper { 184 .fav-brand-swiper {
185 185
186 .swiper-header { 186 .swiper-header {
187 - height: pxToRem(60px); 187 + height: pxToRem(100px);
188 padding: pxToRem(20px) pxToRem(30px); 188 padding: pxToRem(20px) pxToRem(30px);
189 display: inline-block; 189 display: inline-block;
  190 + position: relative;
  191 + width: 100%;
  192 + @include box-sizing();
190 193
191 .swiper-logo { 194 .swiper-logo {
192 height: 100%; 195 height: 100%;
@@ -229,6 +232,19 @@ $fav: sprite-map("me/fav/*.png",$spacing: 5px); @@ -229,6 +232,19 @@ $fav: sprite-map("me/fav/*.png",$spacing: 5px);
229 } 232 }
230 } 233 }
231 } 234 }
  235 + .fav-more {
  236 + $width: pxToRem(image_width(sprite-file($fav, fav-more)));
  237 + $height: pxToRem(image_height(sprite-file($fav, fav-more)));
  238 +
  239 + @include rem-sprite($fav, fav-more);
  240 + width: $width;
  241 + height: $height;
  242 +
  243 + position: absolute;
  244 + top: 50%;
  245 + right: pxToRem(30px);
  246 + margin-top: -$height / 2;
  247 + }
232 } 248 }
233 .swiper-container { 249 .swiper-container {
234 height: pxToRem(300px); 250 height: pxToRem(300px);
@@ -5,19 +5,20 @@ @@ -5,19 +5,20 @@
5 position: relative; 5 position: relative;
6 padding: 0 pxToRem(30px); 6 padding: 0 pxToRem(30px);
7 color: #fff; 7 color: #fff;
8 - background: #ccc;  
9 font-size: pxToRem(34px); 8 font-size: pxToRem(34px);
10 - line-height: pxToRem(164px);  
11 - height: pxToRem(164px); 9 + line-height: pxToRem(168px);
  10 + height: pxToRem(168px);
  11 + background: image-url("me/index/header-bg.jpg");
  12 + background-size: cover;
12 13
13 .user-avatar { 14 .user-avatar {
14 float: left; 15 float: left;
15 position: relative; 16 position: relative;
16 - top: pxToRem(8px);  
17 - width: pxToRem(132px);  
18 - height: pxToRem(132px); 17 + top: pxToRem(16px);
  18 + width: pxToRem(126px);
  19 + height: pxToRem(126px);
19 border-radius: 50%; 20 border-radius: 50%;
20 - border: pxToRem(8px) solid #a7a8a9; 21 + border: pxToRem(6px) solid #a7a8a9;
21 } 22 }
22 23
23 .username { 24 .username {
@@ -36,13 +36,14 @@ @@ -36,13 +36,14 @@
36 } 36 }
37 37
38 .price { 38 .price {
  39 + position: relative;
39 margin-top: pxToRem(20px); 40 margin-top: pxToRem(20px);
40 font-size: pxToRem(20px); 41 font-size: pxToRem(20px);
41 line-height: 1; 42 line-height: 1;
42 43
43 span { 44 span {
44 - // chrome 最小支持12px  
45 - transform: scale(0.875); 45 + // chrome 最小支持12px, 设计图是 10px ,用CSS3变换
  46 + @include transform(scale(0.875));
46 } 47 }
47 48
48 .sale-price { 49 .sale-price {
@@ -50,7 +51,9 @@ @@ -50,7 +51,9 @@
50 } 51 }
51 52
52 .old-price { 53 .old-price {
53 - float: right; 54 + position: absolute;
  55 + top: 0;
  56 + right: 0;
54 color: #ededed; 57 color: #ededed;
55 } 58 }
56 59
@@ -3,18 +3,25 @@ @@ -3,18 +3,25 @@
3 <span class="active">未使用</span> 3 <span class="active">未使用</span>
4 <span>已使用</span> 4 <span>已使用</span>
5 </div> 5 </div>
  6 +{{# couponsUrl}}
6 <div class="employ-list"> 7 <div class="employ-list">
  8 +
  9 +{{# unused}}
7 <div class="employ-main"> 10 <div class="employ-main">
8 <span>50</span> 11 <span>50</span>
9 <p>【summer sale】下装满¥399减¥50券</p> 12 <p>【summer sale】下装满¥399减¥50券</p>
10 <p>有效期:2014.07.28 - 2014.09.15</p> 13 <p>有效期:2014.07.28 - 2014.09.15</p>
11 </div> 14 </div>
  15 +{{/ unused}}
12 </div> 16 </div>
13 <div class="employ-list not none"> 17 <div class="employ-list not none">
  18 +{{# used}}
14 <div class="employ-main"> 19 <div class="employ-main">
15 - <span>60</span>  
16 - <p>【summer sale】下装满¥399减¥60券</p>  
17 - <p>有效期:2014.07.28 - 2014.09.15</p> 20 + <span>{{ money }}</span>
  21 + <p>{{ coupon_name }}</p>
  22 + <p>{{ couponValidity }}</p>
18 </div> 23 </div>
  24 +{{/ used}}
19 </div> 25 </div>
  26 +{{/ couponsUrl}}
20 {{> layout/footer}} 27 {{> layout/footer}}
@@ -66,7 +66,7 @@ @@ -66,7 +66,7 @@
66 {{/ discount}} 66 {{/ discount}}
67 </div> 67 </div>
68 </div> 68 </div>
69 - <a href="{{link}}"></a> 69 + <a class="fav-more" href="{{link}}"></a>
70 </div> 70 </div>
71 <div id="swiper-container-{{id}}" class="swiper-container" data-id="{{id}}"> 71 <div id="swiper-container-{{id}}" class="swiper-container" data-id="{{id}}">
72 <ul class="swiper-wrapper swiper-wrapper-{{id}}"> 72 <ul class="swiper-wrapper swiper-wrapper-{{id}}">
@@ -50,7 +50,7 @@ @@ -50,7 +50,7 @@
50 <a class="list-item" href="/home/address"> 50 <a class="list-item" href="/home/address">
51 <span class="iconfont icon">&#xe637;</span> 51 <span class="iconfont icon">&#xe637;</span>
52 地址管理 52 地址管理
53 - <span class="iconfont num">3 &#xe604;</span> 53 + <span class="iconfont num">{{address_num}} &#xe604;</span>
54 </a> 54 </a>
55 </div> 55 </div>
56 <div class="group-list"> 56 <div class="group-list">
1 {{> layout/header}} 1 {{> layout/header}}
2 <div class="yoho-suggest-sub-page yoho-page"> 2 <div class="yoho-suggest-sub-page yoho-page">
3 {{# suggestSub}} 3 {{# suggestSub}}
4 - <div class="suggest-sub-form"> 4 + <div class="suggest-sub-form"
  5 + data-version="{{param.app_version}}"
  6 + data-type="{{param.client_type}}"
  7 + data-os-version="{{param.os_version}}"
  8 + data-screen-size="{{param.screen_size}}"
  9 + data-v="{{param.v}}"
  10 + data-project="{{param.project}}"
  11 + data-client-secret="{{param.client_secret}}">
5 <textarea name="" id="suggest-textarea" placeholder="请输入意见反馈,我们会以消息形式回复您的建议或意见,改进产品体验,谢谢!"></textarea> 12 <textarea name="" id="suggest-textarea" placeholder="请输入意见反馈,我们会以消息形式回复您的建议或意见,改进产品体验,谢谢!"></textarea>
6 <div class="img-form"> 13 <div class="img-form">
7 <span class="img-add"> 14 <span class="img-add">
@@ -7,8 +7,8 @@ @@ -7,8 +7,8 @@
7 <li class="swiper-slider"> 7 <li class="swiper-slider">
8 <img class="img-box" src="{{thumb}}"> 8 <img class="img-box" src="{{thumb}}">
9 <div class="price"> 9 <div class="price">
10 - <span class="sale-price"{{salePrice}}</span>  
11 - <span class="old-price"{{price}}</span> 10 + <span class="sale-price {{^price}}no-price{{/price}}"{{salePrice}}</span>
  11 + {{#price}}<span class="old-price"{{.}}</span>{{/price}}
12 </div> 12 </div>
13 </li> 13 </li>
14 {{/recommendList}} 14 {{/recommendList}}
@@ -30,7 +30,7 @@ class HomeController extends AbstractAction @@ -30,7 +30,7 @@ class HomeController extends AbstractAction
30 $uid = 8826435; 30 $uid = 8826435;
31 $data = \Index\UserModel::getUserProfileData($uid); 31 $data = \Index\UserModel::getUserProfileData($uid);
32 $data += \Index\UserModel::getInfoNumData($uid); 32 $data += \Index\UserModel::getInfoNumData($uid);
33 - 33 +
34 // 优选新品数据 34 // 优选新品数据
35 $channel = Helpers::getChannelByCookie(); 35 $channel = Helpers::getChannelByCookie();
36 $data['recommendForYou'] = \Index\UserModel::getPreferenceData($channel); 36 $data['recommendForYou'] = \Index\UserModel::getPreferenceData($channel);
@@ -157,6 +157,15 @@ class HomeController extends AbstractAction @@ -157,6 +157,15 @@ class HomeController extends AbstractAction
157 )); 157 ));
158 } 158 }
159 159
  160 +
  161 + /**
  162 + * 用户收藏的商品-删除
  163 + */
  164 + public function favoriteDelAction() {
  165 +
  166 + //$this->echoJson();
  167 + }
  168 +
160 /** 169 /**
161 * 用户收藏的品牌 170 * 用户收藏的品牌
162 */ 171 */
@@ -212,7 +221,6 @@ class HomeController extends AbstractAction @@ -212,7 +221,6 @@ class HomeController extends AbstractAction
212 'couponsUrl' => \Index\UserModel::getCouponData($uid, $status), 221 'couponsUrl' => \Index\UserModel::getCouponData($uid, $status),
213 'couponsPage' => true 222 'couponsPage' => true
214 ); 223 );
215 - print_r($coupons);  
216 224
217 $this->_view->display('coupons', $coupons); 225 $this->_view->display('coupons', $coupons);
218 } 226 }
@@ -361,26 +369,43 @@ class HomeController extends AbstractAction @@ -361,26 +369,43 @@ class HomeController extends AbstractAction
361 } 369 }
362 370
363 /** 371 /**
364 - * 意见反馈-提交表单 372 + * 意见反馈-提交表单页面
365 */ 373 */
366 - public function suggest_subAction() {  
367 - $udid = $this->getUdid();  
368 - $page = $this->get('page', 1);  
369 - $limit = $this->get('limit', 30); 374 + public function suggestSubAction() {
  375 +
  376 + // 设置网站标题
  377 + $this->setTitle('反馈问题');
  378 +
  379 + $param = \Api\Yohobuy::param();
  380 + unset($param['private_key']);
  381 + $param['project'] = 'suggest';
  382 + $param['client_secret'] = 'e7807a9522ab99af8b8fd926e1ebbd9a';
  383 + $data = array(
  384 + 'suggestPage' => true, //加载js
  385 + 'pageHeader' => array(
  386 + 'navBack' => true,
  387 + 'navTitle' => '反馈问题',
  388 + 'navBtn' => '提交'
  389 + ),
  390 + 'param' => $param,
  391 + 'suggestSub' => true,
  392 + 'pageFooter' => true
  393 + );
  394 + //print_r($data);
  395 +
  396 + $this->_view->display('suggest_sub', $data);
  397 + }
370 398
371 - $suggest = \Index\UserModel::getSuggestData($udid, $page, $limit); 399 + /**
  400 + * 异步上传图片
  401 + */
  402 + public function suggestimgUploadAction() {
  403 + if ($this->isAjax()) {
  404 + $filename = $this->get('filename', '');
  405 + $result = \Plugin\Images::saveImage($filename);
372 406
373 - //print_r($suggest);  
374 - $this->_view->display('suggest_sub', array(  
375 - 'suggestPage' => true, //加载js  
376 - 'pageHeader' => array(  
377 - 'navBack' => true,  
378 - 'navTitle' => '反馈问题',  
379 - 'navBtn' => '提交'  
380 - ),  
381 - 'suggestSub' => true,  
382 - 'pageFooter' => true  
383 - )); 407 + $this->echoJson($result);
  408 + }
384 } 409 }
385 410
386 /** 411 /**