goodsInfo.js 2.74 KB
/**
 * Created by wangqianjun on 16/3/9.
 * 商品详情
 */

var $ = require('jquery'),
    common = require('../common/common');

/*获取基础商品数据*/
var param = location.href.slice(location.href.indexOf("info")).match(/\/\d+/g);
param[0]=param[0].replace(/\//,'');
param[1]=param[1].replace(/\//,'');

common.util.__ajax({url: '/base/goods/getData', data:{productSkn:param[0],isAuditing:param[1]}},function(data){

    console.log(data.data);
    data.data.attribute={"1":"普通商品","2":"赠品","3":"虚拟商品"}[""+data.data.attribute];
    data.data.ageLevel=data.data.ageLevel.replace("1","成人").replace("2","大童").replace("3","小童");
    data.data.gender={"1":"男","2":"女","3":"通用"}[""+data.data.gender];
    data.data.grade={"0":"否","1":"是"}[""+data.data.grade];
    data.data.goodsSeason={"0":"四季","1":"春","2":"夏","3":"秋","4":"冬","5":"春夏","6":"秋冬"}[""+data.data.goodsSeason];
    data.data.isPromotionalGifts={"N":"否","Y":"是"}[""+data.data.isPromotionalGifts];
    data.data.isLimited={"N":"否","Y":"是"}[""+data.data.isLimited];
    data.data.isLimitbuy={"N":"否","Y":"是"}[""+data.data.isLimitbuy];

    var a=common.util.__template2($("#template").html(), data.data);

    $(".contentpanel").html(a);
},true);


// 通过
var BllPass={
	toast:function(content,fn){
        common.dialog.confirm("温馨提示",content,function(){
            common.util.__ajax({
                url:'/base/goods/pass',
                data:fn()
            },function(){
            	// location.reload();
                setTimeout(function(){
                    location.reload();
                },2000);
            });
        });
    }
}

// 驳回
var BllReject={
    toast:function(content,fn){
        common.dialog.confirm("温馨提示",content,function(){
            common.util.__ajax({
                url:'/base/goods/reject',
                data:fn()
            },function(){
            	setTimeout(function(){
                    location.reload();
                },2000);
            });
        });
    }
}

//单个通过
$(document).on("click",".apply-success",function(){
    
    var data=function(){
        return {
                productSknList:JSON.stringify([param[0]]),
            };
    }
    BllPass.toast("你确定审核通过吗?",data);
    return false;
});

//单个驳回
$(document).on("click",".apply-back",function(){
    var data=function(){

        var reason = $('#bohui').val();
        if (reason === '' || $.trim(reason) === '') {
            return "请填写驳回原因";
        }

        return {
            productSknList:JSON.stringify([param[0]]),
            rejectReason:reason
            };
    }
    BllReject.toast($("#bohuiuuu").html(),data);
    return false;
});