detail-dynamic.js 781 Bytes
/**
 * 动态获取页面数据
 * @author liuchuanyang
 * @date 2016/10/09
 */
let $ = require('yoho-jquery');

require('common');

function getDynamicById(id) {
    'use strict';

    let param = {
        id: id
    };

//  //guang.yohobuy.com/guang/info/detailData
    return $.getJSON('/guang/info/detailData', param);
}

function renderData(data) {
    'use strict';

    if (data && data.code === 200 && data.data) {

        $('.guang-detail-page .page-view').text(data.data.browseNum || 0);
        $('.guang-detail-page .comments .seenum span').text(data.data.browseNum || 0);
    }
}

function refreshData() {
    'use strict';

    let qs = window.queryString;

    let id = qs.id || $('.detail').data('id');

    getDynamicById(id).done(renderData);
}

refreshData();