<?php

class IndexAction extends IniAction {

    function __construct() {
        parent::__construct();
    }

    public function index() {
        $where_ad['state'] = 1;
        $ad_arr = M('ad')->where($where_ad)->order("`order` DESC")->select();
        foreach ($ad_arr as $k => $v) {
            if ($v['type'] == 1) {
                $focus[] = $v;
            } elseif ($v['type'] == 2) {
                $flink[] = $v;
            }
        }
        $once = 20;
        $where['state'] = 1;
        $goodsdb = M('goods');
        $totalPage = ceil($goodsdb->where($where)->count() / $once);
        $count = $goodsdb->where($where)->count();
        $page = $this->iniPage($count, $once);
        $this->assign('focus', $focus);
        //$goods = GoodsModel::I()->_getGoodsList($page, $where);
        $this->assign('goods', GoodsModel::I()->_getGoodsList($page, $where));
        $this->assign('totalPage', $totalPage);
        $this->assign('flink', $flink);
        $this->display();
    }
}