Commit c67794898e9c76aa34433b2a71cbabc0d12c1712
1 parent
41dfe5f8
Exists in
master
app-wx(v0.1.0 build 22)
F 评论界面未传图片的时候报错了
Showing
5 changed files
with
17 additions
and
9 deletions
Show diff stats
app-wx/config/params.php
app-wx/modules/order/controllers/CustomerController.php
... | ... | @@ -161,12 +161,18 @@ class CustomerController extends CustomerBaseController |
161 | 161 | $rateModel = RepairOrderRate::create($items); |
162 | 162 | $commentImages = RepairOrderRate::mvImages($orderModel->uuid, $images); |
163 | 163 | $images = []; |
164 | - foreach($commentImages as $k => $v) { | |
165 | - $images[] = $v[0].$v[1]; | |
164 | + if ($commentImages) { | |
165 | + foreach($commentImages as $k => $v) { | |
166 | + $images[] = $v[0].$v[1]; | |
167 | + } | |
166 | 168 | } |
167 | - $rateModel->images = implode(',', $images); | |
168 | - //$rateModel->save(); | |
169 | - if ($rateModel && $rateModel->save()) { | |
169 | + | |
170 | + if ($images) { | |
171 | + $rateModel->images = implode(',', $images); | |
172 | + $rateModel->save(); | |
173 | + } | |
174 | + | |
175 | + if ($rateModel) { | |
170 | 176 | $e->success = true; |
171 | 177 | $e->message = '提交成功'; |
172 | 178 | } else { | ... | ... |
domain/system/SmsMessage.php
... | ... | @@ -24,6 +24,7 @@ class SmsMessage |
24 | 24 | */ |
25 | 25 | private function send(string $mobile, string $signName, string $templateCode, array $templateParam) |
26 | 26 | { |
27 | + AppLog::DEBUG('短信发送结果:' . json_encode($templateParam, JSON_UNESCAPED_UNICODE)); | |
27 | 28 | if (YII_ENV_DEV) { |
28 | 29 | return true; |
29 | 30 | } |
... | ... | @@ -36,7 +37,7 @@ class SmsMessage |
36 | 37 | 'TemplateCode' => $templateCode, |
37 | 38 | ]; |
38 | 39 | if ($templateParam) { |
39 | - $query['TemplateParam'] = json_encode($templateParam); | |
40 | + $query['TemplateParam'] = json_encode($templateParam, JSON_UNESCAPED_UNICODE); | |
40 | 41 | } |
41 | 42 | |
42 | 43 | $result = AlibabaCloud::rpc() |
... | ... | @@ -106,6 +107,7 @@ class SmsMessage |
106 | 107 | |
107 | 108 | /* |
108 | 109 | * 模版CODE: SMS_181853499 |
110 | + * | |
109 | 111 | * 尊敬的车主,您的爱车正在${maintainer}维修,预计${dateTime}维修完成,预估维修内容:${repairPlan},预估维修费:${repairPrice},维修厂地址:${address},联系电话:${tel} |
110 | 112 | * */ |
111 | 113 | public function sendSubmitInfo($phone, $postData) | ... | ... |
web/dist/js/order-app.js
1 | -define("order-app",["mk7/app"],function(t){var e=Dom7,i=function(){var t=e(".ui-loading-block");0==t.length&&(e(".view-main").html('<div class="ui-loading-block" id="ui-loading"><div class="ui-loading-cnt"><div class="spinner"><div class="bounce1"></div><div class="bounce2"></div><div class="bounce3"></div></div><div id="loader-inner"><p></p></div> </div> </div>'),window.waitingTime=1e4,window.loaderTimer&&clearTimeout(window.loaderTimer),window.loaderTimer=setTimeout(function(){var t=document.getElementById("loader-inner"),e=document.createElement("p");e.className="notice",t&&(e.innerHTML='加载速度太慢?试试<a class="link" href="#" onclick="javascript:location.reload();return false;">重新加载</a>',t.appendChild(e))},window.waitingTime))},n=!0;return t.name="order",t.routes={index:function(){return n=!1,i(),t.runController("index")},"index/:tab":function(e){n=!1,i();var a={tab:e};return t.runController("index",a)},submit:function(){return n=!1,i(),t.runController("submit")},"order-details/:id":function(e){n=!1,i();var a={id:e};return t.runController("order-details",a)},"customer-order/:id/:sn":function(e,a){n=!1,i();var r={id:e,sn:a};return t.runController("customer-order",r)},"rate/:id/:sn":function(e,a){n=!1,i();var r={id:e,sn:a};return t.runController("rate",r)},"cost-list/:id":function(e){n=!1,i();var a={id:e};return t.runController("cost-list",a)},"*":function(){return t.runController("index")}},t}),define("order/cost-list-controller",["mk7/controller","mk7/url","mk7/utils","mk7/uploadjs"],function(t,e,i,n){var a=Dom7,t=(Template7,new t),r="/user/default/upload-file",o="/order/default/submit-repair-plans";return t.run=function(){var t=this;t.setPageTitle("费用列表"),t.id=t.params.id,t.imgLimit=9,t.canSubmit=!0,t.render({id:t.id})},t.bindEvents=function(){var t=this;console.log("bindEvents"),t.addEvent(),t.uploadImgEvent(),t.delPlanEvent(),t.inputPriceChangeEvent(),t.submitEvent()},t.addEvent=function(){var t=this;a("#cost-list .add-repair-plan").click(function(e){var i=a("#cost-list .cost-list-div"),n=t.planTpl(i.length+1);a(n).insertBefore(a("#cost-list .cost-total-list-div"))})},t.delPlanEvent=function(){var t=this;a("#cost-list").on("click",".del-plan",function(e){console.log("del plan event"),a(this).parents(".cost-list-div").remove(),a("#cost-list .total-plan-price").html(t.computedPrice())})},t.planTpl=function(t){var e='<div class="cost-list-div"><p class="item-title">第'+t+'项</p><div class="repair-item-cls"><input type="text" class="input-left input-cls" placeholder="填写维修内容" value=""><input type="number" class="input-right input-cls" placeholder="价格" value=""><span class="del-plan"></span></div></div>';return e},t.inputPriceChangeEvent=function(){var t=this;a("#cost-list").on("input propertychange",".input-cls",function(){var e=t.computedPrice();a("#cost-list .total-plan-price").html(e)})},t.computedPrice=function(){var t=a("#cost-list .input-right"),e=0;return a.each(t,function(t,i){e+=1*a(i).val()}),Math.round(e,2)},t.uploadImgEvent=function(){var t=this;a("#cost-list #upload-btn").change(function(){if(""!=a(this).val()&&null!=a(this).val()){var o=a(this).parents("li");n.uploadFile({selector:"#upload-btn",url:e.to(r),processAppendTo:"#cost-list",success:function(e,n){try{if(e.success){var r=e.tmpUrl;a('<li class="upload-li up-img"><div data="'+e.tmpFile+'" data-url="'+r+'" class="upload-item" style="background-image:url('+e.tmpMinUrl+')"></div><span class="del-img"></span></li>').insertBefore(o),t.imgLimit==a("#cost-list #image-list").find(".up-img").length&&a("#cost-list .upload-btn-li").hide()}else i.toast({content:e.message,closeDelay:5e3})}catch(s){console.log(s),i.toast({content:"出错",closeDelay:5e3})}}})}}),a("#cost-list #image-list").on("click",".del-img",function(e){a(this).parent().remove(),t.imgLimit>=a("#cost-list #image-list").find(".up-img").length&&a("#cost-list .upload-btn-li").show()})},t.submitEvent=function(){var t=this;a("#cost-list .btn-submit").click(function(n){var r=a("#cost-list .content-div").find(".repair-item-cls"),s=[],l=!0,c=!0;if(a.each(r,function(t,e){var n=i.trim(a(e).find(".input-left").val()),r=i.trim(a(e).find(".input-right").val());""==n&&(l=!1),""!=r&&0!=r||(c=!1),s.push({content:n,price:r})}),!l)return i.toast({content:"维修清单有部分未填内容"}),!1;if(!c)return i.toast({content:"维修清单有部分未填价格"}),!1;var u=a("#cost-list #image-list").find(".upload-item"),d=[];if(a.each(u,function(t,e){d.push(a(e).attr("data"))}),!t.canSubmit)return!1;t.canSubmit=!1;var m=t.csrf({images:d,plans:s,id:t.id});i.httpPost(o,m,function(n){t.canSubmit=!0,n.success?window.location.replace(e.to("order#index")):i.toast({content:n.message})},!0)})},t}),define("order/customer-order-controller",["mk7/controller","mk7/url","mk7/utils","mk7/photo-browser"],function(t,e,i,n){var a=Dom7,r=Template7,t=new t,o="order/customer/order-details";return t.run=function(){var t=this;t.id=t.params.id,t.sn=t.params.sn,t.success=!0,t.setPageTitle("维修单"),t.loadPage()},t.bindEvents=function(){var t=this;console.log("bindEvents"),t.goToComment(),t.popupImageLayer(),t.agreementEvent()},t.beforeRender=function(){var t=this;console.log("beforeRender"),t.success||(this.view="customer-order-error")},t.loadPage=function(){var t=this,n=t.csrf({id:t.id});i.httpPost(e.to(o),n,function(e){var i=e;t.success=e.success,t.render(i)},!0)},t.goToComment=function(){var t=this;a("#customer-order .rate-btn-cls").click(function(i){window.location.replace(e.to("order/customer#rate/"+t.id+"/"+t.sn))})},t.agreementEvent=function(){a("#customer-order").on("click",".warranty-btn",function(t){a("#warranty-wrapper").remove();var e=a("#customer-order"),i=a("script#warranty-template"),n=r.compile(i.html()),o=n({});e.append(o)}),a("#customer-order").on("click",".agree-btn",function(t){a("#warranty-wrapper").remove()})},t.popupImageLayer=function(){var t=this;a("#customer-order").on("click",".view-img-cls",function(e){var i=a(this).parents("ul"),n=i.find(".view-img-cls"),r=[],o=a(this).attr("data-index");a.each(n,function(t,e){var i=a(e).attr("data-url");r.push(i)});var s=t.app.photoBrowser({photos:r,initialSlide:o});s.open()})},t}),define("order/index-controller",["mk7/controller","mk7/url","mk7/utils"],function(t,e,i){var n=Dom7,a=Template7,t=new t,r="order/default/order-list";return t.run=function(){var t=this;t.setPageTitle("订单列表"),t.tab=t.params.tab,t.page=0,t.nodata="",t.loading=!1,t.pageCount=1,t.render({tab:t.tab}),t.loadPage()},t.bindEvents=function(){var t=this;console.log("bindEvents"),t.tabEvent(),t.bindScrollEvent(),t.addEvent(),t.orderClickEvent()},t.tabEvent=function(){n(".tab-cls").click(function(t){var e=n(this).attr("data-href");window.location.replace(e)})},t.handleNodata=function(){var t=this;t.nodata="没有数据了";var e=n(".nodata");0==e.length&&n("#index .order-list").append('<div class="nodata">'+t.nodata+"</div>"),t.app.detachInfiniteScroll(".infinite-scroll"),n("#index .infinite-scroll-preloader").remove()},t.loadPage=function(){var t=this;if(t.loading=!0,t.page>=t.pageCount)return void t.handleNodata();var a={status:t.tab};a.page=t.page+1,a=t.csrf(a),n.ajax({method:"GET",url:e.to(r),data:a,dataType:"json",beforeSend:function(){t.showIndicator()},success:function(e){if(1==e.success&&(i.isDefined(e.page)&&(t.page=parseInt(e.page)),i.isDefined(e.page_count)&&(t.pageCount=parseInt(e.page_count)),t.renderItems(e.items,!0),t.page>=t.pageCount))return void t.handleNodata()},error:function(t){},complete:function(e){t.hideIndicator(),t.loading=!1}})},t.bindScrollEvent=function(){var t=this;t.app.attachInfiniteScroll("#index .infinite-scroll"),n("#index .infinite-scroll").on("infinite",function(){t.loading||t.nodata||t.loadPage()})},t.renderItems=function(t,e){var i=n("#index .order-list"),r=n("script#order-item-template"),o=a.compile(r.html()),s=o({list:t});0==e&&(i.html(""),i.append(s)),i.append(s)},t.addEvent=function(){n("#index .add-btn-cls").click(function(t){window.location.href=e.to("order/#submit")})},t.orderClickEvent=function(){n("#index").on("click",".order-item",function(t){var i=n(this).attr("data-id");window.location.href=e.to("order#order-details/"+i)})},t}),define("order/order-details-controller",["mk7/controller","mk7/url","mk7/utils","mk7/photo-browser"],function(t,e,i,n){var a=Dom7,t=(Template7,new t),r="order/default/order-details";return t.run=function(){var t=this;t.id=t.params.id,t.success=!0,t.setPageTitle("维修单"),t.loadPage()},t.bindEvents=function(){var t=this;console.log("bindEvents"),t.finishBtnEvent(),t.popupImageLayer()},t.beforeRender=function(){var t=this;console.log("beforeRender"),t.success||(t.view="order-details-error")},t.loadPage=function(){var t=this,n=t.csrf({id:t.id});i.httpPost(e.to(r),n,function(e){var i=e;t.success=e.success,t.render(i)},!0)},t.finishBtnEvent=function(){var t=this;a("#order-details .finish-submit").click(function(i){window.location.replace(e.to("order/#cost-list/"+t.id))})},t.agreementEvent=function(){},t.popupImageLayer=function(){var t=this;a("#order-details").on("click",".view-img-cls",function(e){var i=a(this).parents("ul"),n=i.find(".view-img-cls"),r=[],o=a(this).attr("data-index");a.each(n,function(t,e){var i=a(e).attr("data-url");r.push(i)});var s=t.app.photoBrowser({photos:r,initialSlide:o});s.open()})},t}),define("order/rate-controller",["mk7/controller","mk7/url","mk7/utils","mk7/uploadjs"],function(t,e,i,n){var a=Dom7,t=(Template7,new t),r="order/customer/submit-rate",o="/user/default/upload-file";return t.run=function(){var t=this;t.id=t.params.id,t.sn=t.params.sn,t.imgLimit=4,t.setPageTitle("评价"),t.loadPage()},t.bindEvents=function(){var t=this;console.log("bindEvents"),t.starClickEvent(),t.submitEvent(),t.uploadImgEvent()},t.loadPage=function(){var t=this;t.render({servicePhone:window.$site.servicePhone})},t.starClickEvent=function(){a("#rate").on("click",".img-star",function(t){var e=a(this).attr("data-id"),i=a(this).parent(".star-div"),n=i.find(".img-star");a.each(n,function(t,n){var r=a(n).attr("data-id");if(1*r<=e){a(n).addClass("star-on");var o=i.find(".rate-text"),s=a(n).attr("data-txt");o.html(s)}else a(n).removeClass("star-on")})})},t.uploadImgEvent=function(){var t=this;a("#rate #upload-btn").change(function(){if(""!=a(this).val()&&null!=a(this).val()){var r=a(this).parents("li");n.uploadFile({selector:"#upload-btn",url:e.to(o),processAppendTo:"#rate",success:function(e,n){try{if(e.success){var o=e.tmpUrl;a('<li class="upload-li up-img"><div data="'+e.tmpFile+'" data-url="'+o+'" class="upload-item" style="background-image:url('+e.tmpMinUrl+')"></div><span class="del-img"></span></li>').insertBefore(r),t.imgLimit==a("#rate #image-list").find(".up-img").length&&a("#rate .upload-btn-li").hide()}else i.toast({content:e.message,closeDelay:5e3})}catch(s){console.log(s),i.toast({content:"出错",closeDelay:5e3})}}})}}),a("#rate #image-list").on("click",".del-img",function(e){a(this).parent().remove(),t.imgLimit>=a("#rate #image-list").find(".up-img").length&&a("#rate .upload-btn-li").show()})},t.getUploadImgs=function(){var t=a("#rate #image-list").find(".up-img"),e=[];return 0==t.length?[]:(a.each(t,function(t,i){var n=a(i).find(".upload-item");e.push(n.attr("data"))}),e)},t.submitEvent=function(){var t=this;a("#rate .submit-btn").click(function(n){var o=i.trim(a("#rate .text-content").val()),s=a("#rate .quality-box .img-star"),l=0;a.each(s,function(t,e){a(e).hasClass("star-on")&&l++});var c=a("#rate .effect-box .img-star"),u=0;a.each(c,function(t,e){a(e).hasClass("star-on")&&u++});var d=a("#rate .service-box .img-star"),m=0;a.each(d,function(t,e){a(e).hasClass("star-on")&&m++});var p=t.getUploadImgs(),v=t.csrf({comment:o,id:t.id,qualityStar:l,effectStar:u,serviceStar:m,images:p});i.httpPost(e.to(r),v,function(n){n.success?window.location.replace(e.to("order/customer#customer-order/"+t.id+"/"+t.sn)):i.toast({content:n.message})},!0)})},t}),define("order/submit-controller",["mk7/controller","mk7/url","mk7/utils","mk7/uploadjs","mk7/picker"],function(t,e,n,a,r){var o=Dom7,s=Template7,t=new t,l="/user/default/upload-file",c="/order/default/do-submit",u=!0,d="";return t.run=function(){var t=this;t.setPageTitle("录入维修单"),t.imgLimit=9,t.render(),t.loadInit()},t.bindEvents=function(){var t=this;console.log("bindEvents"),t.uploadImgEvent(),t.submitEvent(),t.selectDateEvent(),t.openCarModel(),t.searchCarModel(),t.carModelClick()},t.loadInit=function(){var t=this;({id:t.id})},t.uploadImgEvent=function(){var t=this;o("#submit #upload-btn").change(function(){if(""!=o(this).val()&&null!=o(this).val()){var i=o(this).parents("li");a.uploadFile({selector:"#upload-btn",url:e.to(l),processAppendTo:"#submit",success:function(e,a){try{if(e.success){var r=e.tmpUrl;o('<li class="upload-li up-img"><div data="'+e.tmpFile+'" data-url="'+r+'" class="upload-item" style="background-image:url('+e.tmpMinUrl+')"></div><span class="del-img"></span></li>').insertBefore(i),t.imgLimit==o("#submit #image-list").find(".up-img").length&&o("#submit .upload-btn-li").hide()}else n.toast({content:e.message,closeDelay:5e3})}catch(s){n.toast({content:"出错",closeDelay:5e3})}}})}}),o("#submit #image-list").on("click",".del-img",function(e){o(this).parent().remove(),t.imgLimit>=o("#submit #image-list").find(".up-img").length&&o("#submit .upload-btn-li").show()})},t.submitEvent=function(){var t=this;o("#submit .submit-btn-cls").click(function(i){var a=n.trim(o("#submit .carNo").val()),r=n.trim(o("#submit .carModel").val()),s=n.trim(o("#submit .customer").val()),l=n.trim(o("#submit .phone").val()),d=n.trim(o("#submit .preRepair").val()),m=n.trim(o("#submit .repairPrice").val()),p=n.trim(o("#submit .finishDate").val());if(0==u)return!1;if(""==a)return n.toast({content:"车牌号必填"}),!1;if(""==r)return n.toast({content:"车辆型号必填"}),!1;if(""==s)return n.toast({content:"客户名称必填"}),!1;if(""==l)return n.toast({content:"客联系电话必填"}),!1;if(!n.isMobile(l)&&!n.isTelephone(l))return n.toast({content:"客联系电话有误"}),!1;if(""==d)return n.toast({content:"预估维修内容必填"}),!1;if(""==m)return n.toast({content:"预估维修费用必填"}),!1;if(""==p)return n.toast({content:"预估完成时间必填"}),!1;var v=t.getUploadImgs();if(0==v.length)return n.toast({content:"请上传车损照"}),!1;u=!1;var f=t.csrf({carNo:a,carModel:r,customer:s,phone:l,preRepair:d,repairPrice:m,finishDate:p,images:v});n.httpPost(c,f,function(t){return u=!0,t.success?void window.location.replace(e.to("order#order-details/"+t.orderId)):(n.toast({content:t.message}),!1)},!0)})},t.getUploadImgs=function(){var t=o("#submit #image-list").find(".up-img"),e=[];return 0==t.length?[]:(o.each(t,function(t,i){var n=o(i).find(".upload-item");e.push(n.attr("data"))}),e)},t.selectDateEvent=function(){var t=this;o("#submit .finish-date-input").click(function(e){var i=o("#submit .finish-date-input").val();t.dateTimeSelector("#submit .finish-date-input",i)})},t.dateTimeSelector=function(t,e){var n=this,a=new Date,r=30,s=a.getFullYear(),l=a.getMonth(),c=a.getDate(),u=a.getHours(),m=s+"-"+(l+1)+"-"+c;if(""!=e&&null!=e&&void 0!==e){var p=e.split(" ");m=p[0],u=p[1]}var v=[];for(i=0;i<=r;i++){var f=new Date;f.setDate(a.getDate()+i);var h=f.getFullYear()+"-"+(f.getMonth()+1)+"-"+f.getDate();v.push(h)}var g=n.app.picker({input:t,toolbarTemplate:'<div class="toolbar"><div class="toolbar-inner"><div class="left">请选择用工时间</div><div class="right"><a href="javascript:void(0);" class="link submit-confirm-picker">确定</a></div></div></div>',value:[m,u],onChange:function(t,e,i){var n,a,r;if(e[0]instanceof Date)n=e[0].getFullYear(),a=e[0].getMonth(),r=e[0].getDate();else{var o=e[0].split("-");n=o[0],a=o[1]-1,r=o[2]}var s=new Date(n,a,r,e[1],0),l=new Date((new Date).getTime()+36e5);if(s<l){if(void 0===t.cols[0])return!1;var c=l.getHours(),u=l.getFullYear()+"-"+(l.getMonth()+1)+"-"+l.getDate(),d=new Date(l.getFullYear(),l.getMonth(),l.getDate(),l.getHours(),0);if(d-new Date<9e5){var m=new Date(d.getTime()+36e5);c=m.getHours(),u=m.getFullYear()+"-"+(m.getMonth()+1)+"-"+m.getDate()}t.cols[0].setValue(u),t.cols[2].setValue(c)}},formatValue:function(t,e,i){var n="";n=e[0]instanceof Date?e[0].getFullYear()+"-"+(e[0].getMonth()+1)+"-"+e[0].getDate():e[0];var a=n+" "+e[1];return a},cols:[{values:v,displayValues:function(){var t=[],e=new Date,i=e.getFullYear(),n=e.getMonth()+1,a=e.getDate();e.setDate(e.getDate()+1);for(var r=0;r<v.length;r++){var o=v[r],s=o.split("-"),l=s[1]+"月"+s[2]+"日";i==s[0]&&1*n==s[1]&&1*a==s[2]&&(l+="(今天)"),1*e.getFullYear()==s[0]&&1*e.getMonth()+1==s[1]&&1*e.getDate()==s[2]&&(l+="(明天)"),t.push(l)}return t}()},{divider:!0,content:" "},{values:function(){for(var t=[],e=0;e<=23;e++)t.push(e);return t}(),displayValues:function(){for(var t=[],e=0;e<=23;e++)t.push(e<10?"0"+e+"时":e+"时");return t}()},{divider:!0,content:" "}],onClose:function(e){if(g){var i=g.value,n=i[1]<10?"0"+i[1]:i[1];d=i[0]+" "+n,o(t).val(d),g.destroy()}}});g.open(),o(".submit-confirm-picker").on("click",function(e){e.preventDefault();var i=g.value,n=i[1]<10?"0"+i[1]:i[1];d=i[0]+" "+n,o(t).val(d),g.destroy()})},t.openCarModel=function(){o("#submit").on("click",".carModel",function(t){o("#search-wrapper").remove();var e=o("#submit"),i=o("script#search-car-model-template"),n=s.compile(i.html()),a=n({keyword:""});e.append(a)})},t.renderCarModelItem=function(t){var e=o("#search-wrapper .model-list"),i=o("script#search-car-model-item-template"),n=s.compile(i.html()),a=n({items:t});e.html(a)},t.searchCarModel=function(){var t=this;o("#submit").on("click",".model-search-btn",function(e){t.ajaxSearch()}),o("#submit").on("submit","#search-form",function(e){return e.preventDefault(),t.ajaxSearch(),!1})},t.ajaxSearch=function(){var t=this,i={keyword:o("#search-wrapper .search-input").val()};o.ajax({method:"POST",url:e.to("order/default/search-model"),data:i,dataType:"json",beforeSend:function(){t.showIndicator()},success:function(e){e.success?t.renderCarModelItem(e.items):t.renderCarModelItem([])},error:function(t){},complete:function(e){t.hideIndicator()}})},t.carModelClick=function(){o("#submit").on("click",".model-div-btn",function(t){var e=o(this).attr("data-value");o("#submit .carModel").val(e),o("#search-wrapper").remove()}),o("#submit").on("click",".closeBtn",function(t){o("#search-wrapper").remove()})},t}); | |
2 | 1 | \ No newline at end of file |
2 | +define("order-app",["mk7/app"],function(t){var e=Dom7,i=function(){var t=e(".ui-loading-block");0==t.length&&(e(".view-main").html('<div class="ui-loading-block" id="ui-loading"><div class="ui-loading-cnt"><div class="spinner"><div class="bounce1"></div><div class="bounce2"></div><div class="bounce3"></div></div><div id="loader-inner"><p></p></div> </div> </div>'),window.waitingTime=1e4,window.loaderTimer&&clearTimeout(window.loaderTimer),window.loaderTimer=setTimeout(function(){var t=document.getElementById("loader-inner"),e=document.createElement("p");e.className="notice",t&&(e.innerHTML='加载速度太慢?试试<a class="link" href="#" onclick="javascript:location.reload();return false;">重新加载</a>',t.appendChild(e))},window.waitingTime))},n=!0;return t.name="order",t.routes={index:function(){return n=!1,i(),t.runController("index")},"index/:tab":function(e){n=!1,i();var a={tab:e};return t.runController("index",a)},submit:function(){return n=!1,i(),t.runController("submit")},"order-details/:id":function(e){n=!1,i();var a={id:e};return t.runController("order-details",a)},"customer-order/:id/:sn":function(e,a){n=!1,i();var r={id:e,sn:a};return t.runController("customer-order",r)},"rate/:id/:sn":function(e,a){n=!1,i();var r={id:e,sn:a};return t.runController("rate",r)},"cost-list/:id":function(e){n=!1,i();var a={id:e};return t.runController("cost-list",a)},"*":function(){return t.runController("index")}},t}),define("order/cost-list-controller",["mk7/controller","mk7/url","mk7/utils","mk7/uploadjs"],function(t,e,i,n){var a=Dom7,t=(Template7,new t),r="/user/default/upload-file",o="/order/default/submit-repair-plans";return t.run=function(){var t=this;t.setPageTitle("费用列表"),t.id=t.params.id,t.imgLimit=9,t.canSubmit=!0,t.render({id:t.id})},t.bindEvents=function(){var t=this;console.log("bindEvents"),t.addEvent(),t.uploadImgEvent(),t.delPlanEvent(),t.inputPriceChangeEvent(),t.submitEvent()},t.addEvent=function(){var t=this;a("#cost-list .add-repair-plan").click(function(e){var i=a("#cost-list .cost-list-div"),n=t.planTpl(i.length+1);a(n).insertBefore(a("#cost-list .cost-total-list-div"))})},t.delPlanEvent=function(){var t=this;a("#cost-list").on("click",".del-plan",function(e){console.log("del plan event"),a(this).parents(".cost-list-div").remove(),a("#cost-list .total-plan-price").html(t.computedPrice())})},t.planTpl=function(t){var e='<div class="cost-list-div"><p class="item-title">第'+t+'项</p><div class="repair-item-cls"><input type="text" class="input-left input-cls" placeholder="填写维修内容" value=""><input type="number" class="input-right input-cls" placeholder="价格" value=""><span class="del-plan"></span></div></div>';return e},t.inputPriceChangeEvent=function(){var t=this;a("#cost-list").on("input propertychange",".input-cls",function(){var e=t.computedPrice();a("#cost-list .total-plan-price").html(e)})},t.computedPrice=function(){var t=a("#cost-list .input-right"),e=0;return a.each(t,function(t,i){e+=1*a(i).val()}),Math.round(e,2)},t.uploadImgEvent=function(){var t=this;a("#cost-list #upload-btn").change(function(){if(""!=a(this).val()&&null!=a(this).val()){var o=a(this).parents("li");n.uploadFile({selector:"#upload-btn",url:e.to(r),processAppendTo:"#cost-list",success:function(e,n){try{if(e.success){var r=e.tmpUrl;a('<li class="upload-li up-img"><div data="'+e.tmpFile+'" data-url="'+r+'" class="upload-item" style="background-image:url('+e.tmpMinUrl+')"></div><span class="del-img"></span></li>').insertBefore(o),t.imgLimit==a("#cost-list #image-list").find(".up-img").length&&a("#cost-list .upload-btn-li").hide()}else i.toast({content:e.message,closeDelay:5e3})}catch(s){console.log(s),i.toast({content:"出错",closeDelay:5e3})}}})}}),a("#cost-list #image-list").on("click",".del-img",function(e){a(this).parent().remove(),t.imgLimit>=a("#cost-list #image-list").find(".up-img").length&&a("#cost-list .upload-btn-li").show()})},t.submitEvent=function(){var t=this;a("#cost-list .btn-submit").click(function(n){var r=a("#cost-list .content-div").find(".repair-item-cls"),s=[],l=!0,c=!0;if(a.each(r,function(t,e){var n=i.trim(a(e).find(".input-left").val()),r=i.trim(a(e).find(".input-right").val());""==n&&(l=!1),""!=r&&0!=r||(c=!1),s.push({content:n,price:r})}),!l)return i.toast({content:"维修清单有部分未填内容"}),!1;if(!c)return i.toast({content:"维修清单有部分未填价格"}),!1;var u=a("#cost-list #image-list").find(".upload-item"),d=[];if(a.each(u,function(t,e){d.push(a(e).attr("data"))}),!t.canSubmit)return!1;t.canSubmit=!1;var m=t.csrf({images:d,plans:s,id:t.id});i.httpPost(o,m,function(n){t.canSubmit=!0,n.success?window.location.replace(e.to("order#index")):i.toast({content:n.message})},!0)})},t}),define("order/customer-order-controller",["mk7/controller","mk7/url","mk7/utils","mk7/photo-browser"],function(t,e,i,n){var a=Dom7,r=Template7,t=new t,o="order/customer/order-details";return t.run=function(){var t=this;t.id=t.params.id,t.sn=t.params.sn,t.success=!0,t.setPageTitle("维修单"),t.loadPage()},t.bindEvents=function(){var t=this;console.log("bindEvents"),t.goToComment(),t.popupImageLayer(),t.agreementEvent()},t.beforeRender=function(){var t=this;console.log("beforeRender"),t.success||(this.view="customer-order-error")},t.loadPage=function(){var t=this,n=t.csrf({id:t.id});i.httpPost(e.to(o),n,function(e){var i=e;t.success=e.success,t.render(i)},!0)},t.goToComment=function(){var t=this;a("#customer-order .rate-btn-cls").click(function(i){window.location.replace(e.to("order/customer#rate/"+t.id+"/"+t.sn))})},t.agreementEvent=function(){a("#customer-order").on("click",".warranty-btn",function(t){a("#warranty-wrapper").remove();var e=a("#customer-order"),i=a("script#warranty-template"),n=r.compile(i.html()),o=n({});e.append(o)}),a("#customer-order").on("click",".agree-btn",function(t){a("#warranty-wrapper").remove()})},t.popupImageLayer=function(){var t=this;a("#customer-order").on("click",".view-img-cls",function(e){var i=a(this).parents("ul"),n=i.find(".view-img-cls"),r=[],o=a(this).attr("data-index");a.each(n,function(t,e){var i=a(e).attr("data-url");r.push(i)});var s=t.app.photoBrowser({photos:r,initialSlide:o});s.open()})},t}),define("order/index-controller",["mk7/controller","mk7/url","mk7/utils"],function(t,e,i){var n=Dom7,a=Template7,t=new t,r="order/default/order-list";return t.run=function(){var t=this;t.setPageTitle("订单列表"),t.tab=t.params.tab,t.page=0,t.nodata="",t.loading=!1,t.pageCount=1,t.render({tab:t.tab}),t.loadPage()},t.bindEvents=function(){var t=this;console.log("bindEvents"),t.tabEvent(),t.bindScrollEvent(),t.addEvent(),t.orderClickEvent()},t.tabEvent=function(){n(".tab-cls").click(function(t){var e=n(this).attr("data-href");window.location.replace(e)})},t.handleNodata=function(){var t=this;t.nodata="没有数据了";var e=n(".nodata");0==e.length&&n("#index .order-list").append('<div class="nodata">'+t.nodata+"</div>"),t.app.detachInfiniteScroll(".infinite-scroll"),n("#index .infinite-scroll-preloader").remove()},t.loadPage=function(){var t=this;if(t.loading=!0,t.page>=t.pageCount)return void t.handleNodata();var a={status:t.tab};a.page=t.page+1,a=t.csrf(a),n.ajax({method:"GET",url:e.to(r),data:a,dataType:"json",beforeSend:function(){t.showIndicator()},success:function(e){if(1==e.success&&(i.isDefined(e.page)&&(t.page=parseInt(e.page)),i.isDefined(e.page_count)&&(t.pageCount=parseInt(e.page_count)),t.renderItems(e.items,!0),t.page>=t.pageCount))return void t.handleNodata()},error:function(t){},complete:function(e){t.hideIndicator(),t.loading=!1}})},t.bindScrollEvent=function(){var t=this;t.app.attachInfiniteScroll("#index .infinite-scroll"),n("#index .infinite-scroll").on("infinite",function(){t.loading||t.nodata||t.loadPage()})},t.renderItems=function(t,e){var i=n("#index .order-list"),r=n("script#order-item-template"),o=a.compile(r.html()),s=o({list:t});0==e&&(i.html(""),i.append(s)),i.append(s)},t.addEvent=function(){n("#index .add-btn-cls").click(function(t){window.location.href=e.to("order/#submit")})},t.orderClickEvent=function(){n("#index").on("click",".order-item",function(t){var i=n(this).attr("data-id");window.location.href=e.to("order#order-details/"+i)})},t}),define("order/order-details-controller",["mk7/controller","mk7/url","mk7/utils","mk7/photo-browser"],function(t,e,i,n){var a=Dom7,t=(Template7,new t),r="order/default/order-details";return t.run=function(){var t=this;t.id=t.params.id,t.success=!0,t.setPageTitle("维修单"),t.loadPage()},t.bindEvents=function(){var t=this;console.log("bindEvents"),t.finishBtnEvent(),t.popupImageLayer()},t.beforeRender=function(){var t=this;console.log("beforeRender"),t.success||(t.view="order-details-error")},t.loadPage=function(){var t=this,n=t.csrf({id:t.id});i.httpPost(e.to(r),n,function(e){var i=e;t.success=e.success,t.render(i)},!0)},t.finishBtnEvent=function(){var t=this;a("#order-details .finish-submit").click(function(i){window.location.replace(e.to("order/#cost-list/"+t.id))})},t.agreementEvent=function(){},t.popupImageLayer=function(){var t=this;a("#order-details").on("click",".view-img-cls",function(e){var i=a(this).parents("ul"),n=i.find(".view-img-cls"),r=[],o=a(this).attr("data-index");a.each(n,function(t,e){var i=a(e).attr("data-url");r.push(i)});var s=t.app.photoBrowser({photos:r,initialSlide:o});s.open()})},t}),define("order/rate-controller",["mk7/controller","mk7/url","mk7/utils","mk7/uploadjs"],function(t,e,i,n){var a=Dom7,t=(Template7,new t),r="order/customer/submit-rate",o="/user/default/upload-file";return t.run=function(){var t=this;t.id=t.params.id,t.sn=t.params.sn,t.imgLimit=4,t.setPageTitle("评价"),t.loadPage()},t.bindEvents=function(){var t=this;console.log("bindEvents"),t.starClickEvent(),t.submitEvent(),t.uploadImgEvent()},t.loadPage=function(){var t=this;t.render({servicePhone:window.$site.servicePhone})},t.starClickEvent=function(){a("#rate").on("click",".img-star",function(t){var e=a(this).attr("data-id"),i=a(this).parent(".star-div"),n=i.find(".img-star");a.each(n,function(t,n){var r=a(n).attr("data-id");if(1*r<=e){a(n).addClass("star-on");var o=i.find(".rate-text"),s=a(n).attr("data-txt");o.html(s)}else a(n).removeClass("star-on")})})},t.uploadImgEvent=function(){var t=this;a("#rate #upload-btn").change(function(){if(""!=a(this).val()&&null!=a(this).val()){var r=a(this).parents("li");n.uploadFile({selector:"#upload-btn",url:e.to(o),processAppendTo:"#rate",success:function(e,n){try{if(e.success){var o=e.tmpUrl;a('<li class="upload-li up-img"><div data="'+e.tmpFile+'" data-url="'+o+'" class="upload-item" style="background-image:url('+e.tmpMinUrl+')"></div><span class="del-img"></span></li>').insertBefore(r),t.imgLimit==a("#rate #image-list").find(".up-img").length&&a("#rate .upload-btn-li").hide()}else i.toast({content:e.message,closeDelay:5e3})}catch(s){console.log(s),i.toast({content:"出错",closeDelay:5e3})}}})}}),a("#rate #image-list").on("click",".del-img",function(e){a(this).parent().remove(),t.imgLimit>=a("#rate #image-list").find(".up-img").length&&a("#rate .upload-btn-li").show()})},t.getUploadImgs=function(){var t=a("#rate #image-list").find(".up-img"),e=[];return 0==t.length?[]:(a.each(t,function(t,i){var n=a(i).find(".upload-item");e.push(n.attr("data"))}),e)},t.submitEvent=function(){var t=this;a("#rate .submit-btn").click(function(n){var o=i.trim(a("#rate .text-content").val()),s=a("#rate .quality-box .img-star"),l=0;a.each(s,function(t,e){a(e).hasClass("star-on")&&l++});var c=a("#rate .effect-box .img-star"),u=0;a.each(c,function(t,e){a(e).hasClass("star-on")&&u++});var d=a("#rate .service-box .img-star"),m=0;a.each(d,function(t,e){a(e).hasClass("star-on")&&m++});var p=t.getUploadImgs(),v=t.csrf({comment:o,id:t.id,qualityStar:l,effectStar:u,serviceStar:m,images:p});i.httpPost(e.to(r),v,function(n){n.success?window.location.replace(e.to("order/customer#customer-order/"+t.id+"/"+t.sn)):i.toast({content:n.message})},!0)})},t}),define("order/submit-controller",["mk7/controller","mk7/url","mk7/utils","mk7/uploadjs","mk7/picker"],function(t,e,n,a,r){var o=Dom7,s=Template7,t=new t,l="/user/default/upload-file",c="/order/default/do-submit",u=!0,d="";return t.run=function(){var t=this;t.setPageTitle("录入维修单"),t.imgLimit=9,t.render(),t.loadInit()},t.bindEvents=function(){var t=this;console.log("bindEvents"),t.uploadImgEvent(),t.submitEvent(),t.selectDateEvent(),t.openCarModel(),t.searchCarModel(),t.carModelClick()},t.loadInit=function(){var t=this;({id:t.id})},t.uploadImgEvent=function(){var t=this;o("#submit #upload-btn").change(function(){if(""!=o(this).val()&&null!=o(this).val()){var i=o(this).parents("li");a.uploadFile({selector:"#upload-btn",url:e.to(l),processAppendTo:"#submit",success:function(e,a){try{if(e.success){var r=e.tmpUrl;o('<li class="upload-li up-img"><div data="'+e.tmpFile+'" data-url="'+r+'" class="upload-item" style="background-image:url('+e.tmpMinUrl+')"></div><span class="del-img"></span></li>').insertBefore(i),t.imgLimit==o("#submit #image-list").find(".up-img").length&&o("#submit .upload-btn-li").hide()}else n.toast({content:e.message,closeDelay:5e3})}catch(s){n.toast({content:"出错",closeDelay:5e3})}}})}}),o("#submit #image-list").on("click",".del-img",function(e){o(this).parent().remove(),t.imgLimit>=o("#submit #image-list").find(".up-img").length&&o("#submit .upload-btn-li").show()})},t.submitEvent=function(){var t=this;o("#submit .submit-btn-cls").click(function(i){var a=n.trim(o("#submit .carNo").val()),r=n.trim(o("#submit .carModel").val()),s=n.trim(o("#submit .customer").val()),l=n.trim(o("#submit .phone").val()),d=n.trim(o("#submit .preRepair").val()),m=n.trim(o("#submit .repairPrice").val()),p=n.trim(o("#submit .finishDate").val());if(0==u)return!1;if(""==a)return n.toast({content:"车牌号必填"}),!1;if(""==r)return n.toast({content:"车辆型号必填"}),!1;if(""==s)return n.toast({content:"客户名称必填"}),!1;if(""==l)return n.toast({content:"客联系电话必填"}),!1;if(!n.isMobile(l)&&!n.isTelephone(l))return n.toast({content:"客联系电话有误"}),!1;if(""==d)return n.toast({content:"预估维修内容必填"}),!1;if(""==m)return n.toast({content:"预估维修费用必填"}),!1;if(""==p)return n.toast({content:"预估完成时间必填"}),!1;var v=t.getUploadImgs();if(0==v.length)return n.toast({content:"请上传车损照"}),!1;u=!1;var f=t.csrf({carNo:a,carModel:r,customer:s,phone:l,preRepair:d,repairPrice:m,finishDate:p,images:v});n.httpPost(c,f,function(t){return u=!0,t.success?void window.location.replace(e.to("order#index")):(n.toast({content:t.message}),!1)},!0)})},t.getUploadImgs=function(){var t=o("#submit #image-list").find(".up-img"),e=[];return 0==t.length?[]:(o.each(t,function(t,i){var n=o(i).find(".upload-item");e.push(n.attr("data"))}),e)},t.selectDateEvent=function(){var t=this;o("#submit .finish-date-input").click(function(e){var i=o("#submit .finish-date-input").val();t.dateTimeSelector("#submit .finish-date-input",i)})},t.dateTimeSelector=function(t,e){var n=this,a=new Date,r=30,s=a.getFullYear(),l=a.getMonth(),c=a.getDate(),u=a.getHours(),m=s+"-"+(l+1)+"-"+c;if(""!=e&&null!=e&&void 0!==e){var p=e.split(" ");m=p[0],u=p[1]}var v=[];for(i=0;i<=r;i++){var f=new Date;f.setDate(a.getDate()+i);var h=f.getFullYear()+"-"+(f.getMonth()+1)+"-"+f.getDate();v.push(h)}var g=n.app.picker({input:t,toolbarTemplate:'<div class="toolbar"><div class="toolbar-inner"><div class="left">请选择用工时间</div><div class="right"><a href="javascript:void(0);" class="link submit-confirm-picker">确定</a></div></div></div>',value:[m,u],onChange:function(t,e,i){var n,a,r;if(e[0]instanceof Date)n=e[0].getFullYear(),a=e[0].getMonth(),r=e[0].getDate();else{var o=e[0].split("-");n=o[0],a=o[1]-1,r=o[2]}var s=new Date(n,a,r,e[1],0),l=new Date((new Date).getTime()+36e5);if(s<l){if(void 0===t.cols[0])return!1;var c=l.getHours(),u=l.getFullYear()+"-"+(l.getMonth()+1)+"-"+l.getDate(),d=new Date(l.getFullYear(),l.getMonth(),l.getDate(),l.getHours(),0);if(d-new Date<9e5){var m=new Date(d.getTime()+36e5);c=m.getHours(),u=m.getFullYear()+"-"+(m.getMonth()+1)+"-"+m.getDate()}t.cols[0].setValue(u),t.cols[2].setValue(c)}},formatValue:function(t,e,i){var n="";n=e[0]instanceof Date?e[0].getFullYear()+"-"+(e[0].getMonth()+1)+"-"+e[0].getDate():e[0];var a=n+" "+e[1];return a},cols:[{values:v,displayValues:function(){var t=[],e=new Date,i=e.getFullYear(),n=e.getMonth()+1,a=e.getDate();e.setDate(e.getDate()+1);for(var r=0;r<v.length;r++){var o=v[r],s=o.split("-"),l=s[1]+"月"+s[2]+"日";i==s[0]&&1*n==s[1]&&1*a==s[2]&&(l+="(今天)"),1*e.getFullYear()==s[0]&&1*e.getMonth()+1==s[1]&&1*e.getDate()==s[2]&&(l+="(明天)"),t.push(l)}return t}()},{divider:!0,content:" "},{values:function(){for(var t=[],e=0;e<=23;e++)t.push(e);return t}(),displayValues:function(){for(var t=[],e=0;e<=23;e++)t.push(e<10?"0"+e+"时":e+"时");return t}()},{divider:!0,content:" "}],onClose:function(e){if(g){var i=g.value,n=i[1]<10?"0"+i[1]:i[1];d=i[0]+" "+n,o(t).val(d),g.destroy()}}});g.open(),o(".submit-confirm-picker").on("click",function(e){e.preventDefault();var i=g.value,n=i[1]<10?"0"+i[1]:i[1];d=i[0]+" "+n,o(t).val(d),g.destroy()})},t.openCarModel=function(){o("#submit").on("click",".carModel",function(t){o("#search-wrapper").remove();var e=o("#submit"),i=o("script#search-car-model-template"),n=s.compile(i.html()),a=n({keyword:""});e.append(a)})},t.renderCarModelItem=function(t){var e=o("#search-wrapper .model-list"),i=o("script#search-car-model-item-template"),n=s.compile(i.html()),a=n({items:t});e.html(a)},t.searchCarModel=function(){var t=this;o("#submit").on("click",".model-search-btn",function(e){t.ajaxSearch()}),o("#submit").on("submit","#search-form",function(e){return e.preventDefault(),t.ajaxSearch(),!1})},t.ajaxSearch=function(){var t=this,i={keyword:o("#search-wrapper .search-input").val()};o.ajax({method:"POST",url:e.to("order/default/search-model"),data:i,dataType:"json",beforeSend:function(){t.showIndicator()},success:function(e){e.success?t.renderCarModelItem(e.items):t.renderCarModelItem([])},error:function(t){},complete:function(e){t.hideIndicator()}})},t.carModelClick=function(){o("#submit").on("click",".model-div-btn",function(t){var e=o(this).attr("data-value");o("#submit .carModel").val(e),o("#search-wrapper").remove()}),o("#submit").on("click",".closeBtn",function(t){o("#search-wrapper").remove()})},t}); | |
3 | 3 | \ No newline at end of file | ... | ... |
web/src/js/order/submit-controller.js