Browse Source

图表我的收藏添加分页

xingzai 2 years ago
parent
commit
10e82013e7
2 changed files with 6 additions and 5 deletions
  1. 2 1
      controllers/chart.go
  2. 4 4
      services/chart.go

+ 2 - 1
controllers/chart.go

@@ -67,8 +67,9 @@ func (this *ChartController) Collection() {
 	}
 	if currentIndex <= 0 {
 		currentIndex = 1
+		pageSize = 0
 	}
-	list, err, total := services.GetChartCollectionByApi(mobile)
+	list, err, total := services.GetChartCollectionByApi(mobile, (currentIndex-1)*pageSize, pageSize)
 	if err != nil {
 		br.Msg = "获取图表分类失败!"
 		br.ErrMsg = "获取图表分类失败"

+ 4 - 4
services/chart.go

@@ -190,14 +190,14 @@ func GetUserTokenByMobile(mobile string) (token string, err error) {
 }
 
 //获取图表收藏
-func GetChartCollectionByApi(mobile string) (items []*models.HomeChartListResp, err error, total int) {
+func GetChartCollectionByApi(mobile string, take, skip int) (items []*models.HomeChartListResp, err error, total int) {
 	defer func() {
 		if err != nil {
 			fmt.Println("GetChartPtagByApi Err:" + err.Error())
 			go utils.SendEmail(utils.APPNAME+"【"+utils.RunMode+"】"+"失败提醒", "GetChartPtagByApi ErrMsg:"+err.Error(), utils.EmailSendToUsers)
 		}
 	}()
-	url := utils.ApiUrl + "charts/favorites"
+	url := utils.ApiUrl + "charts/favorites?take=" + strconv.Itoa(take) + "&skip=" + strconv.Itoa(skip)
 	authorization, err := GetUserTokenByMobile(mobile)
 	if err != nil {
 		fmt.Println(err)
@@ -224,8 +224,8 @@ func GetChartCollectionByApi(mobile string) (items []*models.HomeChartListResp,
 		item.CreateDate = v.ChartInfo.CreateDate
 		item.PtagName = v.ChartInfo.Ptag.Name
 		item.CtagName = v.ChartInfo.Ctag.Name
-		item.BodyHtml = "https://vmp.hzinsights.com/v2/charts/" + strconv.Itoa(v.ChartId)
-		item.HttpUrl = v.ChartInfo.Iframe
+		item.BodyHtml = v.ChartInfo.Cover
+		item.HttpUrl = "https://vmp.hzinsights.com/v2/charts/" + strconv.Itoa(v.ChartId)
 		item.IsNeedJump = true
 		items = append(items, item)
 	}