123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389 |
- window.foton = window.foton || {};
- (function(){
- function pk(){
- this.baseUrl = window.location.origin
- this.init();
- }
-
- p = pk.prototype;
-
- p.init = function(){
- this.bindEvent();
- this.listenTopBar();
- this.yysjLink();
- this.qjzs();
- this.qjgc();
- this.jctj();
- this.yysj();
-
- // 模块动画
- var wow = new WOW({
- boxClass: 'wow',
- animateClass: 'animated',
- offset: 100,
- mobile: false,
- live: true
- });
- wow.init();
- }
-
- p.bindEvent = function(){
- const _this= this
- // 预约试驾
- $(".submit").click(e=>{
- var flag = true;
- var msg = "";
- if(!$("#name").val()) {
- msg = "姓名不能为空!";
- flag = false;
- alertMsg(msg);
- return false;
- }
- p.checkPhoneNum($("#realPhone")).then( result => {
- if(!result){
-
- }else{
- $(".yysj select").each(function() {
- var select = $(this).find("option:selected");
- if(select.val() == -1) {
- flag = false;
- msg = select.html();
- return false;
- }
- });
- flag=true
- if(!flag) {
- alertMsg(msg);
- return false;
- }
-
-
-
- if (flag) {
- var params = {
- BrandId: $("#brand").val(),
- SeriesId: $("#carSeries").val(),
- ProvinceId: $("#province").val(),
- CityId: $("#city").val(),
- DealerId: $("#Dealer").val(),
- Name: $("#name").val(),
- Phone: $("#realPhone").val(),
- Remark: $("#Remark").val()
-
- };
- _this.getData('post', _this.baseUrl+"/tunland/clue/PostLeads", params).then(resp => {
- if(resp.status == 0){
- alertMsg("提交成功");
- }
- })
- p.LzInfo();
- } else {
- alertMsg(msg);
- }
- }
- })
- })
-
- //关闭弹窗按钮
- $(".modalfooter button").on("click", function() {
- $(".alertbox").hide()
- });
- }
-
-
- // 导航栏吸附
- p.listenTopBar = function(){
- $(document).scroll(e=>{
- let bannerH = $(".topImg").height() - 75;
- let top = $(document).scrollTop();
- if(top >= bannerH){
- console.log('ssss')
- $(".titleBox").addClass("fixed");
- }else{
- $(".titleBox").removeClass("fixed");
- }
- })
- // 锚点
- let ary = ["cpld", "qjzs", "jctj", "cspz"];
- let flag = false
- let oldIndex = 0;
- $(".titleBox .tab").click(e=>{
-
- let index = $(e.currentTarget).index();
- if(index>=4){
- return
- }
- let section = $(`.${ary[index]}`);
- let top
- if(oldIndex === 0){
- top = section.offset().top-176;
- }else{
- top = section.offset().top-126;
- }
-
- console.log('index',index,top);
-
- window.scrollTo({
- top: top,
- behavior: "smooth"
- })
- flag = true
- $(".titleBox .tab").removeClass("active");
- $(e.currentTarget).addClass("active");
- oldIndex=index
- })
-
- let topList = []
- ary.forEach((item) => {
- let section = $(`.${item}`);
- topList.push(section.offset().top-256)
- })
- function scroll() {
- flag=false
- var scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
- for (let i = 1; i < 4; i++) {
- if (scrollTop < topList[0]) {
- $(".titleBox .tab").removeClass("active");
- $(".titleBox .tab")[0].className += ' active';
- }
- else if (scrollTop > topList[i - 1] && scrollTop < topList[i]) {
-
- $(".titleBox .tab").removeClass("active");
- $(".titleBox .tab")[i - 1].className += ' active'
- } else if (scrollTop > topList[3]) {
- $(".titleBox .tab").removeClass("active");
- $(".titleBox .tab")[3].className += ' active'
- }
- }
- }
- $(window).scroll(() => {
- if (flag) {
- setTimeout(scroll, 2000)
- } else {
- scroll()
- }
- })
-
-
-
-
- }
- //预约跳转
- p.yysjLink = function(){
- $('.tab.radio').click(()=>{
- window.location.href="https://pickup.foton.com.cn/activity/testdrive/m/"
- })
- }
-
- // 全景展示滚动
- p.qjzs = function(){
- new Swiper(".qjzs .swiper-container", {
- prevButton:'.qjzs .wg',
- nextButton:'.qjzs .ns',
- onSlideChangeStart: function(swiper){
- // alert(swiper.activeIndex);
- $("#container .qjzs .nav .line").toggleClass("right");
- }
- });
-
- }
- //全景观车
- p.qjgc=function(){
- $('.vr_7').click(()=>{
- window.location.href = "http://foton.cloud-top.com.cn/p4_7/"
- })
- $('.vr_9').click(()=>{
- window.location.href = "http://foton.cloud-top.com.cn/p4_9/"
- })
- }
-
- // 精彩图集
- p.jctj = function(){
-
- var galleryTop = new Swiper('.swiper1', {
- // nextButton: '.swiper-button-next',
- // prevButton: '.swiper-button-prev',
- spaceBetween: 10,
- });
- var galleryThumbs = new Swiper('.swiper2', {
- spaceBetween: 10,
- centeredSlides: true,
- slidesPerView: 'auto',
- touchRatio: 0.2,
- slideToClickedSlide: true
- });
- galleryTop.params.control = galleryThumbs;
- galleryThumbs.params.control = galleryTop;
-
-
- }
-
-
-
- // 预约试驾
- p.yysj = function(){
- const _this = this;
- setProvince();
- setBrand();
-
-
-
- function setProvince(){
- _this.getData('get', _this.baseUrl+ "/tunland/clue/getProvince").then(resp => {
- if(resp.status == 1 ){
- return;
- }
-
- $("#province").empty();
-
- resp.data.unshift({ID:-1, FNAME:"省份"});
- $.each(resp.data, function(i, val) {
- var $option = $('<option data-fcode="' + val.FCODE + '" value="' + val.ID + '">' + val.FNAME + '</option>');
- $("#province").append($option);
- });
- })
-
- $("#province").bind("change", function() {
- var provinceid = $("#province option:selected").attr("value");
- setCity(provinceid);
- });
-
- }
- function setCity(provinceid){
- _this.getData('get', _this.baseUrl+ "/tunland/clue/getCityOfPronvince", {pId: provinceid}).then(resp => {
- if(resp.status == 1 ){
- return;
- }
-
- $("#city").empty();
-
- $.each(resp.data, function(i, val) {
- var $option = $('<option value="' + val.dmpCityId + '">' + val.cityName + '</option>');
- $("#city").append($option);
- });
- })
-
- $("#city").unbind("change");
- $("#city").bind("change", function() {
- setShop($("#city").val());
- });
- }
- function setBrand(){
- _this.getData( 'get', _this.baseUrl+ "/tunland/clue/getBrand").then(resp => {
- if(resp.status == 1 ){
- return;
- }
-
- $("#brand").empty();
-
- resp.data.unshift({ID:-1, NAME:"品牌"});
-
- $.each(resp.data, function(i, val) {
- if (val.ID == '504f7428-439a-4f87-9540-1ad1f334962e' || val.ID == -1) {
- var $option = $('<option value="' + val.ID + '">' + val.NAME + '</option>');
- $("#brand").append($option);
- }
- });
- })
-
- $("#brand").bind("change", function() {
- setCarSeries($("#brand").val());
- });
- }
- function setCarSeries(brandId){
- $("#carSeries").empty();
-
- _this.getData( 'get', _this.baseUrl+ "/tunland/clue/getSeries", {brandId}).then( resp => {
- if(resp.status == 1 ){
- return;
- }
-
- resp.data.unshift({ID:-1, NAME:"选择车型"});
-
- $.each(resp.data, function(i, val) {
- var $option = $('<option value="' + val.ID + '">' + val.NAME + '</option>');
- $("#carSeries").append($option);
-
- });
- // if(!isNaN(isbind)) {
- // $("#carSeries").val(isbind);
- // }
- })
- }
- }
-
- p.checkPhoneNum = function(vInput, enable) {
- //手机号
- var reg = /^1(3|4|5|6|8|7)\d{9}$/;
- var flag = false;
-
- var phoneVal = vInput.val();
- if(phoneVal == "" || phoneVal == "手机号码") {
- alertMsg("手机号不能为空");
- } else if(!reg.test(phoneVal)) {
- alertMsg("请输入正确的手机号");
- } else {
- //验证手机号码是否已经注册过
- if(enable) {
- var urlJson = {
- a: "Verifymtel",
- tel: phoneVal
- }
- return new Promise(resolve => {
- this.getData(_this.baseUrl+ "/tunland/clue/getProvince", urlJson).then(resp => {
- if(resp.statcode == 0) {
- resolve(true);
- }else{
- resolve(false);
- }
- })
- })
- } else {
- return Promise.resolve(true);
- }
- }
- return Promise.resolve(flag);
- }
-
- p.LzInfo = function () {
- const _this= this
- $.ajax({
- type: "POST",
- async: false,
- url: _this.baseUrl+"/tunland/dmp/dmpLzInfo",
- data: {
- brandId: $("#brand").val(),
- seriesId: $("#carSeries").val(),
- provinceId: $("#province").val(),
- cityId: $("#city").val(),
- name: $("#name").val(),
- tel: $("#realPhone").val()
- },
- dataType: "json"
- });
- }
-
- p.getData = function(method="GET", url, data={}){
- return new Promise(resolve=>{
- $.ajax({
- url:url,
- method: method,
- data: method.toUpperCase()=="GET" ? data : JSON.stringify(data),
- dataType:'json',
- contentType:"application/json;charset=utf-8",
- success:e=>{
- resolve(e)
- }
- })
- })
- }
-
- function alertMsg(content) {
- $('.alertbox').show();
- $('.alertbox').css("z-index", "999");
- $(".modalbody").html(content);
-
- };
-
- window.foton.pk = pk;
- })()
|