Newsale.php 1.21 KB
<?php

use Action\AbstractAction;
use LibModels\wap\Channel\NewsaleData as Newsale;
use Plugin\Helpers;
/**
 * 新品到着
 */
class NewsaleController extends AbstractAction
{
    public function indexAction()
    {
        $this->_view->assign('title', '新品到着');

        // 新品到着顶部焦点图
        $focusData = Newsale::getNewsaleFocus('a7989369aa86681c678bc40f171b8f1d');
        // 新品到着商品数据
        $productsData = Newsale::getNewsaleProducts('1,3', 1, 60);
        var_dump($productsData);

        // 处理返回的数据
        $focus = array();
        $products = array();
        if($focusData['code'] === 200)
        {
        	foreach ($focusData['data']['data'] as $single)
        	{
        		$single['src'] = Helpers::getImageUrl($val['src'], 375, 667, 1);
        		$focus[] = $single;
        	}
        }
        if($productsData['code'] === 200)
        {
        	$products = $productsData['data'];
        	foreach ($products['product_list'] as &$val) {
        		$val['default_images'] = Helpers::getImageUrl($val['default_images'], 290, 386);
        	}
        }
        var_dump($products);exit;

        $this->_view->display('new', compact('focus', 'products'));
    }
}