details.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. $(function(){
  2. // 视频播放插件
  3. zymedia('video',{autoplay: true});
  4. // 点击关注报名
  5. $('.lpname-title a').on('click',function(){
  6. $('.submit_area input[name="source"]').val('138');
  7. $('.input_text').attr('placeholder','输入手机号关注更多楼盘动态');
  8. $('.bmipc').val('立即关注');
  9. $(".lpapply2").animate({top:"160px"},300);
  10. $('.keep').show();
  11. })
  12. // 关闭按钮
  13. $('.lpapply2_gb').on('click',function(){
  14. shutFn();
  15. })
  16. function shutFn(){
  17. $(".lpapply2").animate({top:"-100%"},300);
  18. $('.keep').hide();
  19. $('.input_text').attr('placeholder','输入手机号码可免费查看全集');
  20. $('.submit_area input[name="source"]').val('138');
  21. $('.bmipc').val('查看视频');
  22. }
  23. // 处理报名窗口获取焦点后向上收
  24. $('.input_text').on('focus',function(){
  25. $(".lpapply2").css("top", "60px");
  26. $('.input_text').attr('placeholder','');
  27. $('.input_text').css('text-align','left');
  28. })
  29. // 获取楼盘ID
  30. var lpid = $('.zy_media').attr('data-id');
  31. $('.submit_area input[name="hid"]').val(lpid); //修改报名窗口的楼盘ID
  32. // 点赞特效 提交 id 及 1 代表点赞,2 代表取消
  33. var objo = new Object();
  34. $('.give').on('click',function(){
  35. var that = $(this);
  36. if(that.hasClass('oin')){
  37. that.removeClass('oin')
  38. }else {
  39. that.addClass('oin');
  40. }
  41. objo.id = that.attr('data-id')
  42. objo.type = that.attr('data-type')
  43. $.ajax({
  44. url:'/video/plays',
  45. dataType:"json",
  46. type:'GET',
  47. data:{id:objo.id,thumbs_up:objo.type},
  48. success:function(data){
  49. if(data.code == 200){
  50. console.log("提交成功!")
  51. that.attr('data-type',"1"); //这里的 1 是返回点赞成功或取消的值
  52. }
  53. }
  54. });
  55. })
  56. // 监听播放按钮,点击播放次数
  57. document.getElementsByClassName("poay")[0].addEventListener("click",
  58. function() {
  59. var id = $("#oid").attr('data-id');
  60. $.ajax({
  61. url:'/video/plays',
  62. dataType:"json",
  63. type:'GET',
  64. data:{id:id},
  65. success:function(data){
  66. }
  67. });
  68. })
  69. /*-------------------------------------------cookie方法封装--------------------------------------------------------------------*/
  70. var cookie = {
  71. //设置cookie方法
  72. set:function(key,val,time){
  73. var date=new Date(); //获取当前时间
  74. var expiresDays=time; //将date设置为n天以后的时间
  75. date.setTime(date.getTime()+expiresDays*24*3600*1000); //格式化为cookie识别的时间
  76. document.cookie=key + "=" + val +";expires="+date.toGMTString(); //设置cookie
  77. },
  78. //获取cookie方法
  79. get:function(key){
  80. /*获取cookie参数*/
  81. var getCookie = document.cookie.replace(/[ ]/g,""); //获取cookie,并且将获得的cookie格式化,去掉空格字符
  82. var arrCookie = getCookie.split(";") //将获得的cookie以"分号"为标识 将cookie保存到arrCookie的数组中
  83. var tips; //声明变量tips
  84. for(var i=0;i<arrCookie.length;i++){ //使用for循环查找cookie中的tips变量
  85. var arr=arrCookie[i].split("="); //将单条cookie用"等号"为标识,将单条cookie保存为arr数组
  86. if(key==arr[0]){ //匹配变量名称,其中arr[0]是指的cookie名称,如果该条变量为tips则执行判断语句中的赋值操作
  87. tips=arr[1]; //将cookie的值赋给变量tips
  88. break; //终止for循环遍历
  89. }
  90. }
  91. return tips;
  92. },
  93. //删除cookie方法
  94. delete:function(key){
  95. var date = new Date(); //获取当前时间
  96. date.setTime(date.getTime()-10000); //将date设置为过去的时间
  97. document.cookie = key + "=v; expires =" +date.toGMTString();//设置cookie
  98. }
  99. }
  100. // 存储、读取
  101. // cookie.set("ID"+lpid,"54165165",24);//设置为24天过期
  102. // console.log(cookie.get("ID"+lpid));//获取cookie
  103. // 当报名过后,在当前浏览器再次打开对应的视频,不需要再进行报名就直接进行观看。存储的cookie 值为 7天
  104. // cookie.delete("ID"+lpid)
  105. // console.log(coki)
  106. var coki = cookie.get("ID"+lpid);
  107. //当cookie 没有存储时,不进行修改;
  108. if(coki != undefined){
  109. $('#oid').attr('data-off',coki);
  110. }
  111. /*-------------------------------------------提交报名--------------------------------------------------------------------*/
  112. var PublicActions = {
  113. /* AjaxSend-----Ajax发送*/
  114. "AjaxSend" :function(e,fnEnd){
  115. var self = this, result;
  116. var urlstr = window.location.href;
  117. var searchurl = urlstr.substring(0,urlstr.indexOf('?')+1);
  118. // var matchdata = urlstr.match(/\.com(\/\w+)/)[1];
  119. // 获取
  120. var oid = e.CORID, //ID
  121. url = '/enroll/signup', //提交地址
  122. type = "POST", //提交方式
  123. async = true; //同步或异步
  124. //点击提交按钮触发事件
  125. $('.'+ oid).on('click',function(){
  126. var $than =$(this);
  127. $than.attr('disabled','disabled');
  128. var that = $(this).parents('form.submit_area'); //获取当前父层
  129. var data = {}, //定义一个对象
  130. ControlSwitch = true; //定义一个开关
  131. that.find('input').each(function () { //遍历父层中所有input
  132. var name = $(this).attr('name'); //当前input 中有name属性
  133. if(typeof name == 'string'){ //input 标签中有name属性才进行以下操作
  134. var txt = $(this).val(); //input 值
  135. var InputName = $(this).attr('name'); //属于 name 的值
  136. txt = self.FilterHTMLTag(txt); //去掉标签
  137. /* 验证电话码号 */
  138. if(InputName == 'mobile'){
  139. if(txt != ""){
  140. if(! self.PhoneVerification(txt)){ //验证电话号码
  141. // 特殊处理
  142. $('body .alert-container').remove(); //删除尾部添加弹窗
  143. self.hint('请输入正确的手机号码!');
  144. $than.removeAttr('disabled');
  145. ControlSwitch = false; //开关为false
  146. return false;
  147. }
  148. }else {
  149. $('body .alert-container').remove(); //删除尾部添加弹窗
  150. self.hint('请输入正确的手机号码!');
  151. $than.removeAttr('disabled');
  152. ControlSwitch = false; //开关为false
  153. return false;
  154. }
  155. }
  156. data[InputName]=txt;
  157. }
  158. })
  159. if(ControlSwitch){ //当电话号码验证不通过时,不执行以下操作
  160. $.ajax({
  161. type:type,
  162. url:url,
  163. data:data,
  164. async:async,
  165. dataType:'json',
  166. error : function(request) {
  167. // alert("未提交成功!");
  168. // 特殊处理
  169. $('body .alert-container').remove(); //删除尾部添加弹窗
  170. self.hint('未提交成功!');
  171. $than.removeAttr('disabled');
  172. },
  173. success : function(data) {
  174. $('body .alert-container').remove(); //删除尾部添加弹窗
  175. var msg = data.msg;
  176. if(data.data != null){
  177. msg = ReturnInfo(data.data);
  178. /*判断调方法时,是否传回调方法;有则执行,否执行默认方法*/
  179. fnEnd ? fnEnd() : self.hint(msg);
  180. $than.removeAttr('disabled');
  181. return ;
  182. }
  183. /*判断调方法时,是否传回调方法;有则执行,否执行默认方法*/
  184. fnEnd ? fnEnd() : self.hint(msg);
  185. // RemoveDiv(); //数据提交成功后关闭弹出层
  186. shutFn();
  187. $than.removeAttr('disabled');
  188. cookie.set("ID"+lpid,"0",7);//设置为7天过期
  189. $('#oid').attr('data-off',"0"); //报名成功后,修改属性值
  190. }
  191. });
  192. event.preventDefault(); //阻止form表单默认提交
  193. return false;
  194. }
  195. })
  196. },
  197. /*-----------------------------------------------------------------------------------------*/
  198. /* 过滤代码标签 */
  199. "FilterHTMLTag" : function(htmlStr){
  200. var msg = htmlStr.replace(/<\/?[^>]*>/g, ''); //去除HTML Tag
  201. return msg;
  202. },
  203. /*-----------------------------------------------------------------------------------------*/
  204. /* 电话验证 */
  205. "PhoneVerification" : function (tel) {
  206. var pattern = /(13\d|14[57]|15[^4,\D]|17[678]|18\d)\d{8}$|170[059]\d{7}$/,
  207. str = tel;
  208. return pattern.test(tel);
  209. },
  210. /*-----------------------------------------------------------------------------------------*/
  211. /* 提示方法优化 */
  212. "hint":function(txt){
  213. /*调用方法*/
  214. var M = {};
  215. if(M.dialog1){
  216. return M.dialog1.show();
  217. }
  218. M.dialog1 = jqueryAlert({
  219. 'content' : txt, //txt 提示内容
  220. 'closeTime' : 2000,
  221. })
  222. },
  223. }
  224. //报名验证及提交的调用
  225. PublicActions.AjaxSend(
  226. {
  227. CORID:'apply_bmipc', /*操作ID*/
  228. }
  229. );
  230. })