{"size": 20038, "ext": "js", "max_stars_repo_path": "src/dest/js/kb_purchase.min.js", "max_stars_repo_name": "keepFur/amazon_email_node", "max_stars_repo_stars_event_min_datetime": "2020-08-08T00:27:46.000Z", "max_stars_repo_stars_event_max_datetime": "2020-08-08T00:27:46.000Z", "max_issues_repo_path": "src/dest/js/kb_purchase.min.js", "max_issues_repo_name": "keepFur/amazon_email_node", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/dest/js/kb_purchase.min.js", "max_forks_repo_name": "keepFur/amazon_email_node", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 20038.0, "max_line_length": 20038, "alphanum_fraction": 0.5485078351}
"use strict";layui.use(["form","element","table","layer","util","upload"],function(){var u=layui.form,d=layui.table,p=layui.layer,a=layui.util,e=layui.upload,m={netErrMsg:"系统已退出登录，请登录系统重试",operatorErrMsg:{single:"请选择一条数据操作",batch:"请至少选择一条数据操作"},level:1,plant:"TB",kbTypeInfo:null},f={p:"",c:"",a:"",pT:"",cT:"",aT:""},l={};function n(e){return!1}function t(e){var a=document.createElement("a");return a.href="/api/downloadTemplate?plant="+m.plant,a.click(),!1}function i(e){var a=$("textarea[name=addressTo]").val();if(!a)return p.msg("请先填写收货地址信息"),!1;var n=a.split(/\n{1,}/g),t=[],l=n.map(function(e){return $.trim(e)}).filter(function(e,a){return 4===e.split(/，|,/).length&&4===e.split(/，|,/)[2].split(/\s{1,}/g).length||(t.push('<span class="layui-text-pink">第'+(a+1)+"个</span>("+e+")； <br>"),!1)});$("#addressFormat").val();return p.open({content:'<span class="layui-text-pink">正确格式：姓名，手机，省（空格）市（空格）县区（空格）详细地址，邮编或快递单号或订单号</span><br>总共收货地址<span class="layui-text-pink">'+n.length+'个</span>，其中有效收货地址<span class="layui-text-pink">'+l.length+'个</span>，无效收货地址<span class="layui-text-pink">'+(n.length-l.length)+"个</span>"+(t.length?"。<br>无效地址分别是在：<br>"+t.join("")+'<span class="layui-text-pink">烦请修改后提交订单，谢谢！</span>':"，非常好！！！")+"<br>",title:"检查地址格式",btn:["确定"],area:["660px","500px"],html:!0,scrollbar:!1}),!1}function s(e){var i=$("textarea[name=addressTo]").val();return i?p.open({content:'<form class="layui-form layui-form-pane" name="getRealOrderForm">\n                            <div class="layui-form-item">\n                                <div class="layui-form-item layui-form-text">\n                                    <label class="layui-form-label">刷单订单的收件人姓名</label>\n                                    <div class="layui-input-block">\n                                        <textarea class="layui-textarea" placeholder="输入刷单订单的收件人姓名,一行一个，请严格按照此格式填写" name="condition"></textarea>\n                                    </div>\n                                </div>\n                            </div>\n                        </form>',title:"过滤真实订单",btn:["确定","取消"],area:["450px"],scrollbar:!1,yes:function(e){var a=$("textarea[name=condition]").val(),n=a.split(/\n{1,}/g),t=i.split(/\n{1,}/g),l=[];a?(p.msg("过滤成功"),p.close(e),l=t.filter(function(e){return-1!==n.indexOf(e.split(/，|,/)[0])}),$("textarea[name=addressTo]").val(l.join("\n")),$("textarea[name=addressTo]").trigger("blur")):p.msg("过滤条件不能为空")}}):p.msg("请先填写收货地址信息"),!1}function o(e){var a=core.getFormValues($("form[name=kbOrderForm]")),n=function(e){if(!e)return{isPass:!1,msg:"参数错误"};if(l.money<=0||l.money<core.computeTotalPrice(m.level,e.total))return{isPass:!1,msg:"主人，您的余额不足，请先充值，谢谢！！！"};return e.kbCompany?e.addressFrom?e.addressTo?e.addressTo.split(/\n{1,}/g).map(function(e){return $.trim(e)}).filter(function(e){return 4===e.split(/，|,/).length&&4===e.split(/，|,/)[2].split(/\s{1,}/g).length}).length?{isPass:!0,msg:""}:{isPass:!1,msg:"请输入正确格式的收货地址"}:{isPass:!1,msg:"请输入收货地址"}:{isPass:!1,msg:"请选择发货地址"}:{isPass:!1,msg:"请选择快递类型"}}(a),t=e.target;return n.isPass?(a.number=APIUtil.generateOrderNumer(),a.addressTo=a.addressTo.split(/\n/g).filter(function(e){return!!e}).map(function(e){return $.trim(e)}),a.addressToPca=function(){var a=[];try{a=$("textarea[name=addressTo]").val().split("\n").filter(function(e){return!!e}).map(function(e){var a=e.split(/,|，/)[2],n=a.split(" ");return n[0]+"-"+n[1]+"-"+n[2]})}catch(e){a=[]}return a}(),a.addressFromPca=a.addressFrom.split(/\s/g)[0],a.total=m.kbTypeInfo.price*a.addressTo.length,a.price=m.kbTypeInfo.price,$.ajax({url:"PDDDZ"==m.plant?"/api/createPDDDZKbOrder":"/api/createKbOrder",type:"POST",data:a,beforeSend:function(){$.lockedBtn($(t),!0,"提交中")},success:function(e,a,n){p.msg(e.success?"操作成功":"操作失败："+e.message),e.success&&core.setWindowHash("manage_kb_order?kbType="+m.plant)},error:function(e,a,n){p.msg(m.errorMsg)},complete:function(){$.unlockBtn($(t),'<i class="layui-icon layui-icon-release"></i>提交订单')}})):p.msg(n.msg),!1}function r(e){return p.open({content:'<form class="layui-form layui-form-pane" name="kbAddressCreateForm">\n                            <div class="layui-form-item">\n                                <div class="layui-form-item">\n                                    <div class="layui-input-inline">\n                                        <select name="pCode" lay-filter="province">\n                                        <option value="">请选择省份</option>\n                                        </select>\n                                    </div>\n                                    <div class="layui-input-inline">\n                                        <select name="cCode" lay-filter="city">\n                                        <option value="">请选择城市</option>\n                                        </select>\n                                    </div>\n                                    <div class="layui-input-inline">\n                                        <select name="aCode" lay-filter="area">\n                                        <option value="">请选择区域</option>\n                                        </select>\n                                    </div>\n                                </div>\n                                <div class="layui-form-item layui-form-text">\n                                    <label class="layui-form-label">详细地址</label>\n                                    <div class="layui-input-block">\n                                        <input class="layui-input" placeholder="此处不需要填省市区了"  name="detail"/>\n                                    </div>\n                                </div>\n                                <div class="layui-form-item layui-form-text">\n                                    <label class="layui-form-label">寄件人</label>\n                                    <div class="layui-input-block">\n                                        <input class="layui-input"  name="contact"/>\n                                    </div>\n                                </div>\n                                <div class="layui-form-item layui-form-text">\n                                    <label class="layui-form-label">手机号</label>\n                                    <div class="layui-input-block">\n                                        <input class="layui-input"  name="phone"/> \n                                    </div>\n                                </div>\n                                <div class="layui-form-item layui-form-text">\n                                    <label class="layui-form-label">邮编</label>\n                                    <div class="layui-input-block">\n                                        <input class="layui-input"  name="email"/> \n                                    </div>\n                                </div>\n                                <div class="layui-form-item layui-form-text">\n                                    <label class="layui-form-label">备注</label>\n                                    <div class="layui-input-block">\n                                        <input type="text" name="remark"  class="layui-input">\n                                    </div>\n                                </div>\n                            </div>\n                        </form>',title:"创建收货地址",btn:["创建","取消"],area:["660px"],yes:function(t,e){var a=core.getFormValues($("form[name=kbAddressCreateForm]")),n=g(a),l=e.find(".layui-layer-btn0");a.pca=f.pT+"-"+f.cT+"-"+f.aT,n.isPass?$.ajax({url:"/api/createKbAddress",type:"POST",data:a,beforeSend:function(){$.lockedBtn(l,!0,"创建中")},success:function(e,a,n){p.msg(e.success?"操作成功":"操作失败"),p.close(t),b(),x()},error:function(e,a,n){p.msg(m.errorMsg)},complete:function(){$.unlockBtn(l,'<i class="layui-icon layui-icon-release"></i>创建')}}):p.msg(n.msg)},success:function(){C(),u.on("select(province)",function(e){A(e.value),f.p=e.value,f.pT=$(e.elem).find("option[value="+e.value+"]").data("name"),f.c="",f.cT="",f.a="",f.aT="",P([],$("select[name=aCode]"),"area")}),u.on("select(city)",function(e){D(f.p,e.value),f.c=e.value,f.cT=$(e.elem).find("option[value="+e.value+"]").data("name"),f.a=""}),u.on("select(area)",function(e){f.a=e.value,f.aT=$(e.elem).find("option[value="+e.value+"]").data("name")})}}),!1}function c(e){var n=d.checkStatus("kbAddressTable").data;if(1===n.length){var a=n[0].contact,t=n[0].phone,l=n[0].detail,i=n[0].remark,s=n[0].email,o=n[0].pCode,r=n[0].cCode,c=n[0].aCode;p.open({content:'<form class="layui-form layui-form-pane" name="kbAddressUpdateForm" lay-filter="kbAddressUpdateForm">\n                            <div class="layui-form-item">\n                                <div class="layui-form-item">\n                                    <div class="layui-input-inline">\n                                        <select name="pCode" lay-filter="province">\n                                        <option value="">请选择省份</option>\n                                        </select>\n                                    </div>\n                                    <div class="layui-input-inline">\n                                        <select name="cCode" lay-filter="city">\n                                        <option value="">请选择城市</option>\n                                        </select>\n                                    </div>\n                                    <div class="layui-input-inline">\n                                        <select name="aCode" lay-filter="area">\n                                        <option value="">请选择区域</option>\n                                        </select>\n                                    </div>\n                                </div>\n                                <div class="layui-form-item layui-form-text">\n                                    <label class="layui-form-label">详细地址</label>\n                                    <div class="layui-input-block">\n                                        <input class="layui-input" placeholder="此处不需要填省市区了" value="'+l+'" name="detail"/>\n                                    </div>\n                                </div>\n                                <div class="layui-form-item layui-form-text">\n                                    <label class="layui-form-label">寄件人</label>\n                                    <div class="layui-input-block">\n                                        <input class="layui-input" value="'+a+'" name="contact" />\n                                    </div>\n                                </div>\n                                <div class="layui-form-item layui-form-text">\n                                    <label class="layui-form-label">手机号</label>\n                                    <div class="layui-input-block">\n                                        <input class="layui-input" value="'+t+'" name="phone"/>\n                                    </div>\n                                </div>\n                                <div class="layui-form-item layui-form-text">\n                                    <label class="layui-form-label">邮编</label>\n                                    <div class="layui-input-block">\n                                        <input class="layui-input" value="'+s+'" name="email"/>\n                                    </div>\n                                </div>\n                                <div class="layui-form-item layui-form-text">\n                                    <label class="layui-form-label">备注</label>\n                                    <div class="layui-input-block">\n                                        <input type="text" name="remark" value="'+i+'" class="layui-input">\n                                    </div>\n                                </div>\n                            </div>\n                        </form>',title:"收货地址信息修改",btn:["确定","取消"],area:["660px"],yes:function(t){var e=core.getFormValues($("form[name=kbAddressUpdateForm]")),a=g(e);e.id=n[0].id,e.pca=f.pT+"-"+f.cT+"-"+f.aT,a.isPass?$.ajax({url:"/api/updateKbAddress",type:"POST",data:e,success:function(e,a,n){p.msg(e.success?"操作成功":"操作失败"+e.message),p.close(t),b(),x()},error:function(e,a,n){p.msg(m.errorMsg)}}):p.msg(a.msg)},success:function(){C(function(){u.val("kbAddressUpdateForm",{pCode:o})}),A(o,function(){u.val("kbAddressUpdateForm",{cCode:r})}),D(o,r,function(){u.val("kbAddressUpdateForm",{aCode:c})}),u.on("select(province)",function(e){A(e.value),f.p=e.value,f.pT=$(e.elem).find("option[value="+e.value+"]").data("name"),f.c="",f.cT="",f.a="",f.aT="",P([],$("select[name=aCode]"),"area")}),u.on("select(city)",function(e){D(f.p,e.value),f.c=e.value,f.cT=$(e.elem).find("option[value="+e.value+"]").data("name"),f.a=""}),u.on("select(area)",function(e){f.a=e.value,f.aT=$(e.elem).find("option[value="+e.value+"]").data("name")})}})}else p.msg(m.operatorErrMsg.single);return!1}function v(e){var a=d.checkStatus("kbAddressTable").data;if(1===a.length){if(1===a[0].isDefault)return p.msg("该地址已经是默认的了"),!1;p.confirm("确定设置为默认发货地址吗？",{btn:["确定","取消"],title:"询问框"},function(){$.ajax({url:"/api/setDefaultKbAddress",type:"POST",data:{id:a[0].id},success:function(e,a,n){p.msg(e.success?"操作成功":"操作失败"+e.message),b(),x()},error:function(e,a,n){p.msg(m.netErrMsg)}})})}else p.msg(m.operatorErrMsg.single);return!1}function y(e){var a=d.checkStatus("kbAddressTable").data,n=e.data.type,t=0===n?"确定禁用吗？":"确定启用吗？";if(1===a.length){if(0===n&&a[0].isDefault)return p.msg("当前地址是默认地址，不允许禁用，请先取消默认地址在进行操作！！！"),!1;p.confirm(t,{btn:["确定","取消"],title:"询问框"},function(){$.ajax({url:"/api/toggleKbAddress",type:"POST",data:{id:a[0].id,status:n},success:function(e,a,n){p.msg(e.success?"操作成功":"操作失败"+e.message),b(),x()},error:function(e,a,n){p.msg(m.netErrMsg)}})})}else p.msg(m.operatorErrMsg.single);return!1}function b(e){d.reload("kbAddressTable",e)}function g(e){return e?e.pCode?e.cCode?e.aCode?e.detail?e.contact?e.phone?e.email?{isPass:!0,msg:""}:{isPass:!1,msg:"邮编不能为空"}:{isPass:!1,msg:"手机号不能为空"}:{isPass:!1,msg:"联系人不能为空"}:{isPass:!1,msg:"详细地址不能为空"}:{isPass:!1,msg:"请选择区域"}:{isPass:!1,msg:"请选择城市"}:{isPass:!1,msg:"请选择省份"}:{isPass:!1,msg:"参数错误"}}function T(a){var n=[];try{n=JSON.parse(localStorage.getItem("getKbTypeClient"))}catch(e){n=[]}return n.filter(function(e){return e.plant===a})}function k(e){var s=$("select[name=kbCompany]");s.empty(),s.append('<option value="">请选择快递类型</option>'),$.each(e,function(e,a){var n=core.fenToYuan(core.computeTotalPrice(m.level,a.price)),t=core.fenToYuan(core.computeTotalPrice(1,a.price)),l=core.fenToYuan(core.computeTotalPrice(2,a.price)),i=["","普通会员","金牌会员","内部会员"][m.level];s.append('<option value="'+a.code+'" data-price="'+a.price+'" data-plant="'+a.plant+'" data-desc="'+a.description+'">'+a.name+" ，你的价格（"+i+"）："+n+"元，普通会员："+t+"元，金牌会员："+l+"元</option>")}),u.render("select")}function x(){$.get("/api/readKbAddress?status=1",function(e){var a,n;a=e.data.rows,(n=$("select[name=addressFrom]")).empty(),n.append(' <option value="">请选择发货地址</option>'),$.each(a,function(e,a){n.append('<option value="'+a.pca+" "+a.detail+'" '+(a.isDefault?"selected":"")+">"+a.pca+" "+a.detail+" "+a.contact+" "+a.phone+" "+a.email+(a.isDefault?"    【默认地址】":"")+"</option>")}),u.render("select")},"json")}function h(){var a=[];try{a=$("textarea[name=addressTo]").val().split("\n").filter(function(e){return!!e})}catch(e){a=[]}return a}function P(e,n,a){n.empty(),n.append('<option value="">请选择'+{province:"省份",city:"城市",area:"区域"}[a]+"</option>"),$.each(e,function(e,a){n.append('<option value="'+a.code+'" data-name="'+a.name+'">'+a.name+"</option>")}),u.render("select")}function C(a){$.get("/api/getProvince",function(e){P(e.rows,$("select[name=pCode]"),"province"),a&&a()},"json")}function A(e,a){$.get("/api/getCityByCode",{code:e},function(e){P(e.rows,$("select[name=cCode]"),"city"),a&&a()},"json")}function D(e,a,n){$.get("/api/getAreaByCode",{pCode:e,cCode:a},function(e){P(e.rows,$("select[name=aCode]"),"area"),n&&n()},"json")}u.render("select"),u.render("radio"),x(),d.render({elem:"#kbAddressTable",url:"/api/readKbAddress",cols:[[{checkbox:!0},{title:"寄件人",field:"contact"},{title:"手机",field:"phone"},{title:"地址",field:"detail",templet:function(e){return e.pca+e.detail}},{title:"邮编",field:"email"},{title:"备注",field:"remark"},{title:"创建时间",field:"createdDate",templet:function(e){return a.toDateString(e.createdDate,"yyyy-MM-dd HH:mm")}},{title:"最后修改时间",field:"updateDate",templet:function(e){return e.updateDate?a.toDateString(e.updateDate,"yyyy-MM-dd HH:mm"):""}},{title:"是否默认",field:"",templet:function(e){return 1===e.isDefault?'<span class="layui-text-pink">是</span>':"否"}},{title:"状态",field:"status",templet:function(e){return 1===e.status?"启用":'<span class="layui-text-pink">停用</span>'}}]],response:{statusCode:!0},parseData:function(e){return{code:e.success,msg:e.msg,data:e.data.rows}}}),u.on("radio",function(e){k(T(e.value));var a="PDD"===e.value?"格式：姓名，手机，省（空格）市（空格）县区（空格）详细地址，订单流水号 \n例如：张三，13688888888 ，广东省 深圳市 罗湖区 深南大道102号，20150831-070478496\n严格按上面的格式来  三个逗号，三个空格，一个都不要少，也不能多\n一行一个地址\nPS：提交订单之前最好先点击下面的【检查地址格式】按钮来检查地址格式是否正确，系统会将不符合格式的地址进行提示，不强制检查。":"PDDDZ"===e.value?"格式：姓名，手机，省（空格）市（空格）县区（空格）详细地址，快递单号 \n例如：张三，13688888888 ，广东省 深圳市 罗湖区 深南大道102号，2015083113213123\n严格按上面的格式来  三个逗号，三个空格，一个都不要少，也不能多\n一行一个地址\nPS：提交订单之前最好先点击下面的【检查地址格式】按钮来检查地址格式是否正确，系统会将不符合格式的地址进行提示，不强制检查。":"格式：姓名，手机，省（空格）市（空格）县区（空格）详细地址，邮编 \n例如：张三，13688888888 ，广东省 深圳市 罗湖区 深南大道102号，518000 \n严格按上面的格式来  三个逗号，三个空格，一个都不要少，也不能多\n一行一个地址\nPS：提交订单之前最好先点击下面的【检查地址格式】按钮来检查地址格式是否正确，系统会将不符合格式的地址进行提示，不强制检查。";$("#addressFormat").val(a),m.plant=e.value,$("#bbDetailContainer").addClass("layui-hide"),$("#description").text("")}),u.on("select(kbCompany)",function(e){if(e.value){var a=$(e.elem).find("option[value="+e.value+"]"),n=a.data("price"),t=a.data("plant"),l=a.data("desc");m.kbTypeInfo={price:n,plant:t,code:e.value},$("#kbPrice").text(core.fenToYuan(n)),$("#discountKbPrice").text(core.fenToYuan(core.computeTotalPrice(m.level,n)));var i=h().length,s=i&&m.kbTypeInfo?i*m.kbTypeInfo.price:0;$("#kbQuantity").text(i),$("#kbSumMoney").text(core.fenToYuan(s)),$("#discountKbSumMoney").text(core.fenToYuan(core.computeTotalPrice(m.level,m.kbTypeInfo?i*m.kbTypeInfo.price:0)*i)),$("#bbDetailContainer").removeClass("layui-hide"),$("#description").text(l)}else m.kbTypeInfo=null,$("#bbDetailContainer").addClass("layui-hide"),$("#description").text("")}),$("textarea[name=addressTo]").on("blur",function(e){var a=h().length,n=a&&m.kbTypeInfo?a*m.kbTypeInfo.price:0;return $("#kbQuantity").text(a),$("#kbSumMoney").text(core.fenToYuan(n)),$("#discountKbSumMoney").text(core.fenToYuan(core.computeTotalPrice(m.level,m.kbTypeInfo?m.kbTypeInfo.price:0)*a)),!1}),$("#importAddressExcelBtn").on("click",n),$("#downloadTemplateBtn").on("click",t),$("#formatAddressBtn").on("click",i),$("#getRealOrderBtn").on("click",s),$("#createKbOrderBtn").on("click",o),$(".js-create-bb-address").on("click",r),$("#updateKbAddressBtn").on("click",c),$("#setDefaultKbAddressBtn").on("click",v),$("#disabledKbAddressBtn").on("click",{type:0},y),$("#enabledKbAddressBtn").on("click",{type:1},y),core.getUserInfoById(function(e){var a;l=e.data.rows[0],m.level=l.level,a="TB",$.get("/api/readKbType?status=1",function(e){localStorage.setItem("getKbTypeClient",JSON.stringify(e.data.rows)),k(T(a))},"json"),$("#userName").data("user",JSON.stringify(e)),$("#userBalance").text(core.fenToYuan(l.money)),$("#userLevel").html(core.getLevelText(l.level)),$("#discountKbSumMoneyText,#discountKbPriceText").toggle(1!==l.level)}),e.render({elem:"#importAddressExcelBtn",url:"/api/importAddressExcel",done:function(e){var a;e.success?(p.msg("数据解析成功！！"),$("textarea[name=addressTo]").val((a=e.data,a.map(function(e){return e.name+"，"+e.phone+"，"+e.province+" "+e.city+" "+e.area+" "+e.detail+"，"+e.email})).join("\n"))):p.msg("数据解析失败："+e.message),p.closeAll("loading")},before:function(e){p.load()},data:{plant:function(){return m.plant}},size:2048,accept:"file",exts:"xls|xlsx|csv",error:function(e){p.closeAll("loading"),p.msg("数据解析失败:服务器异常！！！")}})});