<?php

namespace app\home\controller;

use think\facade\View;
use think\facade\Lang;

/**
 
 * 
 
 * 
 * ----------------------------------------------------------------------------
 * 
 
 * 控制器
 */
class Link extends BaseMall
{

    public function initialize()
    {
        parent::initialize(); // TODO: Change the autogenerated stub
        Lang::load(base_path() . 'home/lang/' . config('lang.default_lang') . '/link.lang.php');
    }

    public function index()
    {
        //把加密的用户id写入cookie
        $uid = input('uid');
        cookie('uid', $uid);

        //友情连接内容
        $link_model = model('link');
        $link_list = $link_model->getLinkList();
        /**
         * 整理图片链接
         */
        if (is_array($link_list)) {
            foreach ($link_list as $k => $v) {
                if (!empty($v['link_pic'])) {
                    $link_list[$k]['link_pic'] = ds_get_pic(DIR_ADMIN . '/link', $v['link_pic']);
                }
            }
        }
        View::assign('link_list', $link_list);
        View::assign('link', 'index');
        return View::fetch($this->template_dir . 'link');
    }
}