|
@@ -335,20 +335,19 @@ if (!function_exists('valid_url')) {
|
|
*/
|
|
*/
|
|
if (!function_exists('pages')) {
|
|
if (!function_exists('pages')) {
|
|
|
|
|
|
- function pages($list,$num){
|
|
|
|
- $arr1 = array_slice(array_chunk($list->items(),$num),0,count(array_chunk($list->items(),$num))-2);
|
|
|
|
- $arr2 = array_slice(array_chunk($list->items(),$num),-2);
|
|
|
|
- $arr3 = [];
|
|
|
|
- if(!empty($arr2)){
|
|
|
|
- foreach ($arr2 as $v){
|
|
|
|
- foreach ($v as $v1){
|
|
|
|
- $arr3[] = $v1;
|
|
|
|
- }
|
|
|
|
|
|
+ function pages($list,$go){
|
|
|
|
+ $num_elements = ceil(count($list->items()) / $go); //每个二维数组包含几个元素
|
|
|
|
+ $items = array_chunk($list->items(), $num_elements);
|
|
|
|
+ $arr = [];
|
|
|
|
+ if($go > count($items)){
|
|
|
|
+ $num = $go-count($items);
|
|
|
|
+ for ($i=0;$i< $num;$i++){
|
|
|
|
+ $arr[] = [];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- $arr = array_merge($arr1,[$arr3]);
|
|
|
|
|
|
+ $items = array_merge($items,$arr);
|
|
return [
|
|
return [
|
|
- 'items' => $arr,
|
|
|
|
|
|
+ 'items' => $items,
|
|
'total' => $list->total(), // 总数
|
|
'total' => $list->total(), // 总数
|
|
'pageSize' => $list->perPage(), // 每页数据
|
|
'pageSize' => $list->perPage(), // 每页数据
|
|
'totalPage' => $list->lastPage(),// 总页数
|
|
'totalPage' => $list->lastPage(),// 总页数
|