Life.php 1.45 KB
<?php

use Action\AbstractAction;
use Plugin\Helpers;
use LibModels\Wap\Coupon\CouponData;

class LifeController extends AbstractAction
{

    const COUPON_ID = 13026;

    public function indexAction()
    {
        $uid = $this->getUid();
        if (!$uid) {
            $this->go(Helpers::url('/signin.html', array('refer' => Helpers::url('/life/index'))));
        }
        $this->_view->display('index');
    }

    //点击领券按钮
    public function sendCouponAction()
    {
        $result = array('code' => 400, 'message' => '领取失败', 'data' => '');
        do {
            if (!$this->isAjax()) {
                break;
            }
            //获取领券参数
            $couponId = self::COUPON_ID;
            $uid = $this->getUid();
            //领取优惠券
            $result = CouponData::receiveCoupon($uid, $couponId);
            if (!isset($result['code'])) {
                break;
            }
        }
        while (false);
        $this->echoJson($result);
    }

    public function loginAction()
    {
        $uid = $this->getUid();
        if (!$uid) {
            $this->go(Helpers::url('/signin.html', array('refer' => Helpers::url('/life/index'))));
        }

        $this->_view->display('login', array(
            'lifePage' => true));
    }

    public function couponAction()
    {
        //获取手机号,传优惠码
        $this->_view->display('coupon', array(
            'couponPage' => true));
    }

}