Authored by 梁志锋

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

@@ -20,7 +20,8 @@ var $num, @@ -20,7 +20,8 @@ var $num,
20 $colorList = $('.color-list ul>li'), 20 $colorList = $('.color-list ul>li'),
21 $sizeList = $('.size-list ul>li'), 21 $sizeList = $('.size-list ul>li'),
22 firstColorId = $colorList.eq(0).data('id'), 22 firstColorId = $colorList.eq(0).data('id'),
23 - colorIndex; 23 + colorIndex,
  24 + confirming;
24 25
25 //初始化购物车面板显示 26 //初始化购物车面板显示
26 $sizeList.each(function() { 27 $sizeList.each(function() {
@@ -31,7 +32,7 @@ $sizeList.each(function() { @@ -31,7 +32,7 @@ $sizeList.each(function() {
31 } 32 }
32 }); 33 });
33 34
34 -// confirm; 35 +
35 36
36 // var tpl; 37 // var tpl;
37 38
@@ -81,41 +82,47 @@ $('.yoho-page').on('touchstart', '.chose-panel', function(e) { @@ -81,41 +82,47 @@ $('.yoho-page').on('touchstart', '.chose-panel', function(e) {
81 }).on('touchstart', '#chose-btn-sure', function() { 82 }).on('touchstart', '#chose-btn-sure', function() {
82 83
83 var productSku, 84 var productSku,
84 - buyNumber = $('#good-num') - 0; 85 + buyNumber = $('#good-num').val() - 0,
  86 +
  87 + promotionId,
  88 + isEdit = 0,
  89 + numInCart = $('.num-tag').html() - 0;
85 90
86 - // promotionId,  
87 - // goodsType, 91 + // goodsType,
88 // isEdit; 92 // isEdit;
89 93
90 $chosed = $('.block-list>ul>li.chosed'); 94 $chosed = $('.block-list>ul>li.chosed');
91 95
92 if (2 === $chosed.length && 0 === $chosed.closest('.zero-stock').length) { 96 if (2 === $chosed.length && 0 === $chosed.closest('.zero-stock').length) {
93 productSku = $sizeList.closest('.chosed').data('skuid'); 97 productSku = $sizeList.closest('.chosed').data('skuid');
  98 + promotionId = $('[data-id="' + productSku + '"]').closest('.advance-block').data('promotion-id');
  99 + if (confirming) {
  100 + return false;
  101 + }
94 102
95 - // if (confirm) {  
96 - // return false;  
97 - // }  
98 -  
99 - // confirm = true; 103 + confirming = true;
100 loading.showLoadingMask(); 104 loading.showLoadingMask();
101 $.ajax({ 105 $.ajax({
102 method: 'POST', 106 method: 'POST',
103 url: '/cart/index/add', 107 url: '/cart/index/add',
104 data: { 108 data: {
105 productSku: productSku, 109 productSku: productSku,
106 - buyNumber: buyNumber 110 + buyNumber: buyNumber,
  111 + promotionId: promotionId,
  112 + isEdit: isEdit
107 } 113 }
108 }).done(function(res) { 114 }).done(function(res) {
109 if (res.code === 200) { 115 if (res.code === 200) {
110 loading.hideLoadingMask(); 116 loading.hideLoadingMask();
111 -  
112 - // confirm = false; 117 + $('.num-tag').html(numInCart + buyNumber);
  118 + $('.num-tag').removeClass('hide');
  119 + confirming = false;
113 remove(); 120 remove();
114 } 121 }
115 }).fail(function() { 122 }).fail(function() {
116 tip.show('网络出了点问题~'); 123 tip.show('网络出了点问题~');
117 124
118 - // confirm = false; 125 + confirming = false;
119 }); 126 });
120 } 127 }
121 128
@@ -8,6 +8,7 @@ var $ = require('jquery'), @@ -8,6 +8,7 @@ var $ = require('jquery'),
8 lazyLoad = require('yoho.lazyload'), 8 lazyLoad = require('yoho.lazyload'),
9 Handlebars = require('yoho.handlebars'), 9 Handlebars = require('yoho.handlebars'),
10 tip = require('../plugin/tip'), 10 tip = require('../plugin/tip'),
  11 + loading = require('../plugin/loading'),
11 chosePanel = require('./chose-panel'); 12 chosePanel = require('./chose-panel');
12 13
13 var panelTmpl, 14 var panelTmpl,
@@ -27,6 +28,7 @@ $.get('/cart/index/giftinfoTpl', function(html) { @@ -27,6 +28,7 @@ $.get('/cart/index/giftinfoTpl', function(html) {
27 }); 28 });
28 29
29 function getProductInfo(skn, promotionId) { 30 function getProductInfo(skn, promotionId) {
  31 + loading.showLoadingMask();
30 $.get('/cart/index/giftinfo', { 32 $.get('/cart/index/giftinfo', {
31 skn: skn, 33 skn: skn,
32 promotionId: promotionId 34 promotionId: promotionId
@@ -48,6 +50,8 @@ function getProductInfo(skn, promotionId) { @@ -48,6 +50,8 @@ function getProductInfo(skn, promotionId) {
48 } 50 }
49 }).fail(function() { 51 }).fail(function() {
50 tip.show('网络错误'); 52 tip.show('网络错误');
  53 + }).always(function() {
  54 + loading.hideLoadingMask();
51 }); 55 });
52 } 56 }
53 57
@@ -92,7 +92,7 @@ function getCouponHandle(coupons) { @@ -92,7 +92,7 @@ function getCouponHandle(coupons) {
92 92
93 // 第一页张数为 0 ,显示优惠券为空 93 // 第一页张数为 0 ,显示优惠券为空
94 if (!coupons.length && page === 2) { 94 if (!coupons.length && page === 2) {
95 - $('.select-coupon-page').html($('#tmpl-no-coupon').html()); 95 + $('.coupin-wrap').html($('#tmpl-no-coupon').html());
96 return; 96 return;
97 } 97 }
98 98
@@ -43,6 +43,8 @@ function request() { @@ -43,6 +43,8 @@ function request() {
43 requesting = false; 43 requesting = false;
44 end = true; 44 end = true;
45 45
  46 + window.rePosFooter();
  47 +
46 }).fail(function() { 48 }).fail(function() {
47 $recommendForYou.hide(); 49 $recommendForYou.hide();
48 }); 50 });
@@ -50,7 +52,7 @@ function request() { @@ -50,7 +52,7 @@ function request() {
50 } 52 }
51 53
52 function scrollHandler() { 54 function scrollHandler() {
53 - if (!end || $(window).scrollTop() + winH >= $(document).height() - 50) { 55 + if (!end || $(window).scrollTop() + winH >= $(document).height() - 200) {
54 request(); 56 request();
55 } 57 }
56 } 58 }
@@ -4,9 +4,11 @@ @@ -4,9 +4,11 @@
4 <input type="text" name="couponCode" value="" placeholder="输入优惠券码"> 4 <input type="text" name="couponCode" value="" placeholder="输入优惠券码">
5 <button type="submit" class="submit">确定</button> 5 <button type="submit" class="submit">确定</button>
6 </form> 6 </form>
7 - <div id="coupon-list" class="coupon-list"></div>  
8 - <div class="not-avaliable-coupon-line hide">不可使用的优惠券</div>  
9 - <div id="coupon-list-not" class="coupon-list"></div> 7 + <div class="coupin-wrap">
  8 + <div id="coupon-list" class="coupon-list"></div>
  9 + <div class="not-avaliable-coupon-line hide">不可使用的优惠券</div>
  10 + <div id="coupon-list-not" class="coupon-list"></div>
  11 + </div>
10 </div> 12 </div>
11 <script id="tmpl-coupon" type="text/tmpl"> 13 <script id="tmpl-coupon" type="text/tmpl">
12 \{{#coupons}} 14 \{{#coupons}}
@@ -15,7 +15,7 @@ @@ -15,7 +15,7 @@
15 } 15 }
16 .help { 16 .help {
17 padding: 30px 30px; 17 padding: 30px 30px;
18 - font-size: 16px; 18 + font-size: 24px;
19 line-height: 1.5; 19 line-height: 1.5;
20 color: #444; 20 color: #444;
21 } 21 }
@@ -36,8 +36,7 @@ @@ -36,8 +36,7 @@
36 </ul> 36 </ul>
37 <p>其他说明:</p> 37 <p>其他说明:</p>
38 <ul> 38 <ul>
39 - <li>1. YOHO!BUY有货对用户在本站进行晒单评价的文字、图片享有使用权利;</li>  
40 - <li>2. 用户所晒单评价的文字、图片提交发布后,默认同步YOHO!SHOW平台;</li> 39 + <li>YOHO!BUY有货对用户在本站进行晒单评价的文字、图片享有使用权利</li>
41 </ul> 40 </ul>
42 </div> 41 </div>
43 </body> 42 </body>
@@ -5,8 +5,8 @@ @@ -5,8 +5,8 @@
5 <a class="swiper-slide" href="{{url}}"> 5 <a class="swiper-slide" href="{{url}}">
6 <img class="swiper-lazy img-box" data-src="{{thumb}}"> 6 <img class="swiper-lazy img-box" data-src="{{thumb}}">
7 <div class="price"> 7 <div class="price">
8 - <span class="sale-price {{^price}}no-price{{/price}}">¥{{salePrice}}</span>  
9 - {{#price}}<span class="old-price">¥{{.}}</span>{{/price}} 8 + <span class="sale-price {{^price}}no-price{{/price}}">&yen;{{salePrice}}</span>
  9 + {{#price}}<span class="old-price">&yen;{{.}}</span>{{/price}}
10 </div> 10 </div>
11 <div class="swiper-lazy-preloader"></div> 11 <div class="swiper-lazy-preloader"></div>
12 </a> 12 </a>
@@ -218,7 +218,7 @@ class OrderModel @@ -218,7 +218,7 @@ class OrderModel
218 //已发货状态,给查看物流URL 218 //已发货状态,给查看物流URL
219 $result['unreceived'] = true; 219 $result['unreceived'] = true;
220 $result['logisticsUrl'] = Helpers::url('/home/logistic', array('order_code' => $order['order_code'])); 220 $result['logisticsUrl'] = Helpers::url('/home/logistic', array('order_code' => $order['order_code']));
221 - if ($showLogistics) { 221 + if ($showLogistics && isset($order['caption'])) {
222 $result['logisticsCompany'] = $order['caption']; 222 $result['logisticsCompany'] = $order['caption'];
223 $result['logisticsNum'] = $order['express_number']; 223 $result['logisticsNum'] = $order['express_number'];
224 } 224 }
@@ -248,9 +248,9 @@ class OrderModel @@ -248,9 +248,9 @@ class OrderModel
248 //待收货状态,给查看物流url 248 //待收货状态,给查看物流url
249 $result['unreceived'] = true; 249 $result['unreceived'] = true;
250 $result['logisticsUrl'] = Helpers::url('/home/logistic', array('order_code' => $order['order_code'])); 250 $result['logisticsUrl'] = Helpers::url('/home/logistic', array('order_code' => $order['order_code']));
251 - if ($showLogistics) {  
252 - $result['logisticsCompany'] = isset($order['caption']) ? $order['caption'] : '';  
253 - $result['logisticsNum'] = isset($order['express_number']) ? $order['express_number'] : ''; 251 + if ($showLogistics && isset($order['caption'])) {
  252 + $result['logisticsCompany'] = $order['caption'];
  253 + $result['logisticsNum'] = $order['express_number'];
254 } 254 }
255 break; 255 break;
256 case 6: 256 case 6:
@@ -241,7 +241,7 @@ class DetailModel @@ -241,7 +241,7 @@ class DetailModel
241 'numInCart' => 0, 241 'numInCart' => 0,
242 'goodsInstore' => $baseInfo['storage'], // 库存量 242 'goodsInstore' => $baseInfo['storage'], // 库存量
243 ); 243 );
244 - $soldOut = $totalStorageNum === 0; 244 + $soldOut = ($baseInfo['storage'] == 0) || ($totalStorageNum === 0);
245 $notForSale = $baseInfo['attribute'] == 2; 245 $notForSale = $baseInfo['attribute'] == 2;
246 // 显示加入购物车链接 246 // 显示加入购物车链接
247 if (!$soldOut && !$notForSale) { 247 if (!$soldOut && !$notForSale) {
@@ -346,7 +346,7 @@ class DetailModel @@ -346,7 +346,7 @@ class DetailModel
346 346
347 $referenceList = array(); 347 $referenceList = array();
348 // 判断是否显示参考尺码 348 // 判断是否显示参考尺码
349 - $showReference = $boyReference || $girlReference; 349 + $showReference = ($boyReference && !empty($sizeInfo['sizeInfoBo']['sizeBoList'][0]['boyReferSize'])) || ($girlReference && !empty($sizeInfo['sizeInfoBo']['sizeBoList'][0]['girlReferSize']) );
350 if ($showReference) { 350 if ($showReference) {
351 $referenceList[0] = array('param' => $referenceName); 351 $referenceList[0] = array('param' => $referenceName);
352 } 352 }
@@ -48,6 +48,7 @@ class IndexController extends AbstractAction @@ -48,6 +48,7 @@ class IndexController extends AbstractAction
48 // 渲染模板 48 // 渲染模板
49 $this->_view->display('index', $data); 49 $this->_view->display('index', $data);
50 } 50 }
  51 +
51 /* 52 /*
52 * 异步获取购物车数据 53 * 异步获取购物车数据
53 */ 54 */
@@ -79,7 +80,7 @@ class IndexController extends AbstractAction @@ -79,7 +80,7 @@ class IndexController extends AbstractAction
79 if ($this->isAjax()) { 80 if ($this->isAjax()) {
80 $productId = $this->post('skuList', 0); 81 $productId = $this->post('skuList', 0);
81 $uid = $this->getUid(true); 82 $uid = $this->getUid(true);
82 - $shoppingKey = $this->getSession('shoppingKey'); 83 + $shoppingKey = Helpers::getShoppingKeyByCookie();
83 $result = CartModel::selectGoods($uid, $productId, $shoppingKey); 84 $result = CartModel::selectGoods($uid, $productId, $shoppingKey);
84 } 85 }
85 86
@@ -100,7 +101,7 @@ class IndexController extends AbstractAction @@ -100,7 +101,7 @@ class IndexController extends AbstractAction
100 if ($this->isAjax()) { 101 if ($this->isAjax()) {
101 $productId = $this->post('id', 0); 102 $productId = $this->post('id', 0);
102 $uid = $this->getUid(true); 103 $uid = $this->getUid(true);
103 - $shoppingKey = $this->getSession('shoppingKey'); 104 + $shoppingKey = Helpers::getShoppingKeyByCookie();
104 $result = CartModel::removeFromCart($uid, $productId, $shoppingKey); 105 $result = CartModel::removeFromCart($uid, $productId, $shoppingKey);
105 } 106 }
106 107
@@ -191,6 +192,7 @@ class IndexController extends AbstractAction @@ -191,6 +192,7 @@ class IndexController extends AbstractAction
191 192
192 /* 193 /*
193 * 获取购物车加价购商品数据模板 194 * 获取购物车加价购商品数据模板
  195 + * 需要返回模板的html代码,不能渲染
194 */ 196 */
195 public function giftinfoTplAction() 197 public function giftinfoTplAction()
196 { 198 {
@@ -206,11 +208,11 @@ class IndexController extends AbstractAction @@ -206,11 +208,11 @@ class IndexController extends AbstractAction
206 { 208 {
207 $result = array(); 209 $result = array();
208 210
209 -// if ($this->isAjax()) { 211 + if ($this->isAjax()) {
210 $skn = $this->get('skn', null); 212 $skn = $this->get('skn', null);
211 $promotionId = $this->get('promotionId', null); 213 $promotionId = $this->get('promotionId', null);
212 $result = CartModel::giftProductData($skn, $promotionId); 214 $result = CartModel::giftProductData($skn, $promotionId);
213 -// } 215 + }
214 216
215 if (empty($result)) { 217 if (empty($result)) {
216 echo ' '; 218 echo ' ';
@@ -227,7 +229,7 @@ class IndexController extends AbstractAction @@ -227,7 +229,7 @@ class IndexController extends AbstractAction
227 $result = array(); 229 $result = array();
228 230
229 if ($this->isAjax()) { 231 if ($this->isAjax()) {
230 - $shoppingKey = $this->getSession('shoppingKey'); 232 + $shoppingKey = Helpers::getShoppingKeyByCookie();
231 $uid = $this->getUid(true); 233 $uid = $this->getUid(true);
232 234
233 $sku= $this->post('sku', 0); 235 $sku= $this->post('sku', 0);
@@ -251,7 +253,7 @@ class IndexController extends AbstractAction @@ -251,7 +253,7 @@ class IndexController extends AbstractAction
251 $result = array(); 253 $result = array();
252 254
253 if ($this->isAjax()) { 255 if ($this->isAjax()) {
254 - $shoppingKey = $this->getSession('shoppingKey'); 256 + $shoppingKey = Helpers::getShoppingKeyByCookie();
255 $uid = $this->getUid(true); 257 $uid = $this->getUid(true);
256 258
257 $params = array(); 259 $params = array();
@@ -356,7 +358,7 @@ class IndexController extends AbstractAction @@ -356,7 +358,7 @@ class IndexController extends AbstractAction
356 } 358 }
357 359
358 if (empty($result)) { 360 if (empty($result)) {
359 - echo ' '; 361 + echo '[]';
360 } else { 362 } else {
361 $this->echoJson($result); 363 $this->echoJson($result);
362 } 364 }
@@ -17,26 +17,25 @@ class BindController extends AbstractAction @@ -17,26 +17,25 @@ class BindController extends AbstractAction
17 public function indexAction() 17 public function indexAction()
18 { 18 {
19 $refer = $this->get('refer'); 19 $refer = $this->get('refer');
20 - if (!empty($refer))  
21 - { 20 + if (!empty($refer)) {
22 $this->setCookie('refer', $refer); 21 $this->setCookie('refer', $refer);
23 } 22 }
24 23
25 $this->setTitle('绑定手机号'); 24 $this->setTitle('绑定手机号');
26 - 25 +
27 $openId = $this->get('openId'); 26 $openId = $this->get('openId');
28 $sourceType = $this->get('sourceType'); 27 $sourceType = $this->get('sourceType');
29 $nickname = $this->get('nickname'); 28 $nickname = $this->get('nickname');
30 $data = array( 29 $data = array(
31 - 'bindIndex'=>true,//js标识  
32 - 'backUrl' => '/', // 返回的URL链接 30 + 'bindIndex' => true, //js标识
  31 + 'backUrl' => Helpers::url('/signin.html'), // 返回的URL链接
33 'showHeaderImg' => true, // 控制显示头部图片 32 'showHeaderImg' => true, // 控制显示头部图片
34 'isPassportPage' => true, // 模板中模块标识 33 'isPassportPage' => true, // 模板中模块标识
35 'sourceType' => $sourceType, // 第三方登录来源 34 'sourceType' => $sourceType, // 第三方登录来源
36 - 'platform'=>$sourceType, 35 + 'platform' => $sourceType,
37 'openId' => $openId, // openId 36 'openId' => $openId, // openId
38 - 'areaCode'=>'+86',//默认区号  
39 - 'countrys'=>RegData::getAreasData(),//国别码 37 + 'areaCode' => '+86', //默认区号
  38 + 'countrys' => RegData::getAreasData(), //国别码
40 'nickname' => $nickname, //昵称 39 'nickname' => $nickname, //昵称
41 ); 40 );
42 41
@@ -49,26 +48,25 @@ class BindController extends AbstractAction @@ -49,26 +48,25 @@ class BindController extends AbstractAction
49 */ 48 */
50 public function codeAction() 49 public function codeAction()
51 { 50 {
52 -  
53 $this->setTitle('验证手机'); 51 $this->setTitle('验证手机');
54 $openId = $this->get('openId'); 52 $openId = $this->get('openId');
55 $sourceType = $this->get('sourceType'); 53 $sourceType = $this->get('sourceType');
56 $nickname = $this->get('nickname'); 54 $nickname = $this->get('nickname');
57 $areaCode = $this->get('areaCode', '86'); 55 $areaCode = $this->get('areaCode', '86');
58 $isReg = $this->get('isReg'); 56 $isReg = $this->get('isReg');
59 - $phoneNum=$this->get('phoneNum');  
60 - 57 + $phoneNum = $this->get('phoneNum');
  58 +
61 $data = array( 59 $data = array(
62 - 'bindCode'=>true,//js标识  
63 - 'backUrl' => '/', // 返回的URL链接 60 + 'bindCode' => true, //js标识
  61 + 'backUrl' => Helpers::url('/signin.html'), // 返回的URL链接
64 'showHeaderImg' => true, // 控制显示头部图片 62 'showHeaderImg' => true, // 控制显示头部图片
65 'isPassportPage' => true, // 模板中模块标识 63 'isPassportPage' => true, // 模板中模块标识
66 'sourceType' => $sourceType, // 第三方登录来源 64 'sourceType' => $sourceType, // 第三方登录来源
67 'openId' => $openId, // openId 65 'openId' => $openId, // openId
68 'nickname' => $nickname, //昵称 66 'nickname' => $nickname, //昵称
69 'isReg' => $isReg, //是否是已注册过的手机号 67 'isReg' => $isReg, //是否是已注册过的手机号
70 - 'areaCode' => $areaCode, //国别码  
71 - 'phoneNum'=>$phoneNum,//手机号码 68 + 'areaCode' => $areaCode, //国别码
  69 + 'phoneNum' => $phoneNum, //手机号码
72 ); 70 );
73 71
74 // 渲染模板 72 // 渲染模板
@@ -80,22 +78,21 @@ class BindController extends AbstractAction @@ -80,22 +78,21 @@ class BindController extends AbstractAction
80 */ 78 */
81 public function passwordAction() 79 public function passwordAction()
82 { 80 {
83 -  
84 $this->setTitle('重新设置登录密码'); 81 $this->setTitle('重新设置登录密码');
85 $openId = $this->get('openId'); 82 $openId = $this->get('openId');
86 $sourceType = $this->get('sourceType'); 83 $sourceType = $this->get('sourceType');
87 $nickname = $this->get('nickname'); 84 $nickname = $this->get('nickname');
88 $areaCode = $this->get('areaCode', '86'); 85 $areaCode = $this->get('areaCode', '86');
89 - $phoneNum=$this->get('phoneNum'); 86 + $phoneNum = $this->get('phoneNum');
90 $data = array( 87 $data = array(
91 - 'bindPwd'=>true,//js标识  
92 - 'backUrl' => '/', // 返回的URL链接 88 + 'bindPwd' => true, //js标识
  89 + 'backUrl' => Helpers::url('/signin.html'), // 返回的URL链接
93 'showHeaderImg' => true, // 控制显示头部图片 90 'showHeaderImg' => true, // 控制显示头部图片
94 'isPassportPage' => true, // 模板中模块标识 91 'isPassportPage' => true, // 模板中模块标识
95 'sourceType' => $sourceType, // 第三方登录来源 92 'sourceType' => $sourceType, // 第三方登录来源
96 'openId' => $openId, // openId 93 'openId' => $openId, // openId
97 'nickname' => $nickname, //昵称 94 'nickname' => $nickname, //昵称
98 - 'areaCode' => $areaCode, //国别码 95 + 'areaCode' => $areaCode, //国别码
99 'phoneNum' => $phoneNum //国别码 96 'phoneNum' => $phoneNum //国别码
100 ); 97 );
101 98
@@ -108,11 +105,9 @@ class BindController extends AbstractAction @@ -108,11 +105,9 @@ class BindController extends AbstractAction
108 { 105 {
109 $data = array('code' => 400, 'message' => '', 'data' => ''); 106 $data = array('code' => 400, 'message' => '', 'data' => '');
110 107
111 - do  
112 - { 108 + do {
113 /* 判断是不是AJAX请求 */ 109 /* 判断是不是AJAX请求 */
114 - if (!$this->isAjax())  
115 - { 110 + if (!$this->isAjax()) {
116 break; 111 break;
117 } 112 }
118 113
@@ -123,27 +118,21 @@ class BindController extends AbstractAction @@ -123,27 +118,21 @@ class BindController extends AbstractAction
123 $nickname = $this->post('nickname'); 118 $nickname = $this->post('nickname');
124 119
125 120
126 - if (!is_numeric($phoneNum) || !$openId || !$areaCode || !$sourceType)  
127 - { 121 + if (!is_numeric($phoneNum) || !$openId || !$areaCode || !$sourceType) {
128 break; 122 break;
129 } 123 }
130 124
131 $res = BindData::bindCheck($phoneNum, $openId, $sourceType); 125 $res = BindData::bindCheck($phoneNum, $openId, $sourceType);
132 - if (!isset($res['code']))  
133 - { 126 + if (!isset($res['code'])) {
134 break; 127 break;
135 } 128 }
136 - if ($res['code'] == 200)  
137 - { 129 + if ($res['code'] == 200) {
138 $next = Helpers::url('/passport/bind/code', array('isReg' => $res['data']['is_register'], 'openId' => $openId, 'sourceType' => $sourceType, 'nickname' => $nickname, 'areaCode' => $areaCode, 'phoneNum' => $phoneNum)); 130 $next = Helpers::url('/passport/bind/code', array('isReg' => $res['data']['is_register'], 'openId' => $openId, 'sourceType' => $sourceType, 'nickname' => $nickname, 'areaCode' => $areaCode, 'phoneNum' => $phoneNum));
139 $data = array('code' => $res['code'], 'message' => $res['message'], 'data' => array('isReg' => $res['data']['is_register'], 'next' => $next)); 131 $data = array('code' => $res['code'], 'message' => $res['message'], 'data' => array('isReg' => $res['data']['is_register'], 'next' => $next));
  132 + } else {
  133 + $data = array('code' => $res['code'], 'message' => $res['message'], 'data' => isset($res['data']) ? $res['data'] : '');
140 } 134 }
141 - else  
142 - {  
143 - $data = array('code' => $res['code'], 'message' => $res['message'], 'data' => isset($res['data'])?$res['data']:'');  
144 - }  
145 - }  
146 - while (false); 135 + } while (false);
147 136
148 $this->echoJson($data); 137 $this->echoJson($data);
149 } 138 }
@@ -153,29 +142,24 @@ class BindController extends AbstractAction @@ -153,29 +142,24 @@ class BindController extends AbstractAction
153 { 142 {
154 $data = array('code' => 400, 'message' => '', 'data' => ''); 143 $data = array('code' => 400, 'message' => '', 'data' => '');
155 144
156 - do  
157 - { 145 + do {
158 /* 判断是不是AJAX请求 */ 146 /* 判断是不是AJAX请求 */
159 - if (!$this->isAjax())  
160 - { 147 + if (!$this->isAjax()) {
161 break; 148 break;
162 } 149 }
163 150
164 $phoneNum = $this->post('phoneNum'); 151 $phoneNum = $this->post('phoneNum');
165 $areaCode = $this->post('areaCode'); 152 $areaCode = $this->post('areaCode');
166 153
167 - if (!is_numeric($phoneNum))  
168 - { 154 + if (!is_numeric($phoneNum)) {
169 break; 155 break;
170 } 156 }
171 157
172 - $data = BindData::sendBindMsg($areaCode,$phoneNum);  
173 - if (!isset($data['code']))  
174 - { 158 + $data = BindData::sendBindMsg($areaCode, $phoneNum);
  159 + if (!isset($data['code'])) {
175 break; 160 break;
176 } 161 }
177 - }  
178 - while (false); 162 + } while (false);
179 163
180 $this->echoJson($data); 164 $this->echoJson($data);
181 } 165 }
@@ -185,11 +169,9 @@ class BindController extends AbstractAction @@ -185,11 +169,9 @@ class BindController extends AbstractAction
185 { 169 {
186 $data = array('code' => 400, 'message' => '', 'data' => ''); 170 $data = array('code' => 400, 'message' => '', 'data' => '');
187 171
188 - do  
189 - { 172 + do {
190 /* 判断是不是AJAX请求 */ 173 /* 判断是不是AJAX请求 */
191 - if (!$this->isAjax())  
192 - { 174 + if (!$this->isAjax()) {
193 break; 175 break;
194 } 176 }
195 177
@@ -197,18 +179,15 @@ class BindController extends AbstractAction @@ -197,18 +179,15 @@ class BindController extends AbstractAction
197 $code = $this->post('code'); 179 $code = $this->post('code');
198 $areaCode = $this->post('areaCode'); 180 $areaCode = $this->post('areaCode');
199 181
200 - if (!is_numeric($phoneNum) || !$code)  
201 - { 182 + if (!is_numeric($phoneNum) || !$code) {
202 break; 183 break;
203 } 184 }
204 185
205 - $data = BindData::checkBindCode($areaCode,$phoneNum, $code);  
206 - if (!isset($data['code']))  
207 - { 186 + $data = BindData::checkBindCode($areaCode, $phoneNum, $code);
  187 + if (!isset($data['code'])) {
208 break; 188 break;
209 } 189 }
210 - }  
211 - while (false); 190 + } while (false);
212 191
213 $this->echoJson($data); 192 $this->echoJson($data);
214 } 193 }
@@ -218,11 +197,9 @@ class BindController extends AbstractAction @@ -218,11 +197,9 @@ class BindController extends AbstractAction
218 { 197 {
219 $data = array('code' => 400, 'message' => '', 'data' => ''); 198 $data = array('code' => 400, 'message' => '', 'data' => '');
220 199
221 - do  
222 - { 200 + do {
223 /* 判断是不是AJAX请求 */ 201 /* 判断是不是AJAX请求 */
224 - if (!$this->isAjax())  
225 - { 202 + if (!$this->isAjax()) {
226 break; 203 break;
227 } 204 }
228 205
@@ -233,42 +210,33 @@ class BindController extends AbstractAction @@ -233,42 +210,33 @@ class BindController extends AbstractAction
233 $nickname = $this->post('nickname'); 210 $nickname = $this->post('nickname');
234 $password = $this->post('password'); 211 $password = $this->post('password');
235 212
236 - if (!is_numeric($phoneNum) || !$openId || !$sourceType || !$areaCode)  
237 - { 213 + if (!is_numeric($phoneNum) || !$openId || !$sourceType || !$areaCode) {
238 break; 214 break;
239 } 215 }
240 216
241 $res = BindData::bindMobile($openId, $nickname, $sourceType, $phoneNum, $areaCode, $password); 217 $res = BindData::bindMobile($openId, $nickname, $sourceType, $phoneNum, $areaCode, $password);
242 - if (!isset($res['code']))  
243 - { 218 + if (!isset($res['code'])) {
244 break; 219 break;
245 } 220 }
246 221
247 //绑定成功,跳转页面 222 //绑定成功,跳转页面
248 $refer = $this->getCookie('refer'); 223 $refer = $this->getCookie('refer');
249 - if (empty($refer))  
250 - { 224 + if (empty($refer)) {
251 $refer = SITE_MAIN . '/?go=1'; 225 $refer = SITE_MAIN . '/?go=1';
252 - }  
253 - else  
254 - { 226 + } else {
255 $refer = rawurldecode($refer); 227 $refer = rawurldecode($refer);
256 } 228 }
257 -  
258 - if (isset($res['code']) && $res['code'] == 200 && !empty($res['data']['uid']))  
259 - { 229 +
  230 + if (isset($res['code']) && $res['code'] == 200 && !empty($res['data']['uid'])) {
260 $token = Helpers::makeToken($res['data']['uid']); 231 $token = Helpers::makeToken($res['data']['uid']);
261 $this->setCookie('_TOKEN', $token); 232 $this->setCookie('_TOKEN', $token);
262 $this->setSession('_TOKEN', $token); 233 $this->setSession('_TOKEN', $token);
263 $refer = Helpers::syncUserSession($res['data']['uid'], $refer); 234 $refer = Helpers::syncUserSession($res['data']['uid'], $refer);
264 $data = array('code' => $res['code'], 'message' => $res['message'], 'data' => array('refer' => $refer)); 235 $data = array('code' => $res['code'], 'message' => $res['message'], 'data' => array('refer' => $refer));
265 - }  
266 - else  
267 - { 236 + } else {
268 $data = array('code' => $res['code'], 'message' => $res['message'], 'data' => array('refer' => $refer)); 237 $data = array('code' => $res['code'], 'message' => $res['message'], 'data' => array('refer' => $refer));
269 } 238 }
270 - }  
271 - while (false); 239 + } while (false);
272 240
273 $this->echoJson($data); 241 $this->echoJson($data);
274 } 242 }
@@ -79,7 +79,7 @@ class LoginController extends AbstractAction @@ -79,7 +79,7 @@ class LoginController extends AbstractAction
79 $refer = $this->server('HTTP_REFERER', SITE_MAIN); 79 $refer = $this->server('HTTP_REFERER', SITE_MAIN);
80 $token = $this->get('token'); 80 $token = $this->get('token');
81 if (!empty($token)) { 81 if (!empty($token)) {
82 - $this->go( Helpers::logoutSession($token, $refer) ); 82 + $this->go(Helpers::logoutSession($token, $refer));
83 } 83 }
84 84
85 $this->go($refer); 85 $this->go($refer);
@@ -119,7 +119,7 @@ class LoginController extends AbstractAction @@ -119,7 +119,7 @@ class LoginController extends AbstractAction
119 } 119 }
120 120
121 /* 调用登录接口进行登录 */ 121 /* 调用登录接口进行登录 */
122 - $data = LoginData::signin($area, $profile, $password); 122 + $data = LoginData::signin($area, $profile, $password);
123 if (!isset($data['code']) || $data['code'] != 200 || !isset($data['data']['uid'])) { 123 if (!isset($data['code']) || $data['code'] != 200 || !isset($data['data']['uid'])) {
124 break; 124 break;
125 } 125 }
@@ -182,12 +182,10 @@ class LoginController extends AbstractAction @@ -182,12 +182,10 @@ class LoginController extends AbstractAction
182 if (isset($realName, $email, $userId)) { 182 if (isset($realName, $email, $userId)) {
183 $result = LoginData::signinByOpenID($realName, $userId, 'alipay'); 183 $result = LoginData::signinByOpenID($realName, $userId, 'alipay');
184 } 184 }
185 - 185 +
186 //判定是否需要绑定手机号 186 //判定是否需要绑定手机号
187 - $isBind = $result['data']['is_bind'];  
188 - if ($isBind == 'N')  
189 - {  
190 - $this->go(Helpers::url('/passport/bind/index',array('openId'=>$userId,'sourceType'=>'alipay','nickname'=>$realName))); 187 + if (isset($result['data']['is_bind']) && $result['data']['is_bind'] == 'N') {
  188 + $this->go(Helpers::url('/passport/bind/index', array('openId' => $userId, 'sourceType' => 'alipay', 'nickname' => $realName)));
191 } 189 }
192 190
193 $refer = $this->getCookie('refer'); 191 $refer = $this->getCookie('refer');
@@ -217,37 +215,29 @@ class LoginController extends AbstractAction @@ -217,37 +215,29 @@ class LoginController extends AbstractAction
217 /* 获取QQ腾讯用户的详细信息 */ 215 /* 获取QQ腾讯用户的详细信息 */
218 $partnerInfo = $qqconnect->getUserInfo($access); 216 $partnerInfo = $qqconnect->getUserInfo($access);
219 $result = array(); 217 $result = array();
220 - if (!empty($partnerInfo) && isset($partnerInfo['nickname']))  
221 - { 218 + if (!empty($partnerInfo) && isset($partnerInfo['nickname'])) {
222 $result = LoginData::signinByOpenID($partnerInfo['nickname'], $access['openid'], 'qq'); 219 $result = LoginData::signinByOpenID($partnerInfo['nickname'], $access['openid'], 'qq');
223 } 220 }
224 221
225 //判定是否需要绑定手机号 222 //判定是否需要绑定手机号
226 $isBind = $result['data']['is_bind']; 223 $isBind = $result['data']['is_bind'];
227 - if ($isBind == 'N')  
228 - {  
229 - $this->go(Helpers::url('/passport/bind/index',array('openId'=>$access['openid'],'sourceType'=>'qq','nickname'=>$partnerInfo['nickname']))); 224 + if ($isBind == 'N') {
  225 + $this->go(Helpers::url('/passport/bind/index', array('openId' => $access['openid'], 'sourceType' => 'qq', 'nickname' => $partnerInfo['nickname'])));
230 } 226 }
231 227
232 $refer = $this->getCookie('refer'); 228 $refer = $this->getCookie('refer');
233 - if (empty($refer))  
234 - { 229 + if (empty($refer)) {
235 $refer = SITE_MAIN . '/?go=1'; 230 $refer = SITE_MAIN . '/?go=1';
236 - }  
237 - else  
238 - { 231 + } else {
239 $refer = rawurldecode($refer); 232 $refer = rawurldecode($refer);
240 } 233 }
241 234
242 - if (isset($result['code']) && $result['code'] == 200 && !empty($result['data']['uid']))  
243 - { 235 + if (isset($result['code']) && $result['code'] == 200 && !empty($result['data']['uid'])) {
244 $token = Helpers::makeToken($result['data']['uid']); 236 $token = Helpers::makeToken($result['data']['uid']);
245 $this->setCookie('_TOKEN', $token); 237 $this->setCookie('_TOKEN', $token);
246 $this->setSession('_TOKEN', $token); 238 $this->setSession('_TOKEN', $token);
247 $this->go(Helpers::syncUserSession($result['data']['uid'], $refer)); 239 $this->go(Helpers::syncUserSession($result['data']['uid'], $refer));
248 - }  
249 - else  
250 - { 240 + } else {
251 $this->go($refer); 241 $this->go($refer);
252 } 242 }
253 } 243 }
@@ -258,9 +248,9 @@ class LoginController extends AbstractAction @@ -258,9 +248,9 @@ class LoginController extends AbstractAction
258 public function sinacallbackAction() 248 public function sinacallbackAction()
259 { 249 {
260 $sina = Factory::create('sinaweibo'); 250 $sina = Factory::create('sinaweibo');
261 - $access = $sina->getAccessToken(); 251 + $access = $sina->getAccessToken();
262 /* 获取用户的详细信息 */ 252 /* 获取用户的详细信息 */
263 - $partnerInfo = $sina->getUserInfo($access); 253 + $partnerInfo = $sina->getUserInfo($access);
264 254
265 $result = array(); 255 $result = array();
266 if ($partnerInfo && is_array($partnerInfo)) { 256 if ($partnerInfo && is_array($partnerInfo)) {
@@ -268,11 +258,10 @@ class LoginController extends AbstractAction @@ -268,11 +258,10 @@ class LoginController extends AbstractAction
268 } 258 }
269 //判定是否需要绑定手机号 259 //判定是否需要绑定手机号
270 $isBind = $result['data']['is_bind']; 260 $isBind = $result['data']['is_bind'];
271 - if ($isBind == 'N')  
272 - {  
273 - $this->go(Helpers::url('/passport/bind/index',array('openId'=>$access['uid'],'sourceType'=>'sina','nickname'=>$partnerInfo['screen_name']))); 261 + if ($isBind == 'N') {
  262 + $this->go(Helpers::url('/passport/bind/index', array('openId' => $access['uid'], 'sourceType' => 'sina', 'nickname' => $partnerInfo['screen_name'])));
274 } 263 }
275 - 264 +
276 $refer = $this->getCookie('refer'); 265 $refer = $this->getCookie('refer');
277 if (empty($refer)) { 266 if (empty($refer)) {
278 $refer = SITE_MAIN . '/?go=1'; 267 $refer = SITE_MAIN . '/?go=1';
@@ -289,5 +278,5 @@ class LoginController extends AbstractAction @@ -289,5 +278,5 @@ class LoginController extends AbstractAction
289 $this->go($refer); 278 $this->go($refer);
290 } 279 }
291 } 280 }
292 - 281 +
293 } 282 }