<?php

namespace app\admin\controller;

use app\admin\model\Admin;
use app\admin\model\User;
use app\common\controller\Backend;
use app\common\model\Attachment;
use app\common\model\Config as ConfigModel;
use fast\Date;
use think\Db;
use think\Env;


class Expet extends Backend
{

    protected $noNeedRight = ['getbindHardwareMsg'];
    /**
     * 查看
     */
    public function index()
    {

        $simNum = [];
        if(Env::get('app.is_fault')){
            $url = config('site.url_type').'/sim/sim/listAllEnable';
            $ret = json_decode(send_get($url),true);
            if($ret['code'] == 200){
                foreach ($ret['data'] as $k => $val){
                    $simNum[] = [
                        'simNum'=>$val['simNum'],
                        'simType'=>$val['simType'],
                    ];
                }
            }
        }

//        $this->assignConfig('sim_sim_type', ConfigModel::getSimTypeList());
        $this->assign('sim_sim_type', ConfigModel::getSimTypeList());
        $this->assign('simNum', $simNum);
        $this->assignConfig('url_type', config('site.url_type'));
        return $this->view->fetch();
    }


    public function getbindHardwareMsg($ids = null){
        if(Env::get('app.is_fault')){
            $url = config('site.url_type').'/sim/fault/listTypeGZBW/'.$ids;
            $ret = json_decode(send_get($url),true);
            if($ret['code'] == 200){
                $remind_day = '<option value="">请选择</option>';
                foreach ($ret['data'] as $key =>$val){
                    $remind_day .= '<option value="'.$val['bindHardwareMsg'].'">'.$val['name'].'</option>';
                }
                $this->success($remind_day);
            }else{
                $this->error($ret['msg']);
            }
        }
    }
}
