Home.php 19.8 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577
<?php

use Action\AbstractAction;
use home\GradeModel;
use home\OrderModel;
use Plugin\Helpers;
use LibModels\Wap\Home\OrderData;

/**
 * 个人中心相关的控制器
 * 
 * @name HomeController
 * @package 
 * @copyright yoho.inc
 * @version 1.0 (2015-10-28 16:28:32)
 * @author fei.hong <fei.hong@yoho.cn>
 */
class HomeController extends AbstractAction
{

    /**
     * 个人中心入口
     */
    public function indexAction() {
        // 设置网站标题
        $this->setTitle('个人中心');
        $this->setNavHeader('个人中心', true, SITE_MAIN);

        // $uid = $this->getUid();
        $uid = 8826435;
        $data = \Index\UserModel::getUserProfileData($uid);
        $data += \Index\UserModel::getInfoNumData($uid);
        
        // 优选新品数据
        $channel = Helpers::getChannelByCookie();
        $data['recommendForYou'] = \Index\UserModel::getPreferenceData($channel);
        // print_r($data);

        $data['myIndexPage'] = true;
        $data['pageFooter'] = true;

        $this->_view->display('index', $data);
    }

    /**
     * 用户收藏的商品
     */
    public function favoriteAction() {
        $uid = $this->getUid();

        $favProducts = \Index\UserModel::getFavProductData($uid);

        //print_r($favProducts);

        $this->_view->display('favorite', array(
            'favPage' => true, //加载js
            'pageHeader' => array(
                'navBack' => true,
                'navTitle' => '我的收藏',
                'navHome' => true
            ),
            'pageFooter' => true,
            'favorite' => true,
            'hasFavProduct' => array(
                '0' => array(
                    'imgUrl' => 'http://img11.static.yhbimg.com/goodsimg/2015/11/04/05/01ce2aff32fc3c90584f516167cd526d91.jpg?imageMogr2/thumbnail/235x314/extent/235x314/background/d2hpdGU=/position/center/quality/90',
                    'title' => 'adidas Originals ZX FLUXM22508 ',
                    'price' => '¥800',
                    'discountPrice' => false,
                    'savePrice' => false,
                    'sellOut' => true
                ),
                '1' => array(
                    'imgUrl' => 'http://img11.static.yhbimg.com/goodsimg/2015/11/04/05/01ce2aff32fc3c90584f516167cd526d91.jpg?imageMogr2/thumbnail/235x314/extent/235x314/background/d2hpdGU=/position/center/quality/90',
                    'title' => 'adidas Originals ZX FLUXM22508 ',
                    'price' => '¥800',
                    'discountPrice' => '¥500',
                    'savePrice' => '¥300',
                    'sellOut' => false
                )
            ),
            'hasFavBrand' => array(
                '0' => array(
                    'id' => '1',
                    'brandImg' => 'http://img11.static.yhbimg.com/goodsimg/2015/11/04/05/01ce2aff32fc3c90584f516167cd526d91.jpg?imageMogr2/thumbnail/235x314/extent/235x314/background/d2hpdGU=/position/center/quality/90',
                    'brandName' => 'VANS',
                    'update' => 12,
                    'discount' => 10,
                    'link' => '#',
                    'productList' => array(
                        '0' => array(
                            'imgUrl' => 'http://img11.static.yhbimg.com/goodsimg/2015/11/04/05/01ce2aff32fc3c90584f516167cd526d91.jpg?imageMogr2/thumbnail/235x314/extent/235x314/background/d2hpdGU=/position/center/quality/90',
                            'price' => '¥240',
                            'discount' => '¥240'
                        ),
                        '1' => array(
                            'imgUrl' => 'http://img11.static.yhbimg.com/goodsimg/2015/11/04/05/01ce2aff32fc3c90584f516167cd526d91.jpg?imageMogr2/thumbnail/235x314/extent/235x314/background/d2hpdGU=/position/center/quality/90',
                            'price' => '¥240',
                            'discount' => '¥240'
                        ),
                        '2' => array(
                            'imgUrl' => 'http://img11.static.yhbimg.com/goodsimg/2015/11/04/05/01ce2aff32fc3c90584f516167cd526d91.jpg?imageMogr2/thumbnail/235x314/extent/235x314/background/d2hpdGU=/position/center/quality/90',
                            'price' => '¥240',
                            'discount' => '¥240'
                        ),
                        '3' => array(
                            'imgUrl' => 'http://img11.static.yhbimg.com/goodsimg/2015/11/04/05/01ce2aff32fc3c90584f516167cd526d91.jpg?imageMogr2/thumbnail/235x314/extent/235x314/background/d2hpdGU=/position/center/quality/90',
                            'price' => '¥240',
                            'discount' => '¥240'
                        )
                    )
                ),
                '1' => array(
                    'id' => '2',
                    'brandImg' => 'http://img11.static.yhbimg.com/goodsimg/2015/11/04/05/01ce2aff32fc3c90584f516167cd526d91.jpg?imageMogr2/thumbnail/235x314/extent/235x314/background/d2hpdGU=/position/center/quality/90',
                    'brandName' => 'VANS',
                    'update' => 12,
                    'discount' => 10,
                    'link' => '#',
                    'productList' => array(
                        '0' => array(
                            'imgUrl' => 'http://img11.static.yhbimg.com/goodsimg/2015/11/04/05/01ce2aff32fc3c90584f516167cd526d91.jpg?imageMogr2/thumbnail/235x314/extent/235x314/background/d2hpdGU=/position/center/quality/90',
                            'price' => '¥240',
                            'discount' => '¥240'
                        ),
                        '1' => array(
                            'imgUrl' => 'http://img11.static.yhbimg.com/goodsimg/2015/11/04/05/01ce2aff32fc3c90584f516167cd526d91.jpg?imageMogr2/thumbnail/235x314/extent/235x314/background/d2hpdGU=/position/center/quality/90',
                            'price' => '¥240',
                            'discount' => '¥240'
                        ),
                        '2' => array(
                            'imgUrl' => 'http://img11.static.yhbimg.com/goodsimg/2015/11/04/05/01ce2aff32fc3c90584f516167cd526d91.jpg?imageMogr2/thumbnail/235x314/extent/235x314/background/d2hpdGU=/position/center/quality/90',
                            'price' => '¥240',
                            'discount' => '¥240'
                        ),
                        '3' => array(
                            'imgUrl' => 'http://img11.static.yhbimg.com/goodsimg/2015/11/04/05/01ce2aff32fc3c90584f516167cd526d91.jpg?imageMogr2/thumbnail/235x314/extent/235x314/background/d2hpdGU=/position/center/quality/90',
                            'price' => '¥240',
                            'discount' => '¥240'
                        )
                    )
                ),
                '2' => array(
                    'id' => '3',
                    'brandImg' => 'http://img11.static.yhbimg.com/goodsimg/2015/11/04/05/01ce2aff32fc3c90584f516167cd526d91.jpg?imageMogr2/thumbnail/235x314/extent/235x314/background/d2hpdGU=/position/center/quality/90',
                    'brandName' => 'VANS',
                    'update' => 12,
                    'discount' => 10,
                    'link' => '#',
                    'productList' => array(
                        'imgUrl' => 'http://img11.static.yhbimg.com/goodsimg/2015/11/04/05/01ce2aff32fc3c90584f516167cd526d91.jpg?imageMogr2/thumbnail/235x314/extent/235x314/background/d2hpdGU=/position/center/quality/90',
                        'price' => '¥240',
                        'discount' => false
                    )
                )
            )
        ));
    }

    /**
     * 用户收藏的品牌
     */
    public function favoritebrandAction() {
        $uid = $this->getUid();
        $gender = Helpers::getGenderByCookie();

        $favBrands = \Index\UserModel::getFavBrandData($uid, $gender);

        print_r($favBrands);
    }

    /**
     * 个人信息
     */
    public function personalDetailsAction() {
        $this->setTitle('个人信息');
        $this->setNavHeader('个人信息', true, SITE_MAIN);

        // $uid = $this->getUid();
        $uid = 967016;
        $data = \Index\UserModel::getUserProfileData($uid);
        $data['pageFooter'] = true;
        $this->_view->display('personal-details', $data);
    }

    /**
     * YOHO币
     */
    public function currencyAction() {
	    $this->setTitle('YOHO币');
        $this->setNavHeader('YOHO币', true, false);

	    // $uid = $this->getUid();
        $uid = 967016;
        $currency = \Index\UserModel::getYohoCoinData($uid);

        $currency['pageFooter'] = true;
        $this->_view->display('currency', $currency);
    }

    /**
     * 优惠券
     */
    public function couponsAction() {

        $this->setTitle('优惠券');
        $this->setNavHeader('优惠券', true, SITE_MAIN);
        // $uid = $this->getUid();
        $uid = 8826435;
        $status = $this->get('status', 0);
        $coupons = array(
            'couponsUrl' => \Index\UserModel::getCouponData($uid, $status),
            'couponsPage' => true
        );
	    print_r($coupons);

        $this->_view->display('coupons', $coupons);
    }

    /**
     * 我的消息
     */
    public function messageAction() {
        // $uid = $this->getUid();
        $page = $this->get('page', 0);
        $size = $this->get('size', 10);

        $uid = 967016;
        $messages = \Index\UserModel::getMessageData($uid, $page, $size);

        print_r($messages);
    }

    /**
     * 地址管理
     */
    public function addressAction() {
        // 设置网站标题
        $this->setTitle('地址管理');
        $this->setNavHeader('地址管理', true, SITE_MAIN);

        // $uid = $this->getUid();
        $uid = 967016;

        $address = \Index\UserModel::getAddressData($uid);
        $addressList = \Index\UserModel::getAddressListData($uid);

        // print_r($addressList);

        $this->_view->display('address', array(
            'addressPage' => true,
            'pageFooter' => true,
            'address' => $address,
            'addressList' => $addressList
        ));
    }

    /**
     * 修改地址或者添加新地址
     */
    public function saveAddressAction() {
        $result = array();

        if ($this->isAjax()) {
            // $uid = $this->getUid();
            $uid = 967016;
            $address = $this->post('address', '');
            $area_code = $this->post('area_code', '');
            $consignee = $this->post('consignee', '');
            $email = $this->post('email', '');
            $id = $this->post('id', null);
            $mobile = $this->post('mobile', '');
            $zip_code = $this->post('zip_code', '');

            $result = \Index\UserModel::saveAddressData($uid, $address, $area_code, $consignee, $email, $id, $mobile, $zip_code);
        }

        if (empty($result)) {
            echo ' ';
        } else {
            $this->echoJson($result);
        }
    }

    /**
     * 设置默认地址
     */
    public function defaultAddressAction() {
        $result = array();

        if ($this->isAjax()) {
            // $uid = $this->getUid();
            $uid = 967016;
            $id = $this->post('id', '');

            $result = \Index\UserModel::setDefaultAddress($uid, $id);
        }

        if (empty($result)) {
            echo ' ';
        } else {
            $this->echoJson($result);
        }
    }

    //在线客服
    public function onlineServiceAction() {
        // 设置网站标题
        $this->setTitle('在线客服');
        $this->setNavHeader('在线客服', true, SITE_MAIN);

        $service = home\OnlineModel::getOnlineServiceInfo();

        $this->_view->display('online-service', array(
            'onlineServicePage' => true,
            // 'pageFooter' => true,
            'service' => $service
        ));
    }

    //在线客服-具体详情
    public function onlineServiceDetailAction() {
        $service = array();
        $cateId = $this->get('cateId', 0);
        $cateName = $this->get('cateName', '');
        if ($cateId > 0) {
            $service = home\OnlineModel::getOnlineServiceDetail($cateId);
        }
        $this->setTitle('在线客服');
        $this->setNavHeader($cateName, true, '');
        $this->_view->display('online-service-detail', $service);
    }

    /**
     * 我的逛
     */
    public function myGuangAction() {
        echo 'My Guang';
    }

    /**
     * 意见反馈
     */
    public function suggestAction() {
        // 设置网站标题
        $this->setTitle('意见反馈');
        $this->setNavHeader('意见反馈', true, SITE_MAIN);

        $udid = $this->getUdid();
        $page = $this->get('page', 1);
        $limit = $this->get('limit', 30);

        $suggest = \Index\UserModel::getSuggestData($udid, $page, $limit);

        $this->_view->display('suggest', array(
            'suggestPage' => true, //加载js
            'pageFooter' => true,
            'suggest' => true,
            'suggestContent' => $suggest
        ));
    }

    /**
     * 意见反馈-提交表单
     */
    public function suggest_subAction() {
        $udid = $this->getUdid();
        $page = $this->get('page', 1);
        $limit = $this->get('limit', 30);

        $suggest = \Index\UserModel::getSuggestData($udid, $page, $limit);

        //print_r($suggest);
        $this->_view->display('suggest_sub', array(
            'suggestPage' => true, //加载js
            'pageHeader' => array(
                'navBack' => true,
                'navTitle' => '反馈问题',
                'navBtn' => '提交'
            ),
            'suggestSub' => true,
            'pageFooter' => true
        ));
    }

    /**
     * 异步保存意见反馈数据
     */
    public function savesuggestAction() {
        if ($this->isAjax()) {
            $uid = $this->getUid();
            $content = $this->post('content', '');
            $suggest_type = $this->get('suggest_type', 2);
            $result = \Index\UserModel::saveSuggestData($uid, $content, $suggest_type);

            $this->echoJson($result);
        }
    }

    /**
     * 会员等级展示页
     */
    public function gradeAction() {
        //设置网站seo信息
        $this->setTitle('会员等级');
        //显示网站导航头部信息
        $this->setNavHeader('会员等级');

        $gender = Helpers::getGenderByCookie();
        $channel = Helpers::getChannelByCookie();
        $uid = $this->getUid();
        $uid = '7566245'; //临时测试用
        $data = GradeModel::getGrade($gender, $channel, $uid);
        $data['pageFooter'] = true;
        $this->_view->display('vip-grade', $data);
    }

    /*
     * 会员特权查看页
     */

    public function preferentialAction() {
        //设置网站seo信息
        $this->setTitle('会员等级');
        //显示网站导航头部信息
        $this->setNavHeader('会员特权详情');

        $channel = Helpers::getChannelByCookie();
        $uid = $this->getUid();
        $data = GradeModel::getPreferential($channel, $uid);
        $data['pageFooter'] = true;
        $this->_view->display('privilege', $data);
    }

    /*
     * 我的订单页面
     */

    public function orderAction() {
        //获得type值
        $type = $this->get('type', 1);
        $this->setTitle('我的订单');
        $this->setNavHeader('我的订单');
        $data = OrderModel::getNavs($type);
        if (!empty($data)) {
            $order['navs'] = $data;
        } else {
            $this->error();
        }

        $this->_view->display('order', array(
            'order' => $order,
            'pageFooter' => true,
            'orderPage' => true
        ));
    }

    //ajax请求订单页面
    public function getOrderAction() {
        //判断是不是ajax请求
        if (!$this->isAjax()) {
            $this->error();
        }
        //获取基本参数:type:1=>全部,2=>待付款,3=>待发货,4=>待收货,5=>待评论
        $type = $this->get('type', 1);
        $page = $this->get('page', 1);
        $limit = $this->get('limit', 10);
        $gender = Helpers::getGenderByCookie();
        $yh_channel = $this->get('yh_channel', 1);
        $uid = $this->getUid();
        $uid = '7566245'; //测试用
        //调用模型层getOrder方法获得并处理数据
        $data = OrderModel::getOrder($type, $page, $limit, $gender, $yh_channel, $uid);
        //如果没有订单数据,就给一个随便逛逛链接
        $order = array();
        if (!empty($data)) {
            $order['orders'] = $data;
        } else {
            if ($page > 1) {
                echo " ";
            } else {
                $order['walkwayUrl'] = 'http://www.baidu.com';
            }
        }
        //渲染模板
        $this->_view->display('order-content', $order);
    }

    /*
     * 我的订单-取消订单
     */

    public function cancelOrderAction() {

        //判断是不是ajax请求
        if (!$this->isAjax()) {
            $this->error();
        }
        //传入order_code和uid以取消订单
        $order_code = $this->get('orderCode');
        $uid = $this->getUid();
        $uid = '10267443'; //测试用
        $gender = Helpers::getGenderByCookie();
        $yh_channel = $this->get('yh_channel', 1);
        $method = 'app.SpaceOrders.close';
        $data = OrderData::cancelOrderData($order_code, $uid, $gender, $yh_channel, $method);
        if ($data['code'] == 200) {
            echo $data['message'];
        }
    }

    /*
     * 我的订单-删除订单
     */

    public function deleteOrderAction() {
        //判断是不是ajax请求
        if (!$this->isAjax()) {
            $this->error();
        }
        //传入order_code和uid以删除订单
        $order_code = $this->get('orderCode');
        $uid = $this->getUid();
        $uid = '10267443'; //测试用
        $gender = Helpers::getGenderByCookie();
        $yh_channel = $this->get('yh_channel', 1);
        $method = 'app.SpaceOrders.delOrderByCode';
        $data = OrderData::deleteOrderData($order_code, $uid, $gender, $yh_channel, $method);
        if ($data['code'] == 200) {
            echo $data['message'];
        }
    }

    /**
     * 订单详情页
     */
    public function orderDetailAction() {
        $data = array(
            'name' => '毛毛莉Lydia',
            'phoneNum' => '18600001133',
            'address' => '南京市建邺区嘉陵江东街18号国家广告产业园5栋17楼',
            'orderStatus' => '订单取消',
            'orderNum' => '418358063',
            'orderTime' => '2014-03-10 17:25:10',
            'orderCancel' => true,
            'goods' => array(
                array(
                    'id' => 1,
                    'thumb' => 'http://img11.static.yhbimg.com/goodsimg/2015/11/04/05/01ce2aff32fc3c90584f516167cd526d91.jpg?imageMogr2/thumbnail/235x314/extent/235x314/background/d2hpdGU=/position/center/quality/90',
                    'name' => 'Adidas Originals ZX FLUXM22508',
                    'color' => '黄',
                    'size' => '43',
                    'price' => '699.00',
                    'count' => '2'
                ),
                array(
                    'id' => 1,
                    'thumb' => 'http://img10.static.yhbimg.com/goodsimg/2015/11/04/05/0188f1aca49ac478a565ec029b5d2d4a6c.jpg?imageMogr2/thumbnail/235x314/extent/235x314/background/d2hpdGU=/position/center/quality/90',
                    'name' => 'B.Duck浴室玩伴mini浮水鸭',
                    'gift' => true,
                    'color' => '黄',
                    'size' => '43',
                    'price' => '0.00',
                    'count' => '1'
                )
            ),
            'sumPrice' => 799,
            'salePrice' => 80,
            'freight' => 5,
            'coupon' => 0,
            'yohoCoin' => 5,
            'price' => 719
        );
        $this->_view->display('order-detail', array('orderDetail' => $data, 'orderDetailPage' => true));
    }

}