Merge branch 'feature/cart' of git.dev.yoho.cn:web/yohobuy into feature/cart
Showing
12 changed files
with
129 additions
and
169 deletions
@@ -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 |
@@ -29,16 +29,56 @@ if ($names.length > 0) { | @@ -29,16 +29,56 @@ if ($names.length > 0) { | ||
29 | $names[0].mlellipsis(2); | 29 | $names[0].mlellipsis(2); |
30 | } | 30 | } |
31 | 31 | ||
32 | +//获取当前购物车类型 | ||
33 | +function getCartType() { | ||
34 | + var $navItem = $('.cart-nav ').find('li'), | ||
35 | + type = 'ordinary'; | ||
36 | + | ||
37 | + if ($navItem.eq(0).hasClass('active')) { | ||
38 | + type = 'ordinary'; | ||
39 | + } else { | ||
40 | + type = 'advance'; | ||
41 | + } | ||
42 | + | ||
43 | + return type; | ||
44 | +} | ||
45 | + | ||
32 | //TIP:事件委托在.cart-goods,商品列表的容器统一需要有.cart-goods | 46 | //TIP:事件委托在.cart-goods,商品列表的容器统一需要有.cart-goods |
33 | $('.cart-goods').on('touchstart', '.checkbox', function() { | 47 | $('.cart-goods').on('touchstart', '.checkbox', function() { |
34 | var $this = $(this), | 48 | var $this = $(this), |
35 | - id = $(this).closest('.shopping-cart-good').data('id'); | 49 | + $good = $this.closest('.shopping-cart-good'), |
50 | + id = $good.data('id'); | ||
51 | + | ||
52 | + var goodsList = [], | ||
53 | + goodInfo = {}, | ||
54 | + isSelected = true; | ||
55 | + | ||
56 | + if ($this.hasClass('icon-cb-checked')) { | ||
57 | + isSelected = true; | ||
58 | + } else { | ||
59 | + isSelected = false; | ||
60 | + } | ||
61 | + | ||
62 | + function GoodInfo(properties) { | ||
63 | + this.goods_type = properties.goods_type; | ||
64 | + this.buy_number = properties.buy_number; | ||
65 | + this.product_sku = properties.product_sku; | ||
66 | + this.selected = properties.selected; | ||
67 | + } | ||
68 | + | ||
69 | + goodInfo.goods_type = getCartType(); | ||
70 | + goodInfo.selected = isSelected ? 'Y' : 'N'; | ||
71 | + goodInfo.product_sku = id; | ||
72 | + goodInfo.buy_number = $good.find('.count').eq(0).text().trim().replace('×', ''); | ||
73 | + | ||
74 | + goodsList.push(new GoodInfo(goodInfo)); | ||
75 | + | ||
36 | 76 | ||
37 | $.ajax({ | 77 | $.ajax({ |
38 | - type: 'GET', | ||
39 | - url: '/cart/index/select', | 78 | + type: 'post', |
79 | + url: 'select', | ||
40 | data: { | 80 | data: { |
41 | - id: id | 81 | + skuList: JSON.stringify(goodsList) |
42 | } | 82 | } |
43 | }).then(function(data) { | 83 | }).then(function(data) { |
44 | if (data.code === 200) { | 84 | if (data.code === 200) { |
@@ -49,9 +89,9 @@ $('.cart-goods').on('touchstart', '.checkbox', function() { | @@ -49,9 +89,9 @@ $('.cart-goods').on('touchstart', '.checkbox', function() { | ||
49 | } | 89 | } |
50 | $.ajax({ | 90 | $.ajax({ |
51 | type: 'GET', | 91 | type: 'GET', |
52 | - url: '/cart/index/getCartData', | 92 | + url: 'getCartData', |
53 | data: { | 93 | data: { |
54 | - skuList: JSON.stringfy(id) | 94 | + id: id |
55 | }, | 95 | }, |
56 | success: function(data) { | 96 | success: function(data) { |
57 | if (data) { | 97 | if (data) { |
@@ -64,7 +104,7 @@ $('.cart-goods').on('touchstart', '.checkbox', function() { | @@ -64,7 +104,7 @@ $('.cart-goods').on('touchstart', '.checkbox', function() { | ||
64 | tip.show('网络错误'); | 104 | tip.show('网络错误'); |
65 | } | 105 | } |
66 | }); | 106 | }); |
67 | - } else if (data.code === 200) { | 107 | + } else if (data.code === 400) { |
68 | tip.show('网络错误'); | 108 | tip.show('网络错误'); |
69 | } | 109 | } |
70 | }).fail(function() { | 110 | }).fail(function() { |
@@ -95,13 +135,6 @@ $('.cart-goods').on('touchstart', '.checkbox', function() { | @@ -95,13 +135,6 @@ $('.cart-goods').on('touchstart', '.checkbox', function() { | ||
95 | 135 | ||
96 | e.stopPropagation(); | 136 | e.stopPropagation(); |
97 | 137 | ||
98 | - //手动触发docTouchEvt清除因点击到del按钮上而被阻止冒泡到doc上的事件从而清除已打开的删除面板 | ||
99 | - //docTouchEvt(); | ||
100 | - // | ||
101 | - //$curDelPanel = $(this).closest('.shopping-cart-good').children('.opt-panel').removeClass('hide'); | ||
102 | - // | ||
103 | - //$(document).on('touchstart', docTouchEvt); | ||
104 | - | ||
105 | dialog.showDialog({ | 138 | dialog.showDialog({ |
106 | dialogText: '您确定要从购物车中删除吗?', | 139 | dialogText: '您确定要从购物车中删除吗?', |
107 | hasFooter: { | 140 | hasFooter: { |
@@ -136,30 +169,6 @@ $('.cart-goods').on('touchstart', '.checkbox', function() { | @@ -136,30 +169,6 @@ $('.cart-goods').on('touchstart', '.checkbox', function() { | ||
136 | 169 | ||
137 | }); | 170 | }); |
138 | 171 | ||
139 | -// .on('touchstart', '.opt-panel', function() { | ||
140 | -// var $this = $(this), | ||
141 | -// id = $this.closest('.shopping-cart-good').data('id'), | ||
142 | -// url; | ||
143 | -// | ||
144 | -// if ($this.closest('.put-in-favorite').length > 0) { | ||
145 | -// | ||
146 | -// //移入收藏夹 | ||
147 | -// url = '/shoppingCart/col'; | ||
148 | -// } else { | ||
149 | -// | ||
150 | -// //删除 | ||
151 | -// url = '/shoppingCart/del'; | ||
152 | -// } | ||
153 | -// | ||
154 | -// $.ajax({ | ||
155 | -// type: 'POST', | ||
156 | -// url: url, | ||
157 | -// data: { | ||
158 | -// id: id | ||
159 | -// } | ||
160 | -// }); | ||
161 | -//}) | ||
162 | - | ||
163 | function requestUpdateAllGoodsCheckStatus(theGoods, successHandeler) { | 172 | function requestUpdateAllGoodsCheckStatus(theGoods, successHandeler) { |
164 | if (requesting) { | 173 | if (requesting) { |
165 | return; | 174 | return; |
@@ -236,24 +245,11 @@ function bottomCheckBoxHandeler(isSelected, type, handlerAfterTouch) { | @@ -236,24 +245,11 @@ function bottomCheckBoxHandeler(isSelected, type, handlerAfterTouch) { | ||
236 | 245 | ||
237 | goodsList.push(new GoodInfo(goodInfo)); | 246 | goodsList.push(new GoodInfo(goodInfo)); |
238 | }); | 247 | }); |
239 | - console.log(goodsList); | ||
240 | 248 | ||
241 | requestUpdateAllGoodsCheckStatus(goodsList, handlerAfterTouch); | 249 | requestUpdateAllGoodsCheckStatus(goodsList, handlerAfterTouch); |
242 | } | 250 | } |
243 | 251 | ||
244 | -//获取当前购物车类型 | ||
245 | -function getCartType() { | ||
246 | - var $navItem = $('.cart-nav ').find('li'), | ||
247 | - type = 'ordinary'; | ||
248 | - | ||
249 | - if ($navItem.eq(0).hasClass('active')) { | ||
250 | - type = 'ordinary'; | ||
251 | - } else { | ||
252 | - type = 'advance'; | ||
253 | - } | ||
254 | 252 | ||
255 | - return type; | ||
256 | -} | ||
257 | 253 | ||
258 | //是否要全选 | 254 | //是否要全选 |
259 | function willBeSelected() { | 255 | function willBeSelected() { |
@@ -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 | } |
@@ -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}}">¥{{salePrice}}</span> |
9 | + {{#price}}<span class="old-price">¥{{.}}</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: |
@@ -646,7 +646,7 @@ class CartModel | @@ -646,7 +646,7 @@ class CartModel | ||
646 | // 缩略图 | 646 | // 缩略图 |
647 | foreach ($val['images_list'] as $image) { | 647 | foreach ($val['images_list'] as $image) { |
648 | $thumbImageList[] = array( | 648 | $thumbImageList[] = array( |
649 | - 'img' => Helpers::getImageUrl($image['image_url'], 60, 60) | 649 | + 'img' => Helpers::getImageUrl($image['image_url'], 80, 106) |
650 | ); | 650 | ); |
651 | } | 651 | } |
652 | 652 |
@@ -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 | } |
@@ -49,6 +49,7 @@ class IndexController extends AbstractAction | @@ -49,6 +49,7 @@ class IndexController extends AbstractAction | ||
49 | // 渲染模板 | 49 | // 渲染模板 |
50 | $this->_view->display('index', $data); | 50 | $this->_view->display('index', $data); |
51 | } | 51 | } |
52 | + | ||
52 | /* | 53 | /* |
53 | * 异步获取购物车数据 | 54 | * 异步获取购物车数据 |
54 | */ | 55 | */ |
@@ -80,7 +81,7 @@ class IndexController extends AbstractAction | @@ -80,7 +81,7 @@ class IndexController extends AbstractAction | ||
80 | if ($this->isAjax()) { | 81 | if ($this->isAjax()) { |
81 | $productId = $this->post('skuList', 0); | 82 | $productId = $this->post('skuList', 0); |
82 | $uid = $this->getUid(true); | 83 | $uid = $this->getUid(true); |
83 | - $shoppingKey = $this->getSession('shoppingKey'); | 84 | + $shoppingKey = Helpers::getShoppingKeyByCookie(); |
84 | $result = CartModel::selectGoods($uid, $productId, $shoppingKey); | 85 | $result = CartModel::selectGoods($uid, $productId, $shoppingKey); |
85 | } | 86 | } |
86 | 87 | ||
@@ -101,7 +102,7 @@ class IndexController extends AbstractAction | @@ -101,7 +102,7 @@ class IndexController extends AbstractAction | ||
101 | if ($this->isAjax()) { | 102 | if ($this->isAjax()) { |
102 | $productId = $this->post('id', 0); | 103 | $productId = $this->post('id', 0); |
103 | $uid = $this->getUid(true); | 104 | $uid = $this->getUid(true); |
104 | - $shoppingKey = $this->getSession('shoppingKey'); | 105 | + $shoppingKey = Helpers::getShoppingKeyByCookie(); |
105 | $result = CartModel::removeFromCart($uid, $productId, $shoppingKey); | 106 | $result = CartModel::removeFromCart($uid, $productId, $shoppingKey); |
106 | } | 107 | } |
107 | 108 | ||
@@ -192,6 +193,7 @@ class IndexController extends AbstractAction | @@ -192,6 +193,7 @@ class IndexController extends AbstractAction | ||
192 | 193 | ||
193 | /* | 194 | /* |
194 | * 获取购物车加价购商品数据模板 | 195 | * 获取购物车加价购商品数据模板 |
196 | + * 需要返回模板的html代码,不能渲染 | ||
195 | */ | 197 | */ |
196 | public function giftinfoTplAction() | 198 | public function giftinfoTplAction() |
197 | { | 199 | { |
@@ -207,11 +209,11 @@ class IndexController extends AbstractAction | @@ -207,11 +209,11 @@ class IndexController extends AbstractAction | ||
207 | { | 209 | { |
208 | $result = array(); | 210 | $result = array(); |
209 | 211 | ||
210 | -// if ($this->isAjax()) { | 212 | + if ($this->isAjax()) { |
211 | $skn = $this->get('skn', null); | 213 | $skn = $this->get('skn', null); |
212 | $promotionId = $this->get('promotionId', null); | 214 | $promotionId = $this->get('promotionId', null); |
213 | $result = CartModel::giftProductData($skn, $promotionId); | 215 | $result = CartModel::giftProductData($skn, $promotionId); |
214 | -// } | 216 | + } |
215 | 217 | ||
216 | if (empty($result)) { | 218 | if (empty($result)) { |
217 | echo ' '; | 219 | echo ' '; |
@@ -228,7 +230,7 @@ class IndexController extends AbstractAction | @@ -228,7 +230,7 @@ class IndexController extends AbstractAction | ||
228 | $result = array(); | 230 | $result = array(); |
229 | 231 | ||
230 | if ($this->isAjax()) { | 232 | if ($this->isAjax()) { |
231 | - $shoppingKey = $this->getSession('shoppingKey'); | 233 | + $shoppingKey = Helpers::getShoppingKeyByCookie(); |
232 | $uid = $this->getUid(true); | 234 | $uid = $this->getUid(true); |
233 | 235 | ||
234 | $sku= $this->post('sku', 0); | 236 | $sku= $this->post('sku', 0); |
@@ -252,7 +254,7 @@ class IndexController extends AbstractAction | @@ -252,7 +254,7 @@ class IndexController extends AbstractAction | ||
252 | $result = array(); | 254 | $result = array(); |
253 | 255 | ||
254 | if ($this->isAjax()) { | 256 | if ($this->isAjax()) { |
255 | - $shoppingKey = $this->getSession('shoppingKey'); | 257 | + $shoppingKey = Helpers::getShoppingKeyByCookie(); |
256 | $uid = $this->getUid(true); | 258 | $uid = $this->getUid(true); |
257 | 259 | ||
258 | $params = array(); | 260 | $params = array(); |
@@ -17,8 +17,7 @@ class BindController extends AbstractAction | @@ -17,8 +17,7 @@ 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 | ||
@@ -28,15 +27,15 @@ class BindController extends AbstractAction | @@ -28,15 +27,15 @@ class BindController extends AbstractAction | ||
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,18 +48,17 @@ class BindController extends AbstractAction | @@ -49,18 +48,17 @@ 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'); | 57 | + $phoneNum = $this->get('phoneNum'); |
60 | 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, // 第三方登录来源 |
@@ -68,7 +66,7 @@ class BindController extends AbstractAction | @@ -68,7 +66,7 @@ class BindController extends AbstractAction | ||
68 | 'nickname' => $nickname, //昵称 | 66 | 'nickname' => $nickname, //昵称 |
69 | 'isReg' => $isReg, //是否是已注册过的手机号 | 67 | 'isReg' => $isReg, //是否是已注册过的手机号 |
70 | 'areaCode' => $areaCode, //国别码 | 68 | 'areaCode' => $areaCode, //国别码 |
71 | - 'phoneNum'=>$phoneNum,//手机号码 | 69 | + 'phoneNum' => $phoneNum, //手机号码 |
72 | ); | 70 | ); |
73 | 71 | ||
74 | // 渲染模板 | 72 | // 渲染模板 |
@@ -80,16 +78,15 @@ class BindController extends AbstractAction | @@ -80,16 +78,15 @@ 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, // 第三方登录来源 |
@@ -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 | 229 | ||
258 | - if (isset($res['code']) && $res['code'] == 200 && !empty($res['data']['uid'])) | ||
259 | - { | 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); |
@@ -184,10 +184,8 @@ class LoginController extends AbstractAction | @@ -184,10 +184,8 @@ class LoginController extends AbstractAction | ||
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 | } |
@@ -268,9 +258,8 @@ class LoginController extends AbstractAction | @@ -268,9 +258,8 @@ 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'); |
-
Please register or login to post a comment