﻿

var ProductDiv  = ";";      //商品属性分隔符
var ProductsDiv = "|";      //商品集合分隔符

//定义商品类
function Product(){
    ProductID       = "";   //商品PKID
    ProductCode     = "";   //商品编号
    ProductName     = "";   //商品名称
    GroupID         = "";   //商品组ID
    ProductImg      = "";   //商品图片
    ProductColor    = "";   //商品颜色
    ProductSize     = "";   //尺寸
    ProductPrice    = "";   //单价
    Amount          = "";   //数量
    Status          = "";   //状态
    
    //促销信息
    blnShirt        = "";   //是否TShirt
    blnTrousers     = "";   //是否裤子
    PromotionName   = "";   //促销名称 
    PromotionValue  = "0";  //促销减价
    
    //定制
    CustomID        = "";   //定制ID
    
    //上级抽象商品编号
    AbstractCode    = "";
    
    //绣花
    ServiceID       = "";   //绣花
    Position        = "";   //位置
    FontSize        = "";   //字体
    Words           = "";   //文字
    ServicePrice    = "0";  //绣花费用
}

//将类属性按规则分解为string
Product.prototype.ToString = function(){
    var strComb = escape(this.ProductID) + ProductDiv
            + escape(this.ProductCode) + ProductDiv
            + escape(this.ProductName) + ProductDiv
            + escape(this.GroupID) + ProductDiv
            + escape(this.ProductImg) + ProductDiv
            + escape(this.ProductColor) + ProductDiv
            + escape(this.ProductSize) + ProductDiv
            + escape(this.ProductPrice) + ProductDiv
            + escape(this.Amount) + ProductDiv
            + escape(this.Status) + ProductDiv
            + escape(this.blnShirt) + ProductDiv
            + escape(this.blnTrousers) + ProductDiv
            + escape(this.PromotionName) + ProductDiv
            + escape(this.PromotionValue) + ProductDiv
            + escape(this.CustomID) + ProductDiv
            + escape(this.AbstractCode) + ProductDiv
            + escape(this.ServiceID) + ProductDiv
            + escape(this.Position) + ProductDiv
            + escape(this.FontSize) + ProductDiv
            + escape(this.Words) + ProductDiv
            + escape(this.ServicePrice);


    return strComb;
}

//根据规则string初始化类
Product.prototype.initByString = function(strComb){
    var strAry = strComb.split(ProductDiv);
    this.ProductID       = unescape(strAry[0]);
    this.ProductCode     = unescape(strAry[1]);
    this.ProductName     = unescape(strAry[2]);
    this.GroupID         = unescape(strAry[3]);
    this.ProductImg      = unescape(strAry[4]);
    this.ProductColor    = unescape(strAry[5]);
    this.ProductSize     = unescape(strAry[6]);
    this.ProductPrice    = unescape(strAry[7]);
    this.Amount          = unescape(strAry[8]);
    this.Status          = unescape(strAry[9]);
    this.blnShirt        = unescape(strAry[10]);
    this.blnTrousers     = unescape(strAry[11]);
    this.PromotionName   = unescape(strAry[12]);
    this.PromotionValue  = unescape(strAry[13]);
    this.CustomID        = unescape(strAry[14]);
    this.AbstractCode    = unescape(strAry[15]);
    this.ServiceID       = unescape(strAry[16]);
    this.Position        = unescape(strAry[17]);   //位置
    this.FontSize        = unescape(strAry[18]);   //字体
    this.Words           = unescape(strAry[19]);   //文字
    this.ServicePrice    = unescape(strAry[20]);   //绣花费用
}

