Life.php 3.07 KB
<?php

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

class LifeController extends AbstractAction
{

    const COUPON_ID = 23360;

    public function indexAction()
    {
        $uid = $this->getUid();
        if (!$uid) {
            $this->go(Helpers::url('/signin.html', array('refer' => Helpers::url('/life/index'))));
        }
        $this->_view->display('index', array(
            'wxshare' => array(
                'shareLink' => 'http://m.yohobuy.com/life/index',
                'shareImg' => 'http://img02.yohoboys.com/staticimg/2016/05/26/17/0208d70abf2b3fc94412f0e4d84f6728df.png',
                'shareTitle' => 'YOHO!BUY有货清凉夏日福利券限时派送中 ',
                'shareDesc' => '我已成功领取36元清凉夏日福利券,你也快来吧!',
            ),
        ));
    }

    //点击领券按钮
    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(
            'wxshare' => array(
                'shareLink' => 'http://m.yohobuy.com/life/index',
                'shareImg' => 'http://img02.yohoboys.com/staticimg/2016/05/26/17/0208d70abf2b3fc94412f0e4d84f6728df.png',
                'shareTitle' => 'YOHO!BUY有货清凉夏日福利券限时派送中 ',
                'shareDesc' => '我已成功领取36元清凉夏日福利券,你也快来吧!',
            ),
            'lifePage' => true));
    }

    public function couponAction()
    {
        //获取手机号,传优惠码
        $this->_view->display('coupon', array(
            'wxshare' => array(
                'shareLink' => 'http://m.yohobuy.com/life/index',
                'shareImg' => 'http://img02.yohoboys.com/staticimg/2016/05/26/17/0208d70abf2b3fc94412f0e4d84f6728df.png',
                'shareTitle' => 'YOHO!BUY有货清凉夏日福利券限时派送中 ',
                'shareDesc' => '我已成功领取36元清凉夏日福利券,你也快来吧!',
            ),
            'couponPage' => true));
    }

    public function getSignPackageAction()
    {
        $curl = 'http://www.yohoshow.com/api/wechat/getSignPackage';
        $pageurl = $this->get('pageurl', '');
        $callback = $this->get('callback', '');
        $url = $curl . '?pageurl=' . urlencode($pageurl) . "&callback=" . $callback;
        $res = file_get_contents($url);
        echo $res;
        exit;
    }

}