schedule.js 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. import Vue from 'vue'
  2. import lib from 'lib'
  3. import _ from 'underscore'
  4. import WjySdk from 'extSdk';
  5. var area = lib.getParam("area")
  6. var timeType = lib.getParam("timeType")
  7. var weekName = ["日","一","二","三","四","五","六"]
  8. export default {
  9. activated() {
  10. },
  11. methods: {
  12. toVideoPreview(articleId){
  13. WjySdk.toVideoPreview(articleId)
  14. },
  15. toCommentaryDetail(commentaryId){
  16. WjySdk.toCommentaryDetail(commentaryId)
  17. },
  18. toVideoDetail(articleId){
  19. WjySdk.toVideoDetail(articleId)
  20. },
  21. changeNav(area,timeType){
  22. this.area = area
  23. this.timeline = 0
  24. this.timeType = timeType
  25. this.articles = []
  26. this.getShowtimes()
  27. lib.setParam("area",area)
  28. lib.setParam("timeType",timeType)
  29. $("html,body").scrollTop(0)
  30. },
  31. getShowtimes(){
  32. let self = this
  33. let url = `${lib.apiUrl}/functionalTopic/showtimes.do`
  34. let param = {
  35. area : self.area,
  36. timeType : self.timeType,
  37. count : 20,
  38. timeline : self.timeline,
  39. channel : "LuciferChannel",
  40. ver : 1,
  41. os : 1,
  42. uid : 1,
  43. token : "lucifer_test_token"
  44. }
  45. self.isloading = true
  46. $.ajax({
  47. type: "get",
  48. url: url,
  49. data: param,
  50. dataType: "jsonp",
  51. success: function (ret) {
  52. ret = lib.formatHttpProtocol(ret);
  53. lib.hideLoading()
  54. self.isloading = false
  55. if(ret.code == 0) {
  56. let data = ret.data
  57. self.nextFlag = data.next
  58. self.timeline = data.timeline
  59. self.articles = self.articles.concat(data.articles)
  60. if (self.timeType==1) {
  61. self.monthList = self.parseMonthList(self.articles)
  62. }
  63. } else {
  64. lib.showDialog(ret.msg)
  65. }
  66. }
  67. })
  68. },
  69. parseMonthList(data){
  70. let self = this,list = {}
  71. let monthGroud = _.groupBy(data,(article) => {
  72. let date = new Date(article.releaseDate)
  73. return date.getFullYear()+""+self.parseTime(date.getMonth()+1)
  74. });
  75. _.each(monthGroud,(monthData,key)=>{
  76. let dayGroud = self.parseDayList(monthData)
  77. list[key] = dayGroud
  78. })
  79. return list
  80. },
  81. parseDayList(data){
  82. let self = this,list = {}
  83. let dayList = _.groupBy(data,function(article){
  84. let date = new Date(article.releaseDate)
  85. let time = date.getFullYear()+""+self.parseTime(date.getMonth()+1)+self.parseTime(date.getDate())+date.getDay()
  86. return time
  87. });
  88. return dayList
  89. },
  90. parseTime : function(value){
  91. return value >= 10 ? value : "0"+value
  92. }
  93. },
  94. data() {
  95. return {
  96. articles : [], //视频列表
  97. area : area || "CN", //地区
  98. timeType : timeType || 0, //时间
  99. monthList : [], //月电影列表
  100. timeline : 0, //翻页标志
  101. isloading : false, //是否loading
  102. nextFlag : 1 //下一页标志
  103. }
  104. },
  105. mounted() {
  106. lib.setTitle("电影上映表")
  107. this.getShowtimes()
  108. },
  109. filters : {
  110. parseMonth : function(value){
  111. return value.slice(0,4) + "." + value.slice(4,6);
  112. },
  113. parseDay : function(value){
  114. let date = value.slice(6,8)
  115. let day = value.slice(8,10)
  116. return date+"日 星期"+weekName[day]
  117. },
  118. parseBoxOffice : function(value){
  119. let result = 0;
  120. if(value > 1e8) {
  121. let num = (value/1e8).toFixed(2)
  122. result = `${num.substring(0,num.lastIndexOf('.')+2)}亿`
  123. } else if(value > 1e4){
  124. let num = Math.floor(value/1e4)
  125. result = `${num}万`
  126. } else {
  127. let num = (value/1e4).toFixed(3)
  128. result = `${num.substring(0,num.lastIndexOf('.')+2)}万`
  129. }
  130. return result;
  131. },
  132. parseReleaseDate : function(value){
  133. let now = new Date()
  134. let nowTime = now.getTime()
  135. let restTime = (nowTime - value) /1000
  136. let restYear = Math.ceil(restTime / (365 * 60 * 60 * 24))
  137. let restDay = Math.ceil(restTime / (60 * 60 * 24))
  138. if (restDay>365) {
  139. return `已上映${restYear}年`
  140. } else if(restDay>=0){
  141. return `已上映${restDay}天`
  142. } else {
  143. return `即将上映`
  144. }
  145. }
  146. }
  147. }