[i].itemIndex; if (!isMini) actLink(`.headline-text${itmI}`, headlinelist[i]); } for (i in buttonlist) buttonFunc(buttonlist[i]); for (i in btntoplist) buttonFunc(btntoplist[i]); for (i in btnbottomlist) buttonFunc(btnbottomlist[i]); function buttonFunc (items) { if (!isMini) { if (items.clickType == 1) actLink(`.brick-button${items.itemIndex}`, items); } if (items.clickType == 2) { $(`.brick-button${items.itemIndex}`).on('click', function(e) { customerDialog(items) }) } } function customerDialog(items) { try { let qr_code = items.popup.qrcode; let lft = items.popup.x; if (!isMobile) { let window_width = $(window).width();//获取浏览器窗口宽度 let left = (window_width - 404) / 2; lft = lft + left; } let qrStyl = { "left": lft / 100 + 'rem', "top": items.popup.y / 100 + 'rem', "width": items.popup.width / 100 + 'rem', "height": items.popup.height / 100 + 'rem' }; if (qr_code) { qrStyl = { "left": lft / 100 + 'rem', "top": items.popup.y / 100 + 'rem', }; } $(".ak_button").attr("data-left", items.popup.x); $(".ak_button .wx-content").css(qrStyl); $(".ak_button .wx-content").addClass(qr_code ? 'qr_akcont' : 'akcont'); $(".ak_button .wx-content .bgimg").attr("src", items.popup.srcs.imgurl); $(".ak_button .wx-content .qrimg").css("display",qr_code ? "block" : "none"); $('.ak_button').fadeIn(300); } catch (error) { console.log(error) } } /* 阅读 */ for (i in readingslist) { let itmI = readingslist[i].itemIndex; $('.zankan' + itmI).on('click', function () { let color = $(this).css('color'); let eleh = $(this).children('.see'); if (color == '#576b95' || color == 'rgb(87, 107, 149)') { $(this).css('color', '#ffc300'); eleh.text(parseInt(eleh.text()) + 1) } else { $(this).css('color', '#576b95'); eleh.text(parseInt(eleh.text()) - 1) } }); } /* 关闭按钮弹框 */ $('.ak_button').on('click', function (evt) { var evt = event.srcElement ? event.srcElement : event.target; if (evt.className == 'alert-bg' || evt.className == 'errClose') $(this).fadeOut(300); }); let citysJ = window.cityJson || [] let city_maps = [] let citylist = JSON.parse(JSON.stringify(citysJ)) citylist.forEach(v => { let maps_chl = [] v.children.forEach(item => { if (item.children) delete item.children maps_chl.push(item) }) v.children = maps_chl city_maps.push(v) }) for (i in formlist) { let itmI = formlist[i].itemIndex; let fobj = formlist[i]; if (sessionStorage.getItem('formEnterPage') == (fobj.name + itmI)) { subtSuccessContent(fobj); } $(".allowIcon" + itmI).on('click', function () { if (fobj.form_fields.allow) { fobj.form_fields.allow = false $(this).removeClass('selected') // $('.submitbtn'+itmI).addClass('disagree') } else { fobj.form_fields.allow = true $(this).addClass('selected') // $('.submitbtn'+itmI).removeClass('disagree') } }); $("#brick" + itmI).on('click', function(event) { var evt = event.srcElement ? event.srcElement : event.target; if (evt.className.indexOf('subtTustomer') >= 0 || evt.className.indexOf('dianjis') >= 0) { customerDialog(fobj); } }); $('.agrLink' + itmI).on('click', function () { $('.default-modal').fadeIn(300); }); $(`.js_dialog_form${itmI}`).on('click', function(event) { var evt = event.srcElement ? event.srcElement : event.target; if(evt.className == 'weui-mask' || evt.className.indexOf('el-icon-close') >= 0) $(this).fadeOut(200); }); $(`input[name=username${itmI}]`).on('input', function () { let ut = $(`.error-username${itmI}`).css('display'); if ($(this).val() && ut == 'block') { $(`.error-username${itmI}`).css('display', 'none'); } }) $(`input[name=phone${itmI}]`).on('input', function () { let reg = /^1[3456789]\d{9}$/; let ut = $(`.error-phone${itmI}`).css('display'); if (reg.test($(this).val()) && ut == 'block') { $(`.error-phone${itmI}`).css('display', 'none'); } }) if (fobj.form_fields.elelist && fobj.form_fields.elelist.length) { fobj.form_fields.elelist.forEach((v, i) => { i = parseInt(i) + 1 if ('cityOne' == v.key || 'cityTwo' == v.key) { let list = 'cityTwo' == v.key ? citysJ : city_maps; $(`#${v.key}${itmI}${i}`).zdCascader({ data: list }); } if ('inputNumber' == v.key) { $(`input[name=${v.key}${itmI}${i}]`).val(v.values) $(`input[name=${v.key}${itmI}${i}]`).on('input', function (e) { let vls = $(this).val() if (vls.length > 10) $(this).val(vls.slice(0, 10)) }) } }) } $('.submitbtn' + itmI).on('click', function () { if ($(this).attr('data-type') == 'argee') { if (fobj.form_fields.allow) { fobj.form_fields.allow = false $(".allowIcon" + itmI).removeClass('selected') } else { fobj.form_fields.allow = true $(".allowIcon" + itmI).addClass('selected') } $(`.js_dialog_form${itmI}`).fadeOut(0); } let isVerify = fobj.form_fields.id && fobj.form_fields.elelist && fobj.form_fields.elelist.length if (isVerify) { fobj.form_fields.elelist.forEach((v, i) => { i = i + 1; v.form_value = ""; if (['username', 'phone', 'email', 'text', 'inputNumber', 'date'].includes(v.key)) { v.form_value = $(`input[name=${v.key}${itmI}${i}]`).val(); } if (['gender'].includes(v.key)) { if ($(`#gender1${itmI}${i}`)[0].checked) v.form_value = $(`#gender1${itmI}${i}`).val(); if ($(`#gender2${itmI}${i}`)[0].checked) v.form_value = $(`#gender2${itmI}${i}`).val(); } if (['textarea'].includes(v.key)) { v.form_value = $(`textarea[name=${v.key}${itmI}${i}]`).val(); } if (['select'].includes(v.key)) { v.form_value = $(`#form_select${itmI}${i}`).val(); let obj = v.subs.find(t => v.form_value == t.kId); if (obj) v.form_vlu = obj.title; } if (['radio'].includes(v.key)) { v.subs.forEach((r, ri) => { ri = parseInt(ri) + 1; if ($(`#radios${itmI}${i}${ri}`)[0] && $(`#radios${itmI}${i}${ri}`)[0].checked) { v.form_value = $(`#radios${itmI}${i}${ri}`).val(); v.form_vlu = r.title; } }) } if (['checkout'].includes(v.key)) { v.form_value = []; v.form_vlu = []; v.subs.forEach((r, ri) => { ri = parseInt(ri) + 1; if ($(`#checkbox${itmI}${i}${ri}`)[0] && $(`#checkbox${itmI}${i}${ri}`)[0].checked) { v.form_value.push($(`#checkbox${itmI}${i}${ri}`).val()); v.form_vlu.push(r.title); } }) } if (['cityOne', 'cityTwo'].includes(v.key)) { v.form_value = $(`#${v.key}${itmI}${i}`).val(); } // getCheckedNodes let vals = null if (['checkout'].includes(v.key)) { if (v.must) vals = v.form_value.length ? 'none' : 'block'; } else if ('phone' == v.key) { let reg = /^1[3456789]\d{9}$/; let txt = v.title + '格式不正确'; if (v.must && !v.form_value) { txt = v.title + '不能为空'; vals = 'block'; } else { vals = reg.test(v.form_value) || !v.form_value ? 'none' : 'block'; } $(`.error${v.key}${itmI}${i}`).text(txt); } else if ('email' == v.key) { let reg = /^[A-Za-z0-9一-龥]+@[\w-]+(\.[\w-]+)+$/; let txt = v.title + '格式不正确'; if (v.must && !v.form_value) { txt = v.title + '不能为空'; vals = 'block'; } else { vals = reg.test(v.form_value) || !v.form_value ? 'none' : 'block'; } $(`.error${v.key}${itmI}${i}`).text(txt); // if (v.must) vals = reg.test(v.form_value) ? 'none' : 'block' } else { if (v.must) vals = v.form_value ? 'none' : 'block'; } $(`.error${v.key}${itmI}${i}`).css('display', vals) if (['phone', 'email'].includes(v.key)) { v.verify = vals == 'none' || (!v.must && !v.form_value) ? true : false; } else { v.verify = vals == 'none' || !v.must ? true : false; } }) } let hg = $(`#brick${itmI} .absolute-frame`).innerHeight(); $(`#brick${itmI} .stream-frame`).css("height", hg / 100 + 'rem'); // if (fobj.form_fields.allow) { let custb = window.jQuery.custb || {} let params = { t: sign, customer_id: custb.id, type: 4, id: log_id, token: custb.token } if (isVerify) { let everyFlag = fobj.form_fields.elelist.every(v => v.verify); if (!everyFlag) return; let username = fobj.form_fields.elelist.find(v => 'username' == v.key); let phone = fobj.form_fields.elelist.find(v => 'phone' == v.key); params.name = username ? username.form_value : null; params.phone = phone ? phone.form_value : null; params.extra_data = fobj.form_fields.elelist; } else { let reg = /^1[3456789]\d{9}$/; let username = $(`input[name=username${itmI}]`).val(); let phone = $(`input[name=phone${itmI}]`).val(); let uflag = username ? true : false; let pflag = reg.test(phone) ? true : false; if (username) { $(`.error-username${itmI}`).css('display', 'none'); } else { $(`.error-username${itmI}`).css('display', 'block'); } if (reg.test(phone)) { $(`.error-phone${itmI}`).css('display', 'none'); } else { $(`.error-phone${itmI}`).css('display', 'block'); } if (!(uflag && pflag)) return; params.name = username; params.phone = phone; } if (!fobj.form_fields.allow) { if ($($(".js_dialog_form"+itmI)).attr('data-type')) { $(".js_dialog_form"+itmI).fadeIn(200); } else { alert('请阅读并同意《个人信息保护声明》'); } return; } if (fobj.sms_fields && fobj.sms_fields.id && fobj.sms_fields.isOpen && params.phone) { console.log('短信验证码 submit') ajaxH5SendMsg(params, fobj, 1); } else { console.log('正常') ajaxForm(params, fobj) } // } }); } function ajaxH5SendMsg(params, fobj, type) { let smsLoading = true; let custb = window.jQuery.custb || {}; let data = { token: custb.token || null, phone: params.phone, sms_config_id: fobj.sms_fields.id }; if (smsLoading) { smsLoading = false; $.post(baseUrl + '/h5SendMsg', data, function(resp) { if (resp.code == 200) { verifyCountDown(); if (type == 1) { sessionStorage.setItem('form_' + sign, JSON.stringify(fobj)); sessionStorage.setItem('form_params_' + sign, JSON.stringify(params)); let phone = params.phone.replace(/(\d{3})\d*(\d{4})/, "$1****$2"); $('.js_dialog_verifyPhone .desc2').text(`已发短信至${phone},请注意查收`); $('.verifyPhone_box .countdown').css({color: '#BFC2CC'}); $('.js_dialog_verifyPhone').fadeIn(200); } } else { alert(resp.msg); } smsLoading = true; }).error(function () { smsLoading = true; }) } } function ajaxForm(params, fobj) { let url = requestUrl + '/add_form'; let isVerify = fobj.form_fields.id && fobj.form_fields.elelist && fobj.form_fields.elelist.length let itmI = fobj.itemIndex; $.post(url, params, function (resp) { if (resp && resp.code == 200) { $('.alert-text-wrap .alert-text').text(fobj.form_fields.tipValue); $('.alert-icon').removeClass('error alert-icon-error'); $('.alert-icon').addClass('success alert-icon-success'); // $('.submitbtn' + itmI).css({'background-color': '#e2e2e2', color: '#999', 'pointer-events': 'none'}); if (params.code) { $('.js_dialog_verifyPhone').fadeOut(200); initVerifyTimer(); } if(fobj.autoplay){ if (fobj.clickType == 2) { customerDialog(fobj); } else { if (fobj.link.type) $('.alert-btn').attr('data-type', fobj.link.type); if (fobj.link.url) $('.alert-btn').attr('data-url', fobj.link.url); if (fobj.link.type || fobj.link.url) { setTimeout(function() { $('.alert-wrap').fadeOut(300); if (fobj.link.type == 'page' && fobj.link.url) window.location.href = fobj.link.url if (fobj.link.type == 'applet') reqFormat(null, 'jump') }, 1000) } $('.alert-wrap').fadeIn(300); } } else { $('.alert-wrap').fadeIn(300); } if (isVerify) { } else { $(`input[name=username${itmI}]`).val(''); $(`input[name=phone${itmI}]`).val(''); } sessionStorage.setItem('formEnterPage', fobj.name + fobj.itemIndex); subtSuccessContent(fobj); } else if (resp && resp.code == 2000) { $('.alert-text-wrap .alert-text').text(resp.msg); $('.alert-icon').removeClass('success alert-icon-success'); $('.alert-icon').addClass('error alert-icon-error'); $('.alert-wrap').fadeIn(300); } else if (resp && resp.code == 402) { $('.js_dialog_verifyPhone .verify_err span').html(resp.msg) $('.js_dialog_verifyPhone .verify_err').css('display', 'flex'); } else { let classname = $('.alert-icon').attr('class') if (classname.includes('alert-icon-success')) { $('.alert-icon').removeClass('success alert-icon-success'); $('.alert-icon').addClass('error alert-icon-error'); } $('.alert-text-wrap .alert-text').text('提交信息失败,请重试!'); $('.alert-wrap').fadeIn(300); } }).error(function () { let classname = $('.alert-icon').attr('class') if (classname.includes('alert-icon-success')) { $('.alert-icon').removeClass('success alert-icon-success'); $('.alert-icon').addClass('error alert-icon-error'); } $('.alert-text-wrap .alert-text').text('提交信息失败,请重试!'); $('.alert-wrap').fadeIn(300); }) } function initVerifyTimer() { let $input = $(".verifyPhone_box .verify_num input"); console.log($input, '34242343') $input.each(function() { $(this).val(''); }); $('.verifyPhone_box .ipt-real-phone').val(''); $('.ipt-active-phone').css('left', '0rem'); clearInterval(verifyTimer); $('.verifyPhone_box .countdown .countdown_text').html(`(60s后)重新获取`); $('.js_dialog_verifyPhone .verify_err').css('display', 'none'); } if (formlist.length) { $('.js_dialog_verifyPhone').on('click', function(event) { let evt = event.srcElement || event.target if(evt.className == 'close21') { $(this).fadeOut(200); initVerifyTimer(); } if (evt.className == 'countdown_text' && evt.innerText == '重新获取验证码') { let fobj = sessionStorage.getItem('form_' + sign) ? JSON.parse(sessionStorage.getItem('form_' + sign)) : {}, params = sessionStorage.getItem('form_params_' + sign) ? JSON.parse(sessionStorage.getItem('form_params_' + sign)) : {}; ajaxH5SendMsg(params, fobj); } }); $('.verifyPhone_box .ipt-real-phone').on('input', function() { let $input = $(".verifyPhone_box .verify_num input"); let $val = $(this).val() if (!$val) { $('.ipt-active-phone').css('left', '0rem'); } if (/^[0-9]*$/g.test($val)) { var pwd = $val.trim(); for (var i = 0, len = pwd.length; i < len; i++) { $input.eq(i).val(pwd[i]); if ($input.eq(i).next().length) { let left = (i + 1) * 45 / 100 $('.ipt-active-phone').css('left', left + 'rem'); } } $input.each(function() { var index = $(this).index(); if (index >= len) $(this).val(""); let display = $('.js_dialog_verifyPhone .verify_err').css('display'); if (display == 'flex') $('.js_dialog_verifyPhone .verify_err').css('display', 'none'); }); if (len == 6) { $('.ipt-active-phone').css('left', (((i - 1) * 45 + 6) / 100) + 'rem'); try { //执行其他操作 // console.log('输入完整,执行操作'); let pwd = $val.trim(), fobj = sessionStorage.getItem('form_' + sign) ? JSON.parse(sessionStorage.getItem('form_' + sign)) : {}, params = sessionStorage.getItem('form_params_' + sign) ? JSON.parse(sessionStorage.getItem('form_params_' + sign)) : {}; if (pwd) params.code = pwd; if (fobj.name && params.code) ajaxForm(params, fobj); if (document.activeElement instanceof HTMLElement) document.activeElement.blur(); } catch (error) { } } } else { var arr = $val.match(/\d/g); $(this).val($val.slice(0, $val.lastIndexOf(arr[arr.length-1])+1)); } }) function verifyCountDown () { let second = 60; verifyTimer = setInterval(() => { second--; $('.verifyPhone_box .countdown .countdown_text').html(`(${second}s后)重新获取`); if (second == 0) { clearInterval(verifyTimer); $('.verifyPhone_box .countdown').css({color: '#141414'}); $('.verifyPhone_box .countdown .countdown_text').html('重新获取验证码'); } }, 1000); } } function subtSuccessContent(items) { let flag = items.autoplay && items.clickType == 2 let html = `
提交成功
您的信息已经成功提交!
${ flag ? `` : ''}
` $('#brick' + items.itemIndex).html(html); } for (i in commentslist) { let itmI = commentslist[i].itemIndex; let oflag = commentslist[i].currStyleClass == 'style-one'; let tflag = commentslist[i].currStyleClass == 'style-two'; let commentlist = commentslist[i].commentlist $(".linkes" + itmI).on('click', function () { let index = $(this).attr('data-linkIndex') || 1; index = parseInt(index) - 1; let list = commentlist[index]; if (!list.isZan) { list.zanInputNum += 1; list.isZan = true; if (oflag) $(this).children('.zan').addClass('icon-dianzanxuanzhong').removeClass('icon-dianzan'); if (tflag) $(this).css('color', '#f56c6c'); } else { list.zanInputNum -= 1; list.isZan = false; if (oflag) $(this).children('.zan').addClass('icon-dianzan').removeClass('icon-dianzanxuanzhong'); if (tflag) $(this).css('color', '#595959'); } let result = null if (oflag) result = list.zanInputNum < 1000 ? list.zanInputNum + '' : parseFloat((list.zanInputNum / 1000).toString().match(/^\d+(?:\.\d{0,1})?/)) + 'K'; if (tflag) result = list.zanInputNum; $(this).children('.lnk').text(result); }) for (t in commentlist) { let n=parseInt(t)+1; let replylist = commentlist[t] && commentlist[t].replylist || []; $(".likesp" + itmI + n).on('click', function () { let index = $(this).attr('data-linkIndex') || 1; index = parseInt(index) - 1; let list = replylist[index]; if (!list.isZan) { list.zanInputNum += 1; list.isZan = true; if (oflag) $(this).children('.zan').addClass('icon-dianzanxuanzhong').removeClass('icon-dianzan'); if (tflag) $(this).css('color', '#f56c6c'); } else { list.zanInputNum -= 1; list.isZan = false; if (oflag) $(this).children('.zan').addClass('icon-dianzan').removeClass('icon-dianzanxuanzhong'); if (tflag) $(this).css('color', '#595959'); } let result = null if (oflag) result = list.zanInputNum < 1000 ? list.zanInputNum + '' : parseFloat((list.zanInputNum / 1000).toString().match(/^\d+(?:\.\d{0,1})?/)) + 'K'; if (tflag) result = list.zanInputNum; $(this).children('.lnk').text(result); }) } } function reqFormat(type, jump) { if (wxMiniUrl) window.location.href = wxMiniUrl; isEnbleCopy = false; let custb = window.jQuery.custb || {} if (custb.configure_type == 4) { if (isWeixin && type == 1) { $('.weixqr').fadeIn(300); return; } let elelist = document.querySelectorAll('.wechat_number') copyw(elelist[0]) } let t = custb.configure_type != 4 ? jump : null; setTimeout(function() { straght(); backpass(1, t); save(); }, 16.6666666) } function cutUrl (url) { if (!url) return ''; if (url.indexOf('http://') == 0) return url.slice(5) if (url.indexOf('https://') == 0) return url.slice(6) } /* 关闭协议弹框 表单点击 */ $('.default-close-btn').on('click', function (e) { $('.default-modal').fadeOut(300); e.stopPropagation(); }); $('.privacy_box').on('click', function (event) { var evt = event.srcElement ? event.srcElement : event.target; if (evt.className == 'dialog-wrapper') $('.default-modal').fadeOut(300); }); /* 打开立即咨询弹框 */ $('.zxunbtn').on('click', function () { if (isWeixin) { $('.weixqr').fadeIn(300); } else { reqFormat(null, 'jump') } }); /* 关闭立即咨询弹框 */ $('.weixqr').on('click', function (evt) { var evt = event.srcElement ? event.srcElement : event.target; if (evt.className == 'alert-bg') $(this).fadeOut(300); }); $('.inputErrClose').on('click', function (evt) { $('.dialog_input').css('display', 'none'); }); $('.dialog_verfiy').on('click', function (event) { let evt = event.srcElement ? event.srcElement : event.target; if (['verfiyErrClose', 'verfiy-cancel'].includes(evt.className)) { $(this).css('display', 'none'); $("#captcha_code").val(''); $('.dialog_verfiy').removeAttr('data-verfiycls'); } if (evt.className == 'verfiy-primary') { let verify_timer = null; let verify_num = 60; let code = $("#captcha_code").val(); let formwp = $(this).attr('data-verfiycls'); let ele = $(`.${formwp} .phone-verify__btn`); if (!code) { alert('请输入验证码'); return; } ele.attr('disabled', true); ele.text(`重新获取(${verify_num})`); verify_timer = setInterval(function () { if (verify_num == 0) { ele.text('获取验证码'); ele.attr('disabled', false); clearInterval(verify_timer); verify_num = 60; } else { verify_num--; ele.text(`重新获取(${verify_num})`); } }, 1000); let phone = $(`.${formwp} input[name="store_phone"]`).val(); let url = baseUrl + '/admin/is_login/sendMsg'; let params = {type: 1, phone, code }; $.ajax({type: 'POST',url, data: params, dataType: 'json', complete: function(resp) { if (resp.status == 200 && resp.responseJSON && resp.responseJSON.code == 200) { $('.dialog_verfiy').css('display', 'none'); $("#captcha_code").val(''); $('.dialog_verfiy').removeAttr('data-verfiycls'); } else { alert('验证码错误'); ele.text('获取验证码'); ele.attr('disabled', false); clearInterval(verify_timer); verify_num = 60; } } }) } }); if (isIOS) { dialogScroll('.dialog_input'); dialogScroll('dialog_verfiy'); function dialogScroll (el) { let isReset; $(el).focusout(()=>{ isReset = true; setTimeout(() => { if (isReset) window.scroll(0, 0); }, 100); }).focusin(()=>{ isReset = false; }) } } /* 表单提交弹框 */ $('.alert-btn').on('click', function (e) { $('.alert-wrap').fadeOut(300); let type = $(this).attr('data-type'); let url = $(this).attr('data-url'); if (type== 'page' && url) window.location.href = url if (type == 'applet') reqFormat(null, 'jump') e.stopPropagation(); }) $('.alert-wrap').on('click', function (event) { var evt = event.srcElement ? event.srcElement : event.target; if (evt.className.includes('alert-mask')) $(this).fadeOut(300); }) // 链接跳转 function actLink(docu, item, name) { if (item.link && item.link.type == 'discern' && isWeixin ) { // longpress(docu) } else { $(docu).on('click', function () { if (name == "NgCarousel") { if (item.linksType == 'page' && item.linksUrl) window.location.href = item.linksUrl if (item.linksType == 'applet') { reqFormat(null, 'jump') } } else { if (item.link.type == 'page' && item.link.url) window.location.href = item.link.url if (item.link.type == 'applet') { reqFormat(name, 'jump') } } }) } } for (i in messageslist) { autoPlay(messageslist[i]) } function autoPlay(tl) { let that = this; let dm_json = tl.messageList; let dm_index = 0; let msgobj = {}; if (typeof danmuTimer != 'undefined') clearInterval(danmuTimer) danmuTimer = setInterval(() => { msgobj = dm_json[dm_index] if (!(msgobj && msgobj.nickname)) return; if (msgobj.nickname) msgobj.isSelected = true if (dm_index == dm_json.length - 1) { dm_index = 0; } else { dm_index++; } let html = `
${msgobj.nickname} ${msgobj.time} ${msgobj.typeName}添加了微信
`; $(`.message-holder${tl.itemIndex}`).html(html) setTimeout(() => { if (msgobj.nickname) { msgobj.isSelected = false if ($(`.message-holder${tl.itemIndex}`)) $(`#njmessage${tl.itemIndex}`).remove() msgobj = {} } }, 2000); }, 5000); } for (i in videolist) { let itmI = videolist[i].itemIndex; let list = videolist[i]; $('.vjsPlay'+itmI).on('click', function() { $(`.videoPreview${itmI}`).removeAttr('style'); $(`.videoPreview${itmI} .nostart`).remove(); $(`.videoPreview${itmI}`).append(``); initVideo("#videojs"+itmI, list.video_fields, list.srcs); }) if (list.video_fields.autoPlay) { let ch = document.body.offsetHeight; let docu = $(`.videoPreview${itmI}`); $(window).on('scroll', throttle(function(e) { let t = $(`.videoPreview${itmI} .vjs-fluid`).length; if (t) return; initDDVideo (itmI, list) })) initDDVideo (itmI, list) } } function initDDVideo (itmI, list) { let a = $("#brick"+itmI).offset().top; let flag = a >= $(window).scrollTop() && a < ($(window).scrollTop() + $(window).height()); if (flag) { $(`.videoPreview${itmI}`).removeAttr('style'); $(`.videoPreview${itmI} .nostart`).remove(); $(`.videoPreview${itmI}`).append(``); initVideo("#videojs"+itmI, list.video_fields, list.srcs); } } var recordVideoFlag = true; for (i in videogrouplist) { let itmI = videogrouplist[i].itemIndex; let list = videogrouplist[i]; let mySwiper = new Swiper(".mySwiper"+itmI, { autoplay: false, loop: false, observer:true, //监听 autoplayDisableOnInteraction : false,// 这样,即使我们滑动之后, 定时器也不会被清除 pagination: { el: ".swiper-group-pagination"+itmI, }, on: { slideChangeTransitionStart: function(swiper,event){ let index = this.realIndex + 1 if ($(`#videoGroupjs${itmI}${this.realIndex}`)[0]) { let vjs = videojs('videoGroupjs'+itmI+this.realIndex) vjs.pause() } }, touchEnd: function(swiper,event){ let index = this.realIndex + 1 if ($(`#videoGroupjs${itmI}${index}`)[0]) { let vjs = videojs('videoGroupjs'+itmI+index) recordVideoFlag = !recordVideoFlag; recordVideoFlag ? vjs.play() : vjs.pause() } }, tap: function(swiper,event){ let index = this.realIndex + 1 let docu = `.mySwiper${itmI} .swiper-slide-active .videoPreview${itmI}${index}`; let slt = list.videoList[this.realIndex] || {} if ($(`.videoPreview${itmI}${index} .vjs-fluid`).length) { // initVideo('#videoGroupjs'+itmI+this.realIndex, list.video_fields, slt); let vjs = videojs('videoGroupjs'+itmI+index); recordVideoFlag ? vjs.play() : vjs.pause() return; } $(docu).removeAttr('style'); $(`${docu} .nostart`).remove(); $(docu).append(``); initVideo('#videoGroupjs'+itmI+index, list.video_fields, slt); }, }, }); if (list.video_fields.autoPlay) { let docu = `.mySwiper${itmI} .swiper-slide-active .videoPreview${itmI}1`; let ch = document.body.offsetHeight; $(window).on('scroll', throttle(function(e) { let t = $(`.videoPreview${itmI}1 .vjs-fluid`).length; if (t) return; initDomVideo(docu, itmI, list, '#videoGroupjs'+itmI+'1') })) initDomVideo(docu, itmI, list, '#videoGroupjs'+itmI+'1') } } function initDomVideo (docu, itmI, list, vDoc) { let a = $("#brick"+itmI).offset().top; let flag = a >= $(window).scrollTop() && a < ($(window).scrollTop() + $(window).height()); if (flag) { $(docu).removeAttr('style'); $(`${docu} .nostart`).remove(); $(docu).append(``); initVideo(vDoc, list.video_fields, list.videoList[0]); } } function initVideo(dom, video_fields, data) { let vjs = videojs(document.querySelector(dom), { autoplay: false, // 如果true,浏览器准备好时开始回放。 muted: video_fields.isMuted, // 默认情况下将会消除任何音频。 loop: video_fields.loop, // 导致视频一结束就重新开始。 preload: "none", // 建议浏览器在