share-test.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739
  1. var media_info = {
  2. "live_in": video.live_in,
  3. "file_living": video.play_hls,
  4. "file_playback": video.urls,
  5. "image": video.head_image,
  6. "watch_number": video.watch_number
  7. };
  8. console.log("media_info:"+JSON.stringify(media_info));
  9. function addMsg(msg) {
  10. var time = webim.Tool.formatTimeStamp(msg.getTime());
  11. var data = convertMsg(msg);
  12. if(! data){
  13. return;
  14. }
  15. if(typeof data !== 'object'){
  16. data = {
  17. "user_level": 122,
  18. "nick_name": "[群提示消息]",
  19. "text": data,
  20. };
  21. }
  22. if (data.type == 1){
  23. var sender = data.ext.sender;
  24. var gif = data.ext.pc_gif || data.ext.pc_icon || data.ext.icon;
  25. showGift([{
  26. nick_name: sender.nick_name,
  27. fromId: sender.user_id,
  28. num: data.ext.plus_num,
  29. giftId: data.ext.prop_id,
  30. gift_type: data.ext.desc,
  31. gift_image: gif,
  32. head_image: sender.head_image,
  33. }]);
  34. }
  35. // if (data.type == 2 && showBarrage && player) {
  36. // var barrage = [
  37. // { "type": "content", "content": data.text, "time": "0" },
  38. // ];
  39. // player.addBarrage(barrage);
  40. // }
  41. $('#msg_box').append('<p><img class="msg-level" src="/public/images/rank/rank_' + data.user_level + '.png"> <label>'+data.nick_name+':</label><span style="color:#E66973">'+data.text+'</span></p>');
  42. }
  43. function showGift(i) {
  44. console.log(i);
  45. var i = i || [
  46. {nick_name:"昵称1", fromId:"34535", num:20, giftId:1111, gift_type:"棒棒糖", gift_image:"http://img.meelive.cn/Mjk4NTIxNDQ3MTQ0MjM2.jpg"},
  47. {nick_name:"昵称1", fromId:"34534", num:20, giftId:1111, gift_type:"棒棒糖", gift_image:"http://img.meelive.cn/Mjk4NTIxNDQ3MTQ0MjM2.jpg"},
  48. {nick_name:"昵称1", fromId:"567567", num:20, giftId:1111, gift_type:"棒棒糖", gift_image:"http://img.meelive.cn/Mjk4NTIxNDQ3MTQ0MjM2.jpg"},
  49. {nick_name:"昵称1", fromId:"7878", num:20, giftId:1111, gift_type:"棒棒糖", gift_image:"http://img.meelive.cn/Mjk4NTIxNDQ3MTQ0MjM2.jpg"},
  50. {nick_name:"昵称1", fromId:"5656", num:20, giftId:1111, gift_type:"棒棒糖", gift_image:"http://img.meelive.cn/Mjk4NTIxNDQ3MTQ0MjM2.jpg"},
  51. {nick_name:"昵称1", fromId:"345345", num:20, giftId:1111, gift_type:"棒棒糖", gift_image:"http://img.meelive.cn/Mjk4NTIxNDQ3MTQ0MjM2.jpg"},
  52. {nick_name:"昵称1", fromId:"7687887", num:20, giftId:1111, gift_type:"棒棒糖", gift_image:"http://img.meelive.cn/Mjk4NTIxNDQ3MTQ0MjM2.jpg"}
  53. ];
  54. for (var e = 0; e < i.length; e++) {
  55. // if (!i[e].gift) return;
  56. // var t = i.ms[e].gift,
  57. // n = i.ms[e].from,
  58. // o = t.seq ? t.seq: 0,
  59. a = {
  60. nick: i[e].nick_name,
  61. fromId: i[e].fromId + "" + i[e].giftId,
  62. num: i[e].num,
  63. giftId: i[e].giftId,
  64. gift_type: i[e].gift_type,
  65. gift_image: i[e].gift_image,
  66. head_image: i[e].head_image
  67. };
  68. ShowGiftAnimate.init(a)
  69. }
  70. }
  71. var chat = function(i, e) {
  72. this.opt = {
  73. isGiftShow: !0,
  74. isGiftManager: !0,
  75. isRecordChat: !0
  76. },
  77. $.extend(!0, this.opt.opt || {}),
  78. this.listeners = {
  79. loginSuccess: function () {
  80. im_message.applyJoinBigGroup(avChatRoomId);
  81. },
  82. recieveGroupMsg: function (newMsgList) {
  83. for (var j in newMsgList) {//遍历新消息
  84. var newMsg = newMsgList[j];
  85. addMsg(newMsg);
  86. }
  87. var el = $('#msg_box');
  88. el.scrollTop(el.prop("scrollHeight"));
  89. },
  90. sendMsgOk: function (msg) {
  91. $('#input-chat-speak').val('');
  92. },
  93. },
  94. this.recordOne = function() {
  95. var i = this;
  96. // e = i.record.data;
  97. // if (!e || 0 == e.length) return void i.getRecordData();
  98. var t = i.pageObj.playerObj.player.getState();
  99. if ("PLAYING" != t && "BUFFERING" != t) return void console.log("录播视频暂停状态 停止 聊天信息");
  100. // var n = e.shift();
  101. // if (i.recordRender(n.data), !e.length) return void i.getRecordData();
  102. // var o = e[0].timestamp - n.timestamp;
  103. // setTimeout(function() {
  104. // i.recordOne()
  105. // },
  106. // o || 100)
  107. }
  108. },
  109. ShowGiftAnimate = {
  110. datas: [],
  111. bigDatas: [],
  112. isAllPlaying: !1,
  113. showSize: 2,
  114. container: "js-gift-show-container",
  115. bigContainer: $("#js-show-big-gift-wrap"),
  116. bigGiftTpl: $("#js-big-gift-wrap-tpl"),
  117. duration: 2e3,
  118. timerArr: [],
  119. isInit: !1,
  120. isGetGift: !1,
  121. giftInfoList: [],
  122. readyBig: [65, 132],
  123. isBigPlaying: !1,
  124. creatList: function() {
  125. for (var i = this,
  126. e = 0; e < $(".gift-pic").length; e++) {
  127. var t = {
  128. id: $(".gift-list li:eq(" + e + ")").attr("data-id"),
  129. icon: $(".gift-pic:eq(" + e + ")").attr("src")
  130. };
  131. i.giftInfoList.push(t)
  132. }
  133. },
  134. init: function(i) {
  135. var e = this;
  136. e.datas.push(i), e.isAllPlaying || e.start();
  137. // e.giftInfoList.length || e.isGetGift ? void(e.isGetGift && e.giftInfoList.length && (i.giftPic = e.getGiftPic(i.giftId), e.readyBig.indexOf(i.giftId) == -1 ? (e.datas.push(i), e.isAllPlaying || e.start()) : Util.ua().android || (e.bigDatas.push(i), e.startBig()), e.isInit || (e.bindEvent(), e.isInit = !0))) : (e.isGetGift = !0, void e.getAllInfo())
  138. },
  139. getAllInfo: function() {
  140. var i = this;
  141. Common.ajax({
  142. url: "/mobile/gift_list",
  143. success: function(e) {
  144. e && 1 * e.error_code === 0 ? i.giftInfoList = e.data: console.log(e.error_msg)
  145. }
  146. })
  147. },
  148. getGiftPic: function(i) {
  149. for (var e = this,
  150. t = "",
  151. n = 0,
  152. o = e.giftInfoList.length; n < o; n++) if (e.giftInfoList[n].id == i) {
  153. t = e.giftInfoList[n].image;
  154. break
  155. }
  156. return t
  157. },
  158. start: function() {
  159. var i = this,
  160. e = i.datas,
  161. t = $("#" + i.container).children("li");
  162. t.each(function(n, o) {
  163. var a = $(o);
  164. if ("false" === a.attr("data-playing") && e.length > 0) {
  165. for (var s = null,
  166. r = i.getCurIds(), d = 0, l = e.length; d < l; d++) {
  167. var c = e[d];
  168. if (r.indexOf(c.fromId) == -1) {
  169. s = e.splice(d, 1)[0];
  170. break
  171. }
  172. }
  173. (i.showOne(a, s), n == t.length - 1 && (i.isAllPlaying = !0))
  174. }
  175. })
  176. },
  177. showOne: function(i, e) {
  178. var t = this;
  179. i.find(".name").html(e.nick || ""),
  180. i.find(".giftType").html(e.gift_type),
  181. 1 * e.num === 0 && (e.num = 1),
  182. i.find(".star").attr("data-num", e.num).html(""),
  183. i.find(".giftImg img").attr("src", e.gift_image),
  184. i.find(".headImg img").attr("src", e.head_image);
  185. var o = i.attr("data-fromId");
  186. if (o == e.fromId) {
  187. console.log(11);
  188. i.find(".pride").addClass("show");
  189. var a = i.find(".star");
  190. a.addClass("zoomIn").show().html("X" + (a.attr("data-num") || 0)),
  191. setTimeout(function() {},
  192. 50),
  193. function(i) {
  194. setTimeout(function() {
  195. t.next(i)
  196. },
  197. t.duration)
  198. } (i)
  199. } else i.find(".pride").removeClass("show"),
  200. setTimeout(function() {
  201. i.find(".pride").addClass("show"),
  202. i.find(".giftImg").removeClass("bounceInLeft"),
  203. setTimeout(function() {
  204. i.find(".giftImg").addClass("bounceInLeft")
  205. },
  206. 50),
  207. function(i) {
  208. setTimeout(function() {
  209. t.next(i)
  210. },
  211. t.duration)
  212. } (i)
  213. },
  214. 30);
  215. i.attr("data-playing", "true").attr("data-fromId", e.fromId)
  216. },
  217. next: function(i) {
  218. var e = this,
  219. t = e.datas,
  220. n = (i.index(), i.attr("data-fromId")),
  221. o = null,
  222. a = e.getCurIds();
  223. if (0 == t.length || !t) return e.hideOne(i),
  224. void(e.isAllPlaying = !1);
  225. if (t[0].fromId == n) o = t.shift();
  226. else {
  227. var s = t.length;
  228. if (t.length > 1) for (var r = 1; r < s; r++) if (a.indexOf(t[r].fromId) == -1) {
  229. o = t.splice(r, 1)[0];
  230. break
  231. }
  232. }
  233. o ? e.showOne(i, o) : (e.hideOne(i), e.isAllPlaying = !1)
  234. },
  235. getCurIds: function() {
  236. var i = this,
  237. e = [];
  238. return $("#" + i.container).children("li").each(function(i, t) {
  239. var n = $(t),
  240. o = 1 * n.attr("data-fromId");
  241. o && e.indexOf(o) == -1 && e.push(1 * o)
  242. }),
  243. e
  244. },
  245. hideOne: function(i) {
  246. i.find(".pride").removeClass("show"),
  247. i.attr("data-playing", "false").removeAttr("data-fromId")
  248. },
  249. clearTimer: function(i) {
  250. clearTimeout(i),
  251. i = null
  252. },
  253. startBig: function() {
  254. var i = this,
  255. e = i.bigDatas;
  256. if (!e || 0 == e.length) return void i.bigContainer.hide();
  257. if (!i.isBigPlaying) {
  258. var t = e.shift(),
  259. n = t.giftId,
  260. o = $("#big-gift-box-" + n);
  261. if (!o.length) return void console.error("big gift id box is null");
  262. $("#live-bg .play-btn").is(":hidden") ? i.bigContainer.show() : i.bigContainer.hide(),
  263. o.find(".u-name").html(t.nick),
  264. o.find(".b-gift-type").html("送一个" + t.type),
  265. o.addClass("show"),
  266. i.isBigPlaying = !0
  267. }
  268. },
  269. bindEvent: function() {
  270. var i = this;
  271. $("#" + i.container).find(".star").bind("webkitAnimationStart",
  272. function() {}),
  273. $("#" + i.container).find(".giftImg").bind("webkitAnimationEnd",
  274. function() {
  275. var i = $(this).closest("li").find(".star");
  276. i.addClass("zoomIn").show().html("X" + (i.attr("data-num") || 0))
  277. }),
  278. $("#" + i.container).find(".star").bind("webkitAnimationEnd",
  279. function() {
  280. $(this).removeClass("zoomIn")
  281. }),
  282. i.bigContainer.on("webkitAnimationEnd ",
  283. function(e) {
  284. console.log("bigContainer webkitAnimationEnd");
  285. var t = $(e.target);
  286. if (console.log(t), t.hasClass("big-gift-box") || t.hasClass("animate-main")) {
  287. var n = t.hasClass("big-gift-box") ? t: t.closest(".big-gift-box");
  288. n.removeClass("show"),
  289. setTimeout(function() {
  290. i.isBigPlaying = !1,
  291. i.startBig()
  292. },
  293. 50)
  294. }
  295. })
  296. }
  297. },
  298. PlayControl = {
  299. player: null,
  300. playerFromRecordList: null,
  301. isRecordList: 0,
  302. mediaInfo: null,
  303. bufferStart: 0,
  304. logBufferState: "",
  305. logBufferTmpNum: 0,
  306. logTimer: null,
  307. conf: "",
  308. opt: {},
  309. isAndroid: /Android/i.test(navigator.userAgent),
  310. isSafari: /Safari/i.test(navigator.userAgent),
  311. auto_height: "",
  312. init: function(i) {
  313. var e = this;
  314. return e.conf = i || {},
  315. e.bindEvent(),
  316. e
  317. },
  318. setUp: function(i, e) {
  319. var t = this;
  320. t.isRecordList = e || 0,
  321. t.bufferStart = 0;
  322. var n = 640 * $(window).width() / 368;
  323. t.auto_height = t.isAndroid ? n: "100%";
  324. var o = {
  325. type: "mp4",
  326. width: $(window).width(),
  327. height: 667,
  328. image: "",
  329. stretching: "fill",
  330. controls: !1,
  331. primary: "html5",
  332. events: {
  333. onReady: t.onReady,
  334. onPlay: t.onPlay,
  335. onPause: t.onPause,
  336. onBuffer: t.onBuffer,
  337. onDisplayClick: t.onDisplayClick,
  338. onSetupError: t.onSetupError,
  339. onComplete: t.onComplete,
  340. onIdle: t.onIdle,
  341. onBeforeComplete: t.onBeforeComplete,
  342. onError: t.onError
  343. }
  344. };
  345. $.extend(!0, o, i || {}),
  346. t.opt = o,
  347. console.log("player defaults", o),
  348. t.player = jwplayer("container").setup(o)
  349. },
  350. onReady: function() {
  351. console.log("onReady", (new Date).getTime());
  352. var i = $("#container").find("video");
  353. i.attr({
  354. "x5-video-player-type": "h5",
  355. "x5-video-player-fullscreen": "true"
  356. }),
  357. i.attr("playsinline", !0);
  358. },
  359. onPlay: function() {
  360. console.log("onplay", (new Date).getTime()),
  361. $("#js-player-loading").hide();
  362. var i = $("#container").find("video");
  363. i.attr({
  364. "x5-video-player-type": "h5",
  365. "x5-video-player-fullscreen": "true"
  366. }),
  367. i.attr("playsinline", !0);
  368. var e = PlayControl;
  369. // t = e.conf.media_info;
  370. // if (e.bufferStart) {
  371. // var n = e.opt.file || e.opt.playlist && e.opt.playlist && e.opt.playlist[0].sources[0].file,
  372. // o = {
  373. // video_loadtime: (new Date).getTime() - e.bufferStart,
  374. // video_status: e.opt.status,
  375. // video_url: n || ""
  376. // };
  377. // Common.trace({
  378. // report_type: "qa",
  379. // other: o
  380. // }),
  381. // e.bufferStart = 0
  382. // }
  383. $("#live-bg").show().attr("class", "is-play"),
  384. $("video") && (device=="android") && setTimeout(function() {
  385. var i = $("video").height();
  386. $("#top").height(window.innerHeight),
  387. i > e.conf.winHeight;
  388. var t = parseInt(window.innerHeight - $("#top").height()) + 15;
  389. $(".btn-box").css("bottom", t),
  390. $("#topBom").css("bottom", t)
  391. },
  392. 200),
  393. $("#js-top-id").show(),
  394. $("#js-looked-num").show(),
  395. $(".js-user-info-con").removeClass("up"),
  396. 1 == 1 ? ($(".btn-box").show(), e.conf.view_uid > 0) : ($(".btn-box").hide(), $("#hf-text").hide()),
  397. $("#topBom").show(),
  398. setTimeout(function() {
  399. $("#msg_box").show(),
  400. $("#js-gift-show-container").show()
  401. },
  402. 50),
  403. $("#bestTop").hide()
  404. },
  405. onPause: function() {
  406. console.log("onpause");
  407. var i = PlayControl;
  408. i.conf.media_info;
  409. if (i.logBufferTmpNum = 0, $("#live-bg").attr("class", "is-pause"), $(".user,#js-top-id").hide(), i.conf.ua.isAndroid) {
  410. var e = $("video") && $("video").height() || 0;
  411. e > i.conf.winHeight && setTimeout(function() {
  412. $("#top").height(window.innerHeight)
  413. },
  414. 100)
  415. }
  416. $(".btn-box,#msg_box,#js-gift-show-container").hide(),
  417. $("#topBom").hide(),
  418. $("#bestTop").show()
  419. },
  420. onBuffer: function() {
  421. var i = PlayControl;
  422. console.log("onBuffer", (new Date).getTime()),
  423. $("#js-player-loading").show(),
  424. i.bufferStart = (new Date).getTime(),
  425. i.logTimer || (i.logTimer = setInterval(function() {
  426. i.logBufferTimes()
  427. },
  428. 1500))
  429. },
  430. onDisplayClick: function() {
  431. console.log("onDisplayClick", (new Date).getTime());
  432. var i = PlayControl,
  433. e = i.conf.media_info;
  434. $(window).scrollTop(0),
  435. 0 == i.isRecordList && 1 == 1 && ($(".btn-box").show(), $(".talk-box").hide());
  436. var t = i.player.getState();
  437. "PLAYING" == t ? 1 != e.status && i.player.pause() : "PAUSED" == t || "IDLE" == t ? i.player.play() : console.log("otherState", t)
  438. },
  439. onSetupError: function() {
  440. console.log("onSetupError", arguments)
  441. },
  442. onComplete: function() {
  443. var i = PlayControl,
  444. e = media_info;
  445. window.console && console.log("onComplete"),
  446. $(document).trigger("living:oncomplete")
  447. },
  448. onIdle: function() {
  449. console.log("onIdle", arguments)
  450. },
  451. onBeforeComplete: function() {
  452. console.log("onBeforeComplete", arguments)
  453. },
  454. onError: function() {
  455. $("#js-player-loading").hide(),
  456. console.error("player onError", arguments)
  457. },
  458. logBufferTimes: function() {
  459. // 缓冲时间
  460. var i = this,
  461. e = i.player.getState();
  462. if ("BUFFERING" == e) if (i.logBufferTmpNum > 0 && "playing" == i.logBufferState) {
  463. var t = i.opt.file || i.opt.playlist && i.opt.playlist && i.opt.playlist[0].sources[0].file;
  464. Common.trace({
  465. report_type: "qa",
  466. other: {
  467. video_url: t || ""
  468. }
  469. }),
  470. i.logBufferState = "buffer"
  471. } else i.logBufferTmpNum = i.logBufferTmpNum + 1;
  472. else "PLAYING" == e && (i.logBufferState = "playing")
  473. },
  474. bindEvent: function() {
  475. var i = this;
  476. $("#live-bg").on("click",
  477. function(e) {
  478. $(this).hasClass("is-finished") || i.onDisplayClick()
  479. }),
  480. $(".shadd3").click(function() {
  481. i.onDisplayClick(),
  482. $(".shadd3").hide()
  483. })
  484. }
  485. },
  486. Page = {
  487. back_video: 0,
  488. ua: {},
  489. isInit: !1,
  490. gConfig: "",
  491. queryData: "",
  492. playerObj: "",
  493. chatObj: "",
  494. giftObj: "",
  495. wrap: $("#js-all-wrap"),
  496. isLogin: !1,
  497. needPlayBeforeLoaded: !1,
  498. init: function() {
  499. var i = this;
  500. i.initSize(),
  501. i.gConfig.winWidth = i.wrap.width(),i.gConfig.winHeight = $(window).height(),
  502. i.playerObj = PlayControl.init(i.gConfig),
  503. i.initStatus(),
  504. i.isInit || (i.isInit = !0, i.bindEvent())
  505. },
  506. initSize: function() {
  507. $("#top").height($(window).height());
  508. },
  509. initStatus: function() {
  510. var i = this,
  511. e = media_info;
  512. e.live_in == 0 ? i.renderNoLiveAndRecord() : (i.renderLiveOrRecord(), i.initPlay()),
  513. i.updateUserNum(e.watch_number, e.live_in)
  514. },
  515. initPlay: function() {
  516. var i = this, live_in = Number(media_info.live_in);
  517. switch(live_in){
  518. case 1:
  519. t = {
  520. file: media_info.file_living,
  521. image: media_info.image
  522. };
  523. break;
  524. case 3:
  525. t = {
  526. file: media_info.file_playback,
  527. image: media_info.image
  528. };
  529. break;
  530. default:
  531. t = {
  532. file: '',
  533. image: media_info.image
  534. };
  535. break;
  536. }
  537. // // 测试数据
  538. // t = {
  539. // file: "http://200022096.vod.myqcloud.com/200022096_81a18c95b6894109a7ef689f00135c49.f0.mp4",
  540. // image: ""
  541. // };
  542. t.status = 1,
  543. i.playerObj.setUp(t)
  544. // i.startPlay()
  545. },
  546. renderNoLiveAndRecord: function() {
  547. $(".no-player-text,.bg_user_pic").show(),
  548. $("#topBom").hide(),
  549. $("#hf-text").hide(),
  550. $("#msg_box").html("").hide(),
  551. $(".btn-box").hide(),
  552. $("#live-bg").show().attr("class", "is-finished"),
  553. $("#top").height("16rem"),
  554. $("#bestTop").css("position", "fixed"),
  555. $("#top2").removeClass("top"),
  556. $("#shadow").show(),
  557. $("#js-gift-show-container").hide()
  558. },
  559. renderLiveOrRecord: function() {
  560. $("#live-bg").show(),
  561. $("#shadow").hide(),
  562. $("#topBom").show()
  563. },
  564. startPlay: function() {
  565. var i = this;
  566. i.playerObj && i.playerObj.player && i.playerObj.player.play(),
  567. i.initChatRoom()
  568. },
  569. updateUserNum: function(i, e) {
  570. var t = this,
  571. i = i || 0;
  572. $("#user_num").html(i + "人看过").show(),
  573. $("#user_num2").html(i);
  574. var n = $("#js-looked-num");
  575. return isAndroid && n.addClass("android"),
  576. void 1 == e ? void n.removeClass("is-live").addClass("is-record") : void(1 == e ? n.removeClass("is-record").addClass("is-live") : n.removeClass("is-live").addClass("is-record"))
  577. },
  578. initGift: function() {
  579. // 初始化礼物
  580. var i = this,
  581. e = i.gConfig;
  582. i.giftObj = new gift_manager(e, i),
  583. i.ua.isWeixin,
  584. i.giftObj.init()
  585. },
  586. initChatRoom: function() {
  587. // 初始化聊天区
  588. var i = this;
  589. console.log("initChatRoom");
  590. if(typeof loginInfo !== 'undefined'){
  591. var chatObj = new chat();
  592. im_message.init(loginInfo, chatObj.listeners);
  593. }
  594. },
  595. showLoading: function(i) {
  596. var e = $("#js-mask-loading");
  597. i ? e.show() : e.hide()
  598. },
  599. bindEvent: function() {
  600. var i = this;
  601. $("#live-bg").on("click",
  602. function(e) {
  603. setTimeout(function() {
  604. i.initChatRoom(),
  605. $("#js-gift-show-container").show()
  606. },
  607. 100)
  608. // i.chatObj && i.chatObj.socket && i.chatObj.socket.socket.connected,
  609. // i.userLog({
  610. // click_id: "play_btn"
  611. // })
  612. }),
  613. $("#shadow").click(function() {
  614. i.playerObj || (i.needPlayBeforeLoaded = !0, console.log("提前play"), i.showLoading(!0))
  615. }),
  616. $(document).on("living:userNumUpdate",
  617. function(e, t) {
  618. i.updateUserNum(t.num)
  619. }),
  620. $(document).on("living:oncomplete",
  621. function(e, t) {
  622. i.renderNoLiveAndRecord()
  623. }),
  624. $(document).on("recordStartInit",
  625. function(e, t) {
  626. console.log(t),
  627. i.renderRecord(t),
  628. i.chatObj && i.chatObj.leaveRoom()
  629. }),
  630. $(window).resize(function() {
  631. setTimeout(function() {
  632. window.scrollTo(0, 0)
  633. },
  634. 100)
  635. }),
  636. $(".js-btn-open-app").on("click",
  637. function(e) {
  638. var t = $(this);
  639. t.attr("data-id") && i.userLog({
  640. click_id: t.attr("data-id")
  641. }),
  642. i.goApp(!0, t),
  643. e.preventDefault()
  644. })
  645. }
  646. };
  647. // 分享页面
  648. $(function(){
  649. Page.init();
  650. // 点击弹出下载提示窗
  651. $(".show_pop_wp").on('click',function(){
  652. $(".pop_wp").css({display:"flex"});
  653. });
  654. $(".pop_close").on('click',function(){
  655. $(".pop_wp").css({display:"none"});
  656. });
  657. $(".js-list-tab").find(".t-one").on('click',function(){
  658. $(this).addClass('active').siblings().removeClass('active');
  659. $(".tab-con-list").find(".one-page").eq($(this).index()).show().siblings().hide();
  660. });
  661. });
  662. // 微信分享
  663. wx.ready(function () {
  664. // 在这里调用 API
  665. wx.onMenuShareTimeline({
  666. title: wx_title, // 分享标题
  667. link: wx_link, // 分享链接
  668. imgUrl: wx_img, // 分享图标
  669. success: function () {
  670. // 用户确认分享后执行的回调函数
  671. },
  672. cancel: function () {
  673. // 用户取消分享后执行的回调函数
  674. }
  675. });
  676. wx.onMenuShareAppMessage({
  677. title: wx_title, // 分享标题
  678. desc: wx_desc, // 分享描述
  679. link: wx_link, // 分享链接
  680. imgUrl: wx_img, // 分享图标
  681. type: 'link', // 分享类型,music、video或link,不填默认为link
  682. // dataUrl: '', // 如果type是music或video,则要提供数据链接,默认为空
  683. success: function () {
  684. // 用户确认分享后执行的回调函数
  685. },
  686. cancel: function () {
  687. // 用户取消分享后执行的回调函数
  688. }
  689. });
  690. wx.onMenuShareQQ({
  691. title: wx_title, // 分享标题
  692. desc: wx_desc, // 分享描述
  693. link: wx_link, // 分享链接
  694. imgUrl: wx_img, // 分享图标
  695. success: function () {
  696. // 用户确认分享后执行的回调函数
  697. },
  698. cancel: function () {
  699. // 用户取消分享后执行的回调函数
  700. }
  701. });
  702. wx.onMenuShareQZone({
  703. title: wx_title, // 分享标题
  704. desc: wx_desc, // 分享描述
  705. link: wx_link, // 分享链接
  706. imgUrl: wx_img, // 分享图标
  707. success: function () {
  708. // 用户确认分享后执行的回调函数
  709. },
  710. cancel: function () {
  711. // 用户取消分享后执行的回调函数
  712. }
  713. });
  714. wx.error(function(res){
  715. // config信息验证失败会执行error函数,如签名过期导致验证失败,具体错误信息可以打开config的debug模式查看,也可以在返回的res参数中查看,对于SPA可以在这里更新签名。
  716. });
  717. });