').text(j))
$li.css('top', -(parseInt(group.digits.charAt(i)) * height) + 'px')
$element.append($li)
}
if (group.unit) $element.append($('
' + group.unit + ''))
}
})
}
// 主线程修改 - 最简单方案
var isFirstCall = true
this.updateValue = function (value) {
if (value !== undefined && value !== null) {
var numericValue = Math.round(parseInt(value) || 0)
if (typeof value === 'string' && isNaN(value)) {
$element.empty().text(value)
currentDisplayValue = value
} else {
if (isFirstCall) {
// 首次调用:直接显示
localStorage.setItem(this.attr("id"), numericValue)
updateDisplay(numericValue)
currentDisplayValue = numericValue
isFirstCall = false
// 同步值到 Worker(但不需要动画)
if (worker) {
worker.postMessage({
type: 'SYNC_VALUE',
payload: numericValue
})
}
} else {
// 后续调用:正常动画
if (worker) {
worker.postMessage({
type: 'START_ANIMATION',
payload: numericValue
})
} else {
updateDisplay(numericValue)
currentDisplayValue = numericValue
}
}
}
}
// 窗口大小变化
var resizeTimer
$(window).on('resize', function () {
clearTimeout(resizeTimer)
resizeTimer = setTimeout(function () {
digitHeight = null
// 使用 currentDisplayValue 而不是 settings.initialValue
updateDisplay(currentDisplayValue)
}, 50)
})
return this
}
// 返回当前值而不是初始值
this.getValue = function () {
return currentDisplayValue
}
this.setAnimationConfig = function (config) {
if (worker) {
worker.postMessage({
type: 'SET_CONFIG',
payload: config,
})
}
return this
}
this.resetFirstLoad = function () {
isFirstLoad = true
if (worker) {
worker.postMessage({
type: 'SET_FIRST_LOAD',
payload: true
})
}
return this
}
this.clearQueue = function () {
if (worker) {
worker.postMessage({ type: 'CLEAR_TIMER' })
}
return this
}
this.isAnimating = function () {
return false
}
this.destroy = function () {
if (worker) {
worker.terminate()
worker = null
}
$element.empty()
$(window).off('resize')
}
return this
},
})
})(jQuery)
$(function () {
// 接口请求开始
let getUrl = 'https://www.yinwang.com/external/uiapi/ads/v1/queryInit'
let pilotPageContainer = $('
')
let mileagePageContainer = $('
')
let avoidPageContainer = $('
')
let pilotDefaultValue = 0
let mileageDefaultValue = 0
let avoidDefaultValue = 0
$('#numberContainer1').append(pilotPageContainer)
$('#numberContainer2').append(mileagePageContainer)
$('#numberContainer3').append(avoidPageContainer)
let pilotInstance = pilotPageContainer.runNum({
initialValue: 0
})
let mileageInstance = mileagePageContainer.runNum({
initialValue: 0
})
let avoidInstance = avoidPageContainer.runNum({
initialValue: 0
})
let isSuccess = true
/**
* 判断值是否为非空、大于0的整数(即正整数)
* @param {*} value - 待判断的值
* @returns {boolean} - 如果是正整数返回 true,否则返回 false
*/
function isPositiveInteger(value) {
// 1. 类型检查:必须是 number 类型
if (typeof value !== 'number') {
return false
}
// 2. 有效性检查:排除 NaN 和 Infinity
if (!isFinite(value)) {
return false
}
// 3. 整数检查:必须是整数
if (!Number.isInteger(value)) {
return false
}
// 4. 范围检查:必须大于 0
if (value <= 0) {
return false
}
return true
}
// 接口请求
function fetchData() {
$.ajax({
url: getUrl,
type: 'GET',
dataType: 'json',
success: function (res) {
if (res.code == '200') {
if (isSuccess) {
var maxPilot = parseInt(res.data[0].pilot.value)
var minPilot = parseInt(res.data[1].pilot.value)
var maxMileage = parseInt(res.data[0].mileage.value)
var minMileage = parseInt(res.data[1].mileage.value)
var maxAvoid = parseInt(res.data[0].avoid.value)
var minAvoid = parseInt(res.data[1].avoid.value)
}
else {
var secondPilotData = parseInt(res.data.pilot.value)
var secondMileageData = parseInt(res.data.mileage.value)
var secondAvoidData = parseInt(res.data.avoid.value)
}
var localPilotValue = localStorage.getItem("pilot") === null ? 0 : parseInt(localStorage.getItem("pilot"))
var localMileageValue = localStorage.getItem("mileage") === null ? 0 : parseInt(localStorage.getItem("mileage"))
var localAvoidValue = localStorage.getItem("avoid") === null ? 0 : parseInt(localStorage.getItem("avoid"))
if (isPositiveInteger(maxPilot) && maxPilot >= localPilotValue && isPositiveInteger(minPilot) && isPositiveInteger(maxMileage) && maxMileage >= localMileageValue && isPositiveInteger(minMileage) && isPositiveInteger(maxAvoid) && maxAvoid >= localAvoidValue && isPositiveInteger(minAvoid)) {
isSuccess = false
$('.ias-safety-setion1').addClass('on')
getUrl = 'https://www.yinwang.com/external/uiapi/ads/v1/query'
pilotDefaultValue = maxPilot
var remotePilotValue = minPilot
pilotInstance.updateValue(localPilotValue > remotePilotValue ? localPilotValue : remotePilotValue)
mileageDefaultValue = maxMileage
var remoteMileageValue = minMileage
mileageInstance.updateValue(localMileageValue > remoteMileageValue ? localMileageValue : remoteMileageValue)
avoidDefaultValue = maxAvoid
var remoteAvoidValue = minAvoid
avoidInstance.updateValue(localAvoidValue > remoteAvoidValue ? localAvoidValue : remoteAvoidValue)
setTimeout(function () {
pilotInstance.updateValue(maxPilot)
mileageInstance.updateValue(maxMileage)
avoidInstance.updateValue(maxAvoid)
}, 10)
} else if (isPositiveInteger(secondPilotData) && isPositiveInteger(secondMileageData) && isPositiveInteger(secondAvoidData)) {
if (secondPilotData >= pilotDefaultValue) {
pilotDefaultValue = secondPilotData
pilotInstance.updateValue(secondPilotData)
} else {
if (pilotDefaultValue == 0) {
$('.ias-safety-setion1').removeClass('on')
} else {
pilotInstance.updateValue(pilotDefaultValue)
}
}
if (secondMileageData >= mileageDefaultValue) {
mileageDefaultValue = secondMileageData
mileageInstance.updateValue(secondMileageData)
} else {
if (mileageDefaultValue == 0) {
$('.ias-safety-setion1').removeClass('on')
} else {
mileageInstance.updateValue(mileageDefaultValue)
}
}
if (secondAvoidData >= avoidDefaultValue) {
avoidDefaultValue = secondAvoidData
avoidInstance.updateValue(secondAvoidData)
} else {
if (avoidDefaultValue == 0) {
$('.ias-safety-setion1').removeClass('on')
} else {
avoidInstance.updateValue(avoidDefaultValue)
}
}
} else {
if (pilotDefaultValue == 0 || mileageDefaultValue == 0 || avoidDefaultValue == 0) {
$('.ias-safety-setion1').removeClass('on')
} else {
pilotInstance.updateValue(pilotDefaultValue)
mileageInstance.updateValue(mileageDefaultValue)
avoidInstance.updateValue(avoidDefaultValue)
}
}
} else {
if (pilotDefaultValue == 0 || mileageDefaultValue == 0 || avoidDefaultValue == 0) {
$('.ias-safety-setion1').removeClass('on')
} else {
pilotInstance.updateValue(pilotDefaultValue)
mileageInstance.updateValue(mileageDefaultValue)
avoidInstance.updateValue(avoidDefaultValue)
}
}
},
error: function () {
// 请求失败时显示异常
if (pilotDefaultValue == 0 || mileageDefaultValue == 0 || avoidDefaultValue == 0) {
$('.ias-safety-setion1').removeClass('on')
} else {
pilotInstance.updateValue(pilotDefaultValue)
mileageInstance.updateValue(mileageDefaultValue)
avoidInstance.updateValue(avoidDefaultValue)
}
},
})
}
fetchData()
setTimeout(fetchData, 1500)
setInterval(fetchData, 3000)
})
$(function () {
setTimeout(function () { $(".video-tanchuang .vjs-big-play-button").addClass('active') }, 200)
var mySwiper11 = new Swiper(".kv-swiper1", {
pagination: '.kv-swiper1 .swiper-pagination-kv',
nextButton: '.kv-swiper1 .swiper-button-next-kv',
prevButton: '.kv-swiper1 .swiper-button-prev-kv',
paginationClickable: true,
autoplay: 5000,
disableOnInteraction: true,
loop: true
})
$(".video-tanchuang .vjs-big-play-button").click(function () {
let videoSrc = $(this).attr('data-video')
$(".popup_box1").show()
$(".popup_box1 .video").attr('src', videoSrc)
$(".popup_box1 .video")[0].play()
})
$(".popup_box1 .video_close").click(function () {
$(".popup_box1").hide()
$(".popup_box1 .video")[0].pause()
})
$(".popup_box1 .popup_bg").click(function () {
$(".popup_box1").hide()
$(".popup_box1 .video")[0].pause()
})
$(window).resize(function () {
var width = $('.live-show').width()
var height = width * 9 / 16
$('.live-show').height(height)
})
$(".play_video").click(function () {
let videoSrc = $(this).attr('data-video')
$(".popup_box2").addClass('active')
var width = $('.live-show').width()
var height = width * 9 / 16
$('.live-show').height(height)
setTimeout(function () {
$('.live-show iframe').attr('src', videoSrc)
}, 200)
})
$(".popup_box2 .video_close").click(function () {
$(".popup_box2").removeClass('active')
$('.live-show iframe').attr('src', '')
})
$(".popup_box2 .popup_bg").click(function () {
$(".popup_box2").removeClass('active')
$('.live-show iframe').attr('src', '')
})
$(".solution-tags a").click(function () {
var tags = $(this).attr('data-id')
if ($(window).width() > 899.9) {
$("html,body").animate(
{
scrollTop: $("#" + tags).offset().top - 10,
},
0
)
} else {
$("html,body").animate(
{
scrollTop: $("#" + tags).offset().top - 40,
},
0
)
}
})
})
var mySwiperKv = new Swiper('.ias-yinwang-kvbanner', {
loop: true,
pagination: {
el: '.swiper-pagination-yinwang-kv',
clickable: true,
},
slidesPerView: 1,
speed: 500,
autoplay: {
delay: 8000,
disableOnInteraction: false,
},
spaceBetween: 4,
keyboard: true,
observer: true,
observeParents: true,
})