const newImage = (src, index = 0) => ({
    "index": ++index,
    "type": "image",
    "name": "图片",
    "src": src,
    "x": 0,
    "y": 0,
    "draggable": true,
    "rotation": 0,
    "fill": "#FFFFFF",
    "align": "left",
    "verticalAlign": "top",
    "width": 50,
    "height": 50,
    "scaleX": 1,
    "scaleY": 1
})

const newText = (index = 0) => ({
    "index": ++index,
    "type": "text",
    "name": "标题",
    "x": 0,
    "y": 0,
    "fontFamily": "楷体",
    "fontStyle": "normal",
    "fontSize": 20,
    "padding": 0,
    "text": "新建文本",
    "draggable": true,
    "rotation": 0,
    "fill": "#FFFFFF",
    "align": "left",
    "verticalAlign": "top",
    "width": null,
    "height": null,
    "scaleX": 1,
    "scaleY": 1
})

const newQrcode = (index = 0) => ({
    "index": ++index,
    "type": "qrcode",
    "name": "商品二维码",
    "text": "二维码信息",
    "x": 0,
    "y": 0,
    "draggable": true,
    "rotation": 0,
    "fill": "#FFFFFF",
    "align": "left",
    "verticalAlign": "top",
    "width": 40,
    "height": 40,
    "scaleX": 1,
    "scaleY": 1
})


const newContent = (width = 296, height = 152) => ({
    "width": width,
    "height": height,
    "background": {
        "type": "color",
        "fill": "#FF0000",
        "x": 0,
        "y": 0,
        "width": width,
        "height": height,
    },
    "blocks": [],
})

const buildBgColors = (width = 296, height = 152) => ([
    {
        "type": "color",
        "fill": "#FF0000",
        "x": 0,
        "y": 0,
        "width": width,
        "height": height,
    },
    {
        "type": "color",
        "fill": "#000000",
        "x": 0,
        "y": 0,
        "width": width,
        "height": height,
    },
    {
        "type": "color",
        "fill": "#FFFFFF",
        "x": 0,
        "y": 0,
        "width": width,
        "height": height,
    },
    {
        "type": "image",
        "image": null,
        "src": null,
        "fill": "#FFFFFF",
        "x": 0,
        "y": 0,
        "width": width,
        "height": height,
    },
])

const fonts = [
    {
        "name": "Times New Roma",
        "value": "http://label.cbelec.cn/font/Times%20New%20Roma.ttf",
    },
    {
        "name": "粗宋简",
        "value": "http://label.cbelec.cn/font/%E7%B2%97%E5%AE%8B%E7%AE%80.ttf",
    },
    {
        "name": "仿宋",
        "value": "http://label.cbelec.cn/font/%E4%BB%BF%E5%AE%8B.ttf",
    },
    {
        "name": "大标宋体",
        "value": "http://label.cbelec.cn/font/%E5%A4%A7%E6%A0%87%E5%AE%8B%E4%BD%93.ttf",
    },
    // {
    //   "name": "宋体-粗",
    //   "value": "http://label.cbelec.cn/font/%E5%AE%8B%E4%BD%93-B.ttf",
    // },
    {
        "name": "宋体",
        "value": "http://label.cbelec.cn/font/%E5%AE%8B%E4%BD%93.ttf",
    },
    {
        "name": "楷体",
        "value": "http://label.cbelec.cn/font/%E6%A5%B7%E4%BD%93.ttf",
    },
    {
        "name": "魏碑",
        "value": "http://label.cbelec.cn/font/%E9%AD%8F%E7%A2%91.ttf",
    },
    {
        "name": "黑体",
        "value": "http://label.cbelec.cn/font/%E9%BB%91%E4%BD%93.ttf",
    },
]

const fontColors = [
    {
        "name": "红色",
        "value": "#FF0000",
    },
    {
        "name": "黑色",
        "value": "#000000",
    },
    {
        "name": "白色",
        "value": "#FFFFFF",
    },
]

const fontStyles = [
    {
        "name": "常规",
        "value": "normal",
    },
    {
        "name": "加粗",
        "value": "bold",
    },
    {
        "name": "斜体",
        "value": "italic",
    },
]

const fontAligns = [
    {
        "name": "居左",
        "value": "left",
    },
    {
        "name": "居中",
        "value": "center",
    },
    {
        "name": "居右",
        "value": "right",
    },
]

const fontVerticalAligns = [
    {
        "name": "居上",
        "value": "top",
    },
    {
        "name": "居中",
        "value": "middle",
    },
    {
        "name": "居下",
        "value": "bottom",
    },
]

const fields = [
    {"name": "商品名称", "value": "goodsName"},
    {"name": "商品价格", "value": "goodsPrice"},
    {"name": "商品折扣", "value": "goodsDiscount"},
]

export {
    newImage,
    newText,
    newQrcode,
    newContent,
    buildBgColors,
    fonts,
    fontColors,
    fontStyles,
    fontAligns,
    fontVerticalAligns,
    fields,
}