index.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  1. $(document).on("pageInit","#page-index", function(e, pageId, $page) {
  2. var app = angular.module('myApp' , ['me-lazyimg']);
  3. var item1 = document.getElementById('item1mobile');
  4. var item2 = document.getElementById('item2mobile');
  5. var item3 = document.getElementById('item3mobile');
  6. // 判断是否登录微信
  7. /* $.ajax({
  8. url: app_url+'/wap/index.php?ctl=index&act=app_login',
  9. type: "GET",
  10. dataType: "json",
  11. success: function(data){
  12. if(data.is_login == 0){
  13. $.modal({
  14. title: '',
  15. text: '<div class="login"><div class="logo"></div><div class="operation"><h1>点击微信登录< text: '<div class="login"><div class="logo"></div><div class="operation"><h1>点击微信登录</h1><div class="mode"><div class="weixin J_weixin_login_btn" sdk-data="'+data.s
  16. buttons: []
  17. });
  18. $(".J_weixin_login_btn").bind("click",function(){
  19. try{
  20. App.login_sdk('wxlogin');
  21. return false;
  22. }
  23. catch(e){
  24. $.toast("SDK调用失败");
  25. return false;
  26. }
  27. });
  28. }
  29. }
  30. });*/
  31. // 搜索
  32. app.controller('key_word_search', function($scope, $http) {
  33. $scope.key_word = '';
  34. $scope.null_tip_show = 'hide';
  35. $scope.change = function(){
  36. $.showIndicator();
  37. var key_word = $("input[name='key_word']").val();
  38. $http.get(app_url+'/wap/index.php?ctl=index&act=search&key_word='+key_word).success(function(data){
  39. $.hideIndicator();
  40. console.log(data.users);
  41. if(key_word){
  42. if(data.users){
  43. $scope.search_user_list = data.users;
  44. }
  45. else{
  46. $scope.search_user_list='';
  47. $scope.null_tip_show = '';
  48. }
  49. }
  50. else{
  51. $scope.null_tip_show = 'hide';
  52. }
  53. });
  54. }
  55. $scope.J_focus = function(id,is_focus,target){
  56. var ajax_url;
  57. is_focus ? ajax_url = app_url+'/wap/index.php?ctl=app&act=follow' : ajax_url = app_url+'/wap/index.php?ctl=app&act=follow';
  58. $.ajax({
  59. url: ajax_url,
  60. dataType: "json",
  61. data:"to_user_id="+id,
  62. type: "POST",
  63. success: function(ajaxobj){
  64. if(is_focus){
  65. $.alert("取消关注成功!");
  66. }
  67. else{
  68. $.alert("关注成功!");
  69. }
  70. },
  71. error:function(ajaxobj)
  72. {
  73. // if(ajaxobj.responseText!='')
  74. // alert(ajaxobj.responseText);
  75. }
  76. });
  77. }
  78. });
  79. $(document).on('click','.open-agreement', function () {
  80. $.popup('.popup-agreement');
  81. });
  82. $(document).on('click','.close-popup-agreement', function () {
  83. $.closeModal('.popup-agreement');
  84. });
  85. $("#J_agree").on('click',function(){
  86. $.closeModal('.popup-agreement');
  87. $.popup('.popup-live');
  88. });
  89. $("#J_agree_1").on('click',function(){
  90. var title = $("input[name='live_name']").val();
  91. $.ajax({
  92. url: app_url+'/wap/index.php?ctl=video&act=add_video',
  93. data:"title="+title,
  94. type: "GET",
  95. dataType: "json",
  96. success: function(data){
  97. if(data.status == 1){
  98. //var data_arr = [{room_id:Number(data.room_id)},{group_id:data.group_id}];
  99. var data_arr = '{"room_id":' +Number(data.room_id) +', "group_id":"' + data.group_id +'"}';
  100. try{
  101. App.create_live(data_arr);
  102. }
  103. catch(e){
  104. $.toast("SDK调用失败");
  105. }
  106. }else{
  107. console.log(111);
  108. }
  109. }
  110. });
  111. });
  112. $(document).on('click','.close-popup-live', function () {
  113. $.closeModal('.popup-live');
  114. });
  115. app.controller('myCtrl_ctrl_pop_live', function($scope) {
  116. $scope.live_name = "";
  117. $scope.toggle = function () {
  118. $scope.focus = !$scope.focus;
  119. }
  120. });
  121. app.controller('myCtrl_header_search', function($scope) {
  122. $scope.blur = "";
  123. });
  124. // bannner 数据
  125. /* app.controller('myCtrl_banner', function($scope, $http) {
  126. $http.get(app_url+'/wap/index.php?ctl=index&act=banner').success(function(data){
  127. var data_banner = data.banner;
  128. $scope.banner = data_banner;
  129. $scope.$on('ngRepeatFinished', function (ngRepeatFinishedEvent) {
  130. $.reinitSwiper();
  131. });
  132. });
  133. });*/
  134. // 热门 数据
  135. app.controller('myCtrl_video_hot', function($scope, $http) {
  136. $.showIndicator();
  137. $http.get(app_url+'/wap/index.php?ctl=index&act=index').success(function(data){
  138. console.log(data);
  139. $(".J_login").on('click',function(){
  140. is_login(data.user_info.is_login,data.user_info.sdk_data);
  141. });
  142. $.hideIndicator();
  143. var data_banner = data.banner;
  144. $scope.banner = data_banner;
  145. var data_video_hot = data.video_hot;
  146. $scope.video_hot = data_video_hot;
  147. $scope.$on('ngRepeatFinished', function (ngRepeatFinishedEvent) {
  148. $.reinitSwiper();
  149. });
  150. });
  151. $scope.join_live = function(room_id){
  152. //var data_video_hot_arr = [{room_id:Number(room_id)},$scope.video_hot];
  153. var data_video_hot_arr = '{"room_id":' +Number(room_id) +', "list":' + JSON.stringify($scope.video_hot) +' }';
  154. try{
  155. App.join_live(data_video_hot_arr);
  156. }
  157. catch(e){
  158. $.toast("SDK调用失败");
  159. }
  160. }
  161. $scope.do_refresher = function() {
  162. $http.get(app_url+'/wap/index.php?ctl=index&act=index').success(function(data){
  163. var data_banner = data.banner;
  164. $scope.banner = data_banner;
  165. var data_video_hot = data.video_hot;
  166. $scope.video_hot = data_video_hot;
  167. });
  168. }
  169. });
  170. // 最新 数据
  171. app.controller('myCtrl_video_new', function($scope, $http) {
  172. $scope.do_load = function() {
  173. $.showIndicator();
  174. $http.get(app_url+'/wap/index.php?ctl=index&act=new_video').success(function(data){
  175. $.hideIndicator();
  176. item3.querySelector('.angluar_loading').remove();
  177. var data_video_new = data.video_new;
  178. $scope.video_new = data_video_new;
  179. });
  180. }
  181. $scope.join_live = function(room_id){
  182. //var data_arr =[{room_id:Number(room_id)},$scope.video_new];
  183. var data_arr = '{"room_id":' +Number(room_id) +', "list":' + JSON.stringify($scope.video_new) +' }';
  184. try{
  185. App.join_live(data_arr);
  186. }
  187. catch(e){
  188. $.toast("SDK调用失败");
  189. }
  190. }
  191. $scope.do_refresher = function() {
  192. $http.get(app_url+'/wap/index.php?ctl=index&act=new_video').success(function(data){
  193. var data_video_new = data.video_new;
  194. $scope.video_new = data_video_new;
  195. });
  196. }
  197. });
  198. // 关注 数据
  199. app.controller('myCtrl_video_playback', function($scope, $http) {
  200. $scope.do_load = function() {
  201. $.showIndicator();
  202. $http.get(app_url+'/wap/index.php?ctl=index&act=focus_video').success(function(data){
  203. $.hideIndicator();
  204. $(".module_item_live_focus").show();
  205. item1.querySelector('.angluar_loading').remove();
  206. // 关注的直播
  207. var data_video_focus = data.video_focus;
  208. var data_video_focus_length = data_video_focus.length;
  209. $scope.video_focus = data_video_focus;
  210. $scope.video_focus_length = data_video_focus_length;
  211. // 精彩回放
  212. var data_view_playback = data.playback;
  213. var data_view_playback_length = data_view_playback.length;
  214. $scope.view_playback = data_view_playback;
  215. $scope.view_playback_length = data_view_playback_length;
  216. });
  217. }
  218. $scope.do_refresher = function() {
  219. $http.get(app_url+'/wap/index.php?ctl=index&act=focus_video').success(function(data){
  220. // 关注的直播
  221. var data_video_focus = data.video_focus;
  222. var data_video_focus_length = data_video_focus.length;
  223. $scope.video_focus = data_video_focus;
  224. $scope.video_focus_length = data_video_focus_length;
  225. // 精彩回放
  226. var data_view_playback = data.playback;
  227. var data_view_playback_length = data_view_playback.length;
  228. $scope.view_playback = data_view_playback;
  229. $scope.view_playback_length = data_view_playback_length;
  230. });
  231. }
  232. });
  233. app.directive('onFinishRenderFilters', function ($timeout) {
  234. return {
  235. restrict: 'A',
  236. link: function(scope, element, attr) {
  237. if (scope.$last === true) {
  238. $timeout(function() {
  239. scope.$emit('ngRepeatFinished');
  240. });
  241. }
  242. }
  243. };
  244. });
  245. mui.init();
  246. (function($) {
  247. //阻尼系数
  248. var deceleration = 0.0005;
  249. $('.mui-scroll-wrapper').scroll({
  250. bounce: false,
  251. indicators: true, //是否显示滚动条
  252. deceleration:deceleration
  253. });
  254. $.ready(function() {
  255. //循环初始化所有下拉刷新,上拉加载。
  256. $.each(document.querySelectorAll('.mui-slider-group .mui-refresh'), function(index, pullRefreshEl) {
  257. $(pullRefreshEl).pullToRefresh({
  258. down: {
  259. callback: function() {
  260. var self = this;
  261. setTimeout(function() {
  262. if(index == 0){var scope = angular.element(ngSection0).scope();}
  263. if(index == 1){var scope = angular.element(ngSection1).scope();}
  264. if(index == 2){var scope = angular.element(ngSection2).scope();}
  265. scope.$apply(function(){
  266. scope.do_refresher();
  267. });
  268. self.endPullDownToRefresh();
  269. }, 500);
  270. }
  271. }
  272. });
  273. // 添加'refresh'监听器
  274. // $(pullRefreshEl).on('refresh', '.pull-to-refresh-content',function(e) {
  275. // // 模拟2s的加载过程
  276. // setTimeout(function() {
  277. // alert(11);
  278. // // 加载完毕需要重置
  279. // $.pullToRefreshDone('.pull-to-refresh-content');
  280. // }, 2000);
  281. // });
  282. // $(document).on('refresh', '.pull-to-refresh-content',function(e) {
  283. // setTimeout(function() {
  284. // alert(1);
  285. // // 加载完毕需要重置
  286. // $.pullToRefreshDone('.pull-to-refresh-content')
  287. // }, 2000);
  288. // });
  289. });
  290. });
  291. // 监听切换页面
  292. document.getElementById('slider').addEventListener('slide', function(e) {
  293. // 如果是(最新)页面
  294. if (e.detail.slideNumber === 2) {
  295. // 判断是否加载过,否则进行加载
  296. if (item3.querySelector('.angluar_loading')) {
  297. var scope = angular.element(ngSection2).scope();
  298. scope.$apply(function(){
  299. scope.do_load();
  300. });
  301. }
  302. // 如果是(关注)页面
  303. } else if (e.detail.slideNumber === 0) {
  304. if (item1.querySelector('.angluar_loading')) {
  305. var scope = angular.element(ngSection0).scope();
  306. scope.$apply(function(){
  307. scope.do_load();
  308. });
  309. }
  310. }
  311. });
  312. })(mui);
  313. });