common.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. function mobile_page($page_info) {
  3. //输出是否有下一页
  4. $extend_data = array();
  5. if($page_info==''){
  6. $extend_data['page_total']=1;
  7. $extend_data['hasmore'] = false;
  8. }else {
  9. $current_page = $page_info->currentPage();
  10. if ($current_page <= 0) {
  11. $current_page = 1;
  12. }
  13. if ($current_page >= $page_info->lastPage()) {
  14. $extend_data['hasmore'] = false;
  15. }
  16. else {
  17. $extend_data['hasmore'] = true;
  18. }
  19. $extend_data['page_total'] = $page_info->lastPage();
  20. }
  21. return $extend_data;
  22. }
  23. /**
  24. * 获取手机端访问使用的浏览器
  25. */
  26. function get_device_type(){
  27. //全部变成小写字母
  28. $agent= strtolower($_SERVER['HTTP_USER_AGENT']);
  29. if(strpos($agent,'miniprogram')){
  30. return 'miniprogram';
  31. }
  32. if(strpos($agent,'micromessenger')){
  33. return 'micromessenger';
  34. }
  35. if(strpos($agent,'android')){
  36. return 'android';
  37. }
  38. if(strpos($agent,'iphone') || strpos($agent,'ipad')){
  39. return 'ios';
  40. }
  41. return 'other';
  42. }