<?php
// +----------------------------------------------------------------------
// | OneThink [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.onethink.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: 麦当苗儿 <zuojiazi@vip.qq.com> <http://www.zjzit.cn>
// +----------------------------------------------------------------------

namespace Home\Controller;
use Common\Model\MemberModel;

/**
 * 前台控制器
 */
class UserController extends HomeController {
	protected $userid;
	protected $source='';
	protected $unionid = '';

	public function _initialize(){
		parent::_initialize();
		
		
		 // if(!in_array(ACTION_NAME, $action_arr)){
		 // if(Check::isLine()){
		 // $this->source = 'line';
		 // $this->unionid = getLineID();
		 // }
		 // elseif (Check::isWeixin()){
		 // $this->source = 'weixin';
		 // $this->unionid = getOpenID();
		 // }elseif (Check::isAlipay()){
		 // $this->source = 'alipay';
		 // $this->unionid = getAlipayID();
		 // }else{
		 // exit('请使用微信或支付宝打开');
		 // }
		 // }

		$this->source = 'line';
		$this->unionid = getLineID();
		 
		
		// $this->source = 'line';
		// $this->unionid = '1625403020';

	}



	//首页
    public function index(){
        $memObj = new MemberModel();
        $memInfo = $memObj->getInfoByUnionid($this->unionid, $this->source);
        
        $this->assign('memInfo',$memInfo);
        
        $this->meta_title = L('my_account');
        $this->display();

    }
    
    
    //优惠券
    public function coupon(){
        $memObj = new MemberModel();
        $memInfo = $memObj->getInfoByUnionid($this->unionid, $this->source);
        $coupon = D('MemberCoupon');
        $lists = $coupon->getList($memInfo['id']);
        
        $this->assign('lists',$lists);
        $this->meta_title = L('coupon');
        $this->display();
    }
    
    
    


    









}