Index.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682
  1. <?php
  2. namespace app\api\controller;
  3. use app\common\controller\Api;
  4. use fast\Random;
  5. use think\Collection;
  6. use \think\Log;
  7. use Redis;
  8. use app\common\library\Sms as Smslib;
  9. use app\common\service\TenimService;
  10. use think\Db;
  11. /**
  12. * 首页接口
  13. */
  14. class Index extends Api
  15. {
  16. protected $noNeedLogin = ['index','contactus','tcpTest','getAppShare','getWebsiteInfo','getUserCharmRankList',
  17. 'getPartyHotList','searchUsers','getInviteCode','getEdition','getInviteImg','getWebsiteInfoForMini','getBankList',
  18. 'getSwitch','ageList','starList','bannerList'];
  19. protected $noNeedRight = ['*'];
  20. /**
  21. * 首页
  22. *
  23. */
  24. public function index()
  25. {
  26. // 强制关闭需要退出正在房间的用户
  27. $tenim = new \app\api\controller\Tenim();
  28. $tenim->outMemberFromRoom(4);
  29. $this->success('请求成功');
  30. }
  31. // /**
  32. // * 生成不重复的随机数字字母组合
  33. // */
  34. // function getUinqueNo($length = 8) {
  35. // $newid = Random::build("alnum",$length);
  36. //// if(in_array($newid,$nos)) {
  37. //// $this->getUinqueNo(8);
  38. //// }
  39. // return $newid;
  40. // }
  41. /**
  42. * 获取用户协议等
  43. */
  44. public function getWebsiteInfo() {
  45. $params = $this->request->request("params"); //内容
  46. if($params == "boxGiftLogo") {
  47. echo $this->success("获取成功!",$this->httpurl(config("site.".$params)));
  48. exit;
  49. }
  50. echo "<html><body>";
  51. echo config("site.".$params);
  52. echo "</body></html>";exit;
  53. }
  54. /**
  55. * 获取用户协议等 小程序
  56. */
  57. public function getWebsiteInfoForMini() {
  58. $params = $this->request->request("params"); //内容
  59. $res = config("site.".$params);
  60. if($params == "boxGiftLogo") $res = $this->httpurl(config("site.".$params));
  61. $this->success("获取成功!",$res);
  62. }
  63. /**
  64. * 联系我们
  65. */
  66. public function contactus() {
  67. $list = \app\common\model\Config::where(["group"=>"basic","name"=>["in",["email","mobile"]]])->select();
  68. $data = [];
  69. foreach($list as $k => $v) {
  70. $v["name"] == "email" && $data["email"] = $v["value"];
  71. $v["name"] == "mobile" && $data["mobile"] = $v["value"];
  72. }
  73. $this->success("获取成功!",$data);
  74. }
  75. /*
  76. * 获取系统消息列表
  77. */
  78. public function getMessageSys() {
  79. $page = $this->request->request('page',1); // 分页
  80. $pageNum = $this->request->request('pageNum',10); // 分页
  81. // 分页搜索构建
  82. $pageStart = ($page-1)*$pageNum;
  83. $flag = $this->request->request("flag",1,"intval"); //标识:1=只取一条,0=全部
  84. $type = $this->request->request("type",1);
  85. $obj = Db::name('message_sys')->where('type',$type)->order("id","desc")->limit($pageStart,$pageNum);
  86. if($flag == 1) {
  87. $list = $obj->find();
  88. $list || $list = [];
  89. $list && $list["createtime"] = $this->get_last_time($list["createtime"]);
  90. } else {
  91. $list = $obj->select();
  92. if($list) foreach($list as $k => &$v) {
  93. $v["createtime"] = $this->get_last_time($v["createtime"]);
  94. }
  95. }
  96. $this->success("获取成功!",$list);
  97. }
  98. /*
  99. * 获取个人消息列表
  100. */
  101. public function getMessage() {
  102. $page = $this->request->request('page',1); // 分页
  103. $pageNum = $this->request->request('pageNum',10); // 分页
  104. // 分页搜索构建
  105. $pageStart = ($page-1)*$pageNum;
  106. $flag = $this->request->request("flag",1,"intval"); //标识:1=只取一条,0=全部
  107. $user_id = $this->auth->id;
  108. $obj = \app\common\model\Message::where(["user_id"=>$user_id])->order("createtime","desc")->limit($pageStart,$pageNum);
  109. if($flag == 1) {
  110. $list = $obj->find();
  111. $list || $list = [];
  112. $list && $list["createtime"] = $this->get_last_time($list["createtime"]);
  113. } else {
  114. $list = $obj->select();
  115. if($list) foreach($list as $k => &$v) {
  116. $v["createtime"] = $this->get_last_time($v["createtime"]);
  117. }
  118. }
  119. $this->success("获取成功!",$list);
  120. }
  121. /**
  122. * 删除个人消息
  123. */
  124. public function delMessage() {
  125. $id = $this->request->request("id",0,"intval"); //消息ID
  126. if($id <= 0) {
  127. $this->error("参数传入错误!");
  128. }
  129. $res = \app\common\model\Message::where(["id"=>$id,"user_id"=>$this->auth->id])->delete();
  130. if($res) {
  131. $this->success("删除成功!");
  132. } else {
  133. $this->error("删除失败!");
  134. }
  135. }
  136. /**
  137. * 获取主播魅力值排行
  138. */
  139. public function getUserCharmRankList() {
  140. $time = $this->request->request("time",0,"intval"); //时间筛选 1=小时榜,2=今日榜,3=本周榜,4=月榜
  141. if(!in_array($time,[1,2,3,4])) {
  142. $this->error("参数传入错误!");
  143. }
  144. $hour = strtotime(date("Y-m-d H:00:00"));
  145. $today = strtotime(date("Y-m-d 00:00:00"));
  146. $weekend = strtotime('monday this week');
  147. // $weekend = mktime(0, 0 , 0,date("m"),date("d")-date("w")+1,date("Y"));
  148. $month = strtotime(date("Y-m-01 00:00:00"));
  149. // 剩余时间
  150. $thistime = time();
  151. switch ($time) {
  152. case 1:
  153. $redtime = 3600-($thistime - $hour);
  154. break;
  155. case 2:
  156. $redtime = 3600*24-($thistime - $today);
  157. break;
  158. case 3:
  159. $redtime = 3600*24*7-($thistime - $weekend);
  160. break;
  161. case 4:
  162. $monthend = mktime(23,59,59,date("m"),date("t"),date("Y"));
  163. $redtime = ($monthend - $month)-($thistime - $month);
  164. break;
  165. }
  166. $timeArr = [1=>$hour,2=>$today,3=>$weekend,4=>$month];
  167. $where = [];
  168. $where["a.createtime"] = ["gt",$timeArr[$time]];
  169. $list = \app\common\model\UserCharmRank::alias("a")
  170. ->field("a.party_id as id,sum(a.charm) as charm,u.avatar,u.nickname,u.gender,u.level,u.is_live")
  171. ->where($where)
  172. ->join("hx_user u","u.id = a.user_id",'LEFT')
  173. // ->join("hx_party p","p.user_id = a.user_id",'LEFT')
  174. ->group("a.user_id")
  175. ->order("charm","desc")
  176. ->limit(100)
  177. ->select();
  178. $data = [];
  179. $data["redtime"] = $redtime;
  180. $data["data"] = $list;
  181. $this->success("获取成功!",$data);
  182. }
  183. /**
  184. * 获取收礼排行
  185. */
  186. public function getUserGiftRank() {
  187. $time = $this->request->request("time",0,"intval"); //时间筛选 1=小时榜,2=今日榜,3=本周榜,4=月榜
  188. if(!in_array($time,[1,2,3,4])) {
  189. $this->error("参数传入错误!");
  190. }
  191. $hour = strtotime(date("Y-m-d H:00:00"));
  192. $today = strtotime(date("Y-m-d 00:00:00"));
  193. $weekend = strtotime('monday this week');
  194. $month = strtotime(date("Y-m-01 00:00:00"));
  195. // 剩余时间
  196. $thistime = time();
  197. switch ($time) {
  198. case 1:
  199. $redtime = 3600-($thistime - $hour);
  200. break;
  201. case 2:
  202. $redtime = 3600*24-($thistime - $today);
  203. break;
  204. case 3:
  205. $redtime = 3600*24*7-($thistime - $weekend);
  206. break;
  207. case 4:
  208. $monthend = mktime(23,59,59,date("m"),date("t"),date("Y"));
  209. $redtime = ($monthend - $month)-($thistime - $month);
  210. break;
  211. }
  212. $timeArr = [1=>$hour,2=>$today,3=>$weekend,4=>$month];
  213. $where = [];
  214. $where["a.createtime"] = ["gt",$timeArr[$time]];
  215. $list = model('GiftUserParty')->alias("a")
  216. ->field("sum(a.value) as total_price,u.avatar,u.nickname")
  217. ->where($where)
  218. ->join("hx_user u","u.id = a.user_id")
  219. ->group("a.user_to_id")
  220. ->order("total_price","desc")
  221. ->limit(100)
  222. ->select();
  223. $data = [];
  224. $data["redtime"] = $redtime;
  225. $data["data"] = $list;
  226. $this->success("获取成功!",$data);
  227. }
  228. /**
  229. * 获取消费排行
  230. */
  231. public function getUserPayRank() {
  232. $time = $this->request->request("time",0,"intval"); //时间筛选 1=小时榜,2=今日榜,3=本周榜,4=月榜
  233. if(!in_array($time,[1,2,3,4])) {
  234. $this->error("参数传入错误!");
  235. }
  236. $hour = strtotime(date("Y-m-d H:00:00"));
  237. $today = strtotime(date("Y-m-d 00:00:00"));
  238. $weekend = strtotime('monday this week');
  239. $month = strtotime(date("Y-m-01 00:00:00"));
  240. // 剩余时间
  241. $thistime = time();
  242. switch ($time) {
  243. case 1:
  244. $redtime = 3600-($thistime - $hour);
  245. break;
  246. case 2:
  247. $redtime = 3600*24-($thistime - $today);
  248. break;
  249. case 3:
  250. $redtime = 3600*24*7-($thistime - $weekend);
  251. break;
  252. case 4:
  253. $monthend = mktime(23,59,59,date("m"),date("t"),date("Y"));
  254. $redtime = ($monthend - $month)-($thistime - $month);
  255. break;
  256. }
  257. $timeArr = [1=>$hour,2=>$today,3=>$weekend,4=>$month];
  258. $where = [];
  259. $where["a.type"] = ["in",[0,2,3,5,6,11,13]];//查看wallet.php文件
  260. $where["a.createtime"] = ["gt",$timeArr[$time]];
  261. $list = model('UserJewelLog')->alias("a")
  262. ->field("sum(a.value) as total_price,u.avatar,u.nickname")
  263. ->where($where)
  264. ->join("hx_user u","u.id = a.user_id")
  265. ->group("a.user_id")
  266. ->order("total_price","desc")
  267. ->limit(100)
  268. ->select();
  269. $data = [];
  270. $data["redtime"] = $redtime;
  271. $data["data"] = $list;
  272. $this->success("获取成功!",$data);
  273. }
  274. /**
  275. * 获取派对热度排序
  276. */
  277. public function getPartyHotList() {
  278. // 剩余时间
  279. $thistime = time();
  280. $hour = strtotime(date("Y-m-d H:00:00"));
  281. $redtime = 3600-($thistime - $hour);
  282. $where = [];
  283. $where["a.createtime"] = ["gt",$hour];
  284. $where["p.room_type"] = 1;
  285. $list = \app\common\model\PartyHot::alias("a")
  286. ->field("sum(a.hot) as hot,p.id,u.avatar,p.party_name,p.party_logo")
  287. ->where($where)
  288. ->join("hx_party p","p.id = a.party_id")
  289. ->join("hx_user u","u.id = p.user_id")
  290. ->group("a.party_id")
  291. ->order("hot","desc")
  292. ->limit(100)
  293. ->select();
  294. $data = [];
  295. $data["redtime"] = $redtime;
  296. $data["data"] = $list;
  297. $this->success("获取成功!",$data);
  298. }
  299. /**
  300. * 首页搜索
  301. */
  302. public function searchUsers() {
  303. $search = $this->request->request("search"); //关键词筛选
  304. if(!$search) {
  305. $this->error("请输入搜索内容!");
  306. }
  307. // 搜索派对
  308. global $whereOr;
  309. $where = [];
  310. $whereOr["party_id"] = $search;
  311. $whereOr["party_name"] = ["like","%$search%"];
  312. $where["room_type"] = 1;
  313. $partyList = \app\common\model\Party::field("id,party_logo,party_id,party_name")
  314. ->where($where)
  315. ->where(function ($query) {
  316. global $whereOr;
  317. $query->whereOr($whereOr);
  318. })->order("party_hot","desc")->select();
  319. // 搜索直播间
  320. global $whereOrlive;
  321. $where = [];
  322. $whereOrlive["party_id"] = $search;
  323. $whereOrlive["party_name"] = ["like","%$search%"];
  324. $where["room_type"] = 2;
  325. $liveList = \app\common\model\Party::field("id,party_logo,party_id,party_name")
  326. ->where($where)
  327. ->where(function ($query) {
  328. global $whereOrlive;
  329. $query->whereOr($whereOrlive);
  330. })
  331. ->order("party_hot","desc")->select();
  332. // 相关用户
  333. $where = [];
  334. $where["a.nickname"] = ["like","%$search%"];
  335. $where["a.u_id"] = $search;
  336. $userList = \app\common\model\User::alias("a")->field("id,avatar,nickname,u_id,f.fans")
  337. ->join("hx_view_fans f","f.user_id = a.id","left")
  338. ->order("a.is_online,a.noble,a.level")
  339. ->whereOr($where)->select();
  340. $res = [];
  341. $res["partylist"] = $partyList;
  342. $res["livelist"] = $liveList;
  343. $res["userlist"] = $userList;
  344. $this->success("获取成功!",$res);
  345. }
  346. /**
  347. * 首页搜索
  348. */
  349. public function searchList() {
  350. $search = $this->request->request("search"); //关键词筛选
  351. if(!$search) {
  352. $this->error("请输入搜索内容!");
  353. }
  354. // 搜索房间(派对和直播)
  355. global $whereOr;
  356. $where = [];
  357. $whereOr["party_id"] = $search;
  358. $whereOr["party_name"] = ["like","%$search%"];
  359. //$where['is_online'] = 1;
  360. $where['status'] = 1;
  361. $partyList = \app\common\model\Party::field("id,party_logo,party_id,party_name")
  362. ->where($where)
  363. ->where(function ($query) {
  364. global $whereOr;
  365. $query->whereOr($whereOr);
  366. })->order("party_hot","desc")->select();
  367. $partyList = collection($partyList)->toArray();
  368. if (!empty($partyList)) {//在线信息
  369. $partyListIds = array_column($partyList,'id');
  370. $tenimService = new TenimService();
  371. $partyParams = ['party_ids'=>$partyListIds];
  372. $partyRes = $tenimService->getRoomUser($partyParams);
  373. if ($partyRes['status'] == 1) {
  374. foreach ($partyList as $pKey => &$pVal) {
  375. if (isset($partyRes['data'][$pVal['id']])) {
  376. $pVal['member_list'] = $partyRes['data'][$pVal['id']]['member_list'];
  377. $pVal['online_num'] = $partyRes['data'][$pVal['id']]['online_num'];
  378. }
  379. }
  380. }
  381. }
  382. // 家族
  383. $guildWhere['status'] = 1;
  384. $guildWhere['name'] = ["like","%$search%"];
  385. $guildList = model('Guild')->where($guildWhere)->with(['guildmember'=>function($gquery){
  386. $gquery->where(['status'=>1]);
  387. }])->field('id,g_id,name,image')->select();
  388. if (!empty($guildList)) {
  389. $userField = 'id,nickname,avatar';
  390. foreach ($guildList as $gKey => &$gVal) {
  391. $userData =[];
  392. if (isset($gVal['guildmember'])) {
  393. $memberUids = array_column($gVal['guildmember'],'user_id');
  394. $userWhere['is_online'] = 1;
  395. $userWhere['id'] = ['in',$memberUids];
  396. $userData = model('User')->field($userField)->where($userWhere)->select();
  397. }
  398. $gVal['member_list'] = $userData;
  399. $gVal['online_num'] = count($userData);
  400. unset($gVal['guildmember']);
  401. }
  402. }
  403. // 相关用户
  404. $where = [];
  405. $where["a.nickname"] = ["like","%$search%"];
  406. $where["a.u_id"] = $search;
  407. $userList = \app\common\model\User::alias("a")->field("id,avatar,nickname,u_id,f.fans")
  408. ->join("hx_view_fans f","f.user_id = a.id","left")
  409. ->order("a.is_online,a.noble,a.level")
  410. ->whereOr($where)->select();
  411. $res = [];
  412. $res["roomlist"] = $partyList;
  413. $res["guildlist"] = $guildList;
  414. $res["userlist"] = $userList;
  415. $this->success("获取成功!",$res);
  416. }
  417. /**
  418. * 获取下载二维码和邀请码
  419. */
  420. public function getInviteCode() {
  421. // 获取二维码
  422. $host = $_SERVER["REQUEST_SCHEME"]."://".$_SERVER["HTTP_HOST"];
  423. $qrcode = $this->httpurl($host.config("site.qrcode"));
  424. $miniqrcode = $this->httpurl($host.config("site.miniqrcode"));
  425. // 获取用户邀请码
  426. $inviteCode = \app\common\model\User::where(["id"=>$this->auth->id])->value("invite_no");
  427. $downlowdLink = $host."/index/index/appJump?t=wlt".rand(10,999).Random::alpha(8);
  428. $this->success("获取成功!",["qrcode"=>$qrcode,"miniqrcode"=>$miniqrcode,"inviteCode"=>$inviteCode,"downlowdLink"=>$downlowdLink]);
  429. }
  430. /**
  431. * 获取app分享海报
  432. */
  433. public function getAppShare() {
  434. $this->success("获取成功!",["url"=>$this->httpurl(config("site.appShare"))]);
  435. }
  436. /**
  437. * 获取版本更新信息
  438. */
  439. public function getEdition() {
  440. // 获取二维码
  441. $is_force = config("site.is_force");
  442. $apkUrl = config("site.apkUrl");
  443. $apkName = config("site.apkName");
  444. $desc = config("site.desc");
  445. $versionCode = config("site.versionCode");
  446. $this->success("获取成功!",["versionCode"=>$versionCode,"isForceUpdate"=>$is_force,"apkUrl"=>$apkUrl,"apkName"=>$apkName,"desc"=>$desc]);
  447. }
  448. /**
  449. * 获取邀请图片
  450. */
  451. public function getInviteImg() {
  452. $plat = $this->request->request("plat",1); //平台:1=小程序,2=app
  453. if(!in_array($plat,[1,2])) $this->error("参数错误");
  454. // 获取用户的邀请码
  455. $invitecode = \app\common\model\User::where(["id"=>$this->auth->id])->value("invite_no");
  456. // 文字图片合成
  457. $bigImgPath = $this->httpurlLocal('/assets/img/inviteimg.jpeg');
  458. $img = imagecreatefromstring(file_get_contents($bigImgPath));
  459. //字体文件
  460. $font = realpath('./assets/fonts/lato/lato-black.ttf');
  461. //字体颜色(RGB)
  462. $black = imagecolorallocate($img, 217, 76, 41);
  463. //字体大小
  464. $fontSize = 30;
  465. //旋转角度
  466. $circleSize = 0;
  467. //左边距
  468. $left = 275;
  469. //上边距
  470. $top = 540;
  471. imagefttext($img, $fontSize, $circleSize, $left, $top, $black, $font, $invitecode);
  472. $filename = date("YmdH").".jpeg";
  473. $path = "/uploads/qrcode/".$filename;
  474. $file = $_SERVER['DOCUMENT_ROOT'] . $path;//打开文件准备写入
  475. list($bgWidth, $bgHight, $bgType) = getimagesize($bigImgPath);
  476. switch ($bgType) {
  477. case 1://gif
  478. header('Content-Type:image/gif');
  479. imagegif($img,$file);
  480. break;
  481. case 2://jpg
  482. header('Content-Type:image/jpg');
  483. imagejpeg($img,$file);
  484. break;
  485. case 3://jpg
  486. header('Content-Type:image/png');
  487. imagepng($img,$file);
  488. break;
  489. default:
  490. break;
  491. }
  492. //销毁照片
  493. imagedestroy($img);
  494. // 图片和二维码合成
  495. $qrcode = $plat == 1 ? config("site.miniqrcode"):config("site.qrcode");
  496. $background = $file;
  497. $target = $this->httpurl($qrcode);
  498. $background_iamge = imagecreatefromstring(file_get_contents($background));
  499. $target_image = imagecreatefromstring(file_get_contents($target));
  500. list($target_width, $target_height, $target_type) = getimagesize($target);
  501. imagecopymerge($background_iamge , $target_image , 250, 700, 0, 0, $target_width, $target_height, 100);
  502. list($background_width, $background_height, $background_type) = getimagesize($background);
  503. switch ($background_type) {
  504. case 1://gif
  505. header('Content-Type:image/gif');
  506. imagegif($background_iamge,$file);
  507. break;
  508. case 2://jpg
  509. header('Content-Type:image/jpg');
  510. imagejpeg($background_iamge,$file);
  511. break;
  512. case 3://jpg
  513. header('Content-Type:image/png');
  514. imagepng($background_iamge,$file);
  515. break;
  516. default:
  517. break;
  518. }
  519. $savepath = $this->httpurlLocal($path);
  520. $this->success("获取成功!",$savepath);
  521. }
  522. /**
  523. * 获取银行列表
  524. */
  525. public function getBankList() {
  526. $this->success("获取成功!",["banklist"=>\app\common\model\Bank::select()]);
  527. }
  528. /**
  529. * 获取开关配置
  530. */
  531. public function getSwitch() {
  532. $this->success("获取成功!",["switch"=>config("site.switch")]);
  533. }
  534. /**
  535. * 评论时间转换
  536. * @param null $time
  537. * @return false|string
  538. */
  539. private function get_last_time($time = NULL) {
  540. $text = '';
  541. $time = $time === NULL || $time > time() ? time() : intval($time);
  542. $t = time() - $time; //时间差 (秒)
  543. $y = date('Y', $time)-date('Y', time());//是否跨年
  544. switch($t){
  545. case $t == 0:
  546. $text = '刚刚';
  547. break;
  548. case $t < 60:
  549. $text = $t . '秒前'; // 一分钟内
  550. break;
  551. case $t < 60 * 60:
  552. $text = floor($t / 60) . '分钟前'; //一小时内
  553. break;
  554. case $t < 60 * 60 * 24:
  555. $text = floor($t / (60 * 60)) . '小时前'; // 一天内
  556. break;
  557. case $t < 60 * 60 * 24 * 3:
  558. $text = floor($time/(60*60*24)) ==1 ?'昨天 ' . date('H:i', $time) : '前天 ' . date('H:i', $time) ; //昨天和前天
  559. break;
  560. case $t < 60 * 60 * 24 * 30:
  561. $text = date('m月d日 H:i', $time); //一个月内
  562. break;
  563. case $t < 60 * 60 * 24 * 365&&$y==0:
  564. $text = date('m月d日', $time); //一年内
  565. break;
  566. default:
  567. $text = date('Y年m月d日', $time); //一年以前
  568. break;
  569. }
  570. return $text;
  571. }
  572. /**
  573. * 年龄段列表
  574. * @return void
  575. */
  576. public function ageList()
  577. {
  578. try {
  579. $field = 'id,name';
  580. $where['status'] = 1;
  581. $result = model('Age')->field($field)->where($where)->order('weigh asc')->select();
  582. $this->success('获取成功',$result);
  583. } catch (Exception $e) {
  584. $this->error($e->getMessage());
  585. }
  586. }
  587. /**
  588. * 星座列表
  589. * @return void
  590. */
  591. public function starList()
  592. {
  593. try {
  594. $field = 'id,name,image';
  595. $where['status'] = 1;
  596. $result = model('Constellation')->field($field)->where($where)->order('weigh asc')->select();
  597. if (!$result) {
  598. $result = list_domain_image($result,['image']);
  599. }
  600. $this->success('获取成功',$result);
  601. } catch (Exception $e) {
  602. $this->error($e->getMessage());
  603. }
  604. }
  605. /**
  606. * 轮播图列表
  607. * @return void
  608. */
  609. public function bannerList()
  610. {
  611. try {
  612. $field = 'id,title,image,url';
  613. $where['status'] = 1;
  614. $result = model('Banner')->field($field)->where($where)->order('weigh asc')->select();
  615. if (!$result) {
  616. $result = list_domain_image($result,['image']);
  617. }
  618. $this->success('获取成功',$result);
  619. } catch (Exception $e) {
  620. $this->error($e->getMessage());
  621. }
  622. }
  623. }