ipad.go 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. package card
  2. import (
  3. "go-common/app/interface/main/app-card/model"
  4. "go-common/app/interface/main/app-card/model/card/ai"
  5. "go-common/app/interface/main/app-card/model/card/operate"
  6. tag "go-common/app/interface/main/tag/model"
  7. account "go-common/app/service/main/account/model"
  8. "go-common/app/service/main/archive/model/archive"
  9. relation "go-common/app/service/main/relation/model"
  10. "go-common/library/log"
  11. )
  12. func ipadHandle(cardGoto model.CardGt, cardType model.CardType, rcmd *ai.Item, tagm map[int64]*tag.Tag, isAttenm map[int64]int8, statm map[int64]*relation.Stat, cardm map[int64]*account.Card) (hander Handler) {
  13. base := &Base{CardGoto: cardGoto, Rcmd: rcmd, Tagm: tagm, IsAttenm: isAttenm, Statm: statm, Cardm: cardm, Columnm: model.ColumnSvrSingle}
  14. switch cardType {
  15. default:
  16. switch cardGoto {
  17. case model.CardGotoAv, model.CardGotoBangumi, model.CardGotoLive, model.CardGotoPGC:
  18. base.CardType = model.LargeCoverV1
  19. base.CardLen = 1
  20. hander = &LargeCoverV1{Base: base}
  21. case model.CardGotoBangumiRcmd:
  22. base.CardType = model.SmallCoverV1
  23. hander = &SmallCoverV1{Base: base}
  24. case model.CardGotoRank:
  25. base.CardType = model.FourItemHV3
  26. hander = &FourItemV3{Base: base}
  27. case model.CardGotoLogin:
  28. base.CardType = model.CoverOnlyV3
  29. base.CardLen = 1
  30. hander = &CoverOnly{Base: base}
  31. case model.CardGotoBanner:
  32. base.CardType = model.BannerV3
  33. hander = &Banner{Base: base}
  34. case model.CardGotoAdAv:
  35. base.CardType = model.CmV1
  36. base.CardLen = 1
  37. hander = &LargeCoverV1{Base: base}
  38. case model.CardGotoAdWebS:
  39. base.CardType = model.CmV1
  40. base.CardLen = 1
  41. hander = &SmallCoverV1{Base: base}
  42. case model.CardGotoAdWeb:
  43. base.CardType = model.CmV1
  44. base.CardLen = 2
  45. hander = &SmallCoverV1{Base: base}
  46. case model.CardGotoSearchUpper:
  47. base.CardType = model.ThreeItemAll
  48. hander = &ThreeItemAll{Base: base}
  49. }
  50. }
  51. return
  52. }
  53. type FourItemV3 struct {
  54. *Base
  55. TitleIcon model.Icon `json:"title_icon,omitempty"`
  56. BannerCover string `json:"banner_cover,omitempty"`
  57. BannerURI string `json:"banner_uri,omitempty"`
  58. MoreURI string `json:"more_uri,omitempty"`
  59. MoreText string `json:"more_text,omitempty"`
  60. Items []*FourItemV3Item `json:"items,omitempty"`
  61. }
  62. type FourItemV3Item struct {
  63. Base
  64. CoverLeftText string `json:"cover_left_text,omitempty"`
  65. CoverLeftIcon model.Icon `json:"cover_left_icon,omitempty"`
  66. Desc1 string `json:"desc_1,omitempty"`
  67. Desc2 string `json:"desc_2,omitempty"`
  68. Badge string `json:"badge,omitempty"`
  69. }
  70. func (c *FourItemV3) From(main interface{}, op *operate.Card) {
  71. switch main.(type) {
  72. case map[model.Gt]interface{}:
  73. intfcm := main.(map[model.Gt]interface{})
  74. if op == nil {
  75. return
  76. }
  77. switch op.CardGoto {
  78. case model.CardGotoRank:
  79. const (
  80. _title = "全站排行榜"
  81. _limit = 4
  82. )
  83. c.Base.from("0", "", _title, "", "", nil)
  84. // c.TitleIcon = model.IconRank
  85. c.MoreURI = model.FillURI(op.Goto, op.URI, nil)
  86. c.MoreText = "查看更多"
  87. c.Items = make([]*FourItemV3Item, 0, _limit)
  88. for _, v := range op.Items {
  89. if v == nil {
  90. continue
  91. }
  92. intfc, ok := intfcm[v.Goto]
  93. if !ok {
  94. continue
  95. }
  96. am := intfc.(map[int64]*archive.ArchiveWithPlayer)
  97. a, ok := am[v.ID]
  98. if !ok || !model.AvIsNormal(a) {
  99. continue
  100. }
  101. item := &FourItemV3Item{
  102. CoverLeftText: model.DurationString(a.Duration),
  103. Desc1: model.ScoreString(v.Score),
  104. }
  105. item.Base.from(v.Param, a.Pic, a.Title, model.GotoAv, v.URI, model.AvPlayHandler(a.Archive3, a.PlayerInfo, op.TrackID))
  106. item.Args.fromArchive(a.Archive3, nil)
  107. c.Items = append(c.Items, item)
  108. if len(c.Items) == _limit {
  109. break
  110. }
  111. }
  112. if len(c.Items) < _limit {
  113. return
  114. }
  115. c.Items[0].CoverLeftIcon = model.IconGoldMedal
  116. c.Items[1].CoverLeftIcon = model.IconSilverMedal
  117. c.Items[2].CoverLeftIcon = model.IconBronzeMedal
  118. default:
  119. log.Warn("FourItemV3 From: unexpected card_goto %s", op.CardGoto)
  120. return
  121. }
  122. default:
  123. log.Warn("FourItemV3 From: unexpected type %T", main)
  124. return
  125. }
  126. c.Right = true
  127. }
  128. func (c *FourItemV3) Get() *Base {
  129. return c.Base
  130. }