Blame view

web/src/js/order/customer-order-controller.js 2.84 KB
3a892ee0   xu   app-wx(v0.1.0 bui...
1
2
3
4
5
6
7
8
9
/**
 * 维修中页
 */
define(
    "order/customer-order-controller",
    [
        'mk7/controller',
        'mk7/url',
        'mk7/utils',
1de3211f   xu   app-wx(v0.1.0 bui...
10
        'mk7/photo-browser'
3a892ee0   xu   app-wx(v0.1.0 bui...
11
12
    ],

1de3211f   xu   app-wx(v0.1.0 bui...
13
    function(ctrl, url, utils, photoBrowser) {
3a892ee0   xu   app-wx(v0.1.0 bui...
14
15
16
17
18
19
20
21
22
23

        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;
6bece648   xu   app-wx(v0.1.0 bui...
24
            me.success = true;
3a892ee0   xu   app-wx(v0.1.0 bui...
25
26
27
            me.setPageTitle("维修单");
            me.loadPage();
        }
6bece648   xu   app-wx(v0.1.0 bui...
28

3a892ee0   xu   app-wx(v0.1.0 bui...
29
30
31
32
        ctrl.bindEvents = function () {
            var me = this;
            console.log("bindEvents");
            me.goToComment();
f3ed8f51   xu   app-wx(v0.1.0 bui...
33
            me.popupImageLayer();
afd2f743   xu   app-ht(v0.0.1 bui...
34
            me.agreementEvent();
3a892ee0   xu   app-wx(v0.1.0 bui...
35
        }
6bece648   xu   app-wx(v0.1.0 bui...
36
37
38
39
40
41
42
43
        ctrl.beforeRender = function() {
            var me = this;
            console.log('beforeRender')
            if (!me.success) {
                this.view = 'customer-order-error';
            }

        }
3a892ee0   xu   app-wx(v0.1.0 bui...
44
45
46
47
48
        ctrl.loadPage = function() {
            var me = this
            var pData = me.csrf({id: me.id});
            utils.httpPost(url.to(pageURL), pData, function(res) {
                var rData = res;
6bece648   xu   app-wx(v0.1.0 bui...
49
                me.success = res.success;
3a892ee0   xu   app-wx(v0.1.0 bui...
50
51
52
53
54
55
56
57
58
59
60
61
                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))
            })

        }
afd2f743   xu   app-ht(v0.0.1 bui...
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
        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() {
1de3211f   xu   app-wx(v0.1.0 bui...
77
            var me = this;
f3ed8f51   xu   app-wx(v0.1.0 bui...
78
            $$('#customer-order').on('click', '.view-img-cls', function(e) {
1de3211f   xu   app-wx(v0.1.0 bui...
79
80
81
82
83
84
85
86
                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)
                })
f3ed8f51   xu   app-wx(v0.1.0 bui...
87

1de3211f   xu   app-wx(v0.1.0 bui...
88
89
                var pBrowser = me.app.photoBrowser({photos:photoBrowserPhotos,initialSlide:initialSlide});
                pBrowser.open();
f3ed8f51   xu   app-wx(v0.1.0 bui...
90
            })
1de3211f   xu   app-wx(v0.1.0 bui...
91

f3ed8f51   xu   app-wx(v0.1.0 bui...
92
        }
3a892ee0   xu   app-wx(v0.1.0 bui...
93
94
95
        return ctrl;
    }
);