boxofficeDetail.js 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. import Vue from 'vue'
  2. import axios from 'axios'
  3. import axiosJsonp from 'axios-jsonp';
  4. import lib from 'lib'
  5. import _ from 'underscore'
  6. import WjySdk from 'extSdk';
  7. var type = lib.getParam("type"),
  8. boxAId = lib.getParam("id"),
  9. weekName = ["日","一","二","三","四","五","六"],
  10. areaName = {
  11. "1" : "中国",
  12. "2" : "美国",
  13. "3" : "美国",
  14. "4" : "美国",
  15. "5" : "全球"
  16. },
  17. cacheArticle = {}, //缓存榜单列表
  18. timeStamp = (new Date()).getTime(),
  19. lastDay = lib.handleTime(timeStamp-24*60*60*1000,2).substring(0,10),
  20. curDay = lib.handleTime(timeStamp,2).substring(0,10),
  21. curMonth = lib.handleTime(timeStamp).substring(0,8),
  22. curFilmReleaseDate = 0; //当前上映时间
  23. export default {
  24. activated() {
  25. },
  26. methods: {
  27. toCommentary(commentaryId,articleId){
  28. if(commentaryId) {
  29. WjySdk.toCommentaryDetail(commentaryId)
  30. } else if(articleId) {
  31. WjySdk.toVideoDetail(articleId)
  32. }
  33. },
  34. onScroll(){
  35. if(this.detailIsloading || this.detailNextFlag==0) return
  36. let boxScroller = this.$refs["filmDetailBoxScroller"],
  37. boxScrollerList = this.$refs["filmDetailBoxList"],
  38. scrollTop = boxScroller.scrollTop,
  39. boxScrollerHeight = boxScroller.clientHeight,
  40. boxScrollerListHeight = boxScrollerList.clientHeight;
  41. if(boxScrollerListHeight <= scrollTop+boxScrollerHeight+40) {
  42. this.getBoxOfficeDetails()
  43. }
  44. },
  45. //获取中国票房电影的详情页
  46. getArticleProDetail(){
  47. let self = this
  48. let url = `${lib.apiUrl}/functionalTopic/boxOfficeArticleProDetail.do`
  49. let param = {
  50. id : boxAId,
  51. channel : "LuciferChannel",
  52. ver : 1,
  53. os : 1,
  54. uid : 1,
  55. token : "lucifer_test_token"
  56. }
  57. self.isloading = true
  58. axios({
  59. url: url,
  60. params : param,
  61. adapter: axiosJsonp,
  62. callbackParamName: 'c' // optional, 'callback' by default
  63. }).then((res) => {
  64. self.isloading = false
  65. let ret = lib.formatHttpProtocol(res.data);
  66. if(ret.code == 0) {
  67. self.detailFilm = ret.data
  68. self.getBoxOfficeDetails()
  69. curFilmReleaseDate = ret.data.releaseDate
  70. lib.setTitle(`${self.detailFilm.name}`)
  71. }
  72. })
  73. },
  74. //根据票房电影的id获取相关票房记录
  75. getBoxOfficeDetails(){
  76. if(this.detailIsloading || this.detailNextFlag==0) return
  77. let self = this
  78. let url = `${lib.apiUrl}/functionalTopic/getBoxOfficeDetails.do`
  79. let param = {
  80. id : boxAId,
  81. count : 20,
  82. timeline : self.detailTimeline,
  83. channel : "LuciferChannel",
  84. ver : 1,
  85. os : 1,
  86. uid : 1,
  87. token : "lucifer_test_token"
  88. }
  89. self.detailIsloading = true
  90. axios({
  91. url: url,
  92. params : param,
  93. adapter: axiosJsonp,
  94. callbackParamName: 'c' // optional, 'callback' by default
  95. }).then((res) => {
  96. self.detailIsloading = false
  97. let ret = lib.formatHttpProtocol(res.data);
  98. let data = ret.data
  99. if(ret.code == 0 && data) {
  100. self.detailNextFlag = data.next
  101. self.detailTimeline = data.timeline
  102. self.detailArticles = data.boxOfficeProArticleList.concat(self.detailArticles)
  103. } else {
  104. self.detailNextFlag = 0
  105. self.detailTimeline = 0
  106. }
  107. })
  108. },
  109. },
  110. data() {
  111. return {
  112. articles : [], //列表
  113. curDay : curDay.replace(/-/g,"."),
  114. curBoxAId : 0, //票房详情-id
  115. detailFilm : {}, //票房详情-电影
  116. detailArticles : [], //票房详情-票房列表
  117. detailTimeline : 0, //票房详情-翻页标志
  118. detailIsloading : false, //票房详情-是否loading
  119. detailNextFlag : 1, //票房详情-下一页标志
  120. }
  121. },
  122. mounted() {
  123. this.getArticleProDetail()
  124. },
  125. filters : {
  126. parseBoxOffice : function(value){
  127. let result = 0;
  128. if(!value) return "--"
  129. if(value > 1e8) {
  130. let num = (value/1e8).toFixed(2)
  131. result = `${num.substring(0,num.lastIndexOf('.')+2)}亿`
  132. }else if(value > 1e4){
  133. let num = Math.floor(value/1e4)
  134. result = `${num}万`
  135. } else {
  136. let num = (value/1e4).toFixed(3)
  137. result = `${num.substring(0,num.lastIndexOf('.')+2)}万`
  138. }
  139. return result;
  140. },
  141. parseReleaseDate : function(value){
  142. let now = new Date()
  143. let nowTime = now.getTime()
  144. let restTime = (nowTime - value) /1000
  145. let restYear = Math.ceil(restTime / (365 * 60 * 60 * 24))
  146. let restDay = Math.ceil(restTime / (60 * 60 * 24))
  147. if(restDay>365){
  148. return `${restYear}年`
  149. }else if(restDay>=0){
  150. return `${restDay}天`
  151. }
  152. },
  153. parseDate : function(value){
  154. return lib.handleTime(value,2).substring(0,10)
  155. },
  156. parseUpdateTime : function(value){
  157. return lib.handleTime(value).substring(11,17);
  158. },
  159. parseReleaseDateStr : function(value){
  160. let curDate = new Date(value),
  161. restTime = (value -curFilmReleaseDate) /1000,
  162. restYear = Math.ceil(restTime / (365 * 60 * 60 * 24)),
  163. restDay = Math.ceil(restTime / (60 * 60 * 24))+1,
  164. restTimeStr = "";
  165. if(restDay>365){
  166. restTimeStr = `上映第${restYear}年`
  167. }else if(restDay>0){
  168. restTimeStr = `上映第${restDay}天`
  169. }else{
  170. restTimeStr = `预售`;
  171. }
  172. return `周${weekName[curDate.getDay()]} ${restTimeStr}`
  173. }
  174. }
  175. }