customer-order-controller.js
3.35 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/**
* 维修中页
*/
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 = '<div id="img-mask" style="z-index:2;background:#000;justify-content:center;position: absolute;bottom:0;top:0;width:100%;display:flex;flex-direction: column;align-items: center"><div style="width:100%;"> <img width="100%" src="'+url+'" /></div></div>';
$$('#customer-order').append(imgContent);
})
$$('#customer-order').on('click', '#img-mask, #img-mask img', function(e) {
e.preventDefault();
e.stopPropagation()
var bh = document.body.clientHeight;
var ih = $$('#img-mask img').height();
console.log(bh+'dddd'+ih)
var interval = Math.abs(ih-bh);
if (interval >=0 && interval <= 20) {
$$('#img-mask').remove();
} else {
var id = $$(e.target).attr('id');
if('img-mask' == id) {
$$('#img-mask').remove();
}
}
})
}
return ctrl;
}
);