<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Insert title here</title>
    <%@include file="/views/common.jsp" %>
</head>
<!-- 牛皮纸手提袋 -->
<style>
    .layui-form-select .layui-input {
        padding: 10px;
    }

    .expressFee + .layui-form-select .layui-edge {
        right: 30px;
    }
</style>
<body>
<div class="big_box">
    <div class="left_div">
        <h1 class="h1">手提袋</h1> <span style="color:red;font-weight:700;"></span>
        <hr class="layui-bg-red">
        <form class="layui-form">
            <div class="layui-input-block">
                <input type="radio" name="k" class="k" lay-filter="k" value="0" title="常规牛皮纸">
                <input type="radio" name="k" class="k" lay-filter="k" value="1" title="白卡纸手提袋">
                <input type="radio" name="k" class="k" lay-filter="k" value="2" title="礼品袋 / 福袋">
                <!-- <input type="radio" name="k" class="k" lay-filter="k" value="3" title="特价白卡手提袋"> -->
                <input type="radio" name="k" class="k" lay-filter="k" value="4" title="牛皮纸手提袋">
            </div>
        </form>
        <form class="layui-form" id="bagForm">
            <input type="hidden" id="proTypeValue" name="proTypeValue" class="layui-input" value="11">
            <div class="cg" style="display: none">
                <%@include file="handBagCG.jsp" %>
            </div>
            <div class="zdy" style="display: none">
                <%@include file="handBagZDY.jsp" %>
            </div>
            <div class="tj" style="display: none">
                <%@include file="handBagTJ.jsp" %>
            </div>
            <div class="npzd" style="display: none">
                <p>使用场景</p>
                <div class="npzd">
                    <input type="radio" name="typeValue" lay-filter="typeValue" value="0" title="烘焙">
                    <input type="radio" name="typeValue" lay-filter="typeValue" value="1" title="外卖送餐">
                    <input type="radio" name="typeValue" lay-filter="typeValue" value="2" title="饮品外卖">
                    <input type="radio" name="typeValue" lay-filter="typeValue" value="3" title="礼品购物">
                </div>
                <p>材质</p>
                <div class="npzd">
                    <select name="kindValue" class="select kindValueCG" lay-filter="kindValue">
                        <option value="0">120克白牛皮</option>
                        <option value="1">120克进口牛卡</option>
                    </select>
                </div>
                <p>规格(CM/厘米) <span style="font-size:14px;color:red">格式: 长 * 宽 * 高</span></p>
                <div class="layui-form-item npzd">
                    <select name="kind2Value" id="spec" class="select kind2Value" lay-filter="kind2Value">
                        <option value="1" selected>1号袋（宽250*高240*厚130）</option>
                        <option value="3">3号袋（宽280*高265*厚150）</option>
                        <option value="6">6号袋（宽160*高230*厚80）</option>
                        <option value="7">7号袋（宽210*高270*厚110）</option>
                        <option value="12">12号袋（宽250*高320*厚130）</option>
                    </select>
                </div>
                <p>
                    数量(个)
                </p>
                <div class="layui-form-item npzd count">
                    <select name="count" class="select countCG" id="npzd_count">
                        <option value=""></option>
                        <%--                        <option value="100">100</option>--%>
                        <option value="500">500</option>
                        <option value="1000">1000</option>
                        <option value="2000">2000</option>
                        <option value="3000">3000</option>
                        <option value="5000">5000</option>
                        <option value="10000">10000</option>
                    </select>
                </div>
                <p>
                    绳子
                </p>
                <div class="layui-form-item npzd">
                    <input type="radio" name="shen_type" lay-filter="shen_type" value="0" title="圆绳子" checked>
                    <input type="radio" name="shen_type" lay-filter="shen_type" value="1" title="扁绳子">
                    <select name="shen_color" class="select countCG" id="shen_color">
                        <option value="" selected></option>
                        <option value="白色">白色</option>
                        <option value="黄牛皮本色">黄牛皮本色</option>
                        <option value="黑色">黑色</option>
                        <option value="大红色">大红色</option>
                        <option value="深蓝色">深蓝色</option>
                        <%--                        <option value="浅蓝色">浅蓝色</option>--%>
                        <option value="黄色">黄色</option>
                    </select>
                </div>
                <p>
                    杯托
                </p>
                <div class="layui-form-item npzd">
                    <input type="checkbox" name="zheye" lay-filter="zheye" value="2" title="单杯杯托">
                    <input type="checkbox" name="zheye" lay-filter="zheye" value="0" title="双杯杯托">
                    <input type="checkbox" name="zheye" lay-filter="zheye" value="1" title="四杯托">
                </div>
            </div>
            <p>
                款数
            </p>
            <div class="layui-form-item">
                <input type="text" placeholder="请输入整数" autocomplete="off" name="number" id="number" value="1"
                       class="layui-input" lay-verify="number">
            </div>
            <p>
                客户旺旺
            </p>
            <div class="layui-form-item">
                <input type="text" placeholder="请输入客户旺旺号" autocomplete="off" name="wangwang" id="wangwang"
                       class="layui-input">
            </div>
            <div id="craft_layout" style="display: none">
                <p>工艺</p>
                <input type="checkbox" name="craft" lay-filter="craft" value="烫金" title="烫金"/>
                <div id="tang_type" class="layui-inline" style="display: none;width: 200px">
                    <select name="craft" class="select" disabled>
                        <option value="单面">单面</option>
                        <option value="双面">双面</option>
                    </select>
                </div>
            </div>
            <div class="layui-input-block">
                <input type="checkbox" name="craft" lay-filter="ui_craft" value="抠图" title="抠图">
                <div class="layui-inline crop" style="display:none;width: 80px">
                    <input class="layui-input" type="text" name="cropNumber">
                </div>
            </div>
            <hr>
            <div class="layui-form-item">
                <button class="layui-btn" lay-submit="" lay-filter="acount_btn" id="queryCondBtn">计算</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
            <h2>计算结果-
                <button type="button" class="layui-btn layui-btn-primary layui-btn-sm copyResult"
                        onclick="copyResult()">点击复制
                </button>
            </h2>
            <div>
                <textarea rows="11" cols="75" id="span_result" readonly="readonly"></textarea>
            </div>
            <!--<h2>下单备注-<button type="button" class="layui-btn layui-btn-primary layui-btn-sm copyResult" onclick="copyBz()">点击复制</button></h2>
            <div>
                <textarea rows="5" cols="75" id="bz_result" readonly="readonly"></textarea>
            </div>-->
            <%-- <%@include file="../acountExpressFeeTooWeight.jsp"%> --%>
            <div class="layui-collapse"
                 style="width: 200px; display: inline-block; float: right">
                <div class="layui-colla-item">
                    <h2 class="layui-colla-title">快递费计算</h2>
                    <div class="layui-colla-content layui-show">
                        快递公司:
                        <select name="changeExpress" lay-filter="changeExpress" class="select expressFee">
                            <option value=""></option>
                            <option value="普通快递">普通快递（偏远地）</option>
                            <option value="顺丰快递">顺丰快递</option>
                        </select>
                        收货地:
                        <select name="expressFee" id="expressFee" lay-filter="expressFee" class="select expressFee"
                                lay-search>
                        </select>
                        重量(kg):<input type="text" id="weight" class="layui-input" autocomplete="off">
                        价格(元):<input type="text" id="price" class="layui-input" value="0" readonly>
                    </div>
                </div>
            </div>
            <div>
                <table class="layui-hide" id="priceTable" lay-filter="priceTable"></table>
            </div>
        </form>
    </div>
    <div class="right_div" style="margin-left:50px;">
        <div class="layui-carousel" id="test1">
            <div carousel-item id="carousel"></div>
            <br>
            <div id="remark" style="font-size:20px;color:red"></div>
        </div>
    </div>
</div>
</body>
<%@include file="/views/copyResult.jsp" %>
<script>
    layui.use(['table', 'form', 'carousel'], function () {
        var form = layui.form; //只有执行了这一步，部分表单元素才会自动修饰成功
        var carousel = layui.carousel;
        var table = layui.table;
        //建造实例
        ins = carousel.render({});

        // 监听回车键，如果敲了回车，调用点击‘计算’
        $(document).keydown(function (e) {
            if (e.keyCode === 13) {
                $("#queryCondBtn").trigger("click");
            }
        });

        // 选择的快递方式
        var changeExpress;
        // 首重
        var firstPrice = 0;
        // 续重
        var continuedPrice = 0;
        // 价格
        var expressPrice = 0;
        // 监听选择的快递
        form.on('select(changeExpress)', function (data) {
            changeExpress = data.value

            // 清空省份下拉框
            $('#expressFee').empty()
            // 下拉框第一列添加空的option
            $('#expressFee').append(new Option("", ""));
            // 获取省份下拉框列表
            $.ajax({
                url: "../../getExpressFees",
                type: 'GET',
                success: function (data) {
                    if (changeExpress == '普通快递') {
                        var datas = data.data.handBag
                    } else {
                        var datas = data.data.allProvinces
                    }
                    $.each(datas, function (index, item) {
                        $('#expressFee').append(
                            new Option(item.province, item.firstWeightPrice + ',' + item.continuedWeightPrice + ',' + item.province));// 下拉菜单里添加元素
                    });
                    form.render("select");
                }
            })
        })

        // 监听重量输入框
        $(function () {
            // 输入框的值改变时触发
            $("#weight").on("input", function (e) {
                // 价格
                expressPrice = (firstPrice + continuedPrice * ($("#weight").val() - 1 > 0 ? Math.ceil($("#weight").val()) - 1 : 0)).toFixed(1)
                if (changeExpress == '普通快递') {
                    // 最低收费60
                    $("#price").val(expressPrice > 60 ? expressPrice : 60)
                } else {
                    // 顺丰无最低收费
                    $("#price").val(expressPrice)
                }
            });
            form.on("checkbox(craft)", function (data) {
                $("#tang_type").hide();
                $("#tang_type select").prop("disabled", true);
                if (data.value == "烫金" && data.elem.checked) {
                    $("#tang_type").show();
                    $("#tang_type select").prop("disabled", false);
                }
                form.render();
            })
            form.on("select(expressFee)", function (selectedData) {
                // 获取选中下拉框的价格（格式：首重,续重）
                price = selectedData.value
                // 首重价格
                firstPrice = parseFloat(price.split(",")[0])
                // 续重价格
                continuedPrice = price.split(",")[1]
                // 价格
                expressPrice = (firstPrice + continuedPrice * ($("#weight").val() - 1 > 0 ? Math.ceil($("#weight").val()) - 1 : 0)).toFixed(1)
                if (changeExpress == '普通快递') {
                    // 最低收费60
                    $("#price").val(expressPrice > 60 ? expressPrice : 60)
                } else {
                    // 顺丰无最低收费
                    $("#price").val(expressPrice)
                }
            })
        });
        form.on("checkbox(zheye)", function (data) {
            if ($("input[name='zheye']:checked").length > 1) {
                $(data.elem).prop("checked", false);
                layer.msg("只能选择一个");
            }
            form.render();
        })
        form.on("radio(shen_type)", function (data) {
            let html = ``;
            if (data.value == 0) {
                html = `<option value="" selected></option>
                        <option value="白色" >白色</option>
                        <option value="黄牛皮本色">黄牛皮本色</option>
                        <option value="黑色">黑色</option>
                        <option value="大红色">大红色</option>
                        <option value="深蓝色">深蓝色</option>
<!--                        <option value="浅蓝色">浅蓝色</option>-->
                        <option value="黄色">黄色</option>`
            }
            if (data.value == 1) {
                html = ` <option value="" selected></option>
                        <option value="白色" >白色</option>
                        <option value="黄牛皮本色">黄牛皮本色</option>
                        <option value="黑色">黑色</option>
                        <option value="大红色">大红色</option>
                        <option value="深蓝色">深蓝色</option>
                        <option value="黄色">黄色</option>`
            }
            $("#shen_color").empty().append(html);
            form.render();
        })
        form.on("select(kindValue)", function (data) {
            setCountHtml();
        })
        form.on("select(kind2Value)", function (data) {

            setCountHtml();
        })
        form.on("radio(typeValue)", function (data) {
            let html = ``;
            $("#spec").empty();
            //烘焙 小+30 大+60
            if (data.value == 0) {
                html = `<option value="1" selected>1号袋（宽230*高250*厚150）</option>
                        <option value="31">小1号袋（宽230*高210*厚150）</option>
                        <option value="62">大2号袋（宽240*高320*厚140）</option>
                        <option value="3">3号袋（宽280*高265*厚150）</option>
                        <option value="6">6号袋（宽160*高230*厚80）</option>
                        <option value="7">7号袋（宽210*高270*厚110）</option>
                        <option value="37">小7号袋（宽210*高230*厚110）</option>
                        <option value="38">小8号袋（宽210*高210*厚140）</option>
                        <option value="10">10号袋（宽320*高270*厚110）</option>
                        <option value="12">12号袋（宽350*高270*厚130）</option>`;
                $("#spec").append(html);

            }
            //外卖送餐
            if (data.value == 1) {
                html = `<option value="2" selected>2号袋（宽240*高265*厚140）</option>
                        <option value="31">小1号袋（宽230*高210*厚150）</option>
                        <option value="62">大2号袋（宽240*高320*厚140）</option>
                        <option value="3">3号袋（宽280*高265*厚150）</option>
                        <option value="4">4号袋（宽130*高175*厚80）</option>
                        <option value="7">7号袋（宽210*高270*厚110）</option>
                        <option value="37">小7号袋（宽210*高230*厚110）</option>
                        <option value="8">8号袋（宽210*高265*厚140）</option>
                        <option value="38">小8号袋（宽210*高210*厚140）</option>
                        <option value="9">9号袋（宽250*高250*厚170）</option>`;
                $("#spec").append(html);
            }
            //饮品外卖
            if (data.value == 2) {
                html = `<option value="5" selected>5号袋（宽130*高260*厚95）</option>
                        <option value="7">7号袋（宽210*高270*厚110）</option>
                        <option value="9">9号袋（宽250*高250*厚170）</option>`;
                $("#spec").append(html);
            }
            //礼品购物
            if (data.value == 3) {
                html = `<option value="4" selected>4号袋（宽130*高175*厚80）</option>
                        <option value="7">7号袋（宽210*高270*厚110）</option>
                        <option value="10">10号袋（宽320*高270*厚110）</option>
                        <option value="11">11号袋（宽320*高390*厚110）</option>
                        <option value="12">12号袋（宽350*高270*厚130）</option>`;
                $("#spec").append(html);
            }
            form.render();
            setCountHtml();
        })

        function setCountHtml() {
            let spec = $("#spec").val();
            let kindValue = $(".npzd select[name='kindValue']").val();
            let count_html = `<option value=""></option>`;
            if (spec <= 10 && kindValue == 0) {
                // count_html +=
                //     `<option value="100">100</option>`;
            }
            count_html += `
                        <option value="500">500</option>
                        <option value="1000">1000</option>
                        <option value="2000">2000</option>
                        <option value="3000">3000</option>
                        <option value="5000">5000</option>
                        <option value="10000">10000</option>`;
            $("#npzd_count").empty().append(count_html);
            form.render();
            $("input[name='shen_type']").attr("disabled", false);
            if (spec == 5 || spec == 6) {
                $("input[name='shen_type'][value='1']").attr("disabled", true);
            }
            let html = ` <option value="" selected></option>
                        <option value="白色" >白色</option>
                        <option value="黄牛皮本色">黄牛皮本色</option>
                        <option value="黑色">黑色</option>
                        <option value="大红色">大红色</option>
                        <option value="深蓝色">深蓝色</option>
<!--                        <option value="浅蓝色">浅蓝色</option>-->
                        <option value="黄色">黄色</option>`;
            $("#shen_color").empty().append(html);
            form.render();
        }

        form.on('checkbox(ui_craft)', function (data) {
            let craft_list = [];
            let kindValue = $('input[name="kindValue"]:checked').val();
            craft_list.push($("select[name='craft'] option:selected").val());
            $("input[name='craft']:checked").each(function () {
                if (!$(this).is(':disabled')) {
                    craft_list.push($(this).val());
                }
            });

            if (data.value == '抠图') {
                $(".crop").hide();
                $(".crop").find("input").prop("disabled", true)
                if (data.elem.checked) {
                    $(".crop").show();
                    $(".crop").find("input").prop("disabled", false)
                }
            }
            form.render();
        })
        // 自定义数量
        form.on('checkbox(diyCount)', function (data) {
            //判断当前多选框是选中还是取消选中
            if (data.elem.checked) {
                $(".diyCount").show();
                $(".count").hide();
                $(".diyCount").find(":input").attr("disabled", false);
                $(".count").find(":input").attr("disabled", true);
            } else {
                // 恢复标准数量的时候会被禁用，需要重置一下表单
                //$("#kindValueForm")[0].reset();
                $(".count").show();
                $(".diyCount").hide();
                $(".count").find(":input").attr("disabled", false);
                $(".diyCount").find(":input").attr("disabled", true);
                // 恢复标准数量的时候会被禁用，加这个解决
                form.render();
            }
        });
        // 选择是常规还是自定义
        form.on('radio(k)', function (data) {
            var html = " ";
            var remark = " ";
            // 清空轮播图
            $("#carousel").empty();
            $("#remark").empty();
            $.ajax({
                url: "${pageContext.request.contextPath}/getImgs",
                type: "GET",
                data: {
                    proTypeValue: $("#proTypeValue").val(),
                    kindValue: $('input[name="k"]:checked').val()
                    //kind2Value 	 : $("#kind2Value").val()
                },
                success: function (result) {
                    for (let i = 0; i < result.length; i++) {
                        // 只留一个remark
                        remark = "";
                        html += '<div><img style="width:100%;height: 100%;object-fit: contain" src="' + result[i].imgUrl + '"></div>';
                        remark += '<div><span>' + result[i].remark + '<span/></div>';
                    }
                    $("#carousel").append(html);
                    // 如果没有说明，就不显示null
                    if (remark.indexOf("null") < 0) {
                        $("#remark").append(remark);
                    }
                    if (result.length == 0) {
                        document.getElementById("test1").style.display = "none";   //隐藏
                    } else {
                        document.getElementById("test1").style.display = "block";   //显示
                        ins.reload({
                            elem: '#test1',
                            width: result[0].imgWidth,  //设置容器宽度
                            height: result[0].imgHeight
                        });
                    }
                }
            });
            $("#tang_type").hide();
            $("#tang_type select").prop("disabled", true);
            $("#bagForm")[0].reset();
            var level = data.value;//被点击的radio的value值
            $("#craft_layout").hide();
            $("#craft_layout").find(":input").attr("disabled", true);
            if (level == 0) {
                $(".cg").show();
                $(".zdy").hide();
                $(".tj").hide();
                $(".npzd").hide();
                $(".cg").find(":input").attr("disabled", false);
                $(".zdy").find(":input").attr("disabled", true);
                $(".tj").find(":input").attr("disabled", true);
                $(".npzd").find(":input").attr("disabled", true);
            } else if (level == 1) {
                $(".cg").hide();
                $(".tj").hide();
                /* $(".dz").hide(); */
                $(".zdy").show();
                $(".npzd").hide();
                $(".zdy").find(":input").attr("disabled", false);
                $(".cg").find(":input").attr("disabled", true);
                $(".tj").find(":input").attr("disabled", true);
                $(".dz").find(":input").attr("disabled", true);
                $(".npzd").find(":input").attr("disabled", true);
                $("#craft_layout").show();
                $("#craft_layout").find(":input").attr("disabled", false);
            } else if (level == 2) {
                $(".cg").hide();
                $(".tj").hide();
                $(".zdy").show();
                $(".aaa").hide();
                $(".npzd").hide();
                /* $(".dz").show(); */
                $(".zdy").find(":input").attr("disabled", false);
                $(".cg").find(":input").attr("disabled", true);
                $(".tj").find(":input").attr("disabled", true);
                $(".aaa").find(":input").attr("disabled", true);
                $(".npzd").find(":input").attr("disabled", true);
            } else if (level == 4) {
                $(".cg").hide();
                $(".tj").hide();
                $(".zdy").hide();
                $(".aaa").hide();
                $(".npzd").show();
                /* $(".dz").show(); */
                $(".zdy").find(":input").attr("disabled", true);
                $(".cg").find(":input").attr("disabled", true);
                $(".tj").find(":input").attr("disabled", true);
                $(".aaa").find(":input").attr("disabled", true);
                $(".npzd").find(":input").attr("disabled", false);
            } else {
                $(".cg").hide();
                $(".zdy").hide();
                $(".npzd").hide();
                /* $(".dz").hide(); */
                $(".tj").show();
                $(".tj").find(":input").attr("disabled", false);
                $(".cg").find(":input").attr("disabled", true);
                $(".zdy").find(":input").attr("disabled", true);
                $(".dz").find(":input").attr("disabled", true);
                $(".npzd").find(":input").attr("disabled", true);
            }
            // 点击计算，计算价格
            form.on('submit(acount_btn)', function (data) {
                var diyCount = $('input[name="diyCount"]:checked').val();
                // 勾了少数量
                if (diyCount) {
                    if ($(".countDIY").val() % 1000 != 0) {
                        layer.msg('自定义数量需为 1000 的整数倍！', {offset: ['300px', '300px']}, function () {
                        });
                        return false;
                    }
                }
                if (level != 0 && level != 3) {
                    if (level != 4) {
                        var size = $("#size").val();
                        if (!size) {
                            layer.msg('请填写尺寸！', {offset: ['300px', '300px']}, function () {
                            });
                            return false;
                        }
                        if (size.indexOf("*") != -1 && size.indexOf(("*"), size.indexOf("*") + 1) == -1) {
                            layer.msg('请填写正确的尺寸格式！', {offset: ['300px', '300px']}, function () {
                            });
                            return false;
                        }
                        if ($("#count").val() < 100) {
                            layer.msg('数量不少于100个！', {offset: ['300px', '300px']}, function () {
                            });
                            return false;
                        }
                    } else {
                        if ($("#npzd_count").val() < 100) {
                            layer.msg('数量不少于100个！', {offset: ['300px', '300px']}, function () {
                            });
                            return false;
                        }
                        let shen_color = $('.npzd select[name="shen_color"] option:selected').val()
                        if (shen_color == "") {
                            layer.msg('请选择颜色！', {offset: ['300px', '300px']}, function () {
                            });
                            return false;
                        }
                    }

                }
                if (level == 1) {
                    var size = $("#size").val();
                    let d_size = size.split("*");
                    if (d_size[0] < 10 || d_size[1] < 0 || d_size[2] < 10) {
                        layer.msg('尺寸格式不能小于10CM！', {offset: ['300px', '300px']}, function () {
                        });
                        return false;
                    }
                }
                // 现货白卡纸只能选择250克
                if (level == 3) {
                    $("#proTypeValue").val(12)
                } else {
                    $("#proTypeValue").val(11)
                }
                form.render();

                $.ajax({
                    url: "${pageContext.request.contextPath}/getThanSum",
                    type: "GET",
                    data: $(".big_box form").serialize(),
                    success: function (result) {
                        if (result.code != 200) {
                            layer.msg(result.msg, {offset: ['300px', '300px']}, {icon: 5, time: 1000});
                            return false;
                        }
                        let arr = [];
                        $("input:checkbox[name='craft']:checked").each(function (i) {
                            if (!$(this).is(':disabled')) {
                                if ($(this).val() == "烫金") {
                                    arr.push($("#tang_type select option:selected").val() + $(this).val());
                                }
                                if ($(this).val() == "抠图") {
                                    arr.push($(this).val() + $("input[name='cropNumber']").val());
                                    return;
                                }
                                arr.push($(this).val());
                            }
                        });
                        var data = result.data.proList;
                        var number = $("#number").val();
                        if (level == 0) {
                            var kindData = {
                                0: "130克进口白牛皮",
                                1: "130克国产黄牛皮",
                                2: "130克进口黄牛皮"
                            }, kind2Data = {
                                0: "20*11*27CM",
                                1: "21*14*27CM",
                                2: "23*15*25CM"
                            }
                            var kind = kindData[$(".kindValueCG").val()];
                            var kind2 = kind2Data[$(".kind2Value").val()];
                            var count = $(".countCG").val();

                            // textarea
                            var span_result = "手提袋- " + kind + ' - ' + kind2 + '\n';
                            span_result += "工艺：" + arr.join(",") + '\n';
                            if (number > 1) {
                                for (let i = 0; i < data.length; i++) {
                                    span_result += number + '款 各' + data[i].count + "个，共" + data[i].price + "元" + '\n'
                                    data[i].number = number;
                                }
                            } else {
                                for (let i = 0; i < data.length; i++) {
                                    span_result += number + '款 ' + data[i].count + "个，共" + data[i].price + "元" + '\n'
                                    data[i].number = number;
                                }
                            }
                        } else if (level == 3) {
                            // 特价白卡纸手提袋
                            var kindData = {
                                0: "竖款26*8*36CM",
                                1: "竖款25*8*33CM",
                                2: "竖款28*8*40CM",
                                3: "竖款30*10*40CM",
                                4: "竖款23*13*25CM",
                                5: "横款26*8*25CM",
                                6: "横款26*13*35CM",
                                7: "横款32*14*35CM"
                            };
                            var kind = kindData[$(".kindValueTJ").val()];
                            // var count = $(".countTJ").val();

                            // textarea
                            var span_result = "手提袋 - 250克白卡纸手提袋 - " + kind + '--' + '\n';
                            if (number > 1) {
                                for (let i = 0; i < data.length; i++) {
                                    span_result += number + '款 各' + data[i].count + "个，共" + data[i].price + "元" + '\n'
                                    data[i].number = number;
                                    data[i].kindLabel = '特价白卡纸手提袋'
                                }
                            } else {
                                for (let i = 0; i < data.length; i++) {
                                    span_result += number + '款 ' + data[i].count + "个，共" + data[i].price + "元" + '\n'
                                    data[i].number = number;
                                    data[i].kindLabel = '特价白卡纸手提袋'
                                }
                            }
                        } else if (level == 1) {
                            var kindData = {
                                5: "250克白卡纸手提袋"
                            }
                            var kind = kindData[$(".kindValueZDY").val()];
                            var size = $(".size").val();
                            var count = $(".countZDY").val();
                            // textarea
                            var span_result = "手提袋--" + kind + '--' + size + 'CM\n';
                            span_result += "工艺：" + arr.join(",") + '\n';
                            if (number > 1) {
                                for (let i = 0; i < data.length; i++) {
                                    span_result += number + '款 各' + data[i].count + "个，共" + data[i].price + "元" + '\n'
                                    data[i].number = number;
                                }
                            } else {
                                for (let i = 0; i < data.length; i++) {
                                    span_result += number + '款 ' + data[i].count + "个，共" + data[i].price + "元" + '\n'
                                    data[i].number = number;
                                }
                            }
                        } else if (level == 4) {
                            let shen = ['圆绳', '扁绳'];
                            let zheye_list = ['双杯杯托', '四杯托', '单杯托']
                            let kindValue = $(".npzd select[name='kindValue'] option:selected").text();
                            let spec = $("#spec option:selected").text();
                            let zheye = $('.npzd input[name="zheye"]:checked').val()
                            let shen_type = $('.npzd input[name="shen_type"]:checked').val()
                            let shen_color = $('.npzd select[name="shen_color"] option:selected').text()

                            var span_result = "手提袋-" + kindValue + '-' + spec + '-' + shen_color + shen[shen_type];
                            if (zheye) {
                                span_result += '-' + zheye_list[zheye];

                            }
                            span_result += '\n';
                            if (number > 1) {
                                for (let i = 0; i < data.length; i++) {
                                    span_result += number + '款 各' + data[i].count + "个，共" + data[i].price + "元" + '\n'
                                    data[i].number = number;
                                }
                            } else {
                                for (let i = 0; i < data.length; i++) {
                                    span_result += number + '款 ' + data[i].count + "个，共" + data[i].price + "元" + '\n'
                                    data[i].number = number;
                                }
                            }
                        } else {
                            var size = $(".size").val();
                            var count = $(".countZDY").val();
                            // textarea
                            var span_result = "手提袋-250克白卡纸手提袋" + '--' + size + 'CM\n';
                            if (number > 1) {
                                for (let i = 0; i < data.length; i++) {
                                    span_result += number + '款 各' + data[i].count + "个，共" + data[i].price + "元" + '\n'
                                    data[i].number = number;
                                }
                            } else {
                                for (let i = 0; i < data.length; i++) {
                                    span_result += number + '款 ' + data[i].count + "个，共" + data[i].price + "元" + '\n'
                                    data[i].number = number;
                                }
                            }
                        }
                        span_result += '包邮，免费设计呢~（偏远地区需补邮费）'
                        if (window.parent.system_isGai) {
                            span_result += "\n\n亲 现在下单可以参加淘宝活动8.5折折扣哦!"
                        }
                        addLog(span_result);
                        $("#span_result").val(span_result);

                        var size = "";
                        if (level == 0) {
                            size = $(".kind2Value option:selected").text();
                            count = $(".countCG option:selected").val();
                            size = size.replace("CM", "");
                        } else {
                            size = $("#size").val();
                            count = $("#count").val();
                            kind = $(".kindValueZDY option:selected").text();
                        }

                        getRemark("手提袋", size, count + "个", kind + "-四面彩印", number, "", "");
                        //计算完自动复制文本
                        var e = document.getElementById("span_result");//对象是content
                        if (e.value != "") {
                            e.select();//选择对象
                            document.execCommand("Copy");//执行浏览器复制命令
                        }

                        //生成表格
                        table.render({
                            elem: '#priceTable',
                            even: true, //隔行变色
                            data: data, // 赋值已知数据
                            width: 550,
                            cols: [[
                                {
                                    field: 'number',
                                    width: '11%',
                                    align: "center",
                                    title: '款数'
                                }, {
                                    field: 'count',
                                    width: '13%',
                                    align: "center",
                                    title: '数量'
                                }, {
                                    field: 'price',
                                    width: '14%',
                                    align: "center",
                                    title: '报价'
                                }, {
                                    field: 'wangwang',
                                    align: "center",
                                    width: '14%',
                                    title: '折扣价'
                                }, {
                                    field: 'weight',
                                    width: '19%',
                                    align: "center",
                                    title: '重量（kg）'
                                }, {
                                    field: 'weight',
                                    width: '24%',
                                    align: "center",
                                    title: '单个重量（kg）',
                                    templet: function (d) {
                                        return (d.weight / d.count).toFixed(2)
                                    }
                                }
                            ]],
                            done: function () {
                            }
                        });
                    }
                });
                return false;
            });
        });
    });

</script>
</html>