index.page.js 973 Bytes
/**
 * 购物车商品
 * @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();
})