<?php
/**
 * Copyright (C) LJCMS All rights reserved.
 * <E-Mail：aspcms@qq.com>
 * Url http://www.liangjing.org
 *     http://www.8CMS.com
 * Update 2016.03.19
 */

class control extends indexbase {
    
    public function control_run() {
        list($page_title, $page_description, $page_keyword) = XSeo::buildSeo("ch_index");
        $model= parent::model('index', 'im');
        $language= parent::$lang;
        $newsid = $model->getnewsid($language);
        $productid= $model->getproductid($language);
        $userid=$_SESSION['user_id'];
        list($total,$data) = $model->keyword($userid);
        $var_array = array(
            '$total'=>$total,
            'data'=>$data,
            'page_title'=>$page_title,
            'page_description'=>$page_description,
            'page_keyword'=>$page_keyword,
            'newsid'=>$newsid,
            'productid'=>$productid
        );
        $this->view($var_array, "index");
	}
        public function control_qielang(){
            $lang= $_REQUEST['lang'];
            $model= parent::model('language', 'am');
            $data= $model->getData($lang);
           // print_r($data);
           session_start();
           $_SESSION["lang"]=$data['lang'];

             
        }

        public function control_shopping(){
            $downloadid=$_REQUEST['downloadid'];
            $username=$_SESSION['user_id'];
            $usbynum=$_REQUEST['buynum'];
            $model = parent::model('product', 'im');
            $data=$model->goshopping($downloadid,$username);
            if(!empty($data)){
                     $data=array(
                        'response'=>0,
                        'result'=>'已经添加到购物车',
                        'jumpurl'=>'./index.php?c=user&a=shopping'
                    );
                    echo json_encode($data);
                    die;                 
            }
            $arr['productid']=$downloadid;
            $arr['userid']=$username;
            $arr['productnum']=$usbynum;
            $res=$model->shoppings($arr);
            if($res){
                   $data=array(
                        'response'=>1,
                        'result'=>'添加成功',
                        'jumpurl'=>'./index.php?c=user&a=order'
                    );
                    echo json_encode($data);
                    die; 
            } else {
                    $data=array(
                        'response'=>0,
                        'result'=>'添加失败'
                    );
                    echo json_encode($data);
                    die;                
            }
        }
        public function control_delshous(){
            $id = $_REQUEST['gid'];
           $model = parent::model('product', 'im');
            $res=$model->delshous($id);
            if($res){
                    $data=array(
                        'response'=>1,
                        'result'=>'操作成功'
                    );
                    echo json_encode($data);
                    die;                
            }
        }
                public function control_get_wx(){
            $model = parent::model('aplipay', 'am');
            $data = $model->getData_wx();  
            echo json_encode($data);
        }
        
}
?>
