| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697 | 
							- <?php
 
- namespace app\api\controller;
 
- use app\common\controller\Api;
 
- use app\common\service\RoomService;
 
- use fast\Random;
 
- use think\Collection;
 
- use \think\Log;
 
- use Redis;
 
- use app\common\library\Sms as Smslib;
 
- use app\common\service\TenimService;
 
- use think\Db;
 
- /**
 
-  * 首页接口
 
-  */
 
- class Index extends Api
 
- {
 
-     protected $noNeedLogin = ['index','contactus','tcpTest','getAppShare','getWebsiteInfo','getUserCharmRankList',
 
-         'getPartyHotList','searchUsers','getInviteCode','getEdition','getInviteImg','getWebsiteInfoForMini','getBankList',
 
-         'getSwitch','ageList','starList','bannerList'];
 
-     protected $noNeedRight = ['*'];
 
-     /**
 
-      * 首页
 
-      *
 
-      */
 
-     public function index()
 
-     {
 
-         // 强制关闭需要退出正在房间的用户
 
-         $tenim = new \app\api\controller\Tenim();
 
-         $tenim->outMemberFromRoom(4);
 
-         $this->success('请求成功');
 
-     }
 
- //    /**
 
- //     * 生成不重复的随机数字字母组合
 
- //     */
 
- //    function getUinqueNo($length = 8) {
 
- //        $newid = Random::build("alnum",$length);
 
- ////        if(in_array($newid,$nos)) {
 
- ////            $this->getUinqueNo(8);
 
- ////        }
 
- //        return $newid;
 
- //    }
 
-     /**
 
-      * 获取用户协议等
 
-      */
 
-     public function getWebsiteInfo() {
 
-         $params = $this->request->request("params"); //内容
 
-         if($params == "boxGiftLogo") {
 
-             echo $this->success("获取成功!",$this->httpurl(config("site.".$params)));
 
-             exit;
 
-         }
 
-         echo "<html><body>";
 
-         echo config("site.".$params);
 
-         echo "</body></html>";exit;
 
-     }
 
-     /**
 
-      * 获取用户协议等 小程序
 
-      */
 
-     public function getWebsiteInfoForMini() {
 
-         $params = $this->request->request("params"); //内容
 
-         $res = config("site.".$params);
 
-         if($params == "boxGiftLogo") $res = $this->httpurl(config("site.".$params));
 
-         $this->success("获取成功!",$res);
 
-     }
 
-     /**
 
-      * 联系我们
 
-      */
 
-     public function contactus() {
 
-         $list = \app\common\model\Config::where(["group"=>"basic","name"=>["in",["email","mobile"]]])->select();
 
-         $data = [];
 
-         foreach($list as $k => $v) {
 
-             $v["name"] == "email" && $data["email"] = $v["value"];
 
-             $v["name"] == "mobile" && $data["mobile"] = $v["value"];
 
-         }
 
-         $this->success("获取成功!",$data);
 
-     }
 
-     /*
 
-      * 获取系统消息列表
 
-      */
 
-     public function getMessageSys() {
 
-         $page = $this->request->request('page',1); // 分页
 
-         $pageNum = $this->request->request('pageNum',10); // 分页
 
-         // 分页搜索构建
 
-         $pageStart = ($page-1)*$pageNum;
 
-         $flag = $this->request->request("flag",1,"intval"); //标识:1=只取一条,0=全部
 
-         $type = $this->request->request("type",1);
 
-         $obj = Db::name('message_sys')->where('type',$type)->order("id","desc")->limit($pageStart,$pageNum);
 
-         if($flag == 1) {
 
-             $list = $obj->find();
 
-             $list || $list = [];
 
-             $list && $list["createtime"] = $this->get_last_time($list["createtime"]);
 
-         } else {
 
-             $list = $obj->select();
 
-             if($list) foreach($list as $k => &$v) {
 
-                 $v["createtime"] = $this->get_last_time($v["createtime"]);
 
-             }
 
-         }
 
-         $this->success("获取成功!",$list);
 
-     }
 
-     /*
 
-      * 获取个人消息列表
 
-      */
 
-     public function getMessage() {
 
-         $page = $this->request->request('page',1); // 分页
 
-         $pageNum = $this->request->request('pageNum',10); // 分页
 
-         // 分页搜索构建
 
-         $pageStart = ($page-1)*$pageNum;
 
-         $flag = $this->request->request("flag",1,"intval"); //标识:1=只取一条,0=全部
 
-         $user_id = $this->auth->id;
 
-         $obj = \app\common\model\Message::where(["user_id"=>$user_id])->order("createtime","desc")->limit($pageStart,$pageNum);
 
-         if($flag == 1) {
 
-             $list = $obj->find();
 
-             $list || $list = [];
 
-             $list && $list["createtime"] = $this->get_last_time($list["createtime"]);
 
-         } else {
 
-             $list = $obj->select();
 
-             if($list) foreach($list as $k => &$v) {
 
-                 $v["createtime"] = $this->get_last_time($v["createtime"]);
 
-             }
 
-         }
 
-         $this->success("获取成功!",$list);
 
-     }
 
-     /**
 
-      * 删除个人消息
 
-      */
 
-     public function delMessage() {
 
-         $id = $this->request->request("id",0,"intval"); //消息ID
 
-         if($id <= 0) {
 
-             $this->error("参数传入错误!");
 
-         }
 
-         $res = \app\common\model\Message::where(["id"=>$id,"user_id"=>$this->auth->id])->delete();
 
-         if($res) {
 
-             $this->success("删除成功!");
 
-         } else {
 
-             $this->error("删除失败!");
 
-         }
 
-     }
 
-     /**
 
-      * 获取主播魅力值排行
 
-      */
 
-     public function getUserCharmRankList() {
 
-         $time = $this->request->request("time",0,"intval"); //时间筛选 1=小时榜,2=今日榜,3=本周榜,4=月榜
 
-         if(!in_array($time,[1,2,3,4])) {
 
-             $this->error("参数传入错误!");
 
-         }
 
-         $hour = strtotime(date("Y-m-d H:00:00"));
 
-         $today = strtotime(date("Y-m-d 00:00:00"));
 
-         $weekend = strtotime('monday this week');
 
- //        $weekend = mktime(0, 0 , 0,date("m"),date("d")-date("w")+1,date("Y"));
 
-         $month = strtotime(date("Y-m-01 00:00:00"));
 
-         // 剩余时间
 
-         $thistime = time();
 
-         switch ($time) {
 
-             case 1:
 
-                 $redtime = 3600-($thistime - $hour);
 
-                 break;
 
-             case 2:
 
-                 $redtime = 3600*24-($thistime - $today);
 
-                 break;
 
-             case 3:
 
-                 $redtime = 3600*24*7-($thistime - $weekend);
 
-                 break;
 
-             case 4:
 
-                 $monthend = mktime(23,59,59,date("m"),date("t"),date("Y"));
 
-                 $redtime = ($monthend - $month)-($thistime - $month);
 
-                 break;
 
-         }
 
-         $timeArr = [1=>$hour,2=>$today,3=>$weekend,4=>$month];
 
-         $where = [];
 
-         $where["a.createtime"] = ["gt",$timeArr[$time]];
 
-         $list = \app\common\model\UserCharmRank::alias("a")
 
-             ->field("a.party_id as id,sum(a.charm) as charm,u.avatar,u.nickname,u.gender,u.level,u.is_live")
 
-             ->where($where)
 
-             ->join("hx_user u","u.id = a.user_id",'LEFT')
 
- //            ->join("hx_party p","p.user_id = a.user_id",'LEFT')
 
-             ->group("a.user_id")
 
-             ->order("charm","desc")
 
-             ->limit(100)
 
-             ->select();
 
-         $data = [];
 
-         $data["redtime"] = $redtime;
 
-         $data["data"] = $list;
 
-         $this->success("获取成功!",$data);
 
-     }
 
-     /**
 
-      * 获取收礼排行
 
-      */
 
-     public function getUserGiftRank() {
 
-         $time = $this->request->request("time",0,"intval"); //时间筛选 1=小时榜,2=今日榜,3=本周榜,4=月榜
 
-         if(!in_array($time,[1,2,3,4])) {
 
-             $this->error("参数传入错误!");
 
-         }
 
-         $hour = strtotime(date("Y-m-d H:00:00"));
 
-         $today = strtotime(date("Y-m-d 00:00:00"));
 
-         $weekend = strtotime('monday this week');
 
-         $month = strtotime(date("Y-m-01 00:00:00"));
 
-         // 剩余时间
 
-         $thistime = time();
 
-         switch ($time) {
 
-             case 1:
 
-                 $redtime = 3600-($thistime - $hour);
 
-                 break;
 
-             case 2:
 
-                 $redtime = 3600*24-($thistime - $today);
 
-                 break;
 
-             case 3:
 
-                 $redtime = 3600*24*7-($thistime - $weekend);
 
-                 break;
 
-             case 4:
 
-                 $monthend = mktime(23,59,59,date("m"),date("t"),date("Y"));
 
-                 $redtime = ($monthend - $month)-($thistime - $month);
 
-                 break;
 
-         }
 
-         $timeArr = [1=>$hour,2=>$today,3=>$weekend,4=>$month];
 
-         $where = [];
 
-         $where["a.createtime"] = ["gt",$timeArr[$time]];
 
-         $list = model('GiftUserParty')->alias("a")
 
-             ->field("sum(a.value) as total_price,u.avatar,u.nickname")
 
-             ->where($where)
 
-             ->join("hx_user u","u.id = a.user_id")
 
-             ->group("a.user_to_id")
 
-             ->order("total_price","desc")
 
-             ->limit(100)
 
-             ->select();
 
-         $data = [];
 
-         $data["redtime"] = $redtime;
 
-         $data["data"] = $list;
 
-         $this->success("获取成功!",$data);
 
-     }
 
-     /**
 
-      * 获取消费排行
 
-      */
 
-     public function getUserPayRank() {
 
-         $time = $this->request->request("time",0,"intval"); //时间筛选 1=小时榜,2=今日榜,3=本周榜,4=月榜
 
-         if(!in_array($time,[1,2,3,4])) {
 
-             $this->error("参数传入错误!");
 
-         }
 
-         $hour = strtotime(date("Y-m-d H:00:00"));
 
-         $today = strtotime(date("Y-m-d 00:00:00"));
 
-         $weekend = strtotime('monday this week');
 
-         $month = strtotime(date("Y-m-01 00:00:00"));
 
-         // 剩余时间
 
-         $thistime = time();
 
-         switch ($time) {
 
-             case 1:
 
-                 $redtime = 3600-($thistime - $hour);
 
-                 break;
 
-             case 2:
 
-                 $redtime = 3600*24-($thistime - $today);
 
-                 break;
 
-             case 3:
 
-                 $redtime = 3600*24*7-($thistime - $weekend);
 
-                 break;
 
-             case 4:
 
-                 $monthend = mktime(23,59,59,date("m"),date("t"),date("Y"));
 
-                 $redtime = ($monthend - $month)-($thistime - $month);
 
-                 break;
 
-         }
 
-         $timeArr = [1=>$hour,2=>$today,3=>$weekend,4=>$month];
 
-         $where = [];
 
-         $where["a.type"] = ["in",[0,2,3,5,6,11,13]];//查看wallet.php文件
 
-         $where["a.createtime"] = ["gt",$timeArr[$time]];
 
-         $list = model('UserJewelLog')->alias("a")
 
-             ->field("sum(a.value) as total_price,u.avatar,u.nickname")
 
-             ->where($where)
 
-             ->join("hx_user u","u.id = a.user_id")
 
-             ->group("a.user_id")
 
-             ->order("total_price","desc")
 
-             ->limit(100)
 
-             ->select();
 
-         $data = [];
 
-         $data["redtime"] = $redtime;
 
-         $data["data"] = $list;
 
-         $this->success("获取成功!",$data);
 
-     }
 
-     /**
 
-      * 获取派对热度排序
 
-      */
 
-     public function getPartyHotList() {
 
-         // 剩余时间
 
-         $thistime = time();
 
-         $hour = strtotime(date("Y-m-d H:00:00"));
 
-         $redtime = 3600-($thistime - $hour);
 
-         $where = [];
 
-         $where["a.createtime"] = ["gt",$hour];
 
-         $where["p.room_type"] = 1;
 
-         $list = \app\common\model\PartyHot::alias("a")
 
-             ->field("sum(a.hot) as hot,p.id,u.avatar,p.party_name,p.party_logo")
 
-             ->where($where)
 
-             ->join("hx_party p","p.id = a.party_id")
 
-             ->join("hx_user u","u.id = p.user_id")
 
-             ->group("a.party_id")
 
-             ->order("hot","desc")
 
-             ->limit(100)
 
-             ->select();
 
-         $data = [];
 
-         $data["redtime"] = $redtime;
 
-         $data["data"] = $list;
 
-         $this->success("获取成功!",$data);
 
-     }
 
-     /**
 
-      * 首页搜索
 
-      */
 
-     public function searchUsers() {
 
-         $search = $this->request->request("search"); //关键词筛选
 
-         if(!$search) {
 
-             $this->error("请输入搜索内容!");
 
-         }
 
-         // 搜索派对
 
-         global $whereOr;
 
-         $where = [];
 
-         $whereOr["party_id"] = $search;
 
-         $whereOr["party_name"] = ["like","%$search%"];
 
-         $where["room_type"] = 1;
 
-         $partyList = \app\common\model\Party::field("id,party_logo,party_id,party_name")
 
-             ->where($where)
 
-             ->where(function ($query) {
 
-             global $whereOr;
 
-             $query->whereOr($whereOr);
 
-         })->order("party_hot","desc")->select();
 
-         // 搜索直播间
 
-         global $whereOrlive;
 
-         $where = [];
 
-         $whereOrlive["party_id"] = $search;
 
-         $whereOrlive["party_name"] = ["like","%$search%"];
 
-         $where["room_type"] = 2;
 
-         $liveList = \app\common\model\Party::field("id,party_logo,party_id,party_name")
 
-             ->where($where)
 
-             ->where(function ($query) {
 
-                 global $whereOrlive;
 
-                 $query->whereOr($whereOrlive);
 
-             })
 
-             ->order("party_hot","desc")->select();
 
-         // 相关用户
 
-         $where = [];
 
-         $where["a.nickname"] = ["like","%$search%"];
 
-         $where["a.u_id"] = $search;
 
-         $userList = \app\common\model\User::alias("a")->field("id,avatar,nickname,u_id,f.fans")
 
-             ->join("hx_view_fans f","f.user_id = a.id","left")
 
-             ->order("a.is_online,a.noble,a.level")
 
-             ->whereOr($where)->select();
 
-         $res = [];
 
-         $res["partylist"] = $partyList;
 
-         $res["livelist"] = $liveList;
 
-         $res["userlist"] = $userList;
 
-         $this->success("获取成功!",$res);
 
-     }
 
-     /**
 
-      * 首页搜索
 
-      */
 
-     public function searchList() {
 
-         $search = $this->request->request("search"); //关键词筛选
 
-         if(!$search) {
 
-             $this->error("请输入搜索内容!");
 
-         }
 
-         // 搜索房间(派对和直播)
 
-         global $whereOr;
 
-         $where = [];
 
-         $whereOr["party_id"] = $search;
 
-         $whereOr["party_name"] = ["like","%$search%"];
 
-         //$where['is_online'] = 1;
 
-         $where['status'] = 1;
 
-         $partyList = \app\common\model\Party::field("id,party_logo,party_id,party_name,party_type")
 
-             ->where($where)
 
-             ->where(function ($query) {
 
-                 global $whereOr;
 
-                 $query->whereOr($whereOr);
 
-             })->order("party_hot","desc")->select();
 
-         $partyList = collection($partyList)->toArray();
 
-         if (!empty($partyList)) {//在线信息
 
-             $partyListIds = array_column($partyList,'id');
 
-             /*$tenimService = new TenimService();
 
-             $partyParams = ['party_ids'=>$partyListIds];
 
-             $partyRes = $tenimService->getRoomUser($partyParams);*/
 
-             /*if ($partyRes['status'] == 1) {
 
-             }*/
 
-             $roomService = new RoomService();
 
-             foreach ($partyList as $pKey => &$pVal) {
 
-                 // 派对类型
 
-                 $partyTypeName = "普通房";
 
-                 if($pVal["party_type"]) {
 
-                     $partyTypeName = \app\common\model\PartyType::where(["id"=>$pVal["party_type"]])->value("name");
 
-                 }
 
-                 $mod = isset($pVal["party_type"])?intval($pVal["party_type"])%5:1;
 
-                 $pVal["party_type_color"] = $mod == 0?5:$mod;
 
-                 $pVal["type_name"] = $partyTypeName;
 
-                 $userDataResult = $roomService->getPartyUserList(['party_id'=>$pVal['id']]);
 
-                 $userDataRes = isset($userDataResult['data']) ? $userDataResult['data'] : [];
 
-                 $pVal['member_list'] = isset($userDataRes['member_list']) ? $userDataRes['member_list'] : [];
 
-                 $pVal['online_num']  = isset($userDataRes['online_num']) ? $userDataRes['online_num'] : [];
 
-             }
 
-         }
 
-         // 家族
 
-         $guildWhere['status'] = 1;
 
-         $guildWhere['name'] = ["like","%$search%"];
 
-         $guildList = model('Guild')->where($guildWhere)->with(['guildmember'=>function($gquery){
 
-             $gquery->where(['status'=>1]);
 
-         }])->field('id,g_id,name,image')->select();
 
-         if (!empty($guildList)) {
 
-             $userField = 'id,nickname,avatar';
 
-             foreach ($guildList as $gKey => &$gVal) {
 
-                 $userData =[];
 
-                 if (isset($gVal['guildmember'])) {
 
-                     $memberUids = array_column($gVal['guildmember'],'user_id');
 
-                     $userWhere['is_online'] = 1;
 
-                     $userWhere['id'] = ['in',$memberUids];
 
-                     $userData = model('User')->field($userField)->where($userWhere)->select();
 
-                 }
 
-                 /*$mod = intval($gKey)%5;
 
-                 $pVal["party_type_color"] = $mod == 0?5:$mod;*/
 
-                 $pVal["party_type_color"] = 1;
 
-                 $pVal["type_name"] = '普通房';
 
-                 $gVal['member_list'] = $userData;
 
-                 $gVal['online_num'] = count($userData);
 
-                 unset($gVal['guildmember']);
 
-             }
 
-         }
 
-         // 相关用户
 
-         $where = [];
 
-         $where["a.nickname"] = ["like","%$search%"];
 
-         $where["a.u_id"] = $search;
 
-         $userList = \app\common\model\User::alias("a")->field("id,avatar,nickname,u_id,f.fans")
 
-             ->join("hx_view_fans f","f.user_id = a.id","left")
 
-             ->order("a.is_online,a.noble,a.level")
 
-             ->whereOr($where)->select();
 
-         $res = [];
 
-         $res["roomlist"] = $partyList;
 
-         $res["guildlist"] = $guildList;
 
-         $res["userlist"] = $userList;
 
-         $this->success("获取成功!",$res);
 
-     }
 
-     /**
 
-      * 获取下载二维码和邀请码
 
-      */
 
-     public function getInviteCode() {
 
-         // 获取二维码
 
-         $host = $_SERVER["REQUEST_SCHEME"]."://".$_SERVER["HTTP_HOST"];
 
-         $qrcode = $this->httpurl($host.config("site.qrcode"));
 
-         $miniqrcode = $this->httpurl($host.config("site.miniqrcode"));
 
-         // 获取用户邀请码
 
-         $inviteCode = \app\common\model\User::where(["id"=>$this->auth->id])->value("invite_no");
 
-         $downlowdLink = $host."/index/index/appJump?t=wlt".rand(10,999).Random::alpha(8);
 
-         $this->success("获取成功!",["qrcode"=>$qrcode,"miniqrcode"=>$miniqrcode,"inviteCode"=>$inviteCode,"downlowdLink"=>$downlowdLink]);
 
-     }
 
-     /**
 
-      * 获取app分享海报
 
-      */
 
-     public function getAppShare() {
 
-         $this->success("获取成功!",["url"=>$this->httpurl(config("site.appShare"))]);
 
-     }
 
-     /**
 
-      * 获取版本更新信息
 
-      */
 
-     public function getEdition() {
 
-         // 获取二维码
 
-         $is_force = config("site.is_force");
 
-         $apkUrl = config("site.apkUrl");
 
-         $apkName = config("site.apkName");
 
-         $desc = config("site.desc");
 
-         $versionCode = config("site.versionCode");
 
-         $this->success("获取成功!",["versionCode"=>$versionCode,"isForceUpdate"=>$is_force,"apkUrl"=>$apkUrl,"apkName"=>$apkName,"desc"=>$desc]);
 
-     }
 
-     /**
 
-      * 获取邀请图片
 
-      */
 
-     public function getInviteImg() {
 
-         $plat = $this->request->request("plat",1); //平台:1=小程序,2=app
 
-         if(!in_array($plat,[1,2])) $this->error("参数错误");
 
-         // 获取用户的邀请码
 
-         $invitecode = \app\common\model\User::where(["id"=>$this->auth->id])->value("invite_no");
 
-         // 文字图片合成
 
-         $bigImgPath = $this->httpurlLocal('/assets/img/inviteimg.jpeg');
 
-         $img = imagecreatefromstring(file_get_contents($bigImgPath));
 
-         //字体文件
 
-         $font = realpath('./assets/fonts/lato/lato-black.ttf');
 
-         //字体颜色(RGB)
 
-         $black = imagecolorallocate($img, 217, 76, 41);
 
-         //字体大小
 
-         $fontSize = 30;
 
-         //旋转角度
 
-         $circleSize = 0;
 
-         //左边距
 
-         $left = 275;
 
-         //上边距
 
-         $top = 540;
 
-         imagefttext($img, $fontSize, $circleSize, $left, $top, $black, $font, $invitecode);
 
-         $filename = date("YmdH").".jpeg";
 
-         $path = "/uploads/qrcode/".$filename;
 
-         $file = $_SERVER['DOCUMENT_ROOT'] . $path;//打开文件准备写入
 
-         list($bgWidth, $bgHight, $bgType) = getimagesize($bigImgPath);
 
-         switch ($bgType) {
 
-             case 1://gif
 
-                 header('Content-Type:image/gif');
 
-                 imagegif($img,$file);
 
-                 break;
 
-             case 2://jpg
 
-                 header('Content-Type:image/jpg');
 
-                 imagejpeg($img,$file);
 
-                 break;
 
-             case 3://jpg
 
-                 header('Content-Type:image/png');
 
-                 imagepng($img,$file);
 
-                 break;
 
-             default:
 
-                 break;
 
-         }
 
-         //销毁照片
 
-         imagedestroy($img);
 
-         // 图片和二维码合成
 
-         $qrcode = $plat == 1 ? config("site.miniqrcode"):config("site.qrcode");
 
-         $background = $file;
 
-         $target = $this->httpurl($qrcode);
 
-         $background_iamge = imagecreatefromstring(file_get_contents($background));
 
-         $target_image = imagecreatefromstring(file_get_contents($target));
 
-         list($target_width, $target_height, $target_type) = getimagesize($target);
 
-         imagecopymerge($background_iamge , $target_image , 250, 700, 0, 0, $target_width, $target_height, 100);
 
-         list($background_width, $background_height, $background_type) = getimagesize($background);
 
-         switch ($background_type) {
 
-             case 1://gif
 
-                 header('Content-Type:image/gif');
 
-                 imagegif($background_iamge,$file);
 
-                 break;
 
-             case 2://jpg
 
-                 header('Content-Type:image/jpg');
 
-                 imagejpeg($background_iamge,$file);
 
-                 break;
 
-             case 3://jpg
 
-                 header('Content-Type:image/png');
 
-                 imagepng($background_iamge,$file);
 
-                 break;
 
-             default:
 
-                 break;
 
-         }
 
-         $savepath = $this->httpurlLocal($path);
 
-         $this->success("获取成功!",$savepath);
 
-     }
 
-     /**
 
-      * 获取银行列表
 
-      */
 
-     public function getBankList() {
 
-         $this->success("获取成功!",["banklist"=>\app\common\model\Bank::select()]);
 
-     }
 
-     /**
 
-      * 获取开关配置
 
-      */
 
-     public function getSwitch() {
 
-         $this->success("获取成功!",["switch"=>config("site.switch")]);
 
-     }
 
-     /**
 
-      * 评论时间转换
 
-      * @param null $time
 
-      * @return false|string
 
-      */
 
-     private function get_last_time($time = NULL) {
 
-         $text = '';
 
-         $time = $time === NULL || $time > time() ? time() : intval($time);
 
-         $t = time() - $time; //时间差 (秒)
 
-         $y = date('Y', $time)-date('Y', time());//是否跨年
 
-         switch($t){
 
-             case $t == 0:
 
-                 $text = '刚刚';
 
-                 break;
 
-             case $t < 60:
 
-                 $text = $t . '秒前'; // 一分钟内
 
-                 break;
 
-             case $t < 60 * 60:
 
-                 $text = floor($t / 60) . '分钟前'; //一小时内
 
-                 break;
 
-             case $t < 60 * 60 * 24:
 
-                 $text = floor($t / (60 * 60)) . '小时前'; // 一天内
 
-                 break;
 
-             case $t < 60 * 60 * 24 * 3:
 
-                 $text = floor($time/(60*60*24)) ==1 ?'昨天 ' . date('H:i', $time) : '前天 ' . date('H:i', $time) ; //昨天和前天
 
-                 break;
 
-             case $t < 60 * 60 * 24 * 30:
 
-                 $text = date('m月d日 H:i', $time); //一个月内
 
-                 break;
 
-             case $t < 60 * 60 * 24 * 365&&$y==0:
 
-                 $text = date('m月d日', $time); //一年内
 
-                 break;
 
-             default:
 
-                 $text = date('Y年m月d日', $time); //一年以前
 
-                 break;
 
-         }
 
-         return $text;
 
-     }
 
-     /**
 
-      * 年龄段列表
 
-      * @return void
 
-      */
 
-     public function ageList()
 
-     {
 
-         try {
 
-             $field = 'id,name';
 
-             $where['status'] = 1;
 
-             $result = model('Age')->field($field)->where($where)->order('weigh asc')->select();
 
-             $this->success('获取成功',$result);
 
-         } catch (Exception $e) {
 
-             $this->error($e->getMessage());
 
-         }
 
-     }
 
-     /**
 
-      * 星座列表
 
-      * @return void
 
-      */
 
-     public function starList()
 
-     {
 
-         try {
 
-             $field = 'id,name,image';
 
-             $where['status'] = 1;
 
-             $result = model('Constellation')->field($field)->where($where)->order('weigh asc')->select();
 
-             if (!$result) {
 
-                 $result = list_domain_image($result,['image']);
 
-             }
 
-             $this->success('获取成功',$result);
 
-         } catch (Exception $e) {
 
-             $this->error($e->getMessage());
 
-         }
 
-     }
 
-     /**
 
-      * 轮播图列表
 
-      * @return void
 
-      */
 
-     public function bannerList()
 
-     {
 
-         try {
 
-             $field = 'id,title,image,url';
 
-             $where['status'] = 1;
 
-             $result = model('Banner')->field($field)->where($where)->order('weigh asc')->select();
 
-             if (!$result) {
 
-                 $result = list_domain_image($result,['image']);
 
-             }
 
-             $this->success('获取成功',$result);
 
-         } catch (Exception $e) {
 
-             $this->error($e->getMessage());
 
-         }
 
-     }
 
- }
 
 
  |