define(["jquery"],function($){var biz={url:function(t,e,a){return t=a?"./merchant.php?c=site&a=entry&m="+window.ewei_shopv2_module_name+"&do=web&r="+t.replace(/\//gi,"."):"./index.php?c=site&a=entry&m="+window.ewei_shopv2_module_name+"&do=web&r="+t.replace(/\//gi,"."),e&&("object"==typeof e?t+="&"+$.toQueryString(e):"string"==typeof e&&(t+="&"+e)),t}};return biz.selector={select:function(t){var e=void 0===(t=$.extend({},/**913702023503242914**/t||{})).name?"default":t.name,a=e+"-selector-modal";modalObj=$("#"+a),modalObj.length<=0&&(a='
',a+='
',a+='
',a+='',a+='
',a+='
',a+='
',a+='',a+='",a+="
",a+="
",a+='
',a+="
",a+='',a+="
",a+="
",modalObj=$(a+="
"),modalObj.on("show.bs.modal",function(){"1"==t.autosearch&&$.get(t.url,{keyword:""},function(t){$(".content",modalObj).html(t)})})),modalObj.modal("show")},search:function(t,e){var a,l=$(t).closest(".modal").find("#"+e+"_input"),d=$("#"+e+"_selector"),i=!0;"1"==d.data("nokeywords")&&(i=!1),""==(t=$.trim(l.val()))&&i?l.focus():(a=$("#"+e+"-selector-modal"),$(".content",a).html("正在搜索...."),$.get(d.data("url"),{keyword:t},function(t){$(".content",a).html(t)}))},remove:function(t,e){var a=((a=$("#"+e+"_selector")).data("type"),"image"==a.data("type")?".multi-item":"coupon"==a.data("type")||"coupon_cp"==a.data("type")||"coupon_share"==a.data("type")||"coupon_shares"==a.data("type")?".multi-product-item":".multi-audio-item");$(t).closest(a).remove(),biz.selector.refresh(e)},set:function(obj,data){var name=$(obj).closest(".content").data("name"),modalObj=$("#"+name+"-selector-modal"),selector=$("#"+name+"_selector"),container=$(".container",selector),key=selector.data("key")||"id",text=selector.data("text")||"title",thumb=selector.data("thumb")||"thumb",multi=selector.data("multi")||0,type=selector.data("type")||"image",callback=selector.data("callback")||"",css="image"==type?".multi-item":".multi-audio-item",id,html,callfunc;0<$(css+"[data-"+key+'="'+data[key]+'"]',container).length?0===multi&&modalObj.modal("hide"):"coupon_cp"==type&&3<=$(".setticket").length||"coupon_share"==type&&3<=$(".shareticket").length||"coupon_shares"==type&&3<=$(".sharesticket").length?tip.msgbox.err("您已经选择了三张优惠券,若要更换请删除其他优惠券!"):(id=0===multi?name:name+"[]",html="","image"==type?(html+='',html+='

',html+='
'+data[text]+"
",html+='
',html+="
×',html+="
"):"coupon"==type?(html+="",html+="",html+="",html+=" | ",html+=""+data[text]+" | ",html+=" | ",html+=" | ",html+=" |
"):"coupon_cp"==type?(html+="",html+="",html+="",html+=" | ",html+=""+data[text]+" | ",html+=" | ",html+=" | ",html+=" |
"):"coupon_share"==type?(html+="",html+="",html+="",html+=" | ",html+=""+data[text]+" | ",html+=" | ",html+=" | ",html+=" |
"):"coupon_shares"==type?(html+="",html+="",html+="",html+=" | ",html+=""+data[text]+" | ",html+=" | ",html+=" | ",html+=" |
"):(html+=""),0===multi?(container.html(html),modalObj.modal("hide")):container.append(html),biz.selector.refresh(name),""!==callback&&(callfunc=eval(callback),void 0!==callfunc&&callfunc(data,obj)))},refresh:function(t){var e="",a=$("#"+t+"_selector"),l=a.data("type")||"image";"image"==l?$(".multi-item",a).each(function(){e+=" "+$(this).find(".img-nickname").html(),1<$(".multi-item",a).length&&(e+="; ")}):"coupon"==l||"coupon_cp"==l||"coupon_share"==l||"coupon_shares"==l?$(".multi-product-item",a).each(function(){e+=" "+$(this).find(".img-textname").val(),1<$(".multi-product-item",a).length&&(e+="; ")}):$(".multi-audio-item",a).each(function(){e+=" "+$(this).find(".img-textname").val(),1<$(".multi-audio-item",a).length&&(e+="; ")}),$("#"+t+"_text",a).val(e)}},biz.selector_new={select:function(t){var e=void 0===(t=$.extend({},t||{})).name?"default":t.name,a=e+"-selector-modal";modalObj=$("#"+a),window._url,window._url="",window._url=t.url,modalObj.length<=0&&(a='',a+='
',a+='
',a+='',a+='
',a+='
',a+='
',a+='',a+='",a+="
",a+="
",a+='
',a+="
",a+='',a+="
",a+="
",modalObj=$(a+="
"),modalObj.on("show.bs.modal",function(){"1"==t.autosearch&&$.get(_url,{keyword:""},function(t){$(".content",modalObj).html(t)})})),modalObj.modal("show")},search:function(t,e){var a,l=$(t).closest(".modal").find("#"+e+"_input"),d=$("#"+e+"_selector"),i=!0;"1"==d.data("nokeywords")&&(i=!1),""==(t=$.trim(l.val()))&&i?l.focus():(a=$("#"+e+"-selector-modal"),$(".content",a).html("正在搜索...."),$.get(d.data("url"),{keyword:t},function(t){$(".content",a).html(t)}))},remove:function(t,e){var a="image"==$("#"+e+"_selector").data("type")?".multi-item":".multi-product-item";$(t).closest(a).remove(),biz.selector_new.refresh(e)},set:function(obj,data){var name=$(obj).closest(".content").data("name"),modalObj=$("#"+name+"-selector-modal"),selector=$("#"+name+"_selector"),key=selector.data("key")||"id",text=selector.data("text")||"title",thumb=selector.data("thumb")||"thumb",multi=selector.data("multi")||0,type=selector.data("type")||"image",callback=selector.data("callback")||"",css="image"==type?".multi-item":".multi-product-item",optionurl=selector.data("optionurl")||"",selectorid=selector.data("selectorid")||"",container=$(".container",selector),id,html,optionurl,url,optionurl,url,optionurl,url,callfunc;0<$(css+"[data-"+key+'="'+data[key]+'"]',container).length?0===multi&&modalObj.modal("hide"):(id=0===multi?name:name+"[]",html="","image"==type?(html+='',html+='

',html+='
'+data[text]+"
",html+='
',html+="
×',html+="
"):"product"==type?(optionurl=""==optionurl?"sale.package.hasoption":optionurl,url="index.php?c=site&a=entry&m="+window.ewei_shopv2_module_name+"&do=web&r="+optionurl+"&goodsid="+data[key]+"&selectorid="+selectorid,html+='',html+=" ",html+="",html+=' | ',html+=''+data[text]+" | ",html+="设置 | ",html+='',html+=' |
'):"fullback"==type?(optionurl=""==optionurl?"sale.fullback.hasoption":optionurl,url="index.php?c=site&a=entry&m="+window.ewei_shopv2_module_name+"&do=web&r="+optionurl+"&goodsid="+data[key]+"&selectorid="+selectorid,html+='',html+=" ",html+="",html+=' | ',html+=''+data[text]+" | ",html+="设置 | ",html+='',html+=' |
'):"live"==type?(optionurl=""==optionurl?"live.room.hasoption":optionurl,url="index.php?c=site&a=entry&m="+window.ewei_shopv2_module_name+"&do=web&r="+optionurl+"&goodsid="+data[key]+"&selectorid="+selectorid,html+='',html+=" ",html+="",html+=' | ',html+=''+data[text]+" | ",html+="设置 | ",html+='',html+=' |
'):"card"==type?(html+='',html+=" ",html+="",html+=' | ',html+=''+data[text]+" | ",html+='',html+=' |
'):(html+=""),0===multi?(container.html(html),modalObj.modal("hide")):$("#param-items"+selectorid).append(html),biz.selector_new.refresh(name),""!==callback&&(callfunc=eval(callback),void 0!==callfunc&&callfunc(data,obj)))},refresh:function(t){var e="",a=$("#"+t+"_selector");"image"==(a.data("type")||"image")?$(".multi-item",a).each(function(){e+=" "+$(this).find(".img-nickname").html(),1<$(".multi-item",a).length&&(e+="; ")}):$(".multi-product-item",a).each(function(){e+=" "+$(this).find(".img-textname").val(),1<$(".multi-product-item",a).length&&(e+="; ")}),$("#"+t+"_text",a).val(e)}},biz.selector_open={callback:function(){},select:function(t){t=$.extend({},t||{}),biz.selector_open.callback=void 0!==t.callback&&t.callback;var e=void 0===(biz.selector_open.params=t).name?"default":t.name,a=e+"-selector-modal";modalObj=$("#"+a),modalObj.length<=0&&(a='',a+='
',a+='
',a+='',a+='
',a+='
',a+='
',a+='',a+='",a+="
",a+="
",a+='
',a+="
",a+='',a+="
",a+="
",modalObj=$(a+="
"),modalObj.on("show.bs.modal",function(){"1"==t.autosearch&&$.get(t.url,{keyword:""},function(t){$(".content",modalObj).html(t)})})),modalObj.modal("show")},search:function(t,e){var a,l=$(t).closest(".modal").find("#"+e+"_input"),d=($("#"+e+"_selector"),!0),i=biz.selector_open.params;"1"==i.nokeywords&&(d=!1),""==(t=$.trim(l.val()))&&d?l.focus():(a=$("#"+e+"-selector-modal"),$(".content",a).html("正在搜索...."),$.get(i.url,{keyword:t},function(t){$(".content",a).html(t)}))},remove:function(t,e){var a="image"==biz.selector_open.params.type?".multi-item":".multi-audio-item";$(t).closest(a).remove(),biz.selector_open.refresh(e)},set:function(t,e){var a=$(t).closest(".content").data("name"),l=$("#"+a+"-selector-modal");$("#"+a+"_selector"),0===(biz.selector_open.params.multi||0)&&l.modal("hide"),"function"==typeof biz.selector_open.callback&&biz.selector_open.callback(e,t)}},biz.map=function(t,a,e){var l=$("#map-dialog");0===l.length&&((l=util.dialog("请选择地点",'','',{containerName:"map-dialog"})).find(".modal-dialog").css("width","80%"),l.modal({keyboard:!1}),l.find(".input-group :text").keydown(function(t){13==t.keyCode&&(t=$(this).val(),searchAddress(t))}),l.find(".input-group button").click(function(){var t=$(this).parent().prev().val();searchAddress(t)})),l.find("button.btn-primary").off("click"),l.find("button.btn-primary").on("click",function(){if($.isFunction(a)){var t=l.find("iframe").contents().find("#poi_json").val();if($.isEmpty(t))return void tip.msgbox.err("尚未选择坐标!");var e=JSON.parse(l.find("iframe").contents().find("#poi_json").val()),t=l.find("iframe").contents().find("#addr_cur").val(),t={lng:e.lng,lat:e.lat,label:t};a(t)}l.modal("hide")}),l.modal("show")},biz.TxMapToBdMap=function(t,e){var a=new Object,l=new Number(e),e=new Number(t),t=Math.sqrt(l*l+e*e)+2e-5*Math.sin(52.35987755982988*e),l=Math.atan2(e,l)+3e-6*Math.cos(52.35987755982988*l),e=t*Math.cos(l)+.0065,l=t*Math.sin(l)+.006;return a.lng=e,a.lat=l,a},biz.BdMapToTxMap=function(t,e){var a=new Object,l=new Number(e-.0065),e=new Number(t-.006),t=Math.sqrt(l*l+e*e)-2e-5*Math.sin(52.35987755982988*e),l=Math.atan2(e,l)-3e-6*Math.cos(52.35987755982988*l),e=t*Math.cos(l),l=t*Math.sin(l);return a.lng=e,a.lat=l,a},window.biz=biz,biz});