prom_goods_info.html 61.6 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243
<include file="public/layout"/>
<style>
    dd.opt table {
        width: 100%;
    }

    dd.opt tr {
        border: 1px solid #f4f4f4;
        padding: 8px;
    }

    dd.opt tr td {
        border: 1px solid #f4f4f4;
    }

    .btn {
        color: #999;
        cursor: pointer !important;
    }

    .opt table tr th {
        text-align: center;
        font-weight: 600;
        padding: 5px 0;
    }

    select {
        height: 31px;
    }

    .prom_info {
        border: 1px #ddd solid;
        max-width: 1000px;
    }

    .prom_info .prom_top {
        padding: 15px;
        font-size: 0;
        border-bottom: 1px #ddd solid;
    }
    .prom_info .prom_top:last-child {
        border-bottom: 0;
    }

    .prom_info .prom_top .dib_vm {
        display: inline-block;
        *display: inline;
        *zoom: 1;
        width: 0;
        height: 100%;
        vertical-align: middle;
    }

    .prom_info .prom_top .prom_center {
        display: inline-block;
        *display: inline;
        *zoom: 1;
        vertical-align: middle;
        font-size: 12px;
    }

    .prom_info .prom_top .prom_center1 {
        width: 20%;
        text-align: center;
    }

    .prom_info .prom_top .prom_center2 {
        width: 35%;
        text-align: center;
    }

    .prom_info .prom_top .prom_center3 {
        width: 40%;
        padding-left: 5%;
        position: relative;
    }

    .prom_info .prom_top .prom_center3 .close {
        position: absolute;
        right: -5px;
        top: 50%;
        margin-top:-10px;
        z-index: 10;
        font-size: 20px;
    }

    .prom_info .prom_top .prom_center3 li {
        padding: 8px 0;
    }

    .prom_info .prom_top .prom_center3 li .left_span {
        display: inline-block;
        *display: inline;
        *zoom: 1;
        width: 20%;
    }

    .prom_info .prom_top .prom_center3 li .left_span label input {
        margin: -2px 8px 0;
        vertical-align: middle;
    }

    .prom_info .prom_top .prom_center3 li .right_span {
        visibility: hidden;
        display: inline-block;
        *display: inline;
        *zoom: 1;
        width: 65%;
    }

    .prom_info .prom_top .prom_center3 li .right_span select.prom_input {
        width: 100px;
    }

    .prom_info .prom_top .prom_center3 li .right_span img {
        display: inline-block;
        *display: inline;
        *zoom: 1;
        vertical-align: middle;
        margin: -3px 8px 0;
    }

    .prom_input {
        width: 50px;
        margin: 0 5px;
    }

    .prom_center2 .prom_input {
        width: 100px;
        margin: 0 8px;
    }

    .radio1 {
        display: inline-block;
        *zoom: 1;
        *display: inline;
        vertical-align: middle;
        margin: -3px 5px 0;
        width: 19px;
        height: 19px;
        background-image: url("__PUBLIC__/static/images/prom_radio.png");
        background-repeat: no-repeat;
        background-position: center center;
    }

    .radio1.on {
        background-image: url("__PUBLIC__/static/images/prom_radio_on.png");
    }

    .prom_info .prom_bottom {
        padding: 10px 15px;
        border-top: 1px #ddd solid;
    }
    .prom_info_tit{
        border-bottom: 1px #ddd solid;
        padding: 5px 0;
        background-color: #F5F5F5;
    }
.prom_info_tit span{
    display: inline-block;
    *zoom: 1;
    *display: inline;
    text-align: center;

}
    .prom_info .prom_bottom .add {
        display: inline-block;
        *zoom: 1;
        *display: inline;
        font-size: 12px;
        line-height: 24px;
        color: #ff3c3c;
        background-color: #FFFFFF;
        height: 24px;
        padding: 2px 7px;
        border: solid 1px #ff3c3c;
        border-radius: 4px;
    }

    .prom_table {
        margin: 30px 0;
        text-align: center;

    }

    .prom_table td {
        padding: 6px 5px;
        max-height: 61px;
        line-height: 30px;
        overflow: hidden;
    }

</style>
<script src="__PUBLIC__/static/js/layer/laydate/laydate.js"></script>

<body style="background-color: #FFF; overflow: auto;">
<div class="page">
    <div class="fixed-bar">
        <div class="item-title">
            <a class="back" href="javascript:history.back();" title="返回列表">
            <i class="fa fa-arrow-circle-o-left"></i>
            </a>
            <div class="subject">
                <h3>优惠促销管理 - 添加与编辑商品促销活动</h3>
                <h5>系统编辑商品促销活动</h5>
            </div>
        </div>
    </div>
    <!-- 操作说明 -->
    <div id="explanation" class="explanation" style="color: rgb(44, 188, 163); background-color: rgb(237, 251, 248); width: 99%; height: 100%; min-height: 30px;min-width: 100px;">
        <div id="checkZoom" class="title"><i class="fa fa-lightbulb-o"></i>
            <h4 title="提示相关设置操作时应注意的要点">操作提示</h4>
            <span title="收起提示" id="explanationZoom" style="display: block;"></span>
        </div>
        <ul>
            <li><p>1、每件商品只能设置一种满减活动</p>
                <p>2、若商品有参与秒杀/团购/积分购活动,则不会再参与优惠促销的满减活动</p>
                <p>3、满元(件)减价或打折,可同时勾选/包邮、积分、优惠券、赠品</p>
                <p>4、赠送的积分/优惠券需客户确认收货后才可以获取</p></li>
        </ul>
    </div>
    <form class="form-horizontal" id="promotion" action="{:U('Admin/Promotion/prom_goods_save')}" method="post">
        <input type="hidden" name="id" id="prom_id" value="{$info.id}">
        <div class="ncap-form-default">
            <dl class="row">
                <dt class="tit">
                    <label><em>*</em>促销活动名称</label>
                </dt>
                <dd class="opt">
                    <input type="text" name="name" id="name" value="{$info.name}" class="input-txt">
                    <span class="cr dn">活动名称不能为空</span>
                    <p class="notic">促销活动名称</p>
                </dd>
            </dl>
            <dl class="row">
                <dt class="tit">
                    <label><em>*</em>开始时间</label>
                </dt>
                <dd class="opt">
                    <input type="text" id="start_time" name="start_time" value="{$info.start_time}" class="input-txt">
                    <p class="notic">优惠开始时间</p>
                </dd>
            </dl>
            <dl class="row">
                <dt class="tit">
                    <label><em>*</em>结束时间</label>
                </dt>
                <dd class="opt">
                    <input type="text" id="end_time" name="end_time" value="{$info.end_time}" class="input-txt">
                    <span class="cr dn">结束时间必须大于开始时间</span>
                    <p class="notic">优惠结束时间</p>
                </dd>
            </dl>
            <dl class="row">
                <dt class="tit">
                    <label><em>*</em>促销活动类型</label>
                </dt>
                <dd class="opt">
                    <div class="prom_info">
                        <div class="prom_info_tit"><span style="width: 20%">层级</span><span style="width: 35%">优惠门槛</span><span style="width: 40%;padding-left: 5%">优惠方式(可多选)</span></div>
                        <empty name="list">
                            <div class="prom_top" id="tab0">
                                <div class="prom_center prom_center1">
                                    1
                                </div>
                                <div class="prom_center prom_center2">
<input class="prom_input first" type="text" name="data[0][condition]" value=""
                                            onkeyup="check_num(this,0)" autocomplete="off">
                                    <select style="margin-top: -3px" name="prom_type" class="select_syn"
                                            onchange="money_pack(this)">
                                        <option value="0"></option>
                                        <option value="1"></option>
                                    </select>
                                    <span class="cr dn">请输入正确的条件</span>
                                </div>
                                <div class="prom_center prom_center3">
                                    <input type="hidden" name="data[0][id]" value="">
                                    <ul>
                                        <li>
                                            <input type="hidden" name="data[0][is_money]" value="0">
                                            <span class="left_span jianxianjin" onclick="change_type(this,1)">
                                                <em class="radio1"></em>减现金
                                            </span>
                                            <span class="right_span">
<input class="prom_input" name="data[0][money]" type="text" value="0" autocomplete="off"
                                                        onkeyup="this.value = this.value.replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1')">
                                                <span class="cr dn">请输入正确的值</span>
                                            </span>
                                        </li>
                                        <li>
                                            <input type="hidden" name="data[0][is_sale]" value="0">
                                            <span class="left_span" onclick="change_type(this,2)">
                                                <em class="radio1"></em> 打折
                                            </span>
                                            <span class="right_span">
<input class="prom_input" name="data[0][sale]" type="text" value="0" autocomplete="off"
                                                        onkeyup="this.value = this.value.replace(/^(\d+)\.(\d{2})/,'')">
                                                <span class="cr dn">请输入正确的值</span>
                                            </span>
                                        </li>
                                        <li>
                                            <span class="left_span" onclick="change_checkbox(this,1)">
                                                <label><input type="checkbox">包邮</label>
                                            </span>
                                            <span class="right_span">
                                                <input type="hidden" name="data[0][is_past]" value="0">
                                            </span>
                                        </li>
                                        <li>
                                            <span class="left_span" onclick="change_checkbox(this,2)">
                                                <input type="hidden" name="data[0][is_int]" value="0">
                                                <label><input type="checkbox" class="second">积分</label>
                                            </span>
                                            <span class="right_span">
<input class="prom_input" type="text" name="data[0][int]" value="0"
                                                        onkeyup="this.value=this.value.replace(/[^\d]/g,'')"
                                                        autocomplete="off">
                                                <span class="cr dn">请输入正确的值</span>
                                            </span>
                                        </li>
                                        <li>
                                            <span class="left_span" onclick="change_checkbox(this,3)">
                                                <label><input type="checkbox" class="third">优惠券</label>
                                            </span>
                                            <span class="right_span">
                                                <select class="prom_input" name="data[0][coupon]">
                                                    <option value="">未选择</option>
                                                    <volist name="coupon" id="vv">
                                                        <option value="{$vv.id}">{$vv.name}</option>
                                                    </volist>
                                                </select>
                                                <input type="hidden" name="data[0][is_coupon]" value="0">
                                                <a href="javascript:void (0);" onclick="updata(this,'coupon')">
                                                    <img src="__PUBLIC__/static/images/prom_refresh.png" title="刷新数据">
                                                </a>
                                                <a href="{:U('Coupon/coupon_info',['type'=>1])}" target="_blank">
                                                    <img src="__PUBLIC__/static/images/prom_add.png" title="增加优惠券">
                                                </a>
                                            </span>
                                        </li>
                                        <li>
                                            <span class="left_span" onclick="change_checkbox(this,4)">
                                                <label><input type="checkbox" class="fourth">赠品</label>
                                            </span>
                                            <span class="right_span">
<select class="prom_input" name="data[0][gift]">
                                                    <option value="">未选择</option>
                                                    <volist name="gift" id="vv">
                                                        <option value="{$vv.id}">{$vv.title}</option>
                                                    </volist>
                                                </select>
                                                <input type="hidden" name="data[0][is_gift]" value="0">
                                                <a href="javascript:void (0);" onclick="updata(this,'gift')">
                                                    <img src="__PUBLIC__/static/images/prom_refresh.png" title="刷新数据">
                                                </a>
                                                <a href="{:U('Promotion/gift_info')}" target="_blank">
                                                    <img src="__PUBLIC__/static/images/prom_add.png" title="增加赠品">
                                                </a>
                                            </span>
                                        </li>

                                        <li>
                                            <span class="left_span" onclick="change_checkbox(this,4)">
                                                <label><input type="checkbox" class="fourth">礼包</label>
                                            </span>
                                            <span class="right_span">
<select class="prom_input" name="data[0][libao]">
                                                    <option value="">未选择</option>
                                                    <volist name="libao" id="vv">
                                                        <option value="{$vv.id}">{$vv.lbtitle}</option>
                                                    </volist>
                                                </select>
                                                <input type="hidden" name="data[0][is_libao]" value="0">
                                                <a href="javascript:void (0);" onclick="updata(this,'libao_form')">
                                                    <img src="__PUBLIC__/static/images/prom_refresh.png" title="刷新数据">
                                                </a>
                                                <a href="{:U('/Admin/Libao/addlb')}" target="_blank">
                                                    <img src="__PUBLIC__/static/images/prom_add.png" title="增加赠品">
                                                </a>
                                            </span>
                                        </li>
                                    </ul>
                                </div>
                                <div class="clear"></div>
                            </div>
                            <else/>
                            <volist name="list" id="vo" key="k">
                                <div class="prom_top" id="tab{$k-1}">
                                    <div class="prom_center prom_center1">{$k}</div>
                                    <div class="prom_center prom_center2 ">
<input class="prom_input first" type="text" value="{$vo.condition}"
                                                autocomplete="off" name="data[{$k-1}][condition]"
                                                onkeyup="check_num(this,{$vo.prom_type})">
                                        <select style="margin-top: -3px" name="prom_type" class="select_syn"
                                        <if condition="$k eq 1">onchange="money_pack(this)"<else/>disabled</if>>
                                        <option value="0"
                                        <if condition="$vo.prom_type eq 0">selected</if>>元
                                        </option>
                                        <option value="1"
                                        <if condition="$vo.prom_type eq 1">selected</if>>件
                                        </option>
                                        </select>
                                        <span class="cr dn">请输入正确的条件</span>
                                    </div>
                                    <div class="prom_center prom_center3">
                                        <input type="hidden" name="data[{$k-1}][id]" value="{$vo.id}">
                                        <empty name="tpl">
                                            <if condition="$k neq 1">
                                                <div class="close fa fa-trash-o" onclick="tab_del(this)"></div>
                                            </if>
                                        </empty>
                                        <ul>
                                            <li>
                                                <input type="hidden" value="{$vo.preferential_type.is_money}" name="data[{$k-1}][is_money]">
                                                <span class="left_span" onclick="change_type(this,1)">
                                                <em class="radio1 <if condition='$vo.preferential_type.is_money eq 1'>on</if>"></em>减现金
                                                </span>
                                                <span class="right_span"
                                                <if condition='$vo.preferential_type.is_money eq 1'>
                                                    style="visibility:visible"</if>>
<input class="prom_input" name="data[{$k-1}][money]" type="text"
                                                        autocomplete="off" value="{$vo.preferential_type.money}"
                                                        onkeyup="this.value = this.value.replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1')">
                                                <span class="cr dn">请输入正确的值</span>
                                                </span>
                                            </li>
                                            <li>
                                                <input type="hidden" value="{$vo.preferential_type.is_sale}" name="data[{$k-1}][is_sale]">
                                                <span class="left_span" onclick="change_type(this,2)">
                                                <em class="radio1 <if condition='$vo.preferential_type.is_sale eq 1'>on</if>"></em>打折
                                                </span>
                                                <span class="right_span"
                                                <if condition='$vo.preferential_type.is_sale eq 1'>
                                                    style="visibility:visible"</if>>
<input class="prom_input" name="data[{$k-1}][sale]" type="text"
                                                        autocomplete="off" value="{$vo.preferential_type.sale}"
                                                        onkeyup="this.value = this.value.replace(/^(\d+)\.(\d{2})/,'')">
                                                <span class="cr dn">请输入正确的值</span>
                                                </span>
                                            </li>
                                            <li>
                                                <span class="left_span" onclick="change_checkbox(this,1)">
                                                    <label><input type="checkbox"
                                                        <if condition='$vo.preferential_type.is_past eq 1'>checked</if>>包邮</label>
                                                </span>
                                                <span class="right_span"
                                                <if condition='$vo.preferential_type.is_past eq 1'>
                                                    style="visibility:visible"</if>>
                                                <input type="hidden" name="data[{$k-1}][is_past]" value="{$vo.preferential_type.is_past}">
                                                </span>
                                            </li>
                                            <li>
                                                <span class="left_span" onclick="change_checkbox(this,2)">
                                                <input type="hidden" name="data[{$k-1}][is_int]" value="{$vo.preferential_type.is_int}">
                                                <label><input type="checkbox" class="second"
                                                    <if condition='$vo.preferential_type.is_int eq 1'>checked</if>>积分</label>
                                                </span>
                                                <span class="right_span"
                                                <if condition='$vo.preferential_type.is_int eq 1'>
                                                    style="visibility:visible"</if>>
<input class="prom_input" type="text" name="data[{$k-1}][int]"
                                                        autocomplete="off" value="{$vo.preferential_type.int}"
                                                        onkeyup="this.value=this.value.replace(/[^\d]/g,'')">
                                                <span class="cr dn">请输入正确的值</span>
                                                </span>
                                            </li>
                                            <li>
                                                <span class="left_span" onclick="change_checkbox(this,3)">
                                                    <label><input type="checkbox" class="third"
                                                        <if condition='$vo.preferential_type.is_coupon eq 1'>checked</if>>优惠券</label>
                                                </span>
                                                <span class="right_span"
                                                <if condition='$vo.preferential_type.is_coupon eq 1'>
                                                    style="visibility:visible"</if>>
<select class="prom_input" name="data[{$k-1}][coupon]">
                                                    <option value="">未选择</option>
                                                    <volist name="coupon" id="vv">
                                                        <option value="{$vv.id}"
                                                        <if condition="$vo.preferential_type.coupon eq $vv.id">selected</if>>
                                                        {$vv.name}</option>
                                                    </volist>
                                                </select>
                                                <input type="hidden" name="data[{$k-1}][is_coupon]" value="{$vo.preferential_type.is_coupon}">
                                                <a href="javascript:void (0);" onclick="updata(this,'coupon')">
                                                    <img src="__PUBLIC__/static/images/prom_refresh.png" title="刷新数据">
                                                </a>
                                                <a href="{:U('Coupon/coupon_info',['type'=>1])}" target="_blank">
                                                    <img src="__PUBLIC__/static/images/prom_add.png" title="增加优惠券">
                                                </a>
                                                </span>
                                            </li>

                                            <li>
                                                <span class="left_span" onclick="change_checkbox(this,4)">
                                                <label>
                                                    <input type="checkbox" class="fourth"
                                                    <if condition='$vo.preferential_type.is_gift eq 1'>checked</if>>赠品
                                                </label>
                                            </span>
                                                <span class="right_span"
                                                <if condition='$vo.preferential_type.is_gift eq 1'>
                                                    style="visibility:visible"</if>>
<select class="prom_input" name="data[{$k-1}][gift]">
                                                    <option value="">未选择</option>
                                                    <volist name="gift" id="vv">
                                                        <option value="{$vv.id}"
                                                        <if condition="$vo.preferential_type.gift eq $vv.id">selected</if>>
                                                        {$vv.title}</option>
                                                    </volist>
                                                </select>
                                                <input type="hidden" name="data[{$k-1}][is_gift]" value="{$vo.preferential_type.is_gift}">
                                                <a href="javascript:void (0);" onclick="updata(this,'gift')">
                                                    <img src="__PUBLIC__/static/images/prom_refresh.png" title="刷新数据">
                                                </a>
                                                <a href="{:U('Promotion/gift_info')}" target="_blank">
                                                    <img src="__PUBLIC__/static/images/prom_add.png" title="增加赠品">
                                                </a>
                                                </span>
                                            </li>

                                            <li>
                                                <span class="left_span" onclick="change_checkbox(this,4)">
                                                <label>
                                                    <input type="checkbox" class="five"
                                                    <if condition='$vo.preferential_type.is_libao eq 1'>checked</if>>礼包
                                                </label>
                                            </span>
                                                <span class="right_span"
                                                <if condition='$vo.preferential_type.is_libao eq 1'>
                                                    style="visibility:visible"</if>>
<select class="prom_input" name="data[{$k-1}][libao]">
                                                <option value="">未选择</option>
                                                <volist name="libao" id="vv">
                                                    <option value="{$vv.id}"
                                                    <if condition="$vo.preferential_type.libao eq $vv.id">selected</if>>
                                                    {$vv.lbtitle}</option>
                                                </volist>
                                            </select>
                                                <input type="hidden" name="data[{$k-1}][is_libao]" value="{$vo.preferential_type.is_libao}">
                                                <a href="javascript:void (0);" onclick="updata(this,'libao_form')">
                                                    <img src="__PUBLIC__/static/images/prom_refresh.png" title="刷新数据">
                                                </a>
                                                <a href="{:U('/Admin/Libao/addlb')}" target="_blank">
                                                    <img src="__PUBLIC__/static/images/prom_add.png" title="增加赠品">
                                                </a>
                                                </span>
                                            </li>
                                        </ul>
                                    </div>
                                    <div class="clear"></div>
                                </div>
                            </volist>
                        </empty>
                        <empty name="tpl">
                            <div class="prom_bottom">
                                <a href="javascript:void(0);" onclick="add_tab()">
                                    <div class="add" title="新增优惠项">
                                        <span><i class="fa fa-plus"></i>新增优惠项</span>
                                    </div>
                                </a>
                                <span>(最多可设置五个层级,每级优惠不累加)</span>
                            </div>
                        </empty>
                    </div>
                </dd>
            </dl>

            <dl class="row">
                <dt class="tit">
                    是否限制使用优惠券
                </dt>
                <dd class="opt">
                    <input id="is_xz_yh1" name="is_xz_yh" value="1" <if condition='$info.is_xz_yh eq 1'>checked</if> type="radio">
                    <label for="is_xz_yh1"></label>
                    <input id="is_xz_yh0" name="is_xz_yh" value="0" <if condition='$info.is_xz_yh neq 1'>checked</if> type="radio">
                    <label for="is_xz_yh0"></label>
                </dd>
            </dl>

            <dl class="row">
                <dt class="tit">
                    是否倍增
                </dt>
                <dd class="opt" >
                    <input onclick="set_bz()" id="is_bz1" name="is_bz" value="1" <if condition='$info.is_bz eq 1'>checked</if> type="radio">
                    <label onclick="set_bz()" for="is_bz1"></label>
                    <input  id="is_bz0" name="is_bz" value="0" <if condition='$info.is_bz neq 1'>checked</if> type="radio">
                    <label  for="is_bz0"></label>
                </dd>
            </dl>


            <dl class="row">
                <dt class="tit">
                    <label><em>*</em>参与对象</label>
                </dt>
                <dd class="opt">
                    <div>
                        <div class="notic">
                        <span class="mr20">
                            <label>
                                <input name="good_object" type="radio" value="0" class="vam" style="margin-top:-3px;"
                                <if condition="$info.good_object eq 0">checked</if>>全部商品
                            </label>
                        </span>
                            <label>
                                <input name="good_object" type="radio" class="vam" value="1" style="margin-top:-3px;"
                                <if condition="$info.good_object eq 1">checked</if>>
                                <a onclick="selectGoods()" class="ncap-btn"><i class="fa fa-search"></i>指定商品</a>
                            </label>
                        </div>

                        <div style="height: 10px"></div>
                        <label id="fnot_in" <if condition="$info.good_object eq 1">style="display:none"</if>>
                            <a onclick="selectGoods2()" class="ncap-btn"><i class="fa fa-plus"></i>指定商品不参与</a>
                        </label>

                        <table class="prom_table">
                            <thead>
                            <tr>
                                <td>商品编号</td>
                                <td>商品名称</td>
                                <td>手店价</td>
                                <td>市场价</td>
                                <td>库存</td>
                                <if condition='$info.is_end eq 0'>
                                <td>操作</td>
                                </if>
                            </tr>
                            </thead>
                            <tbody id="goods_list">
                            <volist name="prom_goods" id="gg">
                                <tr id="{$gg.goods_id}">
                                    <td>{$gg.goods_sn}
                                        <input type="hidden" name="goods_id[]" value="{$gg.goods_id}">
                                    </td>
                                    <td>{$gg.goods_name}</td>
                                    <td>{$gg.shop_price}</td>
                                    <td>{$gg.market_price}</td>
                                    <td>{$gg.store_count}</td>
                                    <if condition='$info.is_end eq 0'>
                                        <td>
                                            <if condition="$info.good_object eq 0">
                                                <a class="btn red" onclick="cancle_prom(this,0)"><i
                                                        class="fa fa-trash-o"></i>取消</a>
                                            <else/>
                                               <a class="btn red" onclick="$(this).parent().parent().remove();"><i
                                                    class="fa fa-trash-o"></i>取消</a>
                                            </if>
                                        </td>
                                    </if>
                                </tr>
                            </volist>
                            </tbody>
                        </table>

                    </div>
                </dd>
            </dl>
            <empty name="tpl">
                <div class="bot">
                    <a id="sumbitbtn" onclick="adsubmit()" class="ncap-btn-big ncap-btn-green">确认提交</a>
                </div>
            </empty>
        </div>
    </form>
</div>

<input type="hidden"  id="quan_s_time" value="{$quan_s_time}">
<input type="hidden"  id="quan_e_time" value="{$quan_e_time}">
<input type="hidden"  id="zhiding_s_time" value="{$zhiding_s_time}">
<input type="hidden"  id="zhiding_e_time" value="{$zhiding_e_time}">
<input type="hidden"  id="goods_listid" value="{$goods_listid}">
<input type="hidden"  id="g_id" value="{$Think.request.id}">

<script type="text/javascript">

    var condition = false;//活动卡是否输入正确
    var msg = '';//活动卡弹出的提示
    var prom_id = $('#prom_id').val();//活动id
    var sel_val = $('.select_syn').val();//条件选择
    var is_full="{$isfull}";
    var is_all="{$isall}";

    var fir_htm="";
    $(function () {
        fir_htm=$("#tab0").html();
    })

    //input文本框失去焦点事件
    $('input[type="text"]').live('blur', function () {
        var text_val=$(this).val();
        if (text_val != '' && text_val != 0) {
            $(this).nextAll('.cr').addClass('dn');
        }
    });

    //活动类型选择
    $("input:radio[name='good_object']").change(function(){
        if ($(this).val()==0){
            $("#fnot_in").show();
        }
        else {
            $("#fnot_in").hide();
        }
        $("#goods_list").html("");
    });

    // 减现金、打折点击效果
    function change_type(obj, num) {
        $(obj).children().addClass('on');
        $(obj).next().css('visibility', 'visible');
        if (num == 1) {
            $(obj).prev().val(1);
            $(obj).parent().next().find('input[type="hidden"]').val(0);
            $(obj).parent().next().find('.radio1').removeClass('on');
            $(obj).parent().next().find('.right_span').removeAttr('style');
            $(obj).parent().next().find('span :first').attr('onclick', 'change_type(this, 2)');
            $(obj).attr('onclick', 'cancel_type(this, 1)');
        } else {
            $(obj).prev().val(1);
            $(obj).parent().prev().find('input[type="hidden"]').val(0);
            $(obj).parent().prev().find('.radio1').removeClass('on');
            $(obj).parent().prev().find('.right_span').removeAttr('style');
            $(obj).parent().prev().find('span :first').attr('onclick', 'change_type(this, 1)');
            $(obj).attr('onclick', 'cancel_type(this, 2)');
        }
    }

//    取消减现金、打折点击效果
    function cancel_type(obj, num) {
        $(obj).attr('onclick', 'change_type(this, ' + num + ')');
        $(obj).parent().find('input[type="hidden"]').val(0);
        $(obj).children().removeClass('on');
        $(obj).next().removeAttr('style');
    }

//    活动卡多选框点击事件
    function change_checkbox(obj, num) {
        if (num == 1) {
            if ($(obj).find('input[type="checkbox"]').is(':checked')) {
                $(obj).next().find('input[type="hidden"]').val(1);
            } else {
                $(obj).next().find('input[type="hidden"]').val(0);
            }
        }
        if (num == 2) {
            if ($(obj).find('input[type="checkbox"]').is(':checked')) {
                $(obj).next().css('visibility', 'visible');
                $(obj).find('input[type="hidden"]').val(1);
            } else {
                $(obj).find('input[type="hidden"]').val(0);
                $(obj).next().removeAttr('style');
                $(obj).next().find('input[type="text"]').val(0);
            }
        }
        if (num == 3) {
            if ($(obj).find('input[type="checkbox"]').is(':checked')) {
                $(obj).next().css('visibility', 'visible');
                $(obj).next().find('input[type="hidden"]').val(1);
            } else {
                $(obj).next().removeAttr('style');
                $(obj).next().find('input[type="hidden"]').val(0);
            }
        }
        if (num == 4) {
            if ($(obj).find('input[type="checkbox"]').is(':checked')) {
                $(obj).next().css('visibility', 'visible');
                $(obj).next().find('input[type="hidden"]').val(1);
            } else {
                $(obj).next().removeAttr('style');
                $(obj).next().find('input[type="hidden"]').val(0);
            }
        }
    }

//  优惠券、赠品更新事件
    function updata(obj, table) {
        $.ajax({
            url: "{:U('Promotion/up_data')}",
            data: {table: table},
            type: 'POST',
            dataType: 'json',
            beforeSend: function () {
                load = layer.load(2);
            },
            success: function (data) {
                layer.close(load);
                var str='<option value="">未选择</option>';
                if(data.html==str){
                    if(table=='gift')  layer.msg('未找到可用赠品', {icon: 1, time: 1000});
                    else  layer.msg('未找到可用优惠券', {icon: 1, time: 1000});
                    return;
                }

                $(obj).parent().find('select').html(data.html);
                layer.msg('更新成功', {icon: 1, time: 1000});
            },
            error: function () {
                layer.msg('网络繁忙', {icon: 2, time: 1000});
            }
        });
    }

//    活动卡删除事件
    function tab_del(obj) {
        if ($(obj).prev().val() > 0) {
            $.ajax({
                url: "{:U('Promotion/tab_del')}",
                type: 'POST',
                data: {id: $(obj).prev().val()},
                dataType: 'json',
                beforeSend: function () {
                    load = layer.load(2);
                },
                success: function () {
                    layer.close(load);
                    layer.msg('删除成功',{icon:1,time: 1000});
                }
            });
        }
        $('.prom_bottom').show();
        $(obj).parent().parent().remove();
    }

    //活动卡添加
    function add_tab() {

        $is_bz=$('input[name=is_bz]:checked').val();
        if($is_bz=="1"){
            layer.msg('选择倍增,就不能添加新其他的优惠项目!',{icon:1,time: 1000});
            return false;
        }
        for (var i = 0; i < 5; i++) {
            if (!document.getElementById("tab" + i)) {
              var html= '<div class="prom_top" id="tab' + i + '"><div class="prom_center prom_center1">' + (i + 1) + '</div>' +
                    '<div class="prom_center prom_center2">满<input class="prom_input first" type="text" name="data[' + i + '][condition]" value="0" autocomplete="off" onkeyup="check_num(this,0)">' +
                    '<select style="margin-top: -3px" disabled class="select_syn"><option value="0">元</option><option value="1">件</option></select><span class="cr dn">请输入正确的条件</span>' +
                    '</div><div class="prom_center prom_center3"><input type="hidden" name="data[' + i + '][id]" value=""><div class="close fa fa-trash-o" onclick="tab_del(this)"></div><ul>' +
                    '<li><input type="hidden" name="data[' + i + '][is_money]" value="0"><span class="left_span" onclick="change_type(this,1)"><em class="radio1"></em>减现金</span>' +
                    '<span class="right_span">减<input class="prom_input" name="data[' + i + '][money]" type="text" value="0" autocomplete="off" onkeyup="this.value=this.value.replace(/^(\\d+)\.(\\d{3})/,\'\')">元<span class="cr dn">请输入正确的值</span></span></li>' +
                    '<li><input type="hidden" name="data[' + i + '][is_sale]" value="0"><span class="left_span" onclick="change_type(this,2)"><em class="radio1"></em>打折</span>' +
                    '<span class="right_span">打<input class="prom_input" name="data[' + i + '][sale]" type="text" value="0" autocomplete="off" onkeyup="this.value=this.value.replace(/^(\\d+)\.(\\d{2})/,\'\')">折<span class="cr dn">请输入正确的值</span></span></li>' +
                    '<li><span class="left_span" onclick="change_checkbox(this,1)"><label><input type="checkbox">包邮</label></span>' +
                    '<span class="right_span"><input type="hidden" name="data[' + i + '][is_past]" value="0"></span></li>' +
                    '<li><span class="left_span" onclick="change_checkbox(this,2)"><input type="hidden" name="data[' + i + '][is_int]" value="0"><label><input type="checkbox" class="second">积分</label></span>' +
                    '<span class="right_span">送<input class="prom_input" type="text" name="data[' + i + '][int]" value="0" autocomplete="off" onkeyup="this.value=this.value.replace(/[^\\d]/g,\'\')">分<span class="cr dn">请输入正确的值</span></span></li>' +
                    '<li><span class="left_span" onclick="change_checkbox(this,3)"><label><input type="checkbox" class="third">优惠券</label></span>' +
                    '<span class="right_span">送<select class="prom_input" name="data[' + i + '][coupon]"><option value="">未选择</option>' +
                    '<volist name="coupon" id="vv"><option value="{$vv.id}">{$vv.name}</option></volist></select>' +
                    '<input type="hidden" name="data[' + i + '][is_coupon]" value="0"><a href="javascript:void (0);" onclick="updata(this,\'coupon\')"><img src="__PUBLIC__/static/images/prom_refresh.png" title="刷新数据"></a>' +
                    '<a href="{:U(\'Coupon/coupon_info\',[\'type\'=>1])}" target="_blank"><img src="__PUBLIC__/static/images/prom_add.png" title="增加优惠券"></a></span></li>' +
                    '<li><span class="left_span" onclick="change_checkbox(this,4)"><label><input type="checkbox" class="fourth">赠品</label></span>' +
                    '<span class="right_span"> 送<select class="prom_input" name="data[' + i + '][gift]"><option value="">未选择</option>' +
                    '<volist name="gift" id="vv"><option value="{$vv.id}">{$vv.title}</option></volist></select>' +
                    '<input type="hidden" name="data[' + i + '][is_gift]" value="0"><a href="javascript:void (0);" onclick="updata(this,\'gift\')"><img src="__PUBLIC__/static/images/prom_refresh.png" title="刷新数据"></a>' +
                    '<a href="{:U(\'Promotion/gift_info\')}" target="_blank"><img src="__PUBLIC__/static/images/prom_add.png" title="增加赠品"></a></span></li>' +

                    '<li><span class="left_span" onclick="change_checkbox(this,4)"><label><input type="checkbox" class="five">礼包</label></span>\n' +
                    '<span class="right_span">送<select class="prom_input" name="data[0][libao]"><option value="">未选择</option><volist name="libao" id="vv"><option value="{$vv.id}" <if condition="$vo.preferential_type.libao eq $vv.id">selected</if>>{$vv.lbtitle}</option></volist></select><input type="hidden" name="data[0][is_libao]" value="0">\n' +
                    '                                                <a href="javascript:void (0);" onclick="updata(this,\'libao_form\')"><img src="https://mshop-lib.yolipai.net/public/static/images/prom_refresh.png" title="刷新数据"></a>\n' +
                    '                                                <a href="/index.php/Admin/Libao/addlb.html" target="_blank"><img src="https://mshop-lib.yolipai.net/public/static/images/prom_add.png" title="增加赠品"></a>\n' +
                    '                                                </span></li>\n    '+  '</ul></div><div class="clear"></div></div>';


                $('#tab' + (i - 1) + '').after(html);
                break;
            }
        }
        if (document.getElementById("tab4")) {
            $('.prom_bottom').hide();
        }
        add_tab_type('.select_syn:first');
    }
//提交
    function adsubmit() {


        if ($('#name').val() == '') {
            $('#name').focus().next().removeClass('dn');
            layer.msg('活动名称不能为空', {icon: 2, time: 2000});
            return false;
        }

        var con = new Array();

        $('.prom_top').each(function (i, e) {
            var money = parseFloat($(e).find('.first').val());//优惠条件
            if ($(e).find('.first').val() == '' || $(e).find('.first').val() == 0) {
                msg = '条件不能为空或者为零';
                condition = true;
                $(e).find('.first').focus();
                $(e).find('.first').next().next().removeClass('dn');
                return false;
            } else {
                con.push(money);
            }

            if ($(e).find('input[type="hidden"]').eq(1).val() == 0 && $(e).find('input[type="hidden"]').eq(2).val() == 0 && $(e).find('input[type="checkbox"]:checked').length == 0) {
                msg = '请选择一种优惠方式';
                condition = true;
                return false;
            }
//            减现控制
            if ($(e).find('input[type="hidden"]').eq(1).val() == 1) {
                var a = $(e).find('input[type="hidden"]').eq(1).next().next().children().val();
                if (a == 0 || a == '') {
                    condition = true;
                    msg = '减现不能为零或为空';
                    $(e).find('input[type="hidden"]').eq(1).next().next().children().focus();
                    $(e).find('input[type="hidden"]').eq(1).next().next().children().next().removeClass('dn');
                    return false;
                }

                if (sel_val == 0 && parseFloat(a) >= parseFloat(money)) {
                    condition = true;
                    msg = '减现金金额需低于满减金额';
                    $(e).find('input[type="hidden"]').eq(1).next().next().children().focus();
                    $(e).find('input[type="hidden"]').eq(1).next().next().children().next().removeClass('dn');
                    return false;
                }
            }
//            折扣控制
            if ($(e).find('input[type="hidden"]').eq(2).val() == 1) {
                var sale = $(e).find('input[type="hidden"]').eq(2).next().next().children().val();
                if (parseFloat(sale) <= 0 || parseFloat(sale) >= 10 || sale == '') {
                    condition = true;
                    msg = '折扣范围在0.1-9.9之间';
                    $(e).find('input[type="hidden"]').eq(2).next().next().children().focus();
                    $(e).find('input[type="hidden"]').eq(2).next().next().children().next().removeClass('dn');
                    return false;
                }
            }
//            积分控制
            if ($(e).find('.second').is(':checked')) {
                if ($(e).find('.second').parent().parent().next().children().val() == 0 || $(e).find('.second').parent().parent().next().children().val() == '') {
                    condition = true;
                    msg = '积分不能为零或为空';
                    $(e).find('.second').parent().parent().next().children().focus();
                    $(e).find('.second').parent().parent().next().find('.cr').removeClass('dn');
                    return false;
                }
            }
//            优惠券控制
            if ($(e).find('.third').is(':checked') && $(e).find('.third').parent().parent().next().children().val() == '') {
                condition = true;
                msg = '请选择赠送的优惠券';
                return false;
            }
//            赠品控制
            if ($(e).find('.five').is(':checked') && $(e).find('.five').parent().parent().next().children().val() == '') {
                condition = true;
                msg = '请选择赠送的礼包';
                return false;
            }
        });

        var n_con = con.sort();

        for (var i = 0; i < con.length; i++) {
            if (con[i] == n_con[i + 1]) {
                $('.first').focus();
                condition = true;
                msg = '金额条件不能重复';
            }
        }

        if (condition) {
            layer.msg(msg, {icon: 2, time: 2000});
            condition = false;
            msg = '';
            return false;
        }

        if($('#start_time').val()=="") {
            layer.msg('请输入开始开始时间', {icon: 2, time: 1000});
            return false;
        }
        if($('#end_time').val()=="") {
            layer.msg('请输入开始结束时间', {icon: 2, time: 1000});
            return false;
        }

        /*---时间---*/
        var startdate = new Date($('#start_time').val().replace(/-/g, "/"));
        var enddate = new Date($('#end_time').val().replace(/-/g, "/"));
        if (enddate <= startdate) {
            $('#end_time').next().removeClass('dn');
            layer.msg('结束时间必须大于开始时间', {icon: 2, time: 1000});
            return false;
        }

        var ischeck=0;
        //全场活动的开始时间 要大于 所有指定活动的结束时间!
        if(prom_id=="" || prom_id=="0") {
            ischeck=1;
        }else{
           if($.trim($("#goods_list").html())=="") ischeck=1;
        }
        if ($('.vam:checked').val() == 0 && ischeck==1) {
            var start_time = $("#start_time").val();
            var end_time = $("#end_time").val();
            start_time = new Date(start_time.replace(/-/g, "/"));
            end_time = new Date(end_time.replace(/-/g, "/"));
            var max_time = $("#zhiding_e_time").val();
            var min_time = $("#zhiding_s_time").val();
            if (max_time != "") max_time = new Date(max_time.replace(/-/g, "/"));
            if (min_time != "") min_time = new Date(min_time.replace(/-/g, "/"));
            if (max_time != "") {
                if (max_time >= start_time && min_time <=end_time) {
                    if (start_time <= max_time) {
                        layer.msg('全场商品的活动时间与其他的活动时间不能重叠!', {icon: 2, time: 1000});
                        return false;
                    }
                }
            }
        }

        if($('.vam:checked').val() == 1 && is_all=="1"){
            var quan_s_time=$("#quan_s_time").val();
            var quan_e_time=$("#quan_e_time").val();
            var end_time1=$("#end_time").val();
            var start_time1=$("#start_time").val();
            if (quan_s_time != "") quan_s_time = new Date(quan_s_time.replace(/-/g, "/"));
            if (quan_e_time != "") quan_e_time = new Date(quan_e_time.replace(/-/g, "/"));
            if(quan_s_time!=""){
                start_time1 = new Date(start_time1.replace(/-/g, "/"));
                end_time1 = new Date(end_time1.replace(/-/g, "/"));
                if(end_time1>=quan_s_time && start_time1<=quan_e_time){
                    layer.msg('指定商品的活动时间与全场商品的活动时间不能重叠!', {icon: 2, time: 1000});
                    return false;
                }
            }
        }

        if ($('.vam:checked').val() == 1 && trim($('#goods_list').html()) == '') {
            layer.msg('请选择商品', {icon: 2, time: 2000});
            return false;
        }


        if($('.vam:checked').val() == 1 && is_all!="1"){
            var isck=0;
            var goodlist=$("#goods_listid").val();
            if(goodlist!="") {
                //如果包含的指定商品不参与以外的商品要进行时间判断
                $("#goods_list").find('tr').each(function () {
                    var gdid = "," + $(this).attr("id") + ",";
                    if (goodlist.indexOf(gdid)<0){
                        isck=1; return false;
                    }
                });
                if(isck==1) {
                    var quan_s_time = $("#quan_s_time").val();
                    var quan_e_time = $("#quan_e_time").val();
                    var end_time1 = $("#end_time").val();
                    var start_time1 = $("#start_time").val();
                    if (quan_s_time != "") quan_s_time = new Date(quan_s_time.replace(/-/g, "/"));
                    if (quan_e_time != "") quan_e_time = new Date(quan_e_time.replace(/-/g, "/"));
                    if (quan_s_time != "") {
                        start_time1 = new Date(start_time1.replace(/-/g, "/"));
                        end_time1 = new Date(end_time1.replace(/-/g, "/"));
                        if (end_time1 >= quan_s_time && start_time1 <= quan_e_time) {
                            layer.msg('指定商品活动的时间不能和的全场商品活动的时间有重合', {icon: 2, time: 1000});
                            return false;
                        }
                    }
                }
            }
            else{
                //全场活动的判断
                var quan_s_time=$("#quan_s_time").val();
                var quan_e_time=$("#quan_e_time").val();
                var end_time1=$("#end_time").val();
                var start_time1=$("#start_time").val();
                if (quan_s_time != "") quan_s_time = new Date(quan_s_time.replace(/-/g, "/"));
                if (quan_e_time != "") quan_e_time = new Date(quan_e_time.replace(/-/g, "/"));
                if(quan_s_time!=""){
                    start_time1 = new Date(start_time1.replace(/-/g, "/"));
                    end_time1 = new Date(end_time1.replace(/-/g, "/"));
                    if(end_time1>=quan_s_time && start_time1<=quan_e_time){
                        layer.msg('指定商品活动的时间不能和的全场商品活动的时间有重合', {icon: 2, time: 1000});
                        return false;
                    }
                }
            }
        }


        layer.msg('加载中...', {icon: 16, shade: [0.5, '#f5f5f5'], scrollbar: false, offset: '10px', time: 100000});
        $('#promotion').submit();
    }

    //指定商品参加
    function selectGoods() {
        var idlist = '';
        $("input[name*='goods_id']").each(function () {
            idlist += $(this).val() + ',';
        });

        var url = '/index.php?m=Admin&c=Promotion&a=search_goods2&idlist=' + idlist + '&prom_id=' + prom_id+'&isnotin=2';
        layer.open({
            type: 2,
            title: '选择商品',
            shadeClose: true,
            shade: 0.3,
            area: ['96%', '80%'],
            content: url
        });
    }

    //指定商品不参加
    function selectGoods2() {
        var idlist = '';
        $("input[name*='goods_id']").each(function () {
            idlist += $(this).val() + ',';
        });

        var url = '/index.php?m=Admin&c=Promotion&a=search_goods2&idlist=' + idlist + '&prom_id=' + prom_id+'&isnotin=1';
        layer.open({
            type: 2,
            title: '选择商品',
            shadeClose: true,
            shade: 0.3,
            area: ['96%', '80%'],
            content: url
        });
    }

    function call_back_search(table_html) {
        $('#goods_list').append(table_html);
        var a = [];
        $("input[name*='goods_id']").each(function (i, e) {
            if ($.inArray($(e).val(), a) == -1) {
                a[a.length] = $(e).val();
            } else {
                $(e).parent().parent().remove();
            }
        });
        layer.closeAll('iframe');
    }

    function call_back_add(html) {
        $('#goods_list').append(html);
    }

    function call_back_close(id) {
        $('#' + id + '').remove();
    }

//    联动所有活动卡的条件:元、件
    function money_pack(obj) {
        sel_val = $(obj).val();
        $(obj).prev().attr('value', 0);
        $(obj).prev().attr('onkeyup', 'check_num(this,' + sel_val + ')');
        $('.select_syn option[value="' + sel_val + '"]').attr("selected", "selected").parent().prev().attr('onkeyup', 'check_num(this,' + sel_val + ')').attr('value',0);
    }

    function check_num(obj,num) {
        var exp='';
        if (num==1){
            exp=/[^\d]/g;
        }else {
            exp=/^(\d+)\.(\d{3})/;
        }
        var value=$(obj).val().replace(exp,'');
        $(obj).val(value);
    }

//    添加活动卡跟随第一个活动的条件:元、件
    function add_tab_type(obj) {
        var sel_val = $(obj).val();
        $('.select_syn option[value="' + sel_val + '"]').attr("selected", "selected");
    }

    var start = {
        elem: '#start_time',
        format: 'YYYY-MM-DD hh:mm:ss',
        min: laydate.now(), //设定最小日期为当前日期
        max: '2099-12-31 23:59:59', //最大日期
        istime: true,
        choose: function (datas) {
            end.min = datas; //开始日选好后,重置结束日的最小日期
            end.start = datas //将结束日的初始值设定为开始日
        }
    };

    var end = {
        elem: '#end_time',
        format: 'YYYY-MM-DD hh:mm:ss',
        min: $('#start_time').val(),
        max: '2099-12-31 23:59:59',
        istime: true,
        choose: function (datas) {
            start.max = datas; //结束日选好后,重置开始日的最大日期
        }
    };

    laydate.skin('molv'); //选择肤色
    laydate(start);
    laydate(end);
    
    function cancle_prom(ob,type) {
        if(type==0) {
            var gdid = $(ob).parent().parent().attr("id");
            $.ajax({
                url: "{:U('Promotion/is_prom_good')}",
                type: 'POST',
                data: {id: gdid},
                dataType: 'json',
                beforeSend: function () {
                    load = layer.load(2);
                },
                success: function (d) {
                    layer.close(load);
                    if (d == 1) {
                        layer.msg('该商品有参与指定商品优惠活动,不能取消', {icon: 2, time: 1000});
                    } else {
                        $(ob).parent().parent().remove();

                    }
                }
            });
        }else{
            $(ob).parent().parent().parent().remove();
        }
    }

    //添加了多个优惠项目,就不能选择倍增
    function set_bz() {
        var num=$(".prom_top").length;
        if(num>1){
            layer.msg('添加了多个优惠项目,就不能选择倍增!',{icon:1,time: 1000});
            $("#is_bz0").prop('checked',true);
            $("#is_bz1").prop('checked',false);
            return false;
        }
    }


</script>
</body>
</html>