/** * 维修中页 */ define( "order/customer-order-controller", [ 'mk7/controller', 'mk7/url', 'mk7/utils', ], function(ctrl, url, utils) { var $$ = Dom7; var t7 = Template7; var ctrl = new ctrl(); var pageURL = 'order/customer/order-details'; ctrl.run = function () { var me = this; me.id = me.params.id; me.sn = me.params.sn; me.success = true; me.setPageTitle("维修单"); me.loadPage(); } ctrl.bindEvents = function () { var me = this; console.log("bindEvents"); me.goToComment(); me.popupImageLayer(); me.agreementEvent(); } ctrl.beforeRender = function() { var me = this; console.log('beforeRender') if (!me.success) { this.view = 'customer-order-error'; } } ctrl.loadPage = function() { var me = this var pData = me.csrf({id: me.id}); utils.httpPost(url.to(pageURL), pData, function(res) { var rData = res; me.success = res.success; me.render(rData); }, true) } ctrl.goToComment = function() { var me = this; $$('#customer-order .rate-btn-cls').click(function(e){ window.location.replace(url.to('order/customer#rate/'+me.id+'/'+me.sn)) }) } ctrl.agreementEvent = function() { $$('#customer-order').on('click', '.warranty-btn', function(e){ $$('#warranty-wrapper').remove(); var page = $$('#customer-order'); var ele = $$('script#warranty-template'); var compiled = t7.compile(ele.html()); var doms = compiled({}); page.append(doms); }) $$('#customer-order').on('click','.agree-btn', function(e){ $$('#warranty-wrapper').remove(); }) } ctrl.popupImageLayer = function() { $$('#customer-order').on('click', '.view-img-cls', function(e) { var url = $$(this).attr('data-url'); $$('#img-mask').remove(); var imgContent = '