!function(t){function e(n){if(i[n])return i[n].exports;var a=i[n]={i:n,l:!1,exports:{}};return t[n].call(a.exports,a,a.exports,e),a.l=!0,a.exports}var i={};e.m=t,e.c=i,e.d=function(t,i,n){e.o(t,i)||Object.defineProperty(t,i,{configurable:!1,enumerable:!0,get:n})},e.n=function(t){var i=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(i,"a",i),i},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=1)}([function(t,e){var i=function(t){function e(e,i,n){var a='
';e&&(a+="loading"==e?'
':'
'),a+="
"+i+"
",a+="
",a+='',t("body").append(a),n&&"number"==typeof n&&setTimeout(function(){t(".tipHtml").remove()},n)}function i(t){html='",t.append(html)}function n(){t(".tipHtml").remove(),t(".mark").remove()}function a(t,e){var i,n,a;try{n=t.toString().split(".")[1].length}catch(t){n=0}try{a=e.toString().split(".")[1].length}catch(t){a=0}return i=Math.pow(10,Math.max(n,a)),(t*i+e*i)/i}function o(t,e){var i,n,a,o;try{n=t.toString().split(".")[1].length}catch(t){n=0}try{a=e.toString().split(".")[1].length}catch(t){a=0}return i=Math.pow(10,Math.max(n,a)),o=n>=a?n:a,((t*i-e*i)/i).toFixed(o)}function r(t,e){var i=0;try{i+=t.toString().split(".")[1].length}catch(t){}try{i+=e.toString().split(".")[1].length}catch(t){}return Number(t.toString().replace(".",""))*Number(e.toString().replace(".",""))/Math.pow(10,i)}function c(t,e){var i,n,a=0,o=0;try{a=t.toString().split(".")[1].length}catch(t){a=0}try{o=e.toString().split(".")[1].length}catch(t){o=0}return i=Number(t.toString().replace(".","")),n=Number(e.toString().replace(".","")),i/n*Math.pow(10,o-a)}return{tipHtml:e,hideTip:n,loading:i,numAdd:a,numSub:o,numMulti:r,numDiv:c}}(jQuery);t.exports=i},function(t,e,i){var n=i(0),a=i(2);!function(t){function e(){a.getMaterialType(function(e){var i=e.list,n="";e.list.forEach(function(t){n+='"}),t("#diy_color_select").html(n),o(i[0].id)})}function i(){t("#diy_color_select").change(function(){var e=t(this).val();e&&e!=f.mtid&&o(e),f.mtid=e})}function o(e){a.getMaterial(e,function(e){for(var i="",n=0;n',i+='',i+='
',i+="
"+e.list[n].title+"
",i+="
",i+="";t("#diy_box_content").html(i),t(".do-nicescroll").getNiceScroll().resize(),t(".box_item").each(function(){t(this).unbind("click").click(function(){var e=t(this).data("imgurl");f.addImg(e)})})})}function r(){t(window).resize(function(e){f.mainCanvas&&(f.baseWidth=t(".diy_canvas_wrap").width(),f.baseHeight=t(".diy_canvas_wrap").height(),f.cutArea(f.baseWidth,f.baseHeight,!0),f.resizeCanvasSize())})}function c(){t("#diy_resize").click(function(){f.cutArea(f.baseWidth,f.baseHeight),f.resizeRender()})}function s(){t("#view_ward .click_show_item").each(function(){t(this).click(function(){switch(t(this).data("key")){case 0:var e=f.mainCanvas.getActiveObject();if(!e||"undefined"==e)return!1;f.mainCanvas.bringForward(e),f.mainCanvas.renderAll();break;case 1:var e=f.mainCanvas.getActiveObject();if(!e||"undefined"==e)return!1;f.mainCanvas.sendBackwards(e),f.mainCanvas.renderAll();break;case 2:var e=f.mainCanvas.getActiveObject();if(!e||"undefined"==e)return!1;f.mainCanvas.bringToFront(e),f.mainCanvas.renderAll();break;default:var e=f.mainCanvas.getActiveObject();if(!e||"undefined"==e)return!1;f.mainCanvas.sendToBack(e),f.mainCanvas.renderAll()}})})}function l(){a.getColor(function(e){var i="";for(var n in e.colorPanel){for(var a="",o=0;o'.replace(/{color}/g,e.colorPanel[n][o]);i+='{span}
'.replace("{span}",a)}t("#djsy_text_color_panel_content").html(i),t("#djsy_text_color_panel_content .djsy-color-panel-item > span").each(function(){t(this).click(function(){var e=t(this).data("color");f.setActiveStyle("fill",e),t(".color-span >i").css("background-color",e)})})})}function d(){t("#diy_preview").click(function(){var e=f.returnCanvasImg(200),i=document.createElement("canvas"),n=i.getContext("2d"),a=new Image;a.src=f.bottle.img_url,console.log(f.bottle),a.onload=function(){console.log(a.onload),i.width=a.width,i.height=a.height,n.drawImage(a,0,0,a.width,a.height);var o=new Image;o.src=e,o.onload=function(){o.height=.54*a.height,o.width=o.height*f.plateRATIO,n.drawImage(o,(a.width-o.width)/2,.3*a.height,o.width,o.height);var e=i.toDataURL();t("#previewCanvas").show();var r='';t("#previewImgWrap").html(r)}}})}function u(){t(".close_modal").click(function(){t(".GlobalModalsWrapper").hide()})}function v(){t("#diy_save_diy_btn").click(function(){if(f.mainCanvas._objects.length<=0)return alert("请添加内容"),!1;n.tipHtml("loading","正在提交");var t={id:f.diyId,img_url:f.returnCanvasImg(200),content:JSON.stringify(f.returnCanvasJson()),type:f.typeId||""};a.saveDiy(t,function(t){alert(t.msg+"请到个人中心-我的定制中查看"),window.location.href="/user/diy"},function(t){alert(t.msg),window.location.href="/login"})}),t("#addCart").click(function(){if(f.mainCanvas._objects.length<=0)return alert("请添加内容"),!1;n.tipHtml("loading","正在提交");var t={id:f.diyId,img_url:f.returnCanvasImg(200),content:JSON.stringify(f.returnCanvasJson()),type:f.typeId||""};a.addCart(t,function(t){alert(t.msg),window.location.href="/shop/cart"},function(t){alert(t.msg)})})}var f=new Object;f.getActiveStyle=function(t,e){var i=this.mainCanvas;return e=e||i.getActiveObject(),e?e.getSelectionStyles&&e.isEditing?e.getSelectionStyles()[t]||"":e[t]||"":""},f.setActiveStyle=function(t,e,i){var n=this.mainCanvas;if(i=i||n.getActiveObject()){if(i.setSelectionStyles&&i.isEditing){var a={};a[t]=e,i.setSelectionStyles(a),i.setCoords()}else i.set(t,e);i.setCoords(),n.renderAll()}},f.getActiveProp=function(t,e){var i=this.mainCanvas,e=e||i.getActiveObject();return e?e[t]||"":""},f.setActiveProp=function(t,e,i){var n=this.mainCanvas,i=i||n.getActiveObject();i&&(i.set(t,e).setCoords(),n.renderAll())},f.ControlVisibility=function(t){var e={tl:!0,tr:!0,br:!0,bl:!0,ml:0,mt:0,mr:0,mb:0,mtr:!0};for(var i in e)t.setControlVisible(i,e[i])},f.addImg=function(t){var e=this;fabric.Image.fromURL(t,function(t){t.set({cornerSize:15,cornerStyle:"circle",rotatingPointOffset:30,borderDashArray:[3,6],borderColor:"#000",cornerColor:"#000"});var i=t.width/t.height;e.maxWidthImg=.8*e.oldCutWidth,e.maxHeightImg=.8*e.oldCutHeight;var n,a;e.maxHeightImg*i li").each(function(){t(this).click(function(){var e=t(this).data("val");f.setActiveStyle("fontFamily",e),t("#showFont").text(e);var i=t(this).find("div")[0].className;t("#showFont").removeClass().addClass(i)})}),i(),r(),c(),s(),f.cloneObject(),f.delObject(),l(),d(),u(),v()})}(jQuery)},function(t,e,i){var n=i(0),a={getMaterialType:function(t){$.ajax({url:"/api/getMaterialType",type:"GET",dataType:"json",success:function(e){if(!e.success)return void alert(e.msg);"function"==typeof t&&t(e)}})},getMaterial:function(t,e){$.ajax({url:"/api/getMaterial",type:"GET",data:{tid:t},dataType:"json",success:function(t){if(!t.success)return void alert(t.msg);"function"==typeof e&&e(t)}})},getColor:function(t){$.ajax({url:"/admin/js/color.json",type:"GET",dataType:"json",success:function(e){"function"==typeof t&&t(e)}})},uploadImg:function(t,e){$.ajax({url:"/api/uploadImg",type:"POST",data:t,dataType:"json",cache:!1,processData:!1,contentType:!1,success:function(t){if(!t.success)return void alert(t.msg);"function"==typeof e&&e(t)}})},saveDiy:function(t,e,i){$.ajax({url:"/api/saveDiy",type:"POST",data:t,dataType:"json",success:function(t){if(n.hideTip(),!t.success)return void("function"==typeof i&&i(t));"function"==typeof e&&e(t)}})},addCart:function(t,e,i){$.ajax({url:"/api/addCart",type:"POST",data:t,dataType:"json",success:function(t){if(n.hideTip(),!t.success)return void("function"==typeof i&&i(t));"function"==typeof e&&e(t)}})},getDiy:function(t,e,i){$.ajax({url:"/api/getDiyById",type:"GET",data:t,dataType:"json",success:function(t){if(n.hideTip(),!t.success)return void alert(t.msg);"function"==typeof e&&e(t)}})}};t.exports=a}]);