Exemplo n.º 1
0
 /**
  * 添加相关资料到控制器中,方便Action中直接读取
  */
 protected function initAddDataToController()
 {
     //设置当前或之前访问的地区资料
     $cookie = new XF_Cookie('local');
     $province_id = $cookie->read();
     $mod = new Application_Model_City();
     $row = $mod->get($province_id);
     if ($row != false && $row->parent == '0') {
         $obj = (object) array('id' => $province_id, 'name' => $row->name, 'pinyin' => $row->pinyin);
         XF_Controller_Front::getInstance()->addHandleData('nowCity', $obj);
         XF_View::getInstance()->assign('nowCity', $obj);
     }
     //添加静态资源URL
     XF_Controller_Front::getInstance()->addHandleData('static_url', 'http://static.' . XF_Config::getInstance()->getDomain());
 }
Exemplo n.º 2
0
 private function switchCity()
 {
     $isSpider = false;
     $spiders = array('sogou spider', 'Sosospider', '360Spider', 'googlebot', 'mediapartners-google', 'baiduspider', 'msnbot', 'yodaobot', 'yahoo! slurp;', 'yahoo! slurp china;', 'iaskspider', 'sogou web spider', 'sogou push spider');
     foreach ($spiders as $s) {
         if (strpos(strtolower($_SERVER['HTTP_USER_AGENT']), strtolower($s)) !== false) {
             $isSpider = true;
             break;
         }
     }
     //如果来源是本站则不自动跳转
     if ((!isset($_SERVER['HTTP_REFERER']) || strpos($_SERVER['HTTP_REFERER'], XF_Config::getInstance()->getDomain()) == false) && $isSpider == false) {
         $domain_url = XF_Config::getInstance()->getDomain();
         //是否存在cookie
         $cookie = new XF_Cookie('local');
         if ($cookie->isEmpty() == false) {
             $mod = new Application_Model_City();
             $row = $mod->get($cookie->read());
             if ($row != false) {
                 die('<script>window.location.href="http://' . $row->pinyin . '.' . $domain_url . '";</script>');
             }
         }
         /////IP
         $ip = XF_Controller_Request_Http::getInstance()->getClientIp();
         $mod = new Application_Model_IP();
         $row = $mod->getByIP($ip);
         $province_id = 1;
         //如果用户ip不存在则添加到库中
         if ($row == false) {
             $province_id = $mod->add($ip);
         } else {
             $province_id = $row->province_id;
         }
         XF_Config::getInstance()->load('cityDomain');
         $cityDomains = (array) XF_Config::getInstance()->cityDomain;
         foreach ($cityDomains as $domain => $val) {
             if ($val['id'] == $province_id) {
                 die('<script>window.location.href="http://' . $domain . '.' . $domain_url . '";</script>');
             }
         }
         //默认为北京
         die('<script>window.location.href="http://beijing.' . $domain_url . '";</script>');
     }
 }
Exemplo n.º 3
0
 public function buyReportAction()
 {
     $serialId = $this->getParam('serialId');
     $cityid = $this->getParam('city');
     $year = $this->getParam('year');
     $typeId = $this->getParam('typeId');
     $mileage = $this->getParam('mileage');
     if (!isset($serialId) || XF_Functions::isEmpty($serialId)) {
         throw new XF_Exception('车系参数不正确');
     }
     // 当前地区名称
     $name = $this->nowCity->name;
     $this->_view->serialId = $serialId;
     // 获取车型列表
     $mod = new Auto_Model_Type();
     $types = $mod->getsBySerialId($serialId);
     // print_r($types);
     $this->_view->types = $types;
     if ((!isset($serialId) || XF_Functions::isEmpty($typeId)) && !XF_Functions::isEmpty($types)) {
         $typeId = $types[0][1][0]->id;
         $type = $mod->getsByTypeId($typeId);
     } else {
         $type = $mod->getsByTypeId($typeId);
     }
     //        获得session,存车型id
     $gpj_session = new XF_Session("gpj_session");
     $sessionAry = array();
     $sessionAry["modelId"] = $typeId;
     $sessionAry["detail_model"] = $type->detail_model;
     $sessionAry["detail_price"] = $type->price_bn;
     $this->_view->type = $type;
     //        获取评估报告投票
     $vote = new Report_Model_Vote();
     $reportVote = $vote->getVoteByTypeId($typeId);
     if ($reportVote) {
         $this->_view->goodNum = $reportVote->right_vote;
         $this->_view->noGoodNum = $reportVote->noright_vote;
         $this->_view->totalNum = $reportVote->right_vote + $reportVote->noright_vote;
     } else {
         $this->_view->goodNum = 0;
         $this->_view->noGoodNum = 0;
         $this->_view->totalNum = 0;
     }
     $cityModel = new Application_Model_City();
     $cities = $cityModel->getsByCity($this->nowCity->id);
     if (!isset($cityid) || XF_Functions::isEmpty($cityid) || !is_numeric($cityid) || $cityid <= 0) {
         $cityid = $this->nowCity->id;
     }
     $cityObj = $cityModel->get($cityid);
     $this->_view->cities = $cities;
     $this->_view->cityName = $cityObj->name;
     $this->_view->cityId = $cityid;
     $this->_view->cityPinYin = $cityObj->pinyin;
     $sessionAry["province"] = $cityid;
     $d_model = $type->id;
     $year = $year > 0 ? $year : $type->listed_year;
     $mile = floatval($mileage) > 0 ? floatval($mileage) : date("Y") - $type->listed_year;
     $intent = 'buy';
     $this->_view->mileage = $mile;
     $this->_view->year = $year;
     $mod = new Report_Model_Valuation();
     $V = $mod->getValuation($cityid, $d_model, $year, '', $mile, $intent);
     $this->_view->V = $V;
     $sessionAry["detail_year"] = $year;
     $sessionAry["detail_mile"] = $mile;
     $sessionAry["serialId"] = $serialId;
     $gpj_session->write($sessionAry);
     // 随机抽取6辆车型
     $carTypeModel = new Auto_Model_Type();
     $serialCars = $carTypeModel->getsByCityAndSerialId($cityid, $typeId);
     foreach ($serialCars as $key => $val) {
         $val->mile = round($val->mile);
         if (!XF_Functions::isEmpty($val->year)) {
             $val->car_age = date("Y") - $val->year;
         }
         if (!XF_Functions::isEmpty($val->source_type)) {
             $val->source_val = $this->source_type[$val->source_type];
         }
         if (!XF_Functions::isEmpty($val->thumbnail)) {
             $val->thumbnail = $val->thumbnail . "?imageView2/1/w/296/h/193";
         } else {
         }
     }
     $this->_view->serialCars = $serialCars;
     $this->setLayout(new Layout_Default());
     $this->_view->headTitle("买二手车价格评估-买二手车估价-买二手车技巧流程-公平价");
     $this->_view->headMeta("买二手车车评估,买二手车估价,买二手车流程,买二手车技巧");
     $this->_view->headMeta("公平价-买车评估频道为您提供:二手车买车估值、二手车买车估价、二手车买车估价计算器,给您所选爱车一个精准、公平、公道的价格。二手车买车服务就上公平价!");
     // 设置页面资源
     $this->_view->headStylesheet('/css/report/report.css');
     $this->_view->headStylesheet('/css/valid.css');
     $this->_view->headScript('/js/pagejs/buyreport.js');
 }