index.page.js
973 Bytes
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
/**
* 购物车商品
* @author: feng.chen<feng.chen@yoho.cn>
* @date: 2016/12/22
*/
'use strict';
require('cart/index.page.css')
let testData = require('./data.json'),
$ = require('yoho-jquery'),
hbsTemplate = require('cart/index/index.hbs'),
lazyLoad = require('yoho-jquery-lazyload');
let indexObj = {
editMode: false,
init() {
let self = this;
$.ajax({
url: '/cart/index/new/data',
type: 'POST',
success: (data) => {
self.refreshPage(data.data);
}
});
require('./index/recommend-for-you').init(self);
},
refreshPage(data) {
let self = this;
$('.main-wrap').removeClass('edit');
self.editMode = false;
$('.cart-box').html(hbsTemplate(data));
require('./index/cart').init(self);
require('./index/good').init(self);
lazyLoad($('img.lazy'));
}
}
$(() => {
indexObj.init();
})