share-index.js 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  1. // 分享页面
  2. $(document).on("pageInit","#page-share-indexs", function(e, pageId, $page) {
  3. // 点击弹出下载提示窗
  4. $(".show_pop_wp").on('click',function(){
  5. $(".pop_wp").css({display:"flex"});
  6. });
  7. $(".pop_close").on('click',function(){
  8. $(".pop_wp").css({display:"none"});
  9. });
  10. var width = $(window).width();
  11. var height = $(window).height();
  12. console.log("live_in:"+live_in);
  13. if(live_in==1){
  14. if(live_url || live_url2){
  15. (function () {
  16. if(!device || device=='iphone'){
  17. var option ={
  18. "live_url": live_url,
  19. "live_url2": live_url2,
  20. "width": width,
  21. "height": 320,
  22. "x5_type": "h5",
  23. "x5_fullscreen": true,
  24. "h5_start_patch":{
  25. "url": head_image_url,
  26. "stretch": true
  27. }
  28. };
  29. }
  30. else{
  31. var option ={
  32. "live_url": live_url,
  33. "live_url2": live_url2,
  34. "width": width,
  35. "height": 320,
  36. "h5_start_patch":{
  37. "url": head_image_url,
  38. "stretch": true
  39. }
  40. };
  41. }
  42. var player = new qcVideo.Player("id_video_container", option, {
  43. playStatus: function (status,type){
  44. //TODO
  45. console.log(status);
  46. if(status == "playing"){
  47. if(!device || device=='iphone'){
  48. player.resize(width, height);
  49. $(".vedio_wp").css({"height": height});
  50. $(".live_info").show();
  51. $(".pop_download").hide();
  52. }
  53. }
  54. else{
  55. player.resize(width, 320);
  56. }
  57. }
  58. });
  59. $("#startplay").on('click',function(){
  60. $("#liveing").show();
  61. $("#preVedio").hide();
  62. player.play();
  63. });
  64. })();
  65. }else{
  66. (function () {
  67. if(!device || device=='iphone'){
  68. var option ={
  69. "channel_id": channel_id,
  70. "app_id": app_id,
  71. "width": width,
  72. "height": 320,
  73. "x5_type": "h5",
  74. "x5_fullscreen": true,
  75. "h5_start_patch":{
  76. "url": head_image_url,
  77. "stretch": true
  78. }
  79. };
  80. }
  81. else{
  82. var option ={
  83. "channel_id": channel_id,
  84. "app_id": app_id,
  85. "width": width,
  86. "height": 320,
  87. "h5_start_patch":{
  88. "url": head_image_url,
  89. "stretch": true
  90. }
  91. };
  92. }
  93. var player = new qcVideo.Player("id_video_container", option, {
  94. playStatus: function (status){
  95. //TODO
  96. console.log(status);
  97. if(status == "playing"){
  98. if(!device || device=='iphone'){
  99. player.resize(width, height);
  100. $(".vedio_wp").css({"height": height});
  101. $(".live_info").show();
  102. $(".pop_download").hide();
  103. }
  104. }
  105. else{
  106. player.resize(width, 320);
  107. }
  108. }
  109. });
  110. $("#startplay").on('click',function(){
  111. $("#liveing").show();
  112. $("#preVedio").hide();
  113. player.play();
  114. });
  115. })();
  116. }
  117. }else if(live_in==3){
  118. (function () {
  119. if(!device || device=='iphone'){
  120. var option ={
  121. "file_id": file_id,
  122. "app_id": app_id,
  123. "width":width,
  124. "height":320,
  125. "x5_type": "h5",
  126. "x5_fullscreen": true
  127. };
  128. }
  129. else{
  130. var option ={
  131. "file_id": file_id,
  132. "app_id": app_id,
  133. "width":width,
  134. "height":320
  135. };
  136. }
  137. var player = new qcVideo.Player("id_video_container", option, {
  138. playStatus: function (status,type){
  139. //TODO
  140. console.log(status);
  141. if(status == "playing"){
  142. if(!device || device=='iphone'){
  143. player.resize(width, height);
  144. $(".vedio_wp").css({"height": height});
  145. $(".live_info").show();
  146. $(".pop_download").hide();
  147. }
  148. }
  149. else{
  150. player.resize(width, 320);
  151. }
  152. }
  153. });
  154. $("#startplay").on('click',function(){
  155. $("#liveing").show();
  156. $("#preVedio").hide();
  157. player.play();
  158. });
  159. })();
  160. /*var player = new qcVideo.Player("id_video_container", {
  161. "width":width,
  162. "height":height,
  163. "stretch_full":1,
  164. "stop_time":60,
  165. "third_video": {
  166. "urls":{
  167. 20 : urls//演示地址,请替换实际地址
  168. }
  169. }
  170. });*/
  171. }else{
  172. }
  173. wx.ready(function () {
  174. // 在这里调用 API
  175. wx.onMenuShareTimeline({
  176. title: wx_title, // 分享标题
  177. link: wx_link, // 分享链接
  178. imgUrl: wx_img, // 分享图标
  179. success: function () {
  180. // 用户确认分享后执行的回调函数
  181. },
  182. cancel: function () {
  183. // 用户取消分享后执行的回调函数
  184. }
  185. });
  186. wx.onMenuShareAppMessage({
  187. title: wx_title, // 分享标题
  188. desc: wx_desc, // 分享描述
  189. link: wx_link, // 分享链接
  190. imgUrl: wx_img, // 分享图标
  191. type: 'link', // 分享类型,music、video或link,不填默认为link
  192. // dataUrl: '', // 如果type是music或video,则要提供数据链接,默认为空
  193. success: function () {
  194. // 用户确认分享后执行的回调函数
  195. },
  196. cancel: function () {
  197. // 用户取消分享后执行的回调函数
  198. }
  199. });
  200. wx.onMenuShareQQ({
  201. title: wx_title, // 分享标题
  202. desc: wx_desc, // 分享描述
  203. link: wx_link, // 分享链接
  204. imgUrl: wx_img, // 分享图标
  205. success: function () {
  206. // 用户确认分享后执行的回调函数
  207. },
  208. cancel: function () {
  209. // 用户取消分享后执行的回调函数
  210. }
  211. });
  212. wx.onMenuShareQZone({
  213. title: wx_title, // 分享标题
  214. desc: wx_desc, // 分享描述
  215. link: wx_link, // 分享链接
  216. imgUrl: wx_img, // 分享图标
  217. success: function () {
  218. // 用户确认分享后执行的回调函数
  219. },
  220. cancel: function () {
  221. // 用户取消分享后执行的回调函数
  222. }
  223. });
  224. wx.error(function(res){
  225. // config信息验证失败会执行error函数,如签名过期导致验证失败,具体错误信息可以打开config的debug模式查看,也可以在返回的res参数中查看,对于SPA可以在这里更新签名。
  226. });
  227. });
  228. function addMsg(msg) {
  229. var time = webim.Tool.formatTimeStamp(msg.getTime());
  230. var data = convertMsg(msg);
  231. if(! data){
  232. return;
  233. }
  234. if(typeof data !== 'object'){
  235. data = {
  236. "user_level": 122,
  237. "nick_name": "[群提示消息]",
  238. "text": data,
  239. };
  240. }
  241. if (data.type == 2 && showBarrage && player) {
  242. var barrage = [
  243. { "type": "content", "content": data.text, "time": "0" },
  244. ];
  245. player.addBarrage(barrage);
  246. }
  247. $('#chat-box').append('<li><p><a href="javascript:;" class="name"><i class="ico_level"></i>' + data.nick_name + '</a>' + data.text + '</p></li>');
  248. }
  249. var listeners = {
  250. loginSuccess: function () {
  251. im_message.applyJoinBigGroup(avChatRoomId);
  252. },
  253. recieveGroupMsg: function (newMsgList) {
  254. for (var j in newMsgList) {//遍历新消息
  255. var newMsg = newMsgList[j];
  256. addMsg(newMsg);
  257. }
  258. var el = $('#video_sms_list');
  259. el.scrollTop(el.prop("scrollHeight"));
  260. },
  261. sendMsgOk: function (msg) {
  262. $('#input-chat-speak').val('');
  263. },
  264. };
  265. if(typeof loginInfo !== 'undefined'){
  266. im_message.init(loginInfo, listeners);
  267. }
  268. });