Commit 172abb9f by hcy001

更新商品分页

parent 7820ab56
Showing with 4 additions and 2 deletions
...@@ -301,6 +301,7 @@ func PageClear(ctx *gin.Context,total int64) map[string]interface{}{ ...@@ -301,6 +301,7 @@ func PageClear(ctx *gin.Context,total int64) map[string]interface{}{
page["total"] = strconv.FormatInt(total,10) page["total"] = strconv.FormatInt(total,10)
page["current_page"] = p page["current_page"] = p
page["offset"] = page_size page["offset"] = page_size
if total == 10000 { if total == 10000 {
page["total_page"] = math.Ceil(float64(total)/common.MyFloat64(page_size)) page["total_page"] = math.Ceil(float64(total)/common.MyFloat64(page_size))
}else{ }else{
...@@ -318,7 +319,8 @@ func PageClear(ctx *gin.Context,total int64) map[string]interface{}{ ...@@ -318,7 +319,8 @@ func PageClear(ctx *gin.Context,total int64) map[string]interface{}{
if pInt > 1000 { if pInt > 1000 {
pInt = 1000 pInt = 1000
} }
if pInt > 996{ checkPage := gconv.Int(page["total_page"])
if pInt >= checkPage {
for i:=pInt-10;i<=pInt;i++{ for i:=pInt-10;i<=pInt;i++{
//原始查询参数拼接 //原始查询参数拼接
pageData[i] = i pageData[i] = i
...@@ -329,7 +331,7 @@ func PageClear(ctx *gin.Context,total int64) map[string]interface{}{ ...@@ -329,7 +331,7 @@ func PageClear(ctx *gin.Context,total int64) map[string]interface{}{
if pageNum == 10 { if pageNum == 10 {
break break
} }
if pInt >6 && pInt <= 996{ if pInt >6 && pInt <= checkPage{
//大于10页只获取中间10页 //大于10页只获取中间10页
if i < pInt -5 || i > pInt+5{ if i < pInt -5 || i > pInt+5{
continue continue
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment