const orderItemInfoList = JSON.parse(window.sessionStorage.getItem("orderItemInfoList")); //开票项目 const orderInfo = JSON.parse(window.sessionStorage.getItem("orderInfo")); //订单信息 const fpzls = JSON.parse(window.sessionStorage.getItem("fpzls")); //发票类型 const titleInfo = JSON.parse(window.sessionStorage.getItem("titleInfo")); //地址电话银行账号备注 // const titleInfoList = JSON.parse(window.sessionStorage.getItem("titleInfoList")); //发票抬头记录历史信息 const merge = window.localStorage.getItem('merge'); const type = window.localStorage.getItem('type'); // 0 静态码 1动态码 const logo = window.localStorage.getItem("logo"); //logo const secretKey = window.localStorage.getItem("secretKey"); //密钥 const routerType = window.localStorage.getItem("routerType"); //1 不使用公众号 !=1 公众号 let items = []; let cpLock = ""; const $ttType = $('#tt_type'); const $email = $('#email'); const $fpType = $('#fp_type'); const $titleName = $("#titleName"); var $taxpayerId = $("#taxpayerId"); $(function () { //logo配置 const prePath = '../../image/wxscaninvoice/'; const defaultLogoPath = prePath + 'logo.jpg'; if (strIsNull(logo)) { $("#logo").attr("src", defaultLogoPath); } else { $("#logo").attr("src", prePath + logo); } //初始化扫码开票模态框 $ttType.attr('onclick', 'ttType(this)'); //添加合并 if (merge === "1") { $('.merge_click').show(); $('.submit_click').addClass('mergeShow') } else { $('.merge_click').hide(); $('.submit_click').removeClass('mergeShow') } //如果为微信,打开发票抬头的... if(!isWeiXin()){ $('.el-icon-more').css('display', 'none'); }else{ $titleName.css({'width':'73%'}); } const getLastFpType = sessionStorage.getItem('fpType'); const getLastTtType = sessionStorage.getItem('ttType'); const getLastTitleName = sessionStorage.getItem('goTitleName'); const getLastTaxpyerId = sessionStorage.getItem('goTaxpayerId'); const getLastTelephone = sessionStorage.getItem('goTelephone'); const getLastEmail = sessionStorage.getItem('goEmail'); // console.log(strIsNull(titleInfo.ghfqylx)) // console.log(titleInfo.ghfqylx) if (!strIsNull(titleInfo)) { if ( titleInfo.ghfqylx === "01" || getLastTtType === "单位") { $ttType.val("单位"); $ttType.attr('data-id', "01"); //单位时调整文字示例,头部文字调整为"纳税人识别号",头部文字后的*可见,input中的placeholder改为"请输入纳税人识别号", $('#title_nsrsbh').text("纳税人识别号"); $('#title_nsrsbh_star').css('display', 'block'); $('#taxpayerId').attr('placeholder', "请输入纳税人识别号"); } else if (strIsNull(titleInfo.ghfqylx) ||titleInfo.ghfqylx === "03" || getLastTtType === "个人") { $ttType.val("个人"); $ttType.attr('data-id', "03"); //个人时调整文字示例,头部文字调整为"身份证号码",头部文字后的*不可见,input中的placeholder改为"请输入身份证号码", $('#title_nsrsbh').text("身份证号码"); $('#title_nsrsbh_star').css('display', 'none'); $('#taxpayerId').attr('placeholder', "请输入身份证号码"); } else if (titleInfo.ghfqylx === "04" || getLastTtType === "其他") { $ttType.val("其他"); $ttType.attr('data-id', "04"); //其他时调整文字示例,头部文字调整为"统一社会信用代码",头部文字后的*不可见,input中的placeholder改为"请输入统一社会信用代码" $('#title_nsrsbh').text("统一社会信用代码"); $('#title_nsrsbh_star').css('display', 'none'); $('#taxpayerId').attr('placeholder', "请输入统一社会信用代码"); } //切换更多如果有数据记录数据,否则展示默认值 if (!strIsNull(getLastTitleName) || !strIsNull(getLastTaxpyerId) || !strIsNull(getLastTelephone) || !strIsNull(getLastEmail)) { $titleName.val(getLastTitleName); $taxpayerId.val(getLastTaxpyerId); $("#telephone").val(getLastTelephone); $("#email").val(getLastEmail); } else if (getLastTitleName == null && getLastTaxpyerId == null && getLastTelephone == null && getLastEmail == null) { $titleName.val(titleInfo.gfmc); $taxpayerId.val(titleInfo.gfsh); $("#telephone").val(titleInfo.gfsj); $("#email").val(titleInfo.gfyx); } setStorageMsg('bz', titleInfo.bz); //备注 setStorageMsg('registerAddr', titleInfo.gfdz); //注册地址 setStorageMsg('registerPhone', titleInfo.gfdh); //注册电话 setStorageMsg('bankName', titleInfo.gfyh); //开户银行 setStorageMsg('bankAccount', titleInfo.gfzh); //开户账号 } else { } //默认其他 $ttType.val("其他"); $ttType.attr('data-id', "04"); //其他时调整文字示例,头部文字调整为"统一社会信用代码",头部文字后的*不可见,input中的placeholder改为"请输入统一社会信用代码" $('#title_nsrsbh').text("统一社会信用代码"); $('#title_nsrsbh_star').css('display', 'none'); $('#taxpayerId').attr('placeholder', "请输入统一社会信用代码"); //发票类型 if (fpzls.length === 1) { $fpType.val(fpzls[0].value); $fpType.attr("data-id", fpzls[0].key); $('.modelIcon_fplx').css('display', 'none'); } else { $('.modelIcon_fplx').css('display', 'block'); initInvoiceTypePick(fpzls); //初始化当前发票类型绑定key值 } showHideMsg() if (!strIsNull(getLastFpType)) { confirm_fplx_model(1, getLastFpType); //记录填写更多信息返回状态 } //开票项目及总金额 if (type === "0") { $("#zjeInput").show(); $("#zjeSpan").hide(); $("#listLiByStatic").show(); $("#listLiID").hide(); $("#kpxm").val(orderItemInfoList[0].xmmc); $('#kpxm').attr("data-id", orderItemInfoList[0].id); } else { $(".kpje").html(orderInfo.kphjje + "元"); if (orderItemInfoList.length === 1) { $(".Fristxmmc").html(orderItemInfoList[0].xmmc); $(".Fristxmje").html(orderItemInfoList[0].xmje + "元"); } else { $("#listLiID").hide(); for (let i = 0; i < orderItemInfoList.length; i++) { $(".name_li_rBottom").append( '
  • ' + '' + orderItemInfoList[i].xmmc + '' + '' + orderItemInfoList[i].xmje + '元' + '
  • ' ) } } } //模糊查询判断输入是中文还是英文 cpLock = false; document.getElementById("titleName").addEventListener('compositionstart', function () { cpLock = true; }) document.getElementById("titleName").addEventListener('compositionend', function () { cpLock = false; titleOnChange() }) //点击空白处关闭模糊查询弹框 $(".search_shade").on("click", function () { $('.search').hide(); $('.search_shade').hide(); }) }) /*初始化当前发票类型绑定key值,方便传后台*/ function initInvoiceTypePick(fpzls) { for (const i in fpzls) { if (fpzls[i].value.indexOf('增值税电子普通发票') >= 0) { $fpType.val(fpzls[i].value); $fpType.attr("data-id", fpzls[i].key); return; } else { $fpType.val(fpzls[0].value); $fpType.attr("data-id", fpzls[0].key); } } } //控制收票人信息展示隐藏 function showHideMsg() { if (getFpzl() === "2" || getFpzl() === "0") { $('.name_spxx_hide').css('display', 'none'); } else { $('.name_spxx_hide').css('display', 'block'); } } /*控制发票类型模态框显示*/ function fpType(ele) { const data = []; for (const i in fpzls) { const info = {}; info.id = fpzls[i].key; info.value = fpzls[i].value; data[i] = info; } const bankId = ele.dataset['id']; const bankName = ele.dataset['value']; const bankSelect = new IosSelect(1, [data], { container: '.container', title: '发票类型', itemHeight: 50, itemShowCount: 3, oneLevelId: bankId, callback: function (selectOneObj) { ele.value = selectOneObj.value; ele.innerHTML = selectOneObj.value; ele.dataset['id'] = selectOneObj.id; ele.dataset['value'] = selectOneObj.value; } }); } /*控制抬头类型模态框显示*/ function ttType(ele) { let data = [{ 'id': "01", 'value': "单位" }, { 'id': "03", 'value': "个人" }, { 'id': "04", 'value': "其他" }]; if(fpzls.length === 1){ if(fpzls[0].key ==="0" || fpzls[0].key ==="52" || fpzls[0].key ==="01"){ data = [{ 'id': "01", 'value': "单位" }]; } } // if ((JSON.stringify(fpzls).indexOf("0") >= 0 || JSON.stringify(fpzls).indexOf("52") >= 0 || JSON.stringify(fpzls).indexOf("01") >= 0 ) && fpzls.length == 1) { // data = [{ // 'id': "01", // 'value': "单位" // }]; // } const bankId = ele.dataset['id']; const bankName = ele.dataset['value']; const bankSelect = new IosSelect(1, [data], { container: '.container', title: '抬头类型', itemHeight: 50, itemShowCount: 3, oneLevelId: bankId, callback: function (selectOneObj) { ele.value = selectOneObj.value; ele.innerHTML = selectOneObj.value; ele.dataset['id'] = selectOneObj.id; ele.dataset['value'] = selectOneObj.value; } }); } //静态码开票项目 function kpmxSelect(ele) { const data = []; for (const i in orderItemInfoList) { const info = {}; info.id = orderItemInfoList[i].id; info.value = orderItemInfoList[i].xmmc; data[i] = info; } const bankId = ele.dataset['id']; const bankName = ele.dataset['value']; const bankSelect = new IosSelect(1, [data], { container: '.container', title: '开票项目', itemHeight: 50, itemShowCount: 3, oneLevelId: bankId, callback: function (selectOneObj) { ele.value = selectOneObj.value; ele.innerHTML = selectOneObj.value; ele.dataset['id'] = selectOneObj.id; ele.dataset['value'] = selectOneObj.value; } }); } /*发票类型+抬头类型 点击确定*/ function confirm_fplx_model(ele, typeMsg) { setTimeout(function () { if (ele === 1 || $(ele).next().html() === '发票类型') { if (!strIsNull(typeMsg)) { $fpType.val(typeMsg); $fpType.attr('data-id', sessionStorage.getItem('data-id')); } //纸票和专票,去掉收票人信息 if (getFpzl() === "2" || getFpzl() === "0") { $('.name_spxx_hide').css('display', 'none'); } else { $('.name_spxx_hide').css('display', 'block'); } //专用发票时抬头类型只显示单位 if (getFpzl() === "0" || getFpzl() === "52" || getFpzl() === "01") { $ttType.val("单位"); $ttType.attr('data-id', "01"); $ttType.attr('data-value', "单位"); if (sessionStorage.getItem('lastFptt') != null) { $titleName.val(sessionStorage.getItem('lastFptt')); } $('.modelIcon_ttlx').css('display', 'none'); $ttType.removeAttr('onclick'); } else { $('.modelIcon_ttlx').css('display', 'block'); $ttType.attr('onclick', 'ttType(this)'); } } else if (ele === 2 || $(ele).next().html() === '抬头类型') { //个人无更多信息和纳税人识别号 if ($ttType.val() === "个人") { setStorageMsg('lastFptt', $titleName.val()); //如果为全电票,购方名称需要特别说明以(个人)结尾, const titleName = $.trim($titleName.val()); if (getFpzl() === "01" || getFpzl() === "02") { $titleName.val(titleName + "(个人)"); }else{ $titleName.val(titleName + "个人"); } //个人时调整文字示例,头部文字调整为"身份证号码",头部文字后的*不可见,input中的placeholder改为"请输入身份证号码", $('#title_nsrsbh').text("身份证号码"); $('#title_nsrsbh_star').css('display', 'none'); $('#taxpayerId').attr('placeholder', "请输入身份证号码"); }else if($ttType.val() === "其他"){ setStorageMsg('lastFptt', $titleName.val()); $titleName.val("其他"); //其他时调整文字示例,头部文字调整为"统一社会信用代码",头部文字后的*不可见,input中的placeholder改为"请输入统一社会信用代码" $('#title_nsrsbh').text("统一社会信用代码"); $('#title_nsrsbh_star').css('display', 'none'); $('#taxpayerId').attr('placeholder', "请输入统一社会信用代码"); } else if ($ttType.val() === "单位") { $titleName.val(''); //单位时调整文字示例,头部文字调整为"纳税人识别号",头部文字后的*可见,input中的placeholder改为"请输入纳税人识别号", $('#title_nsrsbh').text("纳税人识别号"); $('#title_nsrsbh_star').css('display', 'block'); $('#taxpayerId').attr('placeholder', "请输入纳税人识别号"); // if (!strIsNull(titleInfo)) { // $("#titleName").val(titleInfo.gfmc); // $("#taxpayerId").val(titleInfo.gfsh); // $("#telephone").val(titleInfo.gfsj); // $("#email").val(titleInfo.gfyx); // } } $taxpayerId.val(''); $('#telephone').val(''); $('#email').val(''); } }, 20) } /*发票抬头点击差号清空Input框的值*/ function fptt_close_click(ele, num) { $(ele).prev().val(''); $(ele).css('display', 'none'); if (num === 1) { $('.search').css('display', 'none'); $('.el-icon-more').css('right', '0.1rem'); $titleName.val(''); $taxpayerId.val(''); if (!strIsNull(titleInfo)) { titleInfo.gfdz = ''; titleInfo.gfdh = ''; titleInfo.gfyh = ''; titleInfo.gfzh = ''; sessionStorage.setItem('titleInfo', JSON.stringify(titleInfo)); } else { setStorageMsg('bankName', ''); //开户银行 setStorageMsg('bankAccount', ''); //开户账号 setStorageMsg('registerPhone', ''); //注册电话 setStorageMsg('registerAddr', ''); //注册地址 } } } //获取微信扫一扫服务 function getJSSDK(ele, num) { $.ajax({ type: 'POST', url: '/ele-myinvoice/wx/getJSSDK?url='+window.location.href, async: false, // data: { url: window.location.href }, success: function (data) { const info = data; this.scanShow = true; wx.config({ debug: false, appId: info.appId, beta: true, timestamp: info.timestamp, nonceStr: info.nonceStr, signature: info.signature, jsApiList: ['chooseInvoiceTitle'] }); wx.ready(function() { wx.invoke('chooseInvoiceTitle', { "scene":"1" }, function(res) { res.choose_invoice_title_info = JSON.parse(res.choose_invoice_title_info || '{}') if (res.choose_invoice_title_info.type==="0"){//企业 const nsrmc = res.choose_invoice_title_info.title; let nsrsbh = res.choose_invoice_title_info.taxNumber; nsrsbh = nsrsbh.replace(/ /g,''); let zcdz = res.choose_invoice_title_info.companyAddress; let zcdh = res.choose_invoice_title_info.telephone; let khyh = res.choose_invoice_title_info.bankName; let khzh = res.choose_invoice_title_info.bankAccount; $(".search_ul").empty(); $titleName.val(nsrmc); $taxpayerId.val(nsrsbh); if (strIsNull(khyh )) { khyh = ''; } if (strIsNull(khzh)) { khzh = ''; } if (strIsNull(zcdz)) { zcdz = ''; } if (strIsNull(zcdh)) { zcdh = ''; } if (!strIsNull(titleInfo)) { titleInfo.gfdz = zcdz; titleInfo.gfdh = zcdh; titleInfo.gfyh = khyh; titleInfo.gfzh = khzh; sessionStorage.setItem('titleInfo', JSON.stringify(titleInfo)); } else { setStorageMsg('bankName', khyh); //开户银行 setStorageMsg('bankAccount', khzh); //开户账号 setStorageMsg('registerPhone', zcdz); //注册电话 setStorageMsg('registerAddr', zcdh); //注册地址 } $('#telephone').val(''); $('#email').val(''); $ttType.val("单位"); $ttType.attr('data-id', "01"); $ttType.attr('data-value', "单位"); //单位时调整文字示例,头部文字调整为"纳税人识别号",头部文字后的*可见,input中的placeholder改为"请输入纳税人识别号", $('#title_nsrsbh').text("纳税人识别号"); $('#title_nsrsbh_star').css('display', 'block'); $('#taxpayerId').attr('placeholder', "请输入纳税人识别号"); } if (res.choose_invoice_title_info.type==="1"){ $titleName.val(nsrmc); $('#telephone').val(''); $('#email').val(''); $ttType.val("个人"); $ttType.attr('data-id', "03"); $ttType.attr('data-value', "个人"); //个人时调整文字示例,头部文字调整为"身份证号码",头部文字后的*不可见,input中的placeholder改为"请输入身份证号码", $('#title_nsrsbh').text("身份证号码"); $('#title_nsrsbh_star').css('display', 'none'); $('#taxpayerId').attr('placeholder', "请输入身份证号码"); } $ttType.attr('onclick', 'ttType(this)'); }); }); } }); } function addMerge() { if (type === "0") { alert_timing_open("静态码不支持添加合并"); return } window.location.href = "./merge.html"; } /*点击提交*/ function nextStep() { $('.fptt_close').css('display', 'none'); let titleName = $.trim($titleName.val()); let taxpayerId = $.trim($taxpayerId.val()); let telephone = $.trim($("#telephone").val()); let email = $.trim($("#email").val()); const fplx_name = $.trim($fpType.val()); let je, fp_kpxm; const mpbs = $ttType.attr('data-id'); let registeraddr = titleInfo.gfdz == null ? "" : titleInfo.gfdz; let registerphone = titleInfo.gfdh == null ? "" : titleInfo.gfdh; let bankname = titleInfo.gfyh == null ? "" : titleInfo.gfyh; let bankaccount = titleInfo.gfzh == null ? "" : titleInfo.gfzh; const bz = titleInfo.bz == null ? "" : titleInfo.bz; const isDp = getFpzl() === "51" || getFpzl() === "52" || getFpzl() === "01" || getFpzl() === "02"; if (type === "0") { je = $.trim($("#kphjje").val()); fp_kpxm = $.trim($("#kpxm").val()); } else { je = orderInfo.kphjje; if ($('.name_li_rBottom').find('.listType').length > 1) { fp_kpxm = $('.listType').eq(0).children('.Fristxmmc').html() + '等'; } else { fp_kpxm = $('.Fristxmmc').html(); } } if (fplxOnblur() && ttlxOnblur() && titleOnblur() && taxNoOnblur() && telephoneOnblur() && emailOnblur() && jeonblur()) { //专票更多信息必填 if ((getFpzl() === "0" || getFpzl() === "52") && $ttType.attr('data-id') === "01") { if (registeraddr === '') { alert_timing_open("请点击更多,输入注册地址"); return false; } if (registerphone === '') { alert_timing_open("请点击更多,输入注册电话"); return false; } if (bankname === '') { alert_timing_open("请点击更多,输入开户银行"); return false; } if (bankaccount === '') { alert_timing_open("请点击更多,输入开户账号"); return false; } } $(".seeCardMsg_shade").css("display", "block"); $(".titleName").html(titleName); $(".fplx_type").html(fplx_name); $(".je").html(changeTwoDecimal_f(je) + "元"); $('.fp_kpxm').html(fp_kpxm); //不区分购方类型,都显示税号,名称,地址,电话,银行,帐号 $(".taxpayerid").css("display", "block"); $(".taxpayerId").html(taxpayerId); controlMoreMsgDis('registeraddr', registeraddr); controlMoreMsgDis('registerphone', registerphone); controlMoreMsgDis('bankname', bankname); controlMoreMsgDis('bankaccount', bankaccount); controlMoreMsgDis('bz', bz); //电子发票时显示收票人信息 if (isDp) { $(".phone").css('display', 'block'); $(".email").css('display', 'block'); $(".telephone").html(telephone); if (!strIsNull(email)) { $(".Email").html(email); } else { $(".email").css('display', 'none'); } } else { $(".phone").css('display', 'none'); $(".email").css('display', 'none'); $(".telephone").html(''); $(".Email").html(''); } if (strIsNull(mpbs) || mpbs === "01") { //单位 //如果确认框显示,需要设置税号对应的文字,单位时调整文字示例为"纳税人识别号" $('#confirm_nsrsbh').text("纳税人识别号"); } else if (mpbs === "03") { //个人 //如果为全电票,购方名称需要特别说明以(个人)结尾, // if (getFpzl() === "01" || getFpzl() === "02") { //判断购方名称是不是以(个人)结尾 if(!titleName.endsWith("(个人)")){ titleName += "(个人)"; $(".titleName").html(titleName); $titleName.val(titleName); } //如果购方名称为(个人),设置为个人(个人) if(titleName === "(个人)"){ titleName = "个人(个人)"; $(".titleName").html(titleName); $titleName.val(titleName); } // } //如果确认框显示,需要设置税号对应的文字,个人时调整文字示例为"身份证号码" $('#confirm_nsrsbh').text("身份证号码"); } else if (mpbs === "04") { //其他 //如果确认框显示,需要设置税号对应的文字,其他时调整文字示例为"统一社会信用代码" $('#confirm_nsrsbh').text("统一社会信用代码"); } } } function sureStep(){ $(".seeCardMsg_shade").css("display", "none"); const titleName = $.trim($titleName.val()); let taxpayerId = $.trim($taxpayerId.val()); let telephone = $.trim($("#telephone").val()); let email = $.trim($("#email").val()); const fpzl = getFpzl(); let je; const mpbs = $ttType.attr('data-id'); let registeraddr = titleInfo.gfdz == null ? "" : titleInfo.gfdz; let registerphone = titleInfo.gfdh == null ? "" : titleInfo.gfdh; let bankname = titleInfo.gfyh == null ? "" : titleInfo.gfyh; let bankaccount = titleInfo.gfzh == null ? "" : titleInfo.gfzh; const bz = titleInfo.bz == null ? "" : titleInfo.bz; if (type === "0") { je = $.trim($("#kphjje").val()); } else { je = orderInfo.kphjje; } let pageOrderItemInfo = []; if (type === "0") { const kpxm = $.trim($("#kpxm").val()); let index; for (let i = 0; i < orderItemInfoList.length; i++) { if (kpxm === orderItemInfoList[i].xmmc) { index = i } } let pageOrderItem = { ggxh: orderItemInfoList[index].ggxh, sl: orderItemInfoList[index].sl, xmse: orderItemInfoList[index].se, xmdj: orderItemInfoList[index].xmdj, xmdw: orderItemInfoList[index].xmdw, xmje: je, xmmc: orderItemInfoList[index].xmmc, xmsl: orderItemInfoList[index].xmsl, hsbz: orderItemInfoList[index].hsbz, fphxz: orderItemInfoList[index].fphxz, spbm: orderItemInfoList[index].spbm, yhzcbs: orderItemInfoList[index].yhzcbs, lslbs: orderItemInfoList[index].lslbs, zzstsgl: orderItemInfoList[index].zzstsgl, kce: orderItemInfoList[index].kce, }; pageOrderItemInfo.push(pageOrderItem); } else { for (let i = 0; i < orderItemInfoList.length; i++) { let pageOrderItem = { ggxh: orderItemInfoList[i].ggxh, sl: orderItemInfoList[i].sl, xmse: orderItemInfoList[i].se, xmdj: orderItemInfoList[i].xmdj, xmdw: orderItemInfoList[i].xmdw, xmje: orderItemInfoList[i].xmje, xmmc: orderItemInfoList[i].xmmc, xmsl: orderItemInfoList[i].xmsl, hsbz: orderItemInfoList[i].hsbz, fphxz: orderItemInfoList[i].fphxz, spbm: orderItemInfoList[i].spbm, yhzcbs: orderItemInfoList[i].yhzcbs, lslbs: orderItemInfoList[i].lslbs, zzstsgl: orderItemInfoList[i].zzstsgl, kce: orderItemInfoList[i].kce, }; pageOrderItemInfo.push(pageOrderItem); } } if((getFpzl()==="01" || getFpzl()==="02") && mpbs ==="03"){ if (!titleName.includes('(个人)')) { alert_timing_open("抬头类型是个人时,发票抬头结尾必须包含(个人)"); return false; } } const invoiceMes = { ghfqylx: mpbs, ghfMc: titleName, ghfNsrsbh: taxpayerId, ghfEmail: email, ghfSj: telephone, ghfDz: registeraddr, ghfDh: registerphone, ghfYh: bankname, ghfZh: bankaccount, yfpdm: '', yfphm: '', kplx: "0", kpy: orderInfo.kpr, fhr: orderInfo.fhr, sky: orderInfo.skr, bz: bz, jshj: je, fplx: fpzl, sld: orderInfo.sld, sldmc: orderInfo.sldMc, kpjh: orderInfo.fjh, pageOrderItemInfo: pageOrderItemInfo, uid: '', deptId: '', xhfmc: orderInfo.xhfMc, xhfNsrsbh: orderInfo.xhfNsrsbh, xhfdz: orderInfo.xhfDz, xhfdh: orderInfo.xhfDh, xhfyh: orderInfo.xhfYh, xhfzh: orderInfo.xhfZh, ddh: orderInfo.ddh, ywlx: orderInfo.ywlx, ywlxId: orderInfo.ywlxId, qdbz: "", tqm: orderInfo.tqm, openId: localStorage.getItem('openId'), unionId: localStorage.getItem('unionId'), type: type, kphjje: je, }; alert_loading_open("数据提交中"); let url,data; if(window.sessionStorage.getItem('page') ==="1"){ url=config.projectUrl + '/scanInvoice/getMergeOrderAuthUrl' data=JSON.stringify({ ids:window.sessionStorage.getItem('ids'), xhfNsrsbh:orderInfo.xhfNsrsbh, pageOrder:JSON.stringify(invoiceMes) }) }else{ url=config.projectUrl + '/scanInvoice/getAuthUrl' data = JSON.stringify(invoiceMes) } $.ajax({ url: url, type: "post", data: data, contentType: "application/json;charset=utf-8", async: false, success: function (data) { if (data.code === '0000') { alert_loading_close(); if(routerType ==="1"){ //其他 toPage("/html/wxscaninvoice/successTip.html"); }else{ //公众号 if (!strIsNull(data.data.auth_url)) { window.location.replace(data.data.auth_url); } else { toPage("/html/wxscaninvoice/Followorder.html"); } } } else if (data.code === '1001') { alert_loading_close(); toPage("/html/wxscaninvoice/Followorder.html"); }else if(data.code === '9998'){ alert_loading_close(); alert_prompt_open("提示", data.msg, 1); } else { alert_loading_close(); alert_prompt_open("提示", '开具发票失败', 1); } }, error: function () { alert_loading_close(); alert_prompt_open("提示", "当前网络正忙,请稍后重试", 1); } }) } //普通字符转换成转意符 function html2Escape(sHtml) { return sHtml.replace(/[<>&"]/g, function (c) { return { '<': '<', '>': '>', '&': '&', '"': '"' } [c]; }); } //转意符换成普通字符 function escape2Html(str) { const arrEntities = { 'lt': '<', 'gt': '>', 'nbsp': ' ', 'amp': '&', 'quot': '"' }; return str.replace(/&(lt|gt|nbsp|amp|quot);/ig, function (all, t) { return arrEntities[t]; }); } /*点击提交在确认开票申请中展示更多信息*/ function controlMoreMsgDis(curClass, curMsg) { if (strIsNull(curMsg)) { $("." + curClass).css("display", "none"); } else { $("." + curClass).css("display", "block"); $("." + curClass).find('.name_val').html(curMsg); } } /*纳税人识别号为空提示框点击确认关闭*/ function nsrsh_hide() { $(".nsrsh_model").css("display", "none"); } /*关闭开票申请弹框*/ function seeCard_back_model() { $(".seeCardMsg_shade").css("display", "none"); } /*设置标签只读不生效 手动失去焦点 禁止软键盘弹出*/ function cancelFocus(cancelId) { $("#" + cancelId).blur(); } /*模糊查询*/ function titleEmptyChange() { setTimeout(function () { $('.fptt_close').css('display', 'none'); const nsrmc = $titleName.val(); if (nsrmc.length === 0) { $('.fptt_close_fptt').css('display', 'none'); // historyMsg(); } else { $('.fptt_close_fptt').css('display', 'block'); $(".search").hide(); $('.search_shade').hide(); } }, 100) } /* * 模糊查询 * 注:所有输入框,输入内容后出现叉号,点击叉号全部删除 */ function titleOnChange(ele) { setTimeout(function () { $('.fptt_close').css('display', 'none'); const nsrmc = $titleName.val(); if (nsrmc.length === 0) { $('.fptt_close_fptt').css('display', 'none'); // if (titleInfoList.length != 0) { // historyMsg(); // } else { $('.search').hide(); $('.search_shade').hide(); $taxpayerId.val(''); if (!strIsNull(titleInfo)) { titleInfo.gfdz = ''; titleInfo.gfdh = ''; titleInfo.gfyh = ''; titleInfo.gfzh = ''; sessionStorage.setItem('titleInfo', JSON.stringify(titleInfo)); } else { setStorageMsg('bankName', ''); //开户银行 setStorageMsg('bankAccount', ''); //开户账号 setStorageMsg('registerPhone', ''); //注册电话 setStorageMsg('registerAddr', ''); //注册地址 } // } } else { $('.fptt_close_fptt').css('display', 'block'); } if (nsrmc.length < 1) { return; } //如果抬头类型为个人,不进行查询数据 const mpbs = $ttType.attr('data-id'); if(mpbs === "03" ){ return; } if (!cpLock) { $(".search").hide(); $('.search_shade').hide(); if(secretKey){ //加密请求数据 //{ // "type": "0", // "content": "XXXXXX" // } let content ={ "shList": [orderInfo.xhfNsrsbh] , "entList": [orderInfo.entId?orderInfo.entId:""] , "ghfBm": "", "ghfMc": nsrmc } let reqDate = { "type": "1", "content": encrypt(JSON.stringify(content),secretKey) }; $.ajax({ url: config.simsBaseUrl + "/baseCommon/api/fuzzyGhf", //async: false, type: "post", contentType: 'application/json', data: JSON.stringify(reqDate) , success: function (data) { if (data.code === "0000") { $(".search_ul").empty(); if (strIsNull(data.data)) { return false; } items = data.data; for (let i = 0; i < 4 && i < items.length; i++) { const item = items[i]; //生成下拉列表 $(".search_ul").append('
  • ' + item.purchaseName + '
  • ') } if (items && items.length > 0) { $(".search").show(); $('.search_shade').show(); } if (items && items.length < 0) { $(".search").hide(); $('.search_shade').hide(); } } } }); } } if (nsrmc === '') { ele.value = ''; } }, 100) } /*除了发票抬头其余所有输入框获取焦点事件+失去焦点*/ function otherTitleChange(ele) { setTimeout(function () { $(".search").hide(); $('.search_shade').hide(); $('.fptt_close').css('display', 'none'); if ($(ele).val().length === 0) { $(ele).next().css('display', 'none'); } else { $(ele).next().css('display', 'block'); } }, 10) } function resetCloseIcon(ele) { $(ele).children[1].css('display', 'none'); } /*点击模糊搜索结果*/ function getItemInfo(index, num) { // setStorageMsg('save_historyClick', 0); const nsrmc = items[index].purchaseName; if(secretKey){ //加密请求数据 //{ // "type": "0", // "content": "XXXXXX" // } let content ={ "shList": [orderInfo.xhfNsrsbh] , "entList": [orderInfo.entId?orderInfo.entId:""] , "ghfBm": "", "ghfMc": nsrmc } let reqDate = { "type": "1", "content": encrypt(JSON.stringify(content),secretKey) }; $.ajax({ url: config.simsBaseUrl + "/baseCommon/api/exactGhf", //async: false, type: "post", contentType: 'application/json', data: JSON.stringify(reqDate) , success: function (data) { if (data.code === "0000") { if (strIsNull(data.data)) { //不处理 } else { const resData = data.data; $(".search_ul").empty(); $titleName.val(resData.purchaseName); $taxpayerId.val(resData.taxpayerCode); if (strIsNull(resData.bankOfDeposit)) { resData.bankOfDeposit = ''; } if (strIsNull(resData.bankNumber)) { resData.bankNumber = ''; } if (strIsNull(resData.address)) { resData.address = ''; } if (strIsNull(resData.phone)) { resData.phone = ''; } if (!strIsNull(titleInfo)) { titleInfo.gfdz = resData.address; titleInfo.gfdh = resData.phone; titleInfo.gfyh = resData.bankOfDeposit; titleInfo.gfzh = resData.bankNumber; sessionStorage.setItem('titleInfo', JSON.stringify(titleInfo)); } else { setStorageMsg('bankName', resData.bankOfDeposit); //开户银行 setStorageMsg('bankAccount', resData.bankNumber); //开户账号 setStorageMsg('registerPhone', resData.phone); //注册电话 setStorageMsg('registerAddr', resData.address); //注册地址 } $('#telephone').val(''); $('#email').val(''); } $(".search").hide(); $('.search_shade').hide(); } } }); } } /*点击更多信息填注册地址等*/ function moreMsg() { setStorageMsg('fpType', $fpType.val()); setStorageMsg('fpTypeId', $fpType.attr('data-id')); setStorageMsg('ttType', $ttType.val()); setStorageMsg('ttTypeId', $ttType.attr('data-id')); setStorageMsg('goTitleName', $titleName.val()); setStorageMsg('goTaxpayerId', $('#taxpayerId').val()); setStorageMsg('goTelephone', $('#telephone').val()); setStorageMsg('goEmail', $('#email').val()); toPage("/html/wxscaninvoice/moreMsgFillIn.html"); } /*本地存储更多信息(注册地址等)+抬头+收票人信息*/ function setStorageMsg(key, value) { sessionStorage.setItem(key, value); } /*点击开票说明 + 常见问题 */ const screenHeigth = window.screen.height; function descriptQuestion_click(num) { hideScroll(); if (num === 1) { getEle('.invoiceDescript_shade')[0].style.cssText = 'opacity:1;top:0px;transition-duration:0.3s;transition-timing-function: ease;'; } else if (num === 2) { getEle('.freQuestion_shade')[0].style.cssText = 'opacity:1;top:0px;transition-duration:0.3s;transition-timing-function: ease;'; } } function descriptQuestion_close(num) { cancelScroll(); if (num === 1) { getEle('.invoiceDescript_shade')[0].style.cssText = 'opacity:0;top:' + screenHeigth + 'px;transition-duration:0.3s;transition-timing-function: ease;'; } else if (num === 2) { getEle('.freQuestion_shade')[0].style.cssText = 'opacity:0;top:' + screenHeigth + 'px;transition-duration:0.3s;transition-timing-function: ease;'; } } /*解决微信浏览器禁止页面滑动(但不影响页面内部scroll)*/ function hideScroll() { const overscroll = function (el) { el.addEventListener('touchstart', function () { const top = el.scrollTop; const totalScroll = el.scrollHeight; const currentScroll = top + el.offsetHeight; if (top === 0) { el.scrollTop = 1; } else if (currentScroll === totalScroll) { el.scrollTop = top - 1; } }); el.addEventListener('touchmove', function (evt) { if (el.offsetHeight < el.scrollHeight) evt._isScroller = true; }); }; overscroll(getEle('.freQuestion_content')[0]); document.body.addEventListener('touchmove', defaul, false); } /*解除微信浏览器禁止页面滑动(但不影响页面内部scroll)*/ function cancelScroll() { document.body.removeEventListener('touchmove', defaul, false); } /*原声js添加移除需要针对同一个函数 */ function defaul(evt) { if (!evt._isScroller) { evt.preventDefault(); } } /*验证发票抬头*/ function titleOnblur() { const titleName = $.trim($titleName.val()); if (titleName === '') { alert_timing_open("发票抬头不能为空!"); return false; } var fpzl = $('#fp_type').attr('data-id'); var ttlx = $.trim($("#tt_type").val()); if(fpzl=='02' && ttlx =='个人'){ if(titleName =='(个人)'){ alert_timing_open("抬头类型是个人时,发票抬头不能是(个人)"); return false; } } const length = checkLength(titleName); if (length > 100) { alert_timing_open("发票抬头长度超过限制"); return false; } const tempStr = "|"; if (titleName.indexOf(tempStr) >= 0) { alert_timing_open("发票抬头不能包含 |"); return false; } for (let i = 0; i < titleName.length; i++) { if (titleName[i].charCodeAt() >= 55356 && titleName[i].charCodeAt() <= 59000) { alert_timing_open("发票抬头不能输入表情"); return false; } } return true; } /*验证纳税人识别号*/ function taxNoOnblur() { const taxpayerId = $.trim($taxpayerId.val()); const current_ttlx = $ttType.val(); if (current_ttlx === "单位") { return taxNoOnblurItem(taxpayerId,"纳税人识别号"); }else if (current_ttlx === "个人") { return taxNoOnblurItem(taxpayerId,"身份证号码"); }else if (current_ttlx === "其他") { return taxNoOnblurItem(taxpayerId,"统一社会信用代码"); } return true; } function taxNoOnblurItem(taxpayerId,text) { const ttlx = $.trim($ttType.val()); if (ttlx =="单位" && taxpayerId === "") { $(".nsrsh_model").css("display", "block"); return false; } const length = taxpayerId.length; if (length !== 0 ) { if(length < 6 || length > 20){ alert_timing_open(text + "只能输入6-20个字符!"); return false; } } const regexEl = /^[A-Za-z0-9]+$/; if (length !== 0 && !regexEl.test(taxpayerId)) { alert_timing_open(text + "只能为数字和字母!"); return false; } const tempStr = "|"; if (taxpayerId.indexOf(tempStr) >= 0) { alert_timing_open(text + "不能包含 |"); return false; } if (taxpayerId.indexOf(" ") >= 0) { alert_timing_open(text + "不能包含空格!"); return false; } for (let i = 0; i < taxpayerId.length; i++) { if (taxpayerId[i].charCodeAt() >= 55356 && taxpayerId[i].charCodeAt() <= 59000) { alert_timing_open(text + "不能输入表情"); return false; } } return true; } /*验证手机*/ function telephoneOnblur() { return true; } /*验证邮箱*/ function emailOnblur() { const email = $.trim($("#email").val()); const length = email.length; const regexEl = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/; const isDp = getFpzl() === "51" || getFpzl() === "52" || getFpzl() === "01" || getFpzl() === "02"; if (isDp) { if (email === '') { alert_timing_open("邮箱不能为空!"); return false; } } if (!isValidEmail(email)) { alert_timing_open("邮箱格式错误,请检查后重新提交"); return false; } if (length !== 0 && !regexEl.test(email)) { alert_timing_open("邮箱格式不对"); return false; } if (length > 50) { alert_timing_open("邮箱长度超过限制!"); return false; } const tempStr = "|"; if (email.indexOf(tempStr) >= 0) { alert_timing_open("邮箱不能包含 |"); return false; } if (email.indexOf(" ") >= 0) { alert_timing_open("邮箱不能包含空格!"); return false; } for (let i = 0; i < email.length; i++) { if (email[i].charCodeAt() >= 55356 && email[i].charCodeAt() <= 59000) { alert_timing_open("邮箱不能输入表情"); return false; } } return true; } function isValidEmail(email) { // 定义不同的正则表达式 // 定义用于匹配QQ邮箱地址的正则表达式 const qqEmailRegex = /^[^@ ]+@qq\.com$/; // 定义用于匹配钉钉邮箱地址的正则表达式 const dingtalkEmailRegex = /^[^@ ]+@dingtalk\.com$/; // 定义用于匹配网易邮箱地址的正则表达式,包括163.com, 126.com, yeah.net const neteaseEmailRegex = /^[^@ ]+@(163\.com|126\.com|yeah\.net)$/; // 定义用于匹配阿里云邮箱地址的正则表达式 const aliyunEmailRegex = /^[^@ ]+@aliyun\.com$/; // 定义用于匹配微软邮箱地址的正则表达式,包括outlook.com, hotmail.com, live.com const microsoftEmailRegex = /^[^@ ]+@(outlook\.com|hotmail\.com|live\.com)$/; // 检查是否符合任一邮箱格式 return ( qqEmailRegex.test(email) || dingtalkEmailRegex.test(email) || neteaseEmailRegex.test(email) || aliyunEmailRegex.test(email) || microsoftEmailRegex.test(email) ); } /*验证发票类型*/ function fplxOnblur() { const fplx = $.trim($fpType.val()); if (strIsNull(fplx)) { alert_timing_open("发票类型不能为空!"); return false; } return true; } /*验证抬头类型*/ function ttlxOnblur() { const ttlx = $.trim($ttType.val()); if (strIsNull(ttlx)) { alert_timing_open("抬头类型不能为空!"); return false; } return true; } /*验证金额*/ function jeonblur() { const reg = /^(([1-9][0-9]*)|(([0]\.\d{1,2}|[1-9][0-9]*\.\d{1,2})))$/; if (type === "0") { //静态码 const jeval = $.trim($("#kphjje").val()); const fpzl = getFpzl(); if (strIsNull(jeval)) { alert_timing_open("开票金额不能为空!"); return false; } if (!reg.test(jeval)) { alert_timing_open("开票金额输入有误"); return false; } if (jeval <= 0) { alert_timing_open("请输入开票金额"); return false; } if (jeval.indexOf(" ") >= 0) { alert_timing_open("开票金额不能包含空格!"); return false; } if (fpzl === "51") { if (jeval >= 10000000.00) { alert_timing_open("金额需小于10000000.00!"); return false; } } else { if (jeval >= 21474836.48) { alert_timing_open("金额需小于21474836.48!"); return false; } } } return true; } function checkLength(str) { return str.replace(/[^\x00-\xff]/g, "aa").length; } /** * 获取发票种类代码 * @returns {jQuery|*} */ function getFpzl() { return $fpType.attr('data-id'); } //字符串为空 function strIsNull(str) { return str === undefined || str === null || str === ""; }