recommend-product.js 963 Bytes
/**
 * 为您优选 | 店铺推荐 | 最近浏览
 * @author: wsl<shuiling.wang@yoho.cn>
 * @date: 2016/11/21
 */

var recProduct = require('../../../tpl/product/recommend-product.hbs');
var recTemplet = require('../../../tpl/product/recommend-templet.hbs');

var recommmendProduct = {
    init: function(params) {
        var _this = this;
        var obj = {
            isGoodsDetail: false
        };

        if (params.isGoodsDetail) {
            obj.isGoodsDetail = true;
        }

        $(params.dom).append(recTemplet(obj));

        _this.getRecommendProduct({
            page: 1,
            dom: params.dom
        });
    },
    getRecommendProduct: function(params) {
        $.get('/product/getRecommendProduct', {
            page: params.page
        }, function(data) {
            if (data) {
                $(params.dom).find('.goods-area').html(recProduct(data));
            }
        });
    }
};

module.exports = recommmendProduct;