order-details-controller.js
2.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/**
* 维修中页
*/
define(
"order/order-details-controller",
[
'mk7/controller',
'mk7/url',
'mk7/utils',
'mk7/photo-browser'
],
function(ctrl, url, utils, photoBrowser) {
var $$ = Dom7;
var t7 = Template7;
var ctrl = new ctrl();
var pageURL = 'order/default/order-details';
ctrl.run = function () {
var me = this;
me.id = me.params.id;
me.success = true;
me.setPageTitle("维修单");
me.loadPage();
}
ctrl.bindEvents = function () {
var me = this;
console.log("bindEvents");
me.finishBtnEvent();
me.popupImageLayer();
}
ctrl.beforeRender = function() {
var me = this;
console.log('beforeRender')
if (!me.success) {
me.view = 'order-details-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.finishBtnEvent = function() {
var me = this;
$$('#order-details .finish-submit').click(function(e){
window.location.href = url.to('order/#cost-list/' + me.id);
})
}
ctrl.agreementEvent = function() {
}
ctrl.popupImageLayer = function() {
var me = this;
$$('#order-details').on('click', '.view-img-cls', function(e) {
var parent = $$(this).parents('ul');
var imagesT = parent.find('.view-img-cls');
var photoBrowserPhotos = [];
var initialSlide = $$(this).attr('data-index');
$$.each(imagesT, function(i, n) {
var nURL = $$(n).attr('data-url');
photoBrowserPhotos.push(nURL)
})
var pBrowser = me.app.photoBrowser({photos:photoBrowserPhotos,initialSlide:initialSlide});
pBrowser.open();
})
}
return ctrl;
}
);