invite.js 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. import Vue from 'vue'
  2. import lib from 'lib'
  3. import ext from 'extSdk'
  4. import Clipboard from 'clipboard'
  5. import _ from 'underscore'
  6. import Swiper from 'swiper'
  7. let from = lib.getParam("from")
  8. let isFromApp = from=="wjy" ? true : false;
  9. let uid = lib.getParam("uid")
  10. let token = lib.getParam("token")
  11. export default {
  12. methods: {
  13. copy(){
  14. let self = this
  15. this.clipboard.on('success', function () {
  16. location.href = self.downloadUrl;
  17. });
  18. },
  19. //意见反馈
  20. openFeedback(){
  21. ext.openFeedback();
  22. },
  23. getSupportShareType(){
  24. let self = this
  25. ext.run2('getSupportShareType', [function(list){ //返回[0,1,2,3,4]对应微信,朋友圈,微博,qq,qq空间
  26. if (!list || list.length == 0) {
  27. list = [0,1,2,3,4]
  28. }
  29. if (_.indexOf(list,0) < 0) {
  30. self.isSupportList[0] = false
  31. }
  32. if (_.indexOf(list,1) < 0) {
  33. self.isSupportList[1] = false
  34. }
  35. if (_.indexOf(list,2) < 0) {
  36. self.isSupportList[4] = false
  37. }
  38. if (_.indexOf(list,3) < 0) {
  39. self.isSupportList[2] = false
  40. }
  41. if (_.indexOf(list,4) < 0) {
  42. self.isSupportList[3] = false
  43. }
  44. }]);
  45. },
  46. //app分享
  47. shareMessage(type){
  48. ext.shareMessage(type, this.shareMsg.title, this.shareMsg.link, this.shareMsg.desc, this.shareMsg.imgUrl)
  49. },
  50. getUserInfo () {
  51. let self = this
  52. let url = lib.apiUrl+"/share/getUserInfo.do";
  53. let param = {
  54. channel : "LuciferChannel",
  55. ver : 1,
  56. os : 1,
  57. uid : 1,
  58. targetUid : uid,
  59. token : "lucifer_test_token"
  60. }
  61. $.ajax({
  62. type: "get",
  63. url: url,
  64. data: param,
  65. dataType: "jsonp",
  66. success: function (ret) {
  67. ret = lib.formatHttpProtocol(ret);
  68. let data = ret.data
  69. self.userHeadInfo = {
  70. head : data.head,
  71. id : data.id,
  72. nick : data.nick
  73. }
  74. lib.setWxShare(self.getShareInfo(data.nick));
  75. }
  76. })
  77. },
  78. getInviteInfo () {
  79. let self = this
  80. let url = `${lib.apiUrl}/share/inviteInfo.do`;
  81. let param = {
  82. channel : "LuciferChannel",
  83. ver : 1,
  84. os : 1,
  85. uid : uid,
  86. token : token
  87. }
  88. $.ajax({
  89. type: "get",
  90. url: url,
  91. data: param,
  92. dataType: "jsonp",
  93. success: function (ret) {
  94. ret = lib.formatHttpProtocol(ret);
  95. let data = ret.data
  96. self.invitedUser = data.invitedUser
  97. self.invitedCount = data.invitedCount
  98. self.userHeadInfo = data.userHeadInfo
  99. if(data.userHeadInfo) self.shareMsg = self.getShareInfo(data.userHeadInfo.nick)
  100. }
  101. })
  102. },
  103. //根据专题获取影片列表
  104. getArticleByFeature () {
  105. let self = this
  106. let url = `${lib.apiUrl}/share/getArticleByFeature.do?featureId=38&count=10&timeline=0&channel=LuciferChannel&ver=1&os=1&uid=1&token=lucifer_test_token`;
  107. $.ajax({
  108. type: "get",
  109. url: url,
  110. dataType: "jsonp",
  111. success: function (ret) {
  112. ret = lib.formatHttpProtocol(ret);
  113. self.recommendFilms = ret.data.articles
  114. setTimeout(function(){
  115. new Swiper('.swiper-video', {
  116. slidesPerView: 'auto',
  117. freeMode: true
  118. })
  119. },0);
  120. }
  121. })
  122. },
  123. getShareInfo : function(nick){
  124. var shareObj = {}
  125. shareObj.title = `${nick}邀你来看【微剧院】`
  126. shareObj.link = `https://${location.host}/?page=act-invite&uid=${uid}`
  127. shareObj.desc = `电影解说APP,五分钟呈现电影的精彩。`
  128. shareObj.imgUrl = `https://h5-glance.duowan.com/_src/img/icon-logo.png`
  129. return shareObj;
  130. }
  131. },
  132. mounted () {
  133. let self = this
  134. lib.setTitle(`专属邀请码`)
  135. self.getArticleByFeature();
  136. self.clipboard = new Clipboard(this.$refs.copy)
  137. if (lib.getParam("from") == 'wjy'){
  138. self.getSupportShareType()
  139. self.getInviteInfo()
  140. } else {
  141. self.getUserInfo()
  142. }
  143. },
  144. watch: {
  145. },
  146. data() {
  147. return {
  148. isApp : isFromApp,
  149. downloadUrl : lib.downloadUrl,
  150. isSupportList : [true,true,true,true,true], //是否支持微信,朋友圈,QQ,QQ空间,新浪微博
  151. shareMsg : {},
  152. invitedUser : [],
  153. invitedCount : 0 ,
  154. userHeadInfo : {},
  155. recommendFilms : [],
  156. clipboard : null
  157. };
  158. }
  159. };