コード例 #1
0
ファイル: Address.php プロジェクト: jackycgq/bzfshop
 public function get($f3)
 {
     global $smarty;
     $userInfo = AuthHelper::getAuthUser();
     $userAddressService = new UserAddressService();
     $addressInfo = $userAddressService->loadUserFirstAddress($userInfo['user_id']);
     $smarty->assign($addressInfo->toArray());
     out_display:
     $smarty->display('my_address.tpl', 'get');
 }
コード例 #2
0
ファイル: Show.php プロジェクト: jackycgq/bzfshop
 public function get($f3)
 {
     // 用户没有登陆,让用户去登陆
     if (!AuthHelper::isAuthUser()) {
         // 如果已经记录了一个回跳 URL ,则不要再覆盖这个记录了
         RouteHelper::reRoute($this, '/User/Login', !RouteHelper::hasRememberUrl());
     }
     global $smarty;
     $cartBasicService = new CartBasicService();
     $cartBasicService->loadFromStorage();
     // 加载购物车的数据
     $cartContext =& $cartBasicService->getCartContextRef();
     if ($cartContext->isEmpty()) {
         goto out_display;
     }
     // 做一次购物车计算
     $cartBasicService->calcOrderPrice();
     // 先看购物车里面有没有保存已经提交过的地址
     $addressInfo = $cartContext->getAddressInfo();
     if (empty($addressInfo)) {
         // 从数据库取用户地址
         $userInfo = AuthHelper::getAuthUser();
         $userAddressService = new UserAddressService();
         $addressInfo = $userAddressService->loadUserFirstAddress($userInfo['user_id'], 10);
         // 地址缓存 10 秒钟
         $addressInfo = $addressInfo->toArray();
     }
     // 如果购物车里面有错误消息,我们需要显示它
     if ($cartContext->hasError()) {
         $this->addFlashMessageArray($cartContext->getAndClearErrorMessageArray());
         $cartBasicService->syncStorage();
     }
     // 给模板赋值
     $smarty->assign('cartContext', $cartContext);
     $smarty->assign('orderGoodsArray', $cartContext->orderGoodsArray);
     $smarty->assign($addressInfo);
     $smarty->assign('postscript', $cartContext->getValue('postscript'));
     out_display:
     $smarty->display('cart_show.tpl');
 }