preview.js 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. import Vue from 'vue'
  2. import lib from 'lib'
  3. import _ from 'underscore'
  4. var articleId = lib.getParam("articleId");
  5. var vid = lib.getParam("vid");
  6. export default {
  7. data() {
  8. return {
  9. articleId : articleId,
  10. article : {}, //影片
  11. areas : [], //地区
  12. categories : [], //电影分类
  13. moreCommentaries : {},//更多解说
  14. filmComments : [], //电影评论
  15. articleType: 1,// 1:电影,2:电视剧,3:动画
  16. alias : ["无"], //别名
  17. releaseDate : "",
  18. trailers : {},
  19. videos : [],
  20. curVideo : {},
  21. curVideoPic : "",
  22. curVideoUrl : "",
  23. downloadUrl : lib.downloadUrl,
  24. isiOS : navigator.userAgent.match(/(iPhone|iPod|iPad);?/i) //ios终端
  25. }
  26. },
  27. filters : {
  28. parseReleaseDate(value){
  29. return lib.handleTime(value).substring(0,11)
  30. },
  31. parseVideoLen(value){
  32. let minute = Math.floor(value / 60)
  33. let second = Math.floor(value % 60)
  34. minute = minute >= 10 ? minute : "0"+minute
  35. second = second >= 10 ? second : "0"+second
  36. return minute + ":" + second
  37. }
  38. },
  39. mounted() {
  40. this.getArticle()
  41. },
  42. activated() {
  43. },
  44. methods: {
  45. changeVideo(index){
  46. this.curVideo = this.videos[index]
  47. this.curVideoPic = this.videos[index].cover
  48. this.curVideoUrl = this.videos[index].videoUrls[0].urls[0]
  49. $(".v-mod-preview .list-preview li").eq(index).addClass("active").siblings().removeClass("active")
  50. lib.setParam("vid",this.curVideo.vid)
  51. lib.setWxShare({
  52. title: `我在看《${this.article.name}》预告片`,
  53. desc: `${this.curVideo.title}`,
  54. link: `${location.href}`,
  55. imgUrl: `${this.curVideo.cover}`
  56. });
  57. },
  58. //处理预告片列表
  59. handelVideo(list){
  60. let arr = []
  61. let self = this
  62. let showVideo = {}
  63. if (vid) {
  64. _.each(list,(item)=>{
  65. if(item.vid == vid) {
  66. arr.splice(0,0,item)
  67. showVideo = item
  68. } else {
  69. arr.push(item)
  70. }
  71. })
  72. self.videos = arr.splice(0,5)
  73. } else {
  74. showVideo = list[0]
  75. self.videos = list.splice(0,5)
  76. }
  77. self.curVideo = showVideo
  78. self.curVideoPic = showVideo.cover
  79. self.curVideoUrl = showVideo.videoUrls[0].urls[0]
  80. lib.setWxShare({
  81. title: `我在看《${self.article.name}》预告片`,
  82. desc: `${self.curVideo.title}`,
  83. link: `${location.href}`,
  84. imgUrl: `${self.curVideo.cover}`
  85. });
  86. },
  87. //获取文章详情
  88. getArticle(){
  89. let self = this;
  90. let url = `${lib.apiUrl}/share/article.do`;
  91. let param = {
  92. articleId : articleId,
  93. channel : "LuciferChannel",
  94. ver : 1,
  95. os : 1,
  96. uid : 1,
  97. token : "lucifer_test_token"
  98. }
  99. $.ajax({
  100. type: "get",
  101. url: url,
  102. data: param,
  103. dataType: "jsonp",
  104. success: (ret) => {
  105. var ret = lib.formatHttpProtocol(ret);
  106. if (ret.result == 1){
  107. var data = ret.data;
  108. var article = data.article;
  109. self.article = article;
  110. self.areas = article.areas;
  111. self.categories = article.categories;
  112. self.articleType = article.type;
  113. self.trailers = data.trailers;
  114. if (data.moreCommentaries) self.moreCommentaries = data.moreCommentaries;
  115. if (article.alias && article.alias.length>0){
  116. self.alias = article.alias.slice(0,1);
  117. }
  118. self.handelVideo(data.trailers.videos)
  119. lib.setTitle(`${lib.appName}-${article.name}`)
  120. }
  121. }
  122. });
  123. }
  124. }
  125. }