123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265 |
- $(function(){
- // 视频播放插件
- zymedia('video',{autoplay: true});
- // 点击关注报名
- $('.lpname-title a').on('click',function(){
- $('.submit_area input[name="source"]').val('138');
- $('.input_text').attr('placeholder','输入手机号关注更多楼盘动态');
- $('.bmipc').val('立即关注');
- $(".lpapply2").animate({top:"160px"},300);
- $('.keep').show();
- })
- // 关闭按钮
- $('.lpapply2_gb').on('click',function(){
- shutFn();
- })
- function shutFn(){
- $(".lpapply2").animate({top:"-100%"},300);
- $('.keep').hide();
- $('.input_text').attr('placeholder','输入手机号码可免费查看全集');
- $('.submit_area input[name="source"]').val('138');
- $('.bmipc').val('查看视频');
- }
- // 处理报名窗口获取焦点后向上收
- $('.input_text').on('focus',function(){
- $(".lpapply2").css("top", "60px");
- $('.input_text').attr('placeholder','');
- $('.input_text').css('text-align','left');
- })
- // 获取楼盘ID
- var lpid = $('.zy_media').attr('data-id');
- $('.submit_area input[name="hid"]').val(lpid); //修改报名窗口的楼盘ID
- // 点赞特效 提交 id 及 1 代表点赞,2 代表取消
- var objo = new Object();
- $('.give').on('click',function(){
- var that = $(this);
- if(that.hasClass('oin')){
- that.removeClass('oin')
- }else {
- that.addClass('oin');
- }
- objo.id = that.attr('data-id')
- objo.type = that.attr('data-type')
- $.ajax({
- url:'/video/plays',
- dataType:"json",
- type:'GET',
- data:{id:objo.id,thumbs_up:objo.type},
- success:function(data){
- if(data.code == 200){
- console.log("提交成功!")
- that.attr('data-type',"1"); //这里的 1 是返回点赞成功或取消的值
- }
- }
- });
- })
- // 监听播放按钮,点击播放次数
- document.getElementsByClassName("poay")[0].addEventListener("click",
- function() {
- var id = $("#oid").attr('data-id');
- $.ajax({
- url:'/video/plays',
- dataType:"json",
- type:'GET',
- data:{id:id},
- success:function(data){
- }
- });
- })
- /*-------------------------------------------cookie方法封装--------------------------------------------------------------------*/
- var cookie = {
- //设置cookie方法
- set:function(key,val,time){
- var date=new Date(); //获取当前时间
- var expiresDays=time; //将date设置为n天以后的时间
- date.setTime(date.getTime()+expiresDays*24*3600*1000); //格式化为cookie识别的时间
- document.cookie=key + "=" + val +";expires="+date.toGMTString(); //设置cookie
- },
- //获取cookie方法
- get:function(key){
- /*获取cookie参数*/
- var getCookie = document.cookie.replace(/[ ]/g,""); //获取cookie,并且将获得的cookie格式化,去掉空格字符
- var arrCookie = getCookie.split(";") //将获得的cookie以"分号"为标识 将cookie保存到arrCookie的数组中
- var tips; //声明变量tips
- for(var i=0;i<arrCookie.length;i++){ //使用for循环查找cookie中的tips变量
- var arr=arrCookie[i].split("="); //将单条cookie用"等号"为标识,将单条cookie保存为arr数组
- if(key==arr[0]){ //匹配变量名称,其中arr[0]是指的cookie名称,如果该条变量为tips则执行判断语句中的赋值操作
- tips=arr[1]; //将cookie的值赋给变量tips
- break; //终止for循环遍历
- }
- }
- return tips;
- },
- //删除cookie方法
- delete:function(key){
- var date = new Date(); //获取当前时间
- date.setTime(date.getTime()-10000); //将date设置为过去的时间
- document.cookie = key + "=v; expires =" +date.toGMTString();//设置cookie
- }
- }
- // 存储、读取
- // cookie.set("ID"+lpid,"54165165",24);//设置为24天过期
- // console.log(cookie.get("ID"+lpid));//获取cookie
- // 当报名过后,在当前浏览器再次打开对应的视频,不需要再进行报名就直接进行观看。存储的cookie 值为 7天
- // cookie.delete("ID"+lpid)
- // console.log(coki)
- var coki = cookie.get("ID"+lpid);
- //当cookie 没有存储时,不进行修改;
- if(coki != undefined){
- $('#oid').attr('data-off',coki);
- }
-
- /*-------------------------------------------提交报名--------------------------------------------------------------------*/
- var PublicActions = {
- /* AjaxSend-----Ajax发送*/
- "AjaxSend" :function(e,fnEnd){
- var self = this, result;
- var urlstr = window.location.href;
- var searchurl = urlstr.substring(0,urlstr.indexOf('?')+1);
- // var matchdata = urlstr.match(/\.com(\/\w+)/)[1];
- // 获取
- var oid = e.CORID, //ID
- url = '/enroll/signup', //提交地址
- type = "POST", //提交方式
- async = true; //同步或异步
- //点击提交按钮触发事件
- $('.'+ oid).on('click',function(){
- var $than =$(this);
- $than.attr('disabled','disabled');
- var that = $(this).parents('form.submit_area'); //获取当前父层
- var data = {}, //定义一个对象
- ControlSwitch = true; //定义一个开关
- that.find('input').each(function () { //遍历父层中所有input
- var name = $(this).attr('name'); //当前input 中有name属性
- if(typeof name == 'string'){ //input 标签中有name属性才进行以下操作
- var txt = $(this).val(); //input 值
- var InputName = $(this).attr('name'); //属于 name 的值
- txt = self.FilterHTMLTag(txt); //去掉标签
- /* 验证电话码号 */
- if(InputName == 'mobile'){
- if(txt != ""){
- if(! self.PhoneVerification(txt)){ //验证电话号码
- // 特殊处理
- $('body .alert-container').remove(); //删除尾部添加弹窗
- self.hint('请输入正确的手机号码!');
- $than.removeAttr('disabled');
- ControlSwitch = false; //开关为false
- return false;
- }
- }else {
- $('body .alert-container').remove(); //删除尾部添加弹窗
- self.hint('请输入正确的手机号码!');
-
- $than.removeAttr('disabled');
- ControlSwitch = false; //开关为false
- return false;
- }
- }
- data[InputName]=txt;
- }
- })
- if(ControlSwitch){ //当电话号码验证不通过时,不执行以下操作
- $.ajax({
- type:type,
- url:url,
- data:data,
- async:async,
- dataType:'json',
- error : function(request) {
- // alert("未提交成功!");
- // 特殊处理
- $('body .alert-container').remove(); //删除尾部添加弹窗
- self.hint('未提交成功!');
-
- $than.removeAttr('disabled');
- },
- success : function(data) {
- $('body .alert-container').remove(); //删除尾部添加弹窗
-
- var msg = data.msg;
- if(data.data != null){
- msg = ReturnInfo(data.data);
- /*判断调方法时,是否传回调方法;有则执行,否执行默认方法*/
- fnEnd ? fnEnd() : self.hint(msg);
- $than.removeAttr('disabled');
- return ;
- }
- /*判断调方法时,是否传回调方法;有则执行,否执行默认方法*/
- fnEnd ? fnEnd() : self.hint(msg);
-
- // RemoveDiv(); //数据提交成功后关闭弹出层
- shutFn();
- $than.removeAttr('disabled');
- cookie.set("ID"+lpid,"0",7);//设置为7天过期
- $('#oid').attr('data-off',"0"); //报名成功后,修改属性值
- }
- });
- event.preventDefault(); //阻止form表单默认提交
- return false;
- }
- })
- },
- /*-----------------------------------------------------------------------------------------*/
- /* 过滤代码标签 */
- "FilterHTMLTag" : function(htmlStr){
- var msg = htmlStr.replace(/<\/?[^>]*>/g, ''); //去除HTML Tag
- return msg;
- },
- /*-----------------------------------------------------------------------------------------*/
- /* 电话验证 */
- "PhoneVerification" : function (tel) {
- var pattern = /(13\d|14[57]|15[^4,\D]|17[678]|18\d)\d{8}$|170[059]\d{7}$/,
- str = tel;
- return pattern.test(tel);
- },
- /*-----------------------------------------------------------------------------------------*/
- /* 提示方法优化 */
- "hint":function(txt){
- /*调用方法*/
- var M = {};
- if(M.dialog1){
- return M.dialog1.show();
- }
- M.dialog1 = jqueryAlert({
- 'content' : txt, //txt 提示内容
- 'closeTime' : 2000,
- })
- },
- }
- //报名验证及提交的调用
- PublicActions.AjaxSend(
- {
- CORID:'apply_bmipc', /*操作ID*/
- }
- );
- })
|