index-debug.js 402 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 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 5073 5074 5075 5076 5077 5078 5079 5080 5081 5082 5083 5084 5085 5086 5087 5088 5089 5090 5091 5092 5093 5094 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 5112 5113 5114 5115 5116 5117 5118 5119 5120 5121 5122 5123 5124 5125 5126 5127 5128 5129 5130 5131 5132 5133 5134 5135 5136 5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 5161 5162 5163 5164 5165 5166 5167 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 5182 5183 5184 5185 5186 5187 5188 5189 5190 5191 5192 5193 5194 5195 5196 5197 5198 5199 5200 5201 5202 5203 5204 5205 5206 5207 5208 5209 5210 5211 5212 5213 5214 5215 5216 5217 5218 5219 5220 5221 5222 5223 5224 5225 5226 5227 5228 5229 5230 5231 5232 5233 5234 5235 5236 5237 5238 5239 5240 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 5257 5258 5259 5260 5261 5262 5263 5264 5265 5266 5267 5268 5269 5270 5271 5272 5273 5274 5275 5276 5277 5278 5279 5280 5281 5282 5283 5284 5285 5286 5287 5288 5289 5290 5291 5292 5293 5294 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 5307 5308 5309 5310 5311 5312 5313 5314 5315 5316 5317 5318 5319 5320 5321 5322 5323 5324 5325 5326 5327 5328 5329 5330 5331 5332 5333 5334 5335 5336 5337 5338 5339 5340 5341 5342 5343 5344 5345 5346 5347 5348 5349 5350 5351 5352 5353 5354 5355 5356 5357 5358 5359 5360 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370 5371 5372 5373 5374 5375 5376 5377 5378 5379 5380 5381 5382 5383 5384 5385 5386 5387 5388 5389 5390 5391 5392 5393 5394 5395 5396 5397 5398 5399 5400 5401 5402 5403 5404 5405 5406 5407 5408 5409 5410 5411 5412 5413 5414 5415 5416 5417 5418 5419 5420 5421 5422 5423 5424 5425 5426 5427 5428 5429 5430 5431 5432 5433 5434 5435 5436 5437 5438 5439 5440 5441 5442 5443 5444 5445 5446 5447 5448 5449 5450 5451 5452 5453 5454 5455 5456 5457 5458 5459 5460 5461 5462 5463 5464 5465 5466 5467 5468 5469 5470 5471 5472 5473 5474 5475 5476 5477 5478 5479 5480 5481 5482 5483 5484 5485 5486 5487 5488 5489 5490 5491 5492 5493 5494 5495 5496 5497 5498 5499 5500 5501 5502 5503 5504 5505 5506 5507 5508 5509 5510 5511 5512 5513 5514 5515 5516 5517 5518 5519 5520 5521 5522 5523 5524 5525 5526 5527 5528 5529 5530 5531 5532 5533 5534 5535 5536 5537 5538 5539 5540 5541 5542 5543 5544 5545 5546 5547 5548 5549 5550 5551 5552 5553 5554 5555 5556 5557 5558 5559 5560 5561 5562 5563 5564 5565 5566 5567 5568 5569 5570 5571 5572 5573 5574 5575 5576 5577 5578 5579 5580 5581 5582 5583 5584 5585 5586 5587 5588 5589 5590 5591 5592 5593 5594 5595 5596 5597 5598 5599 5600 5601 5602 5603 5604 5605 5606 5607 5608 5609 5610 5611 5612 5613 5614 5615 5616 5617 5618 5619 5620 5621 5622 5623 5624 5625 5626 5627 5628 5629 5630 5631 5632 5633 5634 5635 5636 5637 5638 5639 5640 5641 5642 5643 5644 5645 5646 5647 5648 5649 5650 5651 5652 5653 5654 5655 5656 5657 5658 5659 5660 5661 5662 5663 5664 5665 5666 5667 5668 5669 5670 5671 5672 5673 5674 5675 5676 5677 5678 5679 5680 5681 5682 5683 5684 5685 5686 5687 5688 5689 5690 5691 5692 5693 5694 5695 5696 5697 5698 5699 5700 5701 5702 5703 5704 5705 5706 5707 5708 5709 5710 5711 5712 5713 5714 5715 5716 5717 5718 5719 5720 5721 5722 5723 5724 5725 5726 5727 5728 5729 5730 5731 5732 5733 5734 5735 5736 5737 5738 5739 5740 5741 5742 5743 5744 5745 5746 5747 5748 5749 5750 5751 5752 5753 5754 5755 5756 5757 5758 5759 5760 5761 5762 5763 5764 5765 5766 5767 5768 5769 5770 5771 5772 5773 5774 5775 5776 5777 5778 5779 5780 5781 5782 5783 5784 5785 5786 5787 5788 5789 5790 5791 5792 5793 5794 5795 5796 5797 5798 5799 5800 5801 5802 5803 5804 5805 5806 5807 5808 5809 5810 5811 5812 5813 5814 5815 5816 5817 5818 5819 5820 5821 5822 5823 5824 5825 5826 5827 5828 5829 5830 5831 5832 5833 5834 5835 5836 5837 5838 5839 5840 5841 5842 5843 5844 5845 5846 5847 5848 5849 5850 5851 5852 5853 5854 5855 5856 5857 5858 5859 5860 5861 5862 5863 5864 5865 5866 5867 5868 5869 5870 5871 5872 5873 5874 5875 5876 5877 5878 5879 5880 5881 5882 5883 5884 5885 5886 5887 5888 5889 5890 5891 5892 5893 5894 5895 5896 5897 5898 5899 5900 5901 5902 5903 5904 5905 5906 5907 5908 5909 5910 5911 5912 5913 5914 5915 5916 5917 5918 5919 5920 5921 5922 5923 5924 5925 5926 5927 5928 5929 5930 5931 5932 5933 5934 5935 5936 5937 5938 5939 5940 5941 5942 5943 5944 5945 5946 5947 5948 5949 5950 5951 5952 5953 5954 5955 5956 5957 5958 5959 5960 5961 5962 5963 5964 5965 5966 5967 5968 5969 5970 5971 5972 5973 5974 5975 5976 5977 5978 5979 5980 5981 5982 5983 5984 5985 5986 5987 5988 5989 5990 5991 5992 5993 5994 5995 5996 5997 5998 5999 6000 6001 6002 6003 6004 6005 6006 6007 6008 6009 6010 6011 6012 6013 6014 6015 6016 6017 6018 6019 6020 6021 6022 6023 6024 6025 6026 6027 6028 6029 6030 6031 6032 6033 6034 6035 6036 6037 6038 6039 6040 6041 6042 6043 6044 6045 6046 6047 6048 6049 6050 6051 6052 6053 6054 6055 6056 6057 6058 6059 6060 6061 6062 6063 6064 6065 6066 6067 6068 6069 6070 6071 6072 6073 6074 6075 6076 6077 6078 6079 6080 6081 6082 6083 6084 6085 6086 6087 6088 6089 6090 6091 6092 6093 6094 6095 6096 6097 6098 6099 6100 6101 6102 6103 6104 6105 6106 6107 6108 6109 6110 6111 6112 6113 6114 6115 6116 6117 6118 6119 6120 6121 6122 6123 6124 6125 6126 6127 6128 6129 6130 6131 6132 6133 6134 6135 6136 6137 6138 6139 6140 6141 6142 6143 6144 6145 6146 6147 6148 6149 6150 6151 6152 6153 6154 6155 6156 6157 6158 6159 6160 6161 6162 6163 6164 6165 6166 6167 6168 6169 6170 6171 6172 6173 6174 6175 6176 6177 6178 6179 6180 6181 6182 6183 6184 6185 6186 6187 6188 6189 6190 6191 6192 6193 6194 6195 6196 6197 6198 6199 6200 6201 6202 6203 6204 6205 6206 6207 6208 6209 6210 6211 6212 6213 6214 6215 6216 6217 6218 6219 6220 6221 6222 6223 6224 6225 6226 6227 6228 6229 6230 6231 6232 6233 6234 6235 6236 6237 6238 6239 6240 6241 6242 6243 6244 6245 6246 6247 6248 6249 6250 6251 6252 6253 6254 6255 6256 6257 6258 6259 6260 6261 6262 6263 6264 6265 6266 6267 6268 6269 6270 6271 6272 6273 6274 6275 6276 6277 6278 6279 6280 6281 6282 6283 6284 6285 6286 6287 6288 6289 6290 6291 6292 6293 6294 6295 6296 6297 6298 6299 6300 6301 6302 6303 6304 6305 6306 6307 6308 6309 6310 6311 6312 6313 6314 6315 6316 6317 6318 6319 6320 6321 6322 6323 6324 6325 6326 6327 6328 6329 6330 6331 6332 6333 6334 6335 6336 6337 6338 6339 6340 6341 6342 6343 6344 6345 6346 6347 6348 6349 6350 6351 6352 6353 6354 6355 6356 6357 6358 6359 6360 6361 6362 6363 6364 6365 6366 6367 6368 6369 6370 6371 6372 6373 6374 6375 6376 6377 6378 6379 6380 6381 6382 6383 6384 6385 6386 6387 6388 6389 6390 6391 6392 6393 6394 6395 6396 6397 6398 6399 6400 6401 6402 6403 6404 6405 6406 6407 6408 6409 6410 6411 6412 6413 6414 6415 6416 6417 6418 6419 6420 6421 6422 6423 6424 6425 6426 6427 6428 6429 6430 6431 6432 6433 6434 6435 6436 6437 6438 6439 6440 6441 6442 6443 6444 6445 6446 6447 6448 6449 6450 6451 6452 6453 6454 6455 6456 6457 6458 6459 6460 6461 6462 6463 6464 6465 6466 6467 6468 6469 6470 6471 6472 6473 6474 6475 6476 6477 6478 6479 6480 6481 6482 6483 6484 6485 6486 6487 6488 6489 6490 6491 6492 6493 6494 6495 6496 6497 6498 6499 6500 6501 6502 6503 6504 6505 6506 6507 6508 6509 6510 6511 6512 6513 6514 6515 6516 6517 6518 6519 6520 6521 6522 6523 6524 6525 6526 6527 6528 6529 6530 6531 6532 6533 6534 6535 6536 6537 6538 6539 6540 6541 6542 6543 6544 6545 6546 6547 6548 6549 6550 6551 6552 6553 6554 6555 6556 6557 6558 6559 6560 6561 6562 6563 6564 6565 6566 6567 6568 6569 6570 6571 6572 6573 6574 6575 6576 6577 6578 6579 6580 6581 6582 6583 6584 6585 6586 6587 6588 6589 6590 6591 6592 6593 6594 6595 6596 6597 6598 6599 6600 6601 6602 6603 6604 6605 6606 6607 6608 6609 6610 6611 6612 6613 6614 6615 6616 6617 6618 6619 6620 6621 6622 6623 6624 6625 6626 6627 6628 6629 6630 6631 6632 6633 6634 6635 6636 6637 6638 6639 6640 6641 6642 6643 6644 6645 6646 6647 6648 6649 6650 6651 6652 6653 6654 6655 6656 6657 6658 6659 6660 6661 6662 6663 6664 6665 6666 6667 6668 6669 6670 6671 6672 6673 6674 6675 6676 6677 6678 6679 6680 6681 6682 6683 6684 6685 6686 6687 6688 6689 6690 6691 6692 6693 6694 6695 6696 6697 6698 6699 6700 6701 6702 6703 6704 6705 6706 6707 6708 6709 6710 6711 6712 6713 6714 6715 6716 6717 6718 6719 6720 6721 6722 6723 6724 6725 6726 6727 6728 6729 6730 6731 6732 6733 6734 6735 6736 6737 6738 6739 6740 6741 6742 6743 6744 6745 6746 6747 6748 6749 6750 6751 6752 6753 6754 6755 6756 6757 6758 6759 6760 6761 6762 6763 6764 6765 6766 6767 6768 6769 6770 6771 6772 6773 6774 6775 6776 6777 6778 6779 6780 6781 6782 6783 6784 6785 6786 6787 6788 6789 6790 6791 6792 6793 6794 6795 6796 6797 6798 6799 6800 6801 6802 6803 6804 6805 6806 6807 6808 6809 6810 6811 6812 6813 6814 6815 6816 6817 6818 6819 6820 6821 6822 6823 6824 6825 6826 6827 6828 6829 6830 6831 6832 6833 6834 6835 6836 6837 6838 6839 6840 6841 6842 6843 6844 6845 6846 6847 6848 6849 6850 6851 6852 6853 6854 6855 6856 6857 6858 6859 6860 6861 6862 6863 6864 6865 6866 6867 6868 6869 6870 6871 6872 6873 6874 6875 6876 6877 6878 6879 6880 6881 6882 6883 6884 6885 6886 6887 6888 6889 6890 6891 6892 6893 6894 6895 6896 6897 6898 6899 6900 6901 6902 6903 6904 6905 6906 6907 6908 6909 6910 6911 6912 6913 6914 6915 6916 6917 6918 6919 6920 6921 6922 6923 6924 6925 6926 6927 6928 6929 6930 6931 6932 6933 6934 6935 6936 6937 6938 6939 6940 6941 6942 6943 6944 6945 6946 6947 6948 6949 6950 6951 6952 6953 6954 6955 6956 6957 6958 6959 6960 6961 6962 6963 6964 6965 6966 6967 6968 6969 6970 6971 6972 6973 6974 6975 6976 6977 6978 6979 6980 6981 6982 6983 6984 6985 6986 6987 6988 6989 6990 6991 6992 6993 6994 6995 6996 6997 6998 6999 7000 7001 7002 7003 7004 7005 7006 7007 7008 7009 7010 7011 7012 7013 7014 7015 7016 7017 7018 7019 7020 7021 7022 7023 7024 7025 7026 7027 7028 7029 7030 7031 7032 7033 7034 7035 7036 7037 7038 7039 7040 7041 7042 7043 7044 7045 7046 7047 7048 7049 7050 7051 7052 7053 7054 7055 7056 7057 7058 7059 7060 7061 7062 7063 7064 7065 7066 7067 7068 7069 7070 7071 7072 7073 7074 7075 7076 7077 7078 7079 7080 7081 7082 7083 7084 7085 7086 7087 7088 7089 7090 7091 7092 7093 7094 7095 7096 7097 7098 7099 7100 7101 7102 7103 7104 7105 7106 7107 7108 7109 7110 7111 7112 7113 7114 7115 7116 7117 7118 7119 7120 7121 7122 7123 7124 7125 7126 7127 7128 7129 7130 7131 7132 7133 7134 7135 7136 7137 7138 7139 7140 7141 7142 7143 7144 7145 7146 7147 7148 7149 7150 7151 7152 7153 7154 7155 7156 7157 7158 7159 7160 7161 7162 7163 7164 7165 7166 7167 7168 7169 7170 7171 7172 7173 7174 7175 7176 7177 7178 7179 7180 7181 7182 7183 7184 7185 7186 7187 7188 7189 7190 7191 7192 7193 7194 7195 7196 7197 7198 7199 7200 7201 7202 7203 7204 7205 7206 7207 7208 7209 7210 7211 7212 7213 7214 7215 7216 7217 7218 7219 7220 7221 7222 7223 7224 7225 7226 7227 7228 7229 7230 7231 7232 7233 7234 7235 7236 7237 7238 7239 7240 7241 7242 7243 7244 7245 7246 7247 7248 7249 7250 7251 7252 7253 7254 7255 7256 7257 7258 7259 7260 7261 7262 7263 7264 7265 7266 7267 7268 7269 7270 7271 7272 7273 7274 7275 7276 7277 7278 7279 7280 7281 7282 7283 7284 7285 7286 7287 7288 7289 7290 7291 7292 7293 7294 7295 7296 7297 7298 7299 7300 7301 7302 7303 7304 7305 7306 7307 7308 7309 7310 7311 7312 7313 7314 7315 7316 7317 7318 7319 7320 7321 7322 7323 7324 7325 7326 7327 7328 7329 7330 7331 7332 7333 7334 7335 7336 7337 7338 7339 7340 7341 7342 7343 7344 7345 7346 7347 7348 7349 7350 7351 7352 7353 7354 7355 7356 7357 7358 7359 7360 7361 7362 7363 7364 7365 7366 7367 7368 7369 7370 7371 7372 7373 7374 7375 7376 7377 7378 7379 7380 7381 7382 7383 7384 7385 7386 7387 7388 7389 7390 7391 7392 7393 7394 7395 7396 7397 7398 7399 7400 7401 7402 7403 7404 7405 7406 7407 7408 7409 7410 7411 7412 7413 7414 7415 7416 7417 7418 7419 7420 7421 7422 7423 7424 7425 7426 7427 7428 7429 7430 7431 7432 7433 7434 7435 7436 7437 7438 7439 7440 7441 7442 7443 7444 7445 7446 7447 7448 7449 7450 7451 7452 7453 7454 7455 7456 7457 7458 7459 7460 7461 7462 7463 7464 7465 7466 7467 7468 7469 7470 7471 7472 7473 7474 7475 7476 7477 7478 7479 7480 7481 7482 7483 7484 7485 7486 7487 7488 7489 7490 7491 7492 7493 7494 7495 7496 7497 7498 7499 7500 7501 7502 7503 7504 7505 7506 7507 7508 7509 7510 7511 7512 7513 7514 7515 7516 7517 7518 7519 7520 7521 7522 7523 7524 7525 7526 7527 7528 7529 7530 7531 7532 7533 7534 7535 7536 7537 7538 7539 7540 7541 7542 7543 7544 7545 7546 7547 7548 7549 7550 7551 7552 7553 7554 7555 7556 7557 7558 7559 7560 7561 7562 7563 7564 7565 7566 7567 7568 7569 7570 7571 7572 7573 7574 7575 7576 7577 7578 7579 7580 7581 7582 7583 7584 7585 7586 7587 7588 7589 7590 7591 7592 7593 7594 7595 7596 7597 7598 7599 7600 7601 7602 7603 7604 7605 7606 7607 7608 7609 7610 7611 7612 7613 7614 7615 7616 7617 7618 7619 7620 7621 7622 7623 7624 7625 7626 7627 7628 7629 7630 7631 7632 7633 7634 7635 7636 7637 7638 7639 7640 7641 7642 7643 7644 7645 7646 7647 7648 7649 7650 7651 7652 7653 7654 7655 7656 7657 7658 7659 7660 7661 7662 7663 7664 7665 7666 7667 7668 7669 7670 7671 7672 7673 7674 7675 7676 7677 7678 7679 7680 7681 7682 7683 7684 7685 7686 7687 7688 7689 7690 7691 7692 7693 7694 7695 7696 7697 7698 7699 7700 7701 7702 7703 7704 7705 7706 7707 7708 7709 7710 7711 7712 7713 7714 7715 7716 7717 7718 7719 7720 7721 7722 7723 7724 7725 7726 7727 7728 7729 7730 7731 7732 7733 7734 7735 7736 7737 7738 7739 7740 7741 7742 7743 7744 7745 7746 7747 7748 7749 7750 7751 7752 7753 7754 7755 7756 7757 7758 7759 7760 7761 7762 7763 7764 7765 7766 7767 7768 7769 7770 7771 7772 7773 7774 7775 7776 7777 7778 7779 7780 7781 7782 7783 7784 7785 7786 7787 7788 7789 7790 7791 7792 7793 7794 7795 7796 7797 7798 7799 7800 7801 7802 7803 7804 7805 7806 7807 7808 7809 7810 7811 7812 7813 7814 7815 7816 7817 7818 7819 7820 7821 7822 7823 7824 7825 7826 7827 7828 7829 7830 7831 7832 7833 7834 7835 7836 7837 7838 7839 7840 7841 7842 7843 7844 7845 7846 7847 7848 7849 7850 7851 7852 7853 7854 7855 7856 7857 7858 7859 7860 7861 7862 7863 7864 7865 7866 7867 7868 7869 7870 7871 7872 7873 7874 7875 7876 7877 7878 7879 7880 7881 7882 7883 7884 7885 7886 7887 7888 7889 7890 7891 7892 7893 7894 7895 7896 7897 7898 7899 7900 7901 7902 7903 7904 7905 7906 7907 7908 7909 7910 7911 7912 7913 7914 7915 7916 7917 7918 7919 7920 7921 7922 7923 7924 7925 7926 7927 7928 7929 7930 7931 7932 7933 7934 7935 7936 7937 7938 7939 7940 7941 7942 7943 7944 7945 7946 7947 7948 7949 7950 7951 7952 7953 7954 7955 7956 7957 7958 7959 7960 7961 7962 7963 7964 7965 7966 7967 7968 7969 7970 7971 7972 7973 7974 7975 7976 7977 7978 7979 7980 7981 7982 7983 7984 7985 7986 7987 7988 7989 7990 7991 7992 7993 7994 7995 7996 7997 7998 7999 8000 8001 8002 8003 8004 8005 8006 8007 8008 8009 8010 8011 8012 8013 8014 8015 8016 8017 8018 8019 8020 8021 8022 8023 8024 8025 8026 8027 8028 8029 8030 8031 8032 8033 8034 8035 8036 8037 8038 8039 8040 8041 8042 8043 8044 8045 8046 8047 8048 8049 8050 8051 8052 8053 8054 8055 8056 8057 8058 8059 8060 8061 8062 8063 8064 8065 8066 8067 8068 8069 8070 8071 8072 8073 8074 8075 8076 8077 8078 8079 8080 8081 8082 8083 8084 8085 8086 8087 8088 8089 8090 8091 8092 8093 8094 8095 8096 8097 8098 8099 8100 8101 8102 8103 8104 8105 8106 8107 8108 8109 8110 8111 8112 8113 8114 8115 8116 8117 8118 8119 8120 8121 8122 8123 8124 8125 8126 8127 8128 8129 8130 8131 8132 8133 8134 8135 8136 8137 8138 8139 8140 8141 8142 8143 8144 8145 8146 8147 8148 8149 8150 8151 8152 8153 8154 8155 8156 8157 8158 8159 8160 8161 8162 8163 8164 8165 8166 8167 8168 8169 8170 8171 8172 8173 8174 8175 8176 8177 8178 8179 8180 8181 8182 8183 8184 8185 8186 8187 8188 8189 8190 8191 8192 8193 8194 8195 8196 8197 8198 8199 8200 8201 8202 8203 8204 8205 8206 8207 8208 8209 8210 8211 8212 8213 8214 8215 8216 8217 8218 8219 8220 8221 8222 8223 8224 8225 8226 8227 8228 8229 8230 8231 8232 8233 8234 8235 8236 8237 8238 8239 8240 8241 8242 8243 8244 8245 8246 8247 8248 8249 8250 8251 8252 8253 8254 8255 8256 8257 8258 8259 8260 8261 8262 8263 8264 8265 8266 8267 8268 8269 8270 8271 8272 8273 8274 8275 8276 8277 8278 8279 8280 8281 8282 8283 8284 8285 8286 8287 8288 8289 8290 8291 8292 8293 8294 8295 8296 8297 8298 8299 8300 8301 8302 8303 8304 8305 8306 8307 8308 8309 8310 8311 8312 8313 8314 8315 8316 8317 8318 8319 8320 8321 8322 8323 8324 8325 8326 8327 8328 8329 8330 8331 8332 8333 8334 8335 8336 8337 8338 8339 8340 8341 8342 8343 8344 8345 8346 8347 8348 8349 8350 8351 8352 8353 8354 8355 8356 8357 8358 8359 8360 8361 8362 8363 8364 8365 8366 8367 8368 8369 8370 8371 8372 8373 8374 8375 8376 8377 8378 8379 8380 8381 8382 8383 8384 8385 8386 8387 8388 8389 8390 8391 8392 8393 8394 8395 8396 8397 8398 8399 8400 8401 8402 8403 8404 8405 8406 8407 8408 8409 8410 8411 8412 8413 8414 8415 8416 8417 8418 8419 8420 8421 8422 8423 8424 8425 8426 8427 8428 8429 8430 8431 8432 8433 8434 8435 8436 8437 8438 8439 8440 8441 8442 8443 8444 8445 8446 8447 8448 8449 8450 8451 8452 8453 8454 8455 8456 8457 8458 8459 8460 8461 8462 8463 8464 8465 8466 8467 8468 8469 8470 8471 8472 8473 8474 8475 8476 8477 8478 8479 8480 8481 8482 8483 8484 8485 8486 8487 8488 8489 8490 8491 8492 8493 8494 8495 8496 8497 8498 8499 8500 8501 8502 8503 8504 8505 8506 8507 8508 8509 8510 8511 8512 8513 8514 8515 8516 8517 8518 8519 8520 8521 8522 8523 8524 8525 8526 8527 8528 8529 8530 8531 8532 8533 8534 8535 8536 8537 8538 8539 8540 8541 8542 8543 8544 8545 8546 8547 8548 8549 8550 8551 8552 8553 8554 8555 8556 8557 8558 8559 8560 8561 8562 8563 8564 8565 8566 8567 8568 8569 8570 8571 8572 8573 8574 8575 8576 8577 8578 8579 8580 8581 8582 8583 8584 8585 8586 8587 8588 8589 8590 8591 8592 8593 8594 8595 8596 8597 8598 8599 8600 8601 8602 8603 8604 8605 8606 8607 8608 8609 8610 8611 8612 8613 8614 8615 8616 8617 8618 8619 8620 8621 8622 8623 8624 8625 8626 8627 8628 8629 8630 8631 8632 8633 8634 8635 8636 8637 8638 8639 8640 8641 8642 8643 8644 8645 8646 8647 8648 8649 8650 8651 8652 8653 8654 8655 8656 8657 8658 8659 8660 8661 8662 8663 8664 8665 8666 8667 8668 8669 8670 8671 8672 8673 8674 8675 8676 8677 8678 8679 8680 8681 8682 8683 8684 8685 8686 8687 8688 8689 8690 8691 8692 8693 8694 8695 8696 8697 8698 8699 8700 8701 8702 8703 8704 8705 8706 8707 8708 8709 8710 8711 8712 8713 8714 8715 8716 8717 8718 8719 8720 8721 8722 8723 8724 8725 8726 8727 8728 8729 8730 8731 8732 8733 8734 8735 8736 8737 8738 8739 8740 8741 8742 8743 8744 8745 8746 8747 8748 8749 8750 8751 8752 8753 8754 8755 8756 8757 8758 8759 8760 8761 8762 8763 8764 8765 8766 8767 8768 8769 8770 8771 8772 8773 8774 8775 8776 8777 8778 8779 8780 8781 8782 8783 8784 8785 8786 8787 8788 8789 8790 8791 8792 8793 8794 8795 8796 8797 8798 8799 8800 8801 8802 8803 8804 8805 8806 8807 8808 8809 8810 8811 8812 8813 8814 8815 8816 8817 8818 8819 8820 8821 8822 8823 8824 8825 8826 8827 8828 8829 8830 8831 8832 8833 8834 8835 8836 8837 8838 8839 8840 8841 8842 8843 8844 8845 8846 8847 8848 8849 8850 8851 8852 8853 8854 8855 8856 8857 8858 8859 8860 8861 8862 8863 8864 8865 8866 8867 8868 8869 8870 8871 8872 8873 8874 8875 8876 8877 8878 8879 8880 8881 8882 8883 8884 8885 8886 8887 8888 8889 8890 8891 8892 8893 8894 8895 8896 8897 8898 8899 8900 8901 8902 8903 8904 8905 8906 8907 8908 8909 8910 8911 8912 8913 8914 8915 8916 8917 8918 8919 8920 8921 8922 8923 8924 8925 8926 8927 8928 8929 8930 8931 8932 8933 8934 8935 8936 8937 8938 8939 8940 8941 8942 8943 8944 8945 8946 8947 8948 8949 8950 8951 8952 8953 8954 8955 8956 8957 8958 8959 8960 8961 8962 8963 8964 8965 8966 8967 8968 8969 8970 8971 8972 8973 8974 8975 8976 8977 8978 8979 8980 8981 8982 8983 8984 8985 8986 8987 8988 8989 8990 8991 8992 8993 8994 8995 8996 8997 8998 8999 9000 9001 9002 9003 9004 9005 9006 9007 9008 9009 9010 9011 9012 9013 9014 9015 9016 9017 9018 9019 9020 9021 9022 9023 9024 9025 9026 9027 9028 9029 9030 9031 9032 9033 9034 9035 9036 9037 9038 9039 9040 9041 9042 9043 9044 9045 9046 9047 9048 9049 9050 9051 9052 9053 9054 9055 9056 9057 9058 9059 9060 9061 9062 9063 9064 9065 9066 9067 9068 9069 9070 9071 9072 9073 9074 9075 9076 9077 9078 9079 9080 9081 9082 9083 9084 9085 9086 9087 9088 9089 9090 9091 9092 9093 9094 9095 9096 9097 9098 9099 9100 9101 9102 9103 9104 9105 9106 9107 9108 9109 9110 9111 9112 9113 9114 9115 9116 9117 9118 9119 9120 9121 9122 9123 9124 9125 9126 9127 9128 9129 9130 9131 9132 9133 9134 9135 9136 9137 9138 9139 9140 9141 9142 9143 9144 9145 9146 9147 9148 9149 9150 9151 9152 9153 9154 9155 9156 9157 9158 9159 9160 9161 9162 9163 9164 9165 9166 9167 9168 9169 9170 9171 9172 9173 9174 9175 9176 9177 9178 9179 9180 9181 9182 9183 9184 9185 9186 9187 9188 9189 9190 9191 9192 9193 9194 9195 9196 9197 9198 9199 9200 9201 9202 9203 9204 9205 9206 9207 9208 9209 9210 9211 9212 9213 9214 9215 9216 9217 9218 9219 9220 9221 9222 9223 9224 9225 9226 9227 9228 9229 9230 9231 9232 9233 9234 9235 9236 9237 9238 9239 9240 9241 9242 9243 9244 9245 9246 9247 9248 9249 9250 9251 9252 9253 9254 9255 9256 9257 9258 9259 9260 9261 9262 9263 9264 9265 9266 9267 9268 9269 9270 9271 9272 9273 9274 9275 9276 9277 9278 9279 9280 9281 9282 9283 9284 9285 9286 9287 9288 9289 9290 9291 9292 9293 9294 9295 9296 9297 9298 9299 9300 9301 9302 9303 9304 9305 9306 9307 9308 9309 9310 9311 9312 9313 9314 9315 9316 9317 9318 9319 9320 9321 9322 9323 9324 9325 9326 9327 9328 9329 9330 9331 9332 9333 9334 9335 9336 9337 9338 9339 9340 9341 9342 9343 9344 9345 9346 9347 9348 9349 9350 9351 9352 9353 9354 9355 9356 9357 9358 9359 9360 9361 9362 9363 9364 9365 9366 9367 9368 9369 9370 9371 9372 9373 9374 9375 9376 9377 9378 9379 9380 9381 9382 9383 9384 9385 9386 9387 9388 9389 9390 9391 9392 9393 9394 9395 9396 9397 9398 9399 9400 9401 9402 9403 9404 9405 9406 9407 9408 9409 9410 9411 9412 9413 9414 9415 9416 9417 9418 9419 9420 9421 9422 9423 9424 9425 9426 9427 9428 9429 9430 9431 9432 9433 9434 9435 9436 9437 9438 9439 9440 9441 9442 9443 9444 9445 9446 9447 9448 9449 9450 9451 9452 9453 9454 9455 9456 9457 9458 9459 9460 9461 9462 9463 9464 9465 9466 9467 9468 9469 9470 9471 9472 9473 9474 9475 9476 9477 9478 9479 9480 9481 9482 9483 9484 9485 9486 9487 9488 9489 9490 9491 9492 9493 9494 9495 9496 9497 9498 9499 9500 9501 9502 9503 9504 9505 9506 9507 9508 9509 9510 9511 9512 9513 9514 9515 9516 9517 9518 9519 9520 9521 9522 9523 9524 9525 9526 9527 9528 9529 9530 9531 9532 9533 9534 9535 9536 9537 9538 9539 9540 9541 9542 9543 9544 9545 9546 9547 9548 9549 9550 9551 9552 9553 9554 9555 9556 9557 9558 9559 9560 9561 9562 9563 9564 9565 9566 9567 9568 9569 9570 9571 9572 9573 9574 9575 9576 9577 9578 9579 9580 9581 9582 9583 9584 9585 9586 9587 9588 9589 9590 9591 9592 9593 9594 9595 9596 9597 9598 9599 9600 9601 9602 9603 9604 9605 9606 9607 9608 9609 9610 9611 9612 9613 9614 9615 9616 9617 9618 9619 9620 9621 9622 9623 9624 9625 9626 9627 9628 9629 9630 9631 9632 9633 9634 9635 9636 9637 9638 9639 9640 9641 9642 9643 9644 9645 9646 9647 9648 9649 9650 9651 9652 9653 9654 9655 9656 9657 9658 9659 9660 9661 9662 9663 9664 9665 9666 9667 9668 9669 9670 9671 9672 9673 9674 9675 9676 9677 9678 9679 9680 9681 9682 9683 9684 9685 9686 9687 9688 9689 9690 9691 9692 9693 9694 9695 9696 9697 9698 9699 9700 9701 9702 9703 9704 9705 9706 9707 9708 9709 9710 9711 9712 9713 9714 9715 9716 9717 9718 9719 9720 9721 9722 9723 9724 9725 9726 9727 9728 9729 9730 9731 9732 9733 9734 9735 9736 9737 9738 9739 9740 9741 9742 9743 9744 9745 9746 9747 9748 9749 9750 9751 9752 9753 9754 9755 9756 9757 9758 9759 9760 9761 9762 9763 9764 9765 9766 9767 9768 9769 9770 9771 9772 9773 9774 9775 9776 9777 9778 9779 9780 9781 9782 9783 9784 9785 9786 9787 9788 9789 9790 9791 9792 9793 9794 9795 9796 9797 9798 9799 9800 9801 9802 9803 9804 9805 9806 9807 9808 9809 9810 9811 9812 9813 9814 9815 9816 9817 9818 9819 9820 9821 9822 9823 9824 9825 9826 9827 9828 9829 9830 9831 9832 9833 9834 9835 9836 9837 9838 9839 9840 9841 9842 9843 9844 9845 9846 9847 9848 9849 9850 9851 9852 9853 9854 9855 9856 9857 9858 9859 9860 9861 9862 9863 9864 9865 9866 9867 9868 9869 9870 9871 9872 9873 9874 9875 9876 9877 9878 9879 9880 9881 9882 9883 9884 9885 9886 9887 9888 9889 9890 9891 9892 9893 9894 9895 9896 9897 9898 9899 9900 9901 9902 9903 9904 9905 9906 9907 9908 9909 9910 9911 9912 9913 9914 9915 9916 9917 9918 9919 9920 9921 9922 9923 9924 9925 9926 9927 9928 9929 9930 9931 9932 9933 9934 9935 9936 9937 9938 9939 9940 9941 9942 9943 9944 9945 9946 9947 9948 9949 9950 9951 9952 9953 9954 9955 9956 9957 9958 9959 9960 9961 9962 9963 9964 9965 9966 9967 9968 9969 9970 9971 9972 9973 9974 9975 9976 9977 9978 9979 9980 9981 9982 9983 9984 9985 9986 9987 9988 9989 9990 9991 9992 9993 9994 9995 9996 9997 9998 9999 10000 10001 10002 10003 10004 10005 10006 10007 10008 10009 10010 10011 10012 10013 10014 10015 10016 10017 10018 10019 10020 10021 10022 10023 10024 10025 10026 10027 10028 10029 10030 10031 10032 10033 10034 10035 10036 10037 10038 10039 10040 10041 10042 10043 10044 10045 10046 10047 10048 10049 10050 10051 10052 10053 10054 10055 10056 10057 10058 10059 10060 10061 10062 10063 10064 10065 10066 10067 10068 10069 10070 10071 10072 10073 10074 10075 10076 10077 10078 10079 10080 10081 10082 10083 10084 10085 10086 10087 10088 10089 10090 10091 10092 10093 10094 10095 10096 10097 10098 10099 10100 10101 10102 10103 10104 10105 10106 10107 10108 10109 10110 10111 10112 10113 10114 10115 10116 10117 10118 10119 10120 10121 10122 10123 10124 10125 10126 10127 10128 10129 10130 10131 10132 10133 10134 10135 10136 10137 10138 10139 10140 10141 10142 10143 10144 10145 10146 10147 10148 10149 10150 10151 10152 10153 10154 10155 10156 10157 10158 10159 10160 10161 10162 10163 10164 10165 10166 10167 10168 10169 10170 10171 10172 10173 10174 10175 10176 10177 10178 10179 10180 10181 10182 10183 10184 10185 10186 10187 10188 10189 10190 10191 10192 10193 10194 10195 10196 10197 10198 10199 10200 10201 10202 10203 10204 10205 10206 10207 10208 10209 10210 10211 10212 10213 10214 10215 10216 10217 10218 10219 10220 10221 10222 10223 10224 10225 10226 10227 10228 10229 10230 10231 10232 10233 10234 10235 10236 10237 10238 10239 10240 10241 10242 10243 10244 10245 10246 10247 10248 10249 10250 10251 10252 10253 10254 10255 10256 10257 10258 10259 10260 10261 10262 10263 10264 10265 10266 10267 10268 10269 10270 10271 10272 10273 10274 10275 10276 10277 10278 10279 10280 10281 10282 10283 10284 10285 10286 10287 10288 10289 10290 10291 10292 10293 10294 10295 10296 10297 10298 10299 10300 10301 10302 10303 10304 10305 10306 10307 10308 10309 10310 10311 10312 10313 10314 10315 10316 10317 10318 10319 10320 10321 10322 10323 10324 10325 10326 10327 10328 10329 10330 10331 10332 10333 10334 10335 10336 10337 10338 10339 10340 10341 10342 10343 10344 10345 10346 10347 10348 10349 10350 10351 10352 10353 10354 10355 10356 10357 10358 10359 10360 10361 10362 10363 10364 10365 10366 10367 10368 10369 10370 10371 10372 10373 10374 10375 10376 10377 10378 10379 10380 10381 10382 10383 10384 10385 10386 10387 10388 10389 10390 10391 10392 10393 10394 10395 10396 10397 10398 10399 10400 10401 10402 10403 10404 10405 10406 10407 10408 10409 10410 10411 10412 10413 10414 10415 10416 10417 10418 10419 10420 10421 10422 10423 10424 10425 10426 10427 10428 10429 10430 10431 10432 10433 10434 10435 10436 10437 10438 10439 10440 10441 10442 10443 10444 10445 10446 10447 10448 10449 10450 10451 10452 10453 10454 10455 10456 10457 10458 10459 10460 10461 10462 10463 10464 10465 10466 10467 10468 10469 10470 10471 10472 10473 10474 10475 10476 10477 10478 10479 10480 10481 10482 10483 10484 10485 10486 10487 10488 10489 10490 10491 10492 10493 10494 10495 10496 10497 10498 10499 10500 10501 10502 10503 10504 10505 10506 10507 10508 10509 10510 10511 10512 10513 10514 10515 10516 10517 10518 10519 10520 10521 10522 10523 10524 10525 10526 10527 10528 10529 10530 10531 10532 10533 10534 10535 10536 10537 10538 10539 10540 10541 10542 10543 10544 10545 10546 10547 10548 10549 10550 10551 10552 10553 10554 10555 10556 10557 10558 10559 10560 10561 10562 10563 10564 10565 10566 10567 10568 10569 10570 10571 10572 10573 10574 10575 10576 10577 10578 10579 10580 10581 10582 10583 10584 10585 10586 10587 10588 10589 10590 10591 10592 10593 10594 10595 10596 10597 10598 10599 10600 10601 10602 10603 10604 10605 10606 10607 10608 10609 10610 10611 10612 10613 10614 10615 10616 10617 10618 10619 10620 10621 10622 10623 10624 10625 10626 10627 10628 10629 10630 10631 10632 10633 10634 10635 10636 10637 10638 10639 10640 10641 10642 10643 10644 10645 10646 10647 10648 10649 10650 10651 10652 10653 10654 10655 10656 10657 10658 10659 10660 10661 10662 10663 10664 10665 10666 10667 10668 10669 10670 10671 10672 10673 10674 10675 10676 10677 10678 10679 10680 10681 10682 10683 10684 10685 10686 10687 10688 10689 10690 10691 10692 10693 10694 10695 10696 10697 10698 10699 10700 10701 10702 10703 10704 10705 10706 10707 10708 10709 10710 10711 10712 10713 10714 10715 10716 10717 10718 10719 10720 10721 10722 10723 10724 10725 10726 10727 10728 10729 10730 10731 10732 10733 10734 10735 10736 10737 10738 10739 10740 10741 10742 10743 10744 10745 10746 10747 10748 10749 10750 10751 10752 10753 10754 10755 10756 10757 10758 10759 10760 10761 10762 10763 10764 10765 10766 10767 10768 10769 10770 10771 10772 10773 10774 10775 10776 10777 10778 10779 10780 10781 10782 10783 10784 10785 10786 10787 10788 10789 10790 10791 10792 10793 10794 10795 10796 10797 10798 10799 10800 10801 10802 10803 10804 10805 10806 10807 10808 10809 10810 10811 10812 10813 10814 10815 10816 10817 10818 10819 10820 10821 10822 10823 10824 10825 10826 10827 10828 10829 10830 10831 10832 10833 10834 10835 10836 10837 10838 10839 10840 10841 10842 10843 10844 10845 10846 10847 10848 10849 10850 10851 10852 10853 10854 10855 10856 10857 10858 10859 10860 10861 10862 10863 10864 10865 10866 10867 10868 10869 10870 10871 10872 10873 10874 10875 10876 10877 10878 10879 10880 10881 10882 10883 10884 10885 10886 10887 10888 10889 10890 10891 10892 10893 10894 10895 10896 10897 10898 10899 10900 10901 10902 10903 10904 10905 10906 10907 10908 10909 10910 10911 10912 10913 10914 10915 10916 10917 10918 10919 10920 10921 10922 10923 10924 10925 10926 10927 10928 10929 10930 10931 10932 10933 10934 10935 10936 10937 10938 10939 10940 10941 10942 10943 10944 10945 10946 10947 10948 10949 10950 10951 10952 10953 10954 10955 10956 10957 10958 10959 10960 10961 10962 10963 10964 10965 10966 10967 10968 10969 10970 10971 10972 10973 10974 10975 10976 10977 10978 10979 10980 10981 10982 10983 10984 10985 10986 10987 10988 10989 10990 10991 10992 10993 10994 10995 10996 10997 10998 10999 11000 11001 11002 11003 11004 11005 11006 11007 11008 11009 11010 11011 11012 11013 11014 11015 11016 11017 11018 11019 11020 11021 11022 11023 11024 11025 11026 11027 11028 11029 11030 11031 11032 11033 11034 11035 11036 11037 11038 11039 11040 11041 11042 11043 11044 11045 11046 11047 11048 11049 11050 11051 11052 11053 11054 11055 11056 11057 11058 11059 11060 11061 11062 11063 11064 11065 11066 11067 11068 11069 11070 11071 11072 11073 11074 11075 11076 11077 11078 11079 11080 11081 11082 11083 11084 11085 11086 11087 11088 11089 11090 11091 11092 11093 11094 11095 11096 11097 11098 11099 11100 11101 11102 11103 11104 11105 11106 11107 11108 11109 11110 11111 11112 11113 11114 11115 11116 11117 11118 11119 11120 11121 11122 11123 11124 11125 11126 11127 11128 11129 11130 11131 11132 11133 11134 11135 11136 11137 11138 11139 11140 11141 11142 11143 11144 11145 11146 11147 11148 11149 11150 11151 11152 11153 11154 11155 11156 11157 11158 11159 11160 11161 11162 11163 11164 11165 11166 11167 11168 11169 11170 11171 11172 11173 11174 11175 11176 11177 11178 11179 11180 11181 11182 11183 11184 11185 11186 11187 11188 11189 11190 11191 11192 11193 11194 11195 11196 11197 11198 11199 11200 11201 11202 11203 11204 11205 11206 11207 11208 11209 11210 11211 11212 11213 11214 11215 11216 11217 11218 11219 11220 11221 11222 11223 11224 11225 11226 11227 11228 11229 11230 11231 11232 11233 11234 11235 11236 11237 11238 11239 11240 11241 11242 11243 11244 11245 11246 11247 11248 11249 11250 11251 11252 11253 11254 11255 11256 11257 11258 11259 11260 11261 11262 11263 11264 11265 11266 11267 11268 11269 11270 11271 11272 11273 11274 11275 11276 11277 11278 11279 11280 11281 11282 11283 11284 11285 11286 11287 11288 11289 11290 11291 11292 11293 11294 11295 11296 11297 11298 11299 11300 11301 11302 11303 11304 11305 11306 11307 11308 11309 11310 11311 11312 11313 11314 11315 11316 11317 11318 11319 11320 11321 11322 11323 11324 11325 11326 11327 11328 11329 11330 11331 11332 11333 11334 11335 11336 11337 11338 11339 11340 11341 11342 11343 11344 11345 11346 11347 11348 11349 11350 11351 11352 11353 11354 11355 11356 11357 11358 11359 11360 11361 11362 11363 11364 11365 11366 11367 11368 11369 11370 11371 11372 11373 11374 11375 11376 11377 11378 11379 11380 11381 11382 11383 11384 11385 11386 11387 11388 11389 11390 11391 11392 11393 11394 11395 11396 11397 11398 11399 11400 11401 11402 11403 11404 11405 11406 11407 11408 11409 11410 11411 11412 11413 11414 11415 11416 11417 11418 11419 11420 11421 11422 11423 11424 11425 11426 11427 11428 11429 11430 11431 11432 11433 11434 11435 11436 11437 11438 11439 11440 11441 11442 11443 11444 11445 11446 11447 11448 11449 11450 11451 11452 11453 11454 11455 11456 11457 11458 11459 11460 11461 11462 11463 11464 11465 11466 11467 11468 11469 11470 11471 11472 11473 11474 11475 11476 11477 11478 11479 11480 11481 11482 11483 11484 11485 11486 11487 11488 11489 11490 11491 11492 11493 11494 11495 11496 11497 11498 11499 11500 11501 11502 11503 11504 11505 11506 11507 11508 11509 11510 11511 11512 11513 11514 11515 11516 11517 11518 11519 11520 11521 11522 11523 11524 11525 11526 11527 11528 11529 11530 11531 11532 11533 11534 11535 11536 11537 11538 11539 11540 11541 11542 11543 11544 11545 11546 11547 11548 11549 11550 11551 11552 11553 11554 11555 11556 11557 11558 11559 11560 11561 11562 11563 11564 11565 11566 11567 11568 11569 11570 11571 11572 11573 11574 11575 11576 11577 11578 11579 11580 11581 11582 11583 11584 11585 11586 11587 11588 11589 11590 11591 11592 11593 11594 11595 11596 11597 11598 11599 11600 11601 11602 11603 11604 11605 11606 11607 11608 11609 11610 11611 11612 11613 11614 11615 11616 11617 11618 11619 11620 11621 11622 11623 11624 11625 11626 11627 11628 11629 11630 11631 11632 11633 11634 11635 11636 11637 11638 11639 11640 11641 11642 11643 11644 11645 11646 11647 11648 11649 11650 11651 11652 11653 11654 11655 11656 11657 11658 11659 11660 11661 11662 11663 11664 11665 11666 11667 11668 11669 11670 11671 11672 11673 11674 11675 11676 11677 11678 11679 11680 11681 11682 11683 11684 11685 11686 11687 11688 11689 11690 11691 11692 11693 11694 11695 11696 11697 11698 11699 11700 11701 11702 11703 11704 11705 11706 11707 11708 11709 11710 11711 11712 11713 11714 11715 11716 11717 11718 11719 11720 11721 11722 11723 11724 11725 11726 11727 11728 11729 11730 11731 11732 11733 11734 11735 11736 11737 11738 11739 11740 11741 11742 11743 11744 11745 11746 11747 11748 11749 11750 11751 11752 11753 11754 11755 11756 11757 11758 11759 11760 11761 11762 11763 11764 11765 11766 11767 11768 11769 11770 11771 11772 11773 11774 11775 11776 11777 11778 11779 11780 11781 11782 11783 11784 11785 11786 11787 11788 11789 11790 11791 11792 11793 11794 11795 11796 11797 11798 11799 11800 11801 11802 11803 11804 11805 11806 11807 11808 11809 11810 11811 11812 11813 11814 11815 11816 11817 11818 11819 11820 11821 11822 11823 11824 11825 11826 11827 11828 11829 11830 11831 11832 11833 11834 11835 11836 11837 11838 11839 11840 11841 11842 11843 11844 11845 11846 11847 11848 11849 11850 11851 11852 11853 11854 11855 11856 11857 11858 11859 11860 11861 11862 11863 11864 11865 11866 11867 11868 11869 11870 11871 11872 11873 11874 11875 11876 11877 11878 11879 11880 11881 11882 11883 11884 11885 11886 11887 11888 11889 11890 11891 11892 11893 11894 11895 11896 11897 11898 11899 11900 11901 11902 11903 11904 11905 11906 11907 11908 11909 11910 11911 11912 11913 11914 11915 11916 11917 11918 11919 11920 11921 11922 11923 11924 11925 11926 11927 11928 11929 11930 11931 11932 11933 11934 11935 11936 11937 11938 11939 11940 11941 11942 11943 11944 11945 11946 11947 11948 11949 11950 11951 11952 11953 11954 11955 11956 11957 11958 11959 11960 11961 11962 11963 11964 11965 11966 11967 11968 11969 11970 11971 11972 11973 11974 11975 11976 11977 11978 11979 11980 11981 11982 11983 11984 11985 11986 11987 11988 11989 11990 11991 11992 11993 11994 11995 11996 11997 11998 11999 12000 12001 12002 12003 12004 12005 12006 12007 12008 12009 12010 12011 12012 12013 12014 12015 12016 12017 12018 12019 12020 12021 12022 12023 12024 12025 12026 12027 12028 12029 12030 12031 12032 12033 12034 12035 12036 12037 12038 12039 12040 12041 12042 12043 12044 12045 12046 12047 12048 12049 12050 12051 12052 12053 12054 12055 12056 12057 12058 12059 12060 12061 12062 12063 12064 12065 12066 12067 12068 12069 12070 12071 12072 12073 12074 12075 12076 12077 12078 12079 12080 12081 12082 12083 12084 12085 12086 12087 12088 12089 12090 12091 12092 12093 12094 12095 12096 12097 12098 12099 12100 12101 12102 12103 12104 12105 12106 12107 12108 12109 12110 12111 12112 12113 12114 12115 12116 12117 12118 12119 12120 12121 12122 12123 12124 12125 12126 12127 12128 12129 12130 12131 12132 12133 12134 12135 12136 12137 12138 12139 12140 12141 12142 12143 12144 12145 12146 12147 12148 12149 12150 12151 12152 12153 12154 12155 12156 12157 12158 12159 12160 12161 12162 12163 12164 12165 12166 12167 12168 12169 12170 12171 12172 12173 12174 12175 12176 12177 12178 12179 12180 12181 12182 12183 12184 12185 12186 12187 12188 12189 12190 12191 12192 12193 12194 12195 12196 12197 12198 12199 12200 12201 12202 12203 12204 12205 12206 12207 12208 12209 12210 12211 12212 12213 12214 12215 12216 12217 12218 12219 12220 12221 12222 12223 12224 12225 12226 12227 12228 12229 12230 12231 12232 12233 12234 12235 12236 12237 12238 12239 12240 12241 12242 12243 12244 12245 12246 12247 12248 12249 12250 12251 12252 12253 12254 12255 12256 12257 12258 12259 12260 12261 12262 12263 12264 12265 12266 12267 12268 12269 12270 12271 12272 12273 12274 12275 12276 12277 12278 12279 12280 12281 12282 12283 12284 12285 12286 12287 12288 12289 12290 12291 12292 12293 12294 12295 12296 12297 12298 12299 12300 12301 12302 12303 12304 12305 12306 12307 12308 12309 12310 12311 12312 12313 12314 12315 12316 12317 12318 12319 12320 12321 12322 12323 12324 12325 12326 12327 12328 12329 12330 12331 12332 12333 12334 12335 12336 12337 12338 12339 12340 12341 12342 12343 12344 12345 12346 12347 12348 12349 12350 12351 12352 12353 12354 12355 12356 12357 12358 12359 12360 12361 12362 12363 12364 12365 12366 12367 12368 12369 12370 12371 12372 12373 12374 12375 12376 12377 12378 12379 12380 12381 12382 12383 12384 12385 12386 12387 12388 12389 12390 12391 12392 12393 12394 12395 12396 12397 12398 12399 12400 12401 12402 12403 12404 12405 12406 12407 12408 12409 12410 12411 12412 12413 12414 12415 12416 12417 12418 12419 12420 12421 12422 12423 12424 12425 12426 12427 12428 12429 12430 12431 12432 12433 12434 12435 12436 12437 12438 12439 12440 12441 12442 12443 12444 12445 12446 12447 12448 12449 12450 12451 12452 12453 12454 12455 12456 12457 12458 12459 12460 12461 12462 12463 12464 12465 12466 12467 12468 12469 12470 12471 12472 12473 12474 12475 12476 12477 12478 12479 12480 12481 12482 12483 12484 12485 12486 12487 12488 12489 12490 12491 12492 12493 12494 12495 12496 12497 12498 12499 12500 12501 12502 12503 12504 12505 12506 12507 12508 12509 12510 12511 12512 12513 12514 12515 12516 12517 12518 12519 12520 12521 12522 12523 12524 12525 12526 12527 12528 12529 12530 12531 12532 12533 12534 12535 12536 12537 12538 12539 12540 12541 12542 12543 12544 12545 12546 12547 12548 12549 12550 12551 12552 12553 12554 12555 12556 12557 12558 12559 12560 12561 12562 12563 12564 12565 12566 12567 12568 12569 12570 12571 12572 12573 12574 12575 12576 12577 12578 12579 12580 12581 12582 12583 12584 12585 12586 12587 12588 12589 12590 12591 12592 12593 12594 12595 12596 12597 12598 12599 12600 12601 12602 12603 12604 12605 12606 12607 12608 12609 12610 12611 12612 12613 12614 12615 12616 12617 12618 12619 12620 12621 12622 12623 12624 12625 12626 12627 12628 12629 12630 12631 12632 12633 12634 12635 12636 12637 12638 12639 12640 12641 12642 12643 12644 12645 12646 12647 12648 12649 12650 12651 12652 12653 12654 12655 12656 12657 12658 12659 12660 12661 12662 12663 12664 12665 12666 12667 12668 12669 12670 12671 12672 12673 12674 12675 12676 12677 12678 12679 12680 12681 12682 12683 12684 12685 12686 12687 12688 12689 12690 12691 12692 12693 12694 12695 12696 12697 12698 12699 12700 12701 12702 12703 12704 12705 12706 12707 12708 12709 12710 12711 12712 12713 12714 12715 12716 12717 12718 12719 12720 12721 12722 12723 12724 12725 12726 12727 12728 12729 12730 12731 12732 12733 12734 12735 12736 12737 12738 12739 12740 12741 12742 12743 12744 12745 12746 12747 12748 12749 12750 12751 12752 12753 12754 12755 12756 12757 12758 12759 12760 12761 12762 12763 12764 12765 12766 12767 12768 12769 12770 12771 12772 12773 12774 12775 12776 12777 12778 12779 12780 12781 12782 12783 12784 12785 12786 12787 12788 12789 12790 12791 12792 12793 12794 12795 12796 12797 12798 12799 12800 12801 12802 12803 12804 12805 12806 12807 12808 12809 12810 12811 12812 12813 12814 12815 12816 12817 12818 12819 12820 12821 12822 12823 12824 12825 12826 12827 12828 12829 12830 12831 12832 12833 12834 12835 12836 12837 12838 12839 12840 12841 12842 12843 12844 12845 12846 12847 12848 12849 12850 12851 12852 12853 12854 12855 12856 12857 12858 12859 12860 12861 12862 12863 12864 12865 12866 12867 12868 12869 12870 12871 12872 12873 12874 12875 12876 12877 12878 12879 12880 12881 12882 12883 12884 12885 12886 12887 12888 12889 12890 12891 12892 12893 12894 12895 12896 12897 12898 12899 12900 12901 12902 12903 12904 12905 12906 12907 12908 12909 12910 12911 12912 12913 12914 12915 12916 12917 12918 12919 12920 12921 12922 12923 12924 12925 12926 12927 12928 12929 12930 12931 12932 12933 12934 12935 12936 12937 12938 12939 12940 12941 12942 12943 12944 12945 12946 12947 12948 12949 12950 12951 12952 12953 12954 12955 12956 12957 12958 12959 12960 12961 12962 12963 12964 12965 12966 12967 12968 12969 12970 12971 12972 12973 12974 12975 12976 12977 12978 12979 12980 12981 12982 12983 12984 12985 12986 12987 12988 12989 12990 12991 12992 12993 12994 12995 12996 12997 12998 12999 13000 13001 13002 13003 13004 13005 13006 13007 13008 13009 13010 13011 13012 13013 13014 13015 13016 13017 13018 13019 13020 13021 13022 13023 13024 13025 13026 13027 13028 13029 13030 13031 13032 13033 13034 13035 13036 13037 13038 13039 13040 13041 13042 13043 13044 13045 13046 13047 13048 13049 13050 13051 13052 13053 13054 13055 13056 13057 13058 13059 13060 13061 13062 13063 13064 13065 13066 13067 13068 13069 13070 13071 13072 13073 13074 13075 13076 13077 13078 13079 13080 13081 13082 13083 13084 13085 13086 13087 13088 13089 13090 13091 13092 13093 13094 13095 13096 13097 13098 13099 13100 13101 13102 13103 13104 13105 13106 13107 13108 13109 13110 13111 13112 13113 13114 13115 13116 13117 13118 13119 13120 13121 13122 13123 13124 13125 13126 13127 13128 13129 13130 13131 13132 13133 13134 13135 13136 13137 13138 13139 13140 13141 13142 13143 13144 13145 13146 13147 13148 13149 13150 13151 13152 13153 13154 13155 13156 13157 13158 13159 13160 13161 13162 13163 13164 13165 13166 13167 13168 13169 13170 13171 13172 13173 13174 13175 13176 13177 13178 13179 13180 13181 13182 13183 13184 13185 13186 13187 13188 13189 13190 13191 13192 13193 13194 13195 13196 13197 13198 13199 13200 13201 13202 13203 13204 13205 13206 13207 13208 13209 13210 13211 13212 13213 13214 13215 13216 13217 13218 13219 13220 13221 13222 13223 13224 13225 13226 13227 13228 13229 13230 13231 13232 13233 13234 13235 13236 13237 13238 13239 13240 13241 13242 13243 13244 13245 13246 13247 13248 13249 13250 13251 13252 13253 13254 13255 13256 13257 13258 13259 13260 13261 13262 13263 13264 13265 13266 13267 13268 13269 13270 13271 13272 13273 13274 13275 13276 13277 13278 13279 13280 13281 13282 13283 13284 13285 13286 13287 13288 13289 13290 13291 13292 13293 13294 13295 13296 13297 13298 13299 13300 13301 13302 13303 13304 13305 13306 13307 13308 13309 13310 13311 13312 13313 13314 13315 13316 13317 13318 13319 13320 13321 13322 13323 13324 13325 13326 13327 13328 13329 13330 13331 13332 13333 13334 13335 13336 13337 13338 13339 13340 13341 13342 13343 13344 13345 13346 13347 13348 13349 13350 13351 13352 13353 13354 13355 13356 13357 13358 13359
define("index", ["jquery","handlebars","source-map","index","lazyload","dot","jquery.placeholder"], function(require, exports, module){
var webYohobuy;

//通用
require("js/common");

//头部
require("js/header");

//简化头部
require("js/simple-header");

//商品(列表、搜索、商品详情)
require("js/product/entry");

//频道页
require("js/index/index");

//品牌一览
require("js/brand/index");

//登录注册找回密码
require("js/passport/entry");

//购物车
require("js/cart/cart");

//个人中心
require("js/home/entry");

//订单确认
require("js/order/ensure");

module.exports = webYohobuy;

});
define("js/common", ["jquery"], function(require, exports, module){
/**
 * 页面公共逻辑和接口
 * @author: xuqi<qi.xu@yoho.cn>
 * @date: 2015/11/23
 */
var $ = require("jquery");


var $body = $('body');

require("js/footer");

function cookie(name) {
    var re = new RegExp(name + '=([^;$]*)', 'i'),
        matchPattern = '$1';

    return re.test(decodeURIComponent(document.cookie)) ? RegExp[matchPattern] : '';
}

function setCookie(name, value, options) {
    var expires = '',
        path,
        domain,
        secure,
        date;

    if (typeof value !== 'undefined') {
        options = options || {};
        if (value === null) {
            value = '';
            options.expires = -1;
        }

        if (options.expires &&
            (typeof options.expires === 'number' || options.expires.toUTCString)) {
            if (typeof options.expires === 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString();
        }
        path = options.path ? '; path=' + options.path : '';
        domain = options.domain ? '; domain=' + options.domain : '';
        secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    }
}

function getUser() {
    var c = cookie('_UID'),
        user;

    if (typeof c === 'undefined') {
        return 0;
    }

    user = c.split('::');

    if (typeof user === 'undefined' || user.length < 4) {
        return 0;
    }

    return user;
}

function getUid() {
    var user = getUser();

    if (user === 0) {
        return 0;
    }

    return user[1];
}

function getShoppingKey() {
    var c = cookie('_g');

    if (typeof c === 'undefined') {
        return '';
    }

    return JSON.parse(c).k;
}

//YAS统计代码
(function(w, d, s, j, f) {
    var a = d.createElement(s);
    var m = d.getElementsByTagName(s)[0];

    w.YohoAcquisitionObject = f;

    w[f] = function() {
        w[f].p = arguments;
    };

    a.async = 1;
    a.src = j;
    m.parentNode.insertBefore(a, m);
})(window, document, 'script', 'http://cdn.yoho.cn/yas-jssdk/1.0.14/yas.js', '_yas');

(function() {
    var uid = getUid();

    uid = uid === 0 ? '' : uid;

    window._ozuid = uid; //暴露ozuid

    if (window._yas) {
        window._yas(1 * new Date(), '1.0.14', 'yohobuy_web', uid, '', '');
    }
}());

//window.resize在width<1180时适配成990
$(window).on('resize', function() {
    var w = $(this).width();

    //return top
    if (w < 1360) {
        $('.return-top').addClass('min');
    } else {
        $('.return-top').removeClass('min');
    }

    //body
    if (w < 1180) {
        $body.addClass('min-screen');
    } else {
        $body.removeClass('min-screen');
    }
}).trigger('resize');

function queryString() {
    var vars = {},
        hash,
        i,
        search = window.location.search,
        hashes = search ? decodeURIComponent(search).slice(1).split('&') : [];

    for (i = 0; i < hashes.length; i++) {
        hash = hashes[i].split('=');
        vars[hash[0]] = hash[1];
    }
    return vars;
}

//个人中心左侧栏头像加载失败后,显示默认头像
(function() {
    $(window).load(function() {
        var thumb = document.getElementById('user-thumb');
        var img;

        if (!thumb) {
            return;
        }

        img = new Image();

        img.src = thumb.src;

        img.onerror = function() {
            $(thumb).parent().append('<div class="default-user-thumb"></div>').end().remove();
        };
    });
}());

window.cookie = cookie;

window.setCookie = setCookie;

window.getUser = getUser;

window.getUid = getUid;

window.getShoppingKey = getShoppingKey;

window.queryString = queryString;

});
define("js/footer", ["jquery"], function(require, exports, module){
/**
 * 尾部
 * @author: wangqing<robin.wang@yoho.cn>
 * @date: 2015/12/01
 */

var $ = require("jquery");

var $returnTop = $('.return-top');

/**
 * 订阅
 * @return {[type]} [description]
 */
function actionSubscription() {
    var $subscriberBox = $('#subscriber-box'),
        $subscriberBtn = $('#subscriber-btn'),
        emailReg = /^[.\-_a-zA-Z0-9]+@[\-_a-zA-Z0-9]+\.[a-zA-Z0-9]/;

    var iconCode = {
        mail: '&#xe61b;',
        tick: '&#xe61a'
    };

    $subscriberBox.focus(function() {
        $(this).val('').css('color', '');
        $subscriberBtn.removeClass('done').html(iconCode.mail);
    });

    $subscriberBtn.click(function() {
        var email = $.trim($subscriberBox.val());

        if (email !== '' && emailReg.test(email)) {
            try {
                $.ajax({
                    url: 'http://new.yohobuy.com/common/emailsubscriber',
                    dataType: 'jsonp',
                    data: {
                        email: email,
                        tmp: Math.random(),
                        uid: window.getUid()
                    },
                    success: function(data) {
                        if (data.data.result === 1) {
                            $subscriberBox.val('已订阅到:' + email);
                            $subscriberBtn.addClass('done').html(iconCode.tick);
                        } else {
                            $subscriberBox.css('color', 'red');
                        }
                    }
                });
            } catch (e) {
                console.log(e.message);
            }
        } else {
            $subscriberBox.css('color', 'red');
        }
    });
}

function actionhomeFootChange() {
    var $vote = $('.vote'),
        $feedBackPage = $('#feed-back-page'),
        count = $vote.children('li').length;

    //意见反馈
    $feedBackPage.on('click', 'span', function() {
        var $this = $(this);

        if ($this.hasClass('cur')) {
            return;
        }

        $this.siblings('.cur').removeClass('cur');
        $this.addClass('cur');

        $vote.children().not('.hide').addClass('hide')
            .end()
            .eq($this.index()).removeClass('hide');
    });

    $vote.on('click', '.feed-back-btn', function() {
        var $this = $(this),
            $li = $this.closest('li'),
            index = $li.index(),
            _solution = [];

        var _answer = $li.find('.feedback-answer').val(),
            _feedback = $li.find('.feedback-id').val(),
            _question = $li.find('.question-id').val();

        $li.find(':checked').each(function() {
            _solution.push($(this).val());
        });

        $.ajax({
            url: 'http://new.yohobuy.com/common/suggestfeedback',
            dataType: 'jsonp',
            data: {
                feedback_id: _feedback || 0,
                question_id: _question || 0,
                answer: _answer || '',
                solution: _solution.join(',')
            },
            success: function(data) {
                var next = index + 1;

                if (~~data.data.result === 1) {
                    if (index === count - 1) {
                        alert('感谢您的参与!');
                        return;
                    }

                    $li.addClass('hide');

                    $vote.children(':eq(' + (index + 1) + ')').removeClass('hide');
                    $feedBackPage.children('.cur').removeClass('cur');
                    $feedBackPage.children(':eq(' + next + ')').addClass('cur');
                }
            }
        });
    });
}

function rePosReturn() {
    if ($(window).height() > $(document).height()) {
        $returnTop.addClass('hide');
    }

    // 只在窗口高度大于文档高度的时候,隐藏返回顶部
    // else {
    //     $returnTop.removeClass('hide');
    // }
}

//返回顶部
$returnTop.click(function() {
    $('html,body').animate({
        scrollTop: 0
    }, 500);
});

$(window).scroll(function() {
    if ($(window).scrollTop() === 0) {
        $returnTop.addClass('hide');
    } else {
        $returnTop.removeClass('hide');
    }
});

//如果初始是隐藏的,监听图片加载,重新确定return-top的高度
if ($returnTop.hasClass('hide')) {
    $('img').load(rePosReturn);
}

//初始化
actionSubscription();
actionhomeFootChange();

//暴露给有可能通AJAX改变内容的页面去用
window.rePosReturnTop = rePosReturn;

});
define("js/header", ["jquery","handlebars","source-map","index"], function(require, exports, module){
/**
 * 头部
 * @author: wangqing<robin.wang@yoho.cn>
 * @date: 2015/12/01
 */
var $ = require("jquery");
var handlebars = require("handlebars");
var json2 = require("index");
var vipInfoCombine = null; //用户信息编译模板
var loginInfoCombine = null; //登录信息编译模板
var apiDomain = $('#api-domain').val(); //获取数据的地址
var cartTpl = ''; //购物车模板
/**
 * 搜寻的时候过滤非法字符(+-/:等非法字符单独出现)
 * @type {RegExp}
 */
var reg = /^[\^\!\+\-\(\)\:\[\]\\\{\}\~\*\?\|\&\;\/]{0,}$/g;
var keyword = '';
var link = '';
var dataLayer = [];
var requestFrame = null;
var logoanimationstart = 0;
var $logotrans = $('.icon-logo');
var isen = true;
var loopdurationtime = 500;
var globaltimeout;
var onetimeoout;
/**
 * banner和地址的映射
 * @type {Object}
 */
var bannerMap = {
    listboys: '4f78b0f418fc42314d8b6e791cfb7fa8',
    listgirls: '00c1f025a51b6b597dc37925951ea27d',
    listkids: 'b02df11184727701ade1b6de9737d08c',
    listlifestyle: 'fd35c52dced0c880976ba858346d1fc5',
    searchboys: '9fb8986ea700cc27a8057361c3924394',
    searchgirls: 'e3e207a1443ca60c8037fe52a5560c18',
    searchkids: '620fc77f479da8feaeb06f2324e5d0bb',
    searchlifestyle: 'a3c93301c6ffaf3ed0f36a4a451be36d',
    uniquebrandboys: '2ebb0810c0d1a67e5229149c9c3aba7d',
    uniquebrandgirls: '99e23385f4ba4b65f406b7e2968ac821',
    uniquebrandkids: 'a74ebc9b17840c91b9ea46568111fe6b',
    uniquebrandlifestyle: '0e8c81ead53f56302baa4d0ad967f527',
    brandsboys: '77b352db07129c76a9d532acad149f9f',
    brandsgirls: 'bf047f16e52ebc38be5ce9c7623831e6',
    brandskids: 'e3ae1ce9b5e13c6d271ef3eccb831652',
    brandslifestyle: 'e4ac8029c30f65d7f1af030980d140fe',
    newboys: '869d3c5f3b450fb52101d00a61ce87cb',
    newgirls: 'd953b6dfdac02483d1dcce8d96055954',
    newkids: '0874cb6d75df8e0e78f2d475e53ecc08',
    newlifestyle: '43e8fc8e178115c262bbce2bd0012db7',
    saleboys: 'c846e3165c994769b4201d8c32f3ae9b',
    salegirls: '52b1d389edcbc62d65de71b80c4d6ad0',
    salekids: 'ad8b1703c761ba00973868ab5199cc27',
    salelifestyle: '7acc64905c70ac91846f43fb2cec4bbd',
    homeboys: 'b0856a771ef1b59ab1234c74688fa42d',
    homegirls: '2bd61fa12e4933211518f70fe5ce3c48',
    homekids: '895c59e8c64b40399c9533509507320c',
    homelifestyle: '2e037d4e25d2767352ca3e0a4627f7bd',
    indexboys: '0c911d3000f52e8ca7cffb74f5864c29',
    indexgirls: 'b645b8980c423ab30485e0a9d08c2ef7',
    indexkids: '17f6d5d5d454d2c507bc5fcbc90f7756',
    indexlifestyle: '735cd393e841762af8793c346abbbc36'
};
var cookieMap = {};

var bannerApi = 'http://new.yohobuy.com/common/getbanner?content_code=';

$('#api-domain').remove(); //删除信息表单

function getSource(column, postition, event) {
    try {
        dataLayer.push({
            louceng: column,
            weizhi: postition,
            event: event
        });
    } catch (e) {}
}


window.submitSearch = function() {
    var $keywordinput = $('#query_key').val();
    var $defaultsearch = $('#defaultsearch').val();
    var column = 'Search';
    var postition = 'Head Search';
    var event = 'Search';
    var $formatkeyword,
        $formatkeywordinput;

    $formatkeyword = $.trim(keyword.toLowerCase());
    $formatkeywordinput = $.trim($keywordinput.toLowerCase());
    getSource(column, postition, event);
    if (link !== '' && keyword !== '' && $formatkeyword === $formatkeywordinput) {
        location.href = link.replace('\'', '');
    } else {
        if (reg.test($keywordinput) && $keywordinput !== '') {
            location.href = 'http://search.yohobuy.com/error?query=' + $keywordinput + '&result=error';
        } else {
            if ($keywordinput === '') {
                $('#query_key').val($defaultsearch);
            }
            $('#searchForm').submit();
            return false;
        }
    }
};
/**
 * 增加关键字
 * @return {[type]} [description]
 */
function actionAddKeyWords() {
    var $keywords = $('#nav_keyword').text();
    var defaultsearch = 'vans';
    var $querykey = $('#query_key');

    if ($keywords !== '') {
        $querykey.css({
            color: '#000'
        });
        $querykey.val($keywords);
    } else {
        $querykey.css({
            color: '#e0e0e0'
        });
        $querykey.val(defaultsearch);
        $querykey.on('focus', function(e) {
            $querykey.css({
                color: '#000'
            });
            $querykey.val('');
        });
    }
}
/**
 * 定义购物车扩展
 */

function actionGoodsCart() {
    var defaults = {
        cookie: '_g',
        cartNum: ''
    };
    var params = '';
    var cartInfo = '';
    var queryNum = 0;
    var listIndex = 0;
    var tmpList = 0;
    var totalNum = 0;
    var text = '';

    $.fn.miniCart = function(options) {
        params = $.extend(defaults, options);
        if (typeof window.cookie(params.cookie) === 'undefined') {
            cartInfo = null;
        } else {
            if (params.cookie) {
                try {
                    cartInfo = json2.parse(window.cookie(params.cookie));
                } catch (e) {

                }

            }

        }
        if (cartInfo !== null && cartInfo !== '') {
            totalNum = parseInt(cartInfo._nac) + parseInt(cartInfo._ac);
            if (totalNum === 0) {
                $('#icart-num').attr('class', 'icart-num icart-none');
            } else {
                $('#icart-num').attr('class', 'icart-num');
            }
            $(params.cartNum).html(totalNum);
        }
    };
    $.fn.search = function(searchDomain) {

        function getKeywords(obj) {
            var key = $.trim($(obj).val());

            key = key.replace(new RegExp('\'', 'gm'), ''); //去掉特殊字符
            if (key === '') {
                $('.search-list').hide();
                return false;
            }
            key = encodeURI(key);
            $.get(searchDomain + '?query=' + key, function(htmlData) {
                $('.search-list').html(htmlData.data);
                queryNum = $('.search-list').children('li').length;
                listIndex = -1;
                if (queryNum > 0) {
                    $('.search-list').show();
                } else {
                    $('.search-list').hide();
                }
                $('.search-list').find('a').hover(function() {
                    $(this).css('background-color', '#eee');
                }, function() {
                    $(this).css('background-color', '#fff');
                });
            }, 'jsonp');
        }

        function getText(obj) {
            $('.search-list li:eq(' + tmpList + ')').children('a').css('background-color', '#fff');
            $('.search-list li:eq(' + listIndex + ')').children('a').css('background-color', '#eee');
            text = $('.search-list li:eq(' + listIndex + ')').children('a').attr('title');
            $('#query_key').val(text);
        }
        return this.each(function() {
            $(this).keyup(function(event) {
                if (event.which === 38) {
                    if (queryNum === 0) {
                        return false;
                    }
                    if (listIndex === -1) {
                        listIndex = 0;
                    }
                    tmpList = listIndex;
                    listIndex = (listIndex - 1 + queryNum) % queryNum;
                    getText(this);
                } else if (event.which === 40) {
                    if (queryNum === 0) {
                        return false;
                    }
                    tmpList = listIndex;
                    listIndex = (listIndex + 1) % queryNum;
                    getText(this);
                } else if (event.which === 13) {
                    window.submitSearch();
                } else {
                    getKeywords(this);
                }
            });
        });
    };
    $.extend({
        getData: function(domain, options, onSuccess) {
            var defaults = {
                page: 1,
                method: '',
                v: 1,
                return_type: 'jsonp',
                open_key: '12345',
                tmp: Math.random()
            };
            var params = '';

            if (typeof (domain) === undefined || domain === '') {
                return false;
            }
            params = $.extend(defaults, options);
            params.page = params.page || 1;
            if (params.method === '') {
                return false;
            }
            try {
                $.getJSON(domain + '/?callback=?', params, function(_data) {
                    if (onSuccess !== '') {
                        if (typeof onSuccess(_data.data) !== 'undefined') {
                            json2.parse(onSuccess(_data.data));
                        }
                        return false;
                    }
                });
            } catch (e) {
                console.log(e.message);
            }
        },
        getShoppingKey: function() {
            var shoppingInfo = window.cookie('_g');
            var shoppingData = json2.parse(shoppingInfo);
            var spk;

            if (typeof shoppingInfo === 'undefined' || shoppingInfo === null) {
                spk = window.cookie('_SPK');
                return spk ? spk : '';
            }
            return shoppingData._k;
        }
    });
}

/**
 * 时间戳
 * @param  {[type]} v1       [description]
 * @param  {[type]} options) {               if (v1 [description]
 * @return {[type]}          [description]
 */
handlebars.registerHelper('timestamp', function() {
    return new Date().getTime();
});
/**
 * 头像
 * @param  {[type]} v1       [description]
 * @param  {[type]} options) {               if (v1 [description]
 * @return {[type]}          [description]
 */
handlebars.registerHelper('headerimg', function(headerimg) {

    if (headerimg === '') {
        return 'http://img10.static.yhbimg.com/headimg/2013/11/28/09/01cae078abe5fe320c88cdf4c220212688.gif' +
            '?imageView/2/w/100/h/100';
    } else {
        return headerimg;
    }

});
/**
 * 判断等级为3的helper
 * @param  {[type]} v1       [description]
 * @param  {[type]} options) {               if (v1 [description]
 * @return {[type]}          [description]
 */

handlebars.registerHelper('equallevelthree', function(v1, options) {

    if (v1 === '3') {
        return options.fn(this);
    } else {
        return options.inverse(this);
    }
});

/**
 * 判断不为'0'的helper
 * @param  {[type]} v1       [description]
 * @param  {[type]} options) {               if (v1 [description]
 * @return {[type]}          [description]
 */

handlebars.registerHelper('notzero', function(v1, options) {
    if (v1 !== '0') {
        return options.fn(this);
    } else {
        return options.inverse(this);
    }
});

/**
 * 获取头部banner的回调函数
 * @param {[type]} data [description]
 */
function JsonPCallBack(data) {
    var topbanner;

    if (+data.code === 200) {
        if (typeof data.data === 'object') {
            if (data.data.url !== '') {
                topbanner = '<a target="_blank" href="' + data.data.url + '" class="page-top-banner"' +
                    'style="height:36px;border:none;background-image:url(' + window.unescape(data.data.src) + ');' +
                    'background-position: center;display:block;">&nbsp;</a>';
            } else {
                topbanner = '<div class="noticewrapper">' +
                    '<div class="noticecontainer">' +
                    '<h1 class="noticetitle">关于系统升级的公告</h1>' +
                    '<div class="noticecontent">' +
                    '<p class="tips">尊敬的顾客:</p>' +
                    '<p class="detail">您好!为了向您提供更优质的服务,目前系统正在升级,请耐心等待。</p>' +
                    '<p class="detail">' +
                    '系统升级期间,部分地区用户体验会有暂时中断,如遇紧急事宜,欢迎垂询客服热线:400-889-9646 09:00-22:30(周一至周日)。稍后系统将恢复正常' +
                    '</p>' +
                    '<p class="detail">使用,欢迎您继续光顾YOHO!BUY有货!带来不便之处深表歉意,请您谅解!</p>' +
                    '</div>' +
                    '</div>' +
                    '</div>';
            }
            $('body').prepend(topbanner);
        }
    }
}

window.JsonPCallBack = JsonPCallBack;


/**
 * 获得banner数据
 * @param  {[string]} code [banner对应的编码]
 * @return {[type]}      [description]
 */
function getBannerData(code) {
    var script = document.createElement('script');

    script.src = bannerApi + code + '&client_type=web&callback=JsonPCallBack';
    document.getElementsByTagName('head')[0].appendChild(script);
}

/**
 * 显示和隐藏
 * @param  {[type]} sourceClass [description]
 * @param  {[type]} targetClass [description]
 * @return {[type]}             [description]
 */
function toggleDisplay(sourceClass, targetClass) {
    var $that,
        targetobj;

    $(sourceClass).hover(function(e) {
        e.preventDefault();
        $that = $(this);
        targetobj = $(targetClass)[0];
        if (targetobj.style.display === '') {
            $that.addClass('acttags');
            targetobj.style.display = 'block';
        } else {
            $that.removeClass('acttags');
            targetobj.style.display = '';
        }
    });
}

/**
 * 执行顶部显示和隐藏
 * @return {[type]} [description]
 */
function actionTopTagToggle() {
    var tags = [{
            sourceClass: '.myyoho',
            targetClass: '.myyoho-info'
        }, {
            sourceClass: '.phone',
            targetClass: '.qr'
        }],
        obj,
        i;

    for (i = 0; i < tags.length; i++) {
        obj = tags[i];
        toggleDisplay(obj.sourceClass, obj.targetClass);
    }
}
/**
 * 执行顶部群组鼠标交互
 * @return {[type]} [description]
 */
function actionYoHoGroup() {
    var $this;

    $('.yohogroup').mouseenter(function() {
        $this = $(this);
        $this.text($this.attr('cn'));
    });
    $('.yohogroup').mouseleave(function() {
        $this = $(this);
        $this.text($this.attr('en'));
    });
}

/**
 * 检测是否支持css3的动画
 * @return {Boolean} [description]
 */
function isSupportCss3Animation() {
    var thisFunc,
        prefixList = ['webkit', 'moz', 'ms'],
        i;

    for (i = 0; i < prefixList.length; i++) {
        thisFunc = prefixList[i] + 'RequestAnimationFrame';
        if (window[thisFunc]) {
            return true;
        } else {
            return false;
        }
    }

}
/**
 * css3动画
 * @param  {Array}  ) {               var thisFunc, prefixList [description]
 * @return {[type]}   [description]
 */
function requestFrameAct() {
    var prefixList = ['webkit', 'moz', 'ms'];
    var func1 = prefixList[0] + 'RequestAnimationFrame';
    var func2 = prefixList[1] + 'RequestAnimationFrame';
    var func3 = prefixList[2] + 'RequestAnimationFrame';

    if (window[func1]) {
        return function(callback) {
            requestAnimationFrame(callback);
        };
    }
    if (window[func2]) {
        return function(callback) {
            window[func2](callback);
        };
    }
    if (window[func3]) {
        return function(callback) {
            window[func3](callback);
        };
    }
    return function(callback) {
        window.setTimeout(callback, 67);
    };
}


/**
 * css3动画
 * @return {[type]} [description]
 */

function tsAnimate() {
    logoanimationstart += 10;
    $logotrans.css({
        transform: 'rotateX(' + logoanimationstart + 'deg)',
        '-webkit-transform': 'rotateX(' + logoanimationstart + 'deg)',
        '-moz-transform': 'rotateX(' + logoanimationstart + 'deg)'
    });
    if (logoanimationstart / 90 % 2 === 1) {
        if (isen) {
            $logotrans.css('background-image', 'url(http://static.yohobuy.com/newheader/img/logo1.png)');
            isen = false;
        } else {
            $logotrans.css('background-image', 'url(http://static.yohobuy.com/newheader/img/logo_e.png)');
            isen = true;
        }
    }
    if (logoanimationstart / 90 % 2 === 0 && logoanimationstart % 360 !== 0) {
        window.setTimeout(tsAnimate, 3000);
    } else {
        if (logoanimationstart % 360 === 0) {
            window.setTimeout(tsAnimate, 1 * 60 * 1000);
        } else {
            requestFrame(function() {
                tsAnimate();
            });
        }
    }
}

/**
 * 淡出
 * @return {[type]} [description]
 */
function fadeAnimate() {
    if (globaltimeout) {
        window.clearTimeout(globaltimeout);
    }
    $logotrans.fadeOut(loopdurationtime, function() {
        isen = false;

        $logotrans.css('background-image', 'url(http://static.yohobuy.com/newheader/img/logo.png)');
        $logotrans.fadeIn(loopdurationtime, function() {
            onetimeoout = window.setTimeout(function() {
                $logotrans.fadeOut(loopdurationtime, function() {
                    window.clearTimeout(onetimeoout);
                    isen = true;
                    $logotrans.css('background-image',
                        'url(http://static.yohobuy.com/newheader/img/logo_e.png)');
                    $logotrans.fadeIn(loopdurationtime, function() {
                        globaltimeout = window.setTimeout(fadeAnimate, 1 * 60 * 1000);
                    });
                });
            }, 3000);
        });
    });
}
/**
 * 执行头部logo动画
 * @return {[type]} [description]
 */
function actionTopLogoAnimate() {
    if (isSupportCss3Animation()) {
        requestFrame = requestFrameAct();
        window.setTimeout(tsAnimate, 3000);
    } else {
        window.setTimeout(fadeAnimate, 3000);
    }
}
window.newArr = [];
window.wrapperindex = 0;
window.gindex = 0;
window.targetArr1 = [];
window.targetArr2 = [];
window.targetArr3 = [];
window.oh1 = 0;
window.oh2 = 0;
window.oh3 = 0;
window.valueIndex = 0;
window.nowIndex = 0;
window.inner1 = '';
window.inner2 = '';
window.inner3 = '';
window.finalresult = '';

function createNewArray(obj) {
    var $thirdnavpanel = $(obj);

    $thirdnavpanel.find('.thirdnavbar').each(function() {
        var $that = $(this);
        var $alink = $that.find('a');
        var _href = $alink.attr('href');
        var hottag = $alink.attr('hot') === 'hot' ? true : false;
        var objt = {};

        if ($that.hasClass('category-title')) {
            objt = {
                type: 'title',
                height: 49,
                content: $that.text(),
                index: window.valueIndex,
                href: _href,
                hot: false
            };
        } else {
            objt = {
                type: 'catlist',
                height: 36,
                content: $alink.text(),
                index: window.valueIndex,
                href: _href,
                hot: hottag
            };
        }
        window.valueIndex++;
        window.newArr.push(objt);
    });
}

function createWrapper() {
    var arrlength = window.newArr.length;
    var i = 0;
    var objnew = [];
    var aobj = [];
    var bobj = [];
    var cobj = [];
    var final1 = '',
        final2 = '',
        final3 = '';
    var a = 0;
    var b = 0;
    var c = 0;

    for (i; i < arrlength; i++) {
        objnew = window.newArr[i];
        if (window.gindex === 0) {
            window.oh1 = (window.oh1 + objnew.height);
            if (window.oh1 >= 340 && i !== (arrlength - 1)) {
                window.targetArr1 = window.newArr.slice(0, objnew.index + 1);
                window.nowIndex = objnew.index + 1;
                window.gindex++;
            }
            if (i === (arrlength - 1)) {
                window.targetArr1 = window.newArr.slice(0, arrlength + 1);
                break;
            }
        }
        if (window.gindex === 1) {
            window.oh2 = (window.oh2 + objnew.height);
            if (window.oh2 >= 340 && i !== (arrlength - 1)) {
                window.targetArr2 = window.newArr.slice(window.nowIndex, objnew.index + 1);
                window.nowIndex = objnew.index + 1;
                window.gindex++;
            }
            if (i === (arrlength - 1)) {
                window.targetArr2 = window.newArr.slice(window.nowIndex, arrlength + 1);
                break;
            }
        }
        if (window.gindex === 2) {
            window.oh3 = (window.oh3 + objnew.height);
            if (window.oh3 >= 340 && i !== (arrlength - 1)) {
                window.targetArr3 = window.newArr.slice(window.nowIndex, objnew.index + 1);
                window.nowIndex = objnew.index + 1;
                window.gindex++;
                break;
            }
            if (i === (arrlength - 1)) {
                window.targetArr3 = window.newArr.slice(window.nowIndex, arrlength + 1);
                break;
            }
        }
    }
    for (a; a < window.targetArr1.length; a++) {
        aobj = window.targetArr1[a] || {};
        if (aobj.type === 'title') {
            window.inner1 = window.inner1 +
                '<li class="cattitle"><h3><a  href="' +
                aobj.href +
                '">' +
                aobj.content +
                '</a></h3></li>';
        } else {
            if (aobj.hot === true) {
                window.inner1 = window.inner1 +
                    '<li class="catdetail"><a  class="thirdcatelink hot" href="' +
                    aobj.href +
                    '">' +
                    aobj.content +
                    '</a></li>';
            } else {
                window.inner1 = window.inner1 +
                    '<li class="catdetail"><a  class="thirdcatelink" href="' +
                    aobj.href + '">' +
                    aobj.content +
                    '</a></li>';
            }

        }
    }
    for (b; b < window.targetArr2.length; b++) {
        bobj = window.targetArr2[b] || {};
        if (bobj.type === 'title') {
            window.inner2 = (window.inner2 +
                '<li class="cattitle"><h3><a  href="' +
                bobj.href + '">' +
                bobj.content +
                '</a></h3></li>');
        } else {
            if (bobj.hot === true) {
                window.inner2 = (window.inner2 +
                    '<li class="catdetail"><a  class="thirdcatelink hot" href="' +
                    bobj.href + '">' + bobj.content + '</a></li>');
            } else {
                window.inner2 = (window.inner2 +
                    '<li class="catdetail"><a  class="thirdcatelink" href="' +
                    bobj.href + '">' + bobj.content + '</a></li>');
            }

        }
    }
    for (c; c < window.targetArr3.length; c++) {
        cobj = window.targetArr3[c] || {};
        if (cobj.type === 'title') {
            window.inner3 = (window.inner3 +
                '<li class="cattitle"><h3><a  href="' +
                cobj.href +
                '">' +
                cobj.content +
                '</a></h3></li>');
        } else {
            if (cobj.hot === true) {
                window.inner3 = (window.inner3 +
                    '<li class="catdetail"><a  class="thirdcatelink hot" href="' +
                    cobj.href + '">' +
                    cobj.content +
                    '</a></li>');
            } else {
                window.inner3 = (window.inner3 +
                    '<li class="catdetail"><a  class="thirdcatelink" href="' +
                    cobj.href + '">' +
                    cobj.content +
                    '</a></li>');
            }

        }
    }
    if (window.inner1 !== '') {
        final1 = '<ul class="cate_row1 cate_row">' +
            window.inner1 +
            '</ul>';
    }
    if (window.inner2 !== '') {
        final2 = '<ul class="cate_row2 cate_row">' +
            window.inner2 +
            '</ul>';
    }
    if (window.inner3 !== '') {
        final3 = '<ul class="cate_row3 cate_row">' +
            window.inner3 +
            '</ul>';
    }
    window.finalresult = final1 + final2 + final3;
    $('#' + window.wrapperindex).empty().append(window.finalresult);
}

function actionNav() {
    $('.categorywrapper').each(function(index) {
        window.wrapperindex = $(this).attr('id');
        window.newArr = [];
        window.gindex = 0;
        window.targetArr1 = [];
        window.targetArr2 = [];
        window.targetArr3 = [];
        window.oh1 = 0;
        window.oh2 = 0;
        window.oh3 = 0;
        window.valueIndex = 0;
        window.nowIndex = 0;
        window.inner1 = '';
        window.inner2 = '';
        window.inner3 = '';
        createNewArray($(this).find('.category'));
        createWrapper();
    });
}

/**
 * 获取三级导航的tip图标
 * @return {[type]} [description]
 */
function actionTipPic() {
    var tipscode = {};
    var $contentcode = '';
    var $img = '';
    var $title = '';
    var $link = '';
    var logolink = '';

    $(document).on('mouseenter', '.sub-nav-item', function() {
        $contentcode = $(this).find('.showdetail').attr('data-code');
        if ($contentcode) {
            if (!tipscode[$contentcode]) {
                tipscode[$contentcode] = $contentcode;
                $img = $(this).find('.showdetail').find('img');
                $title = $(this).find('.showdetail').find('.title');
                $link = $(this).find('.showdetail').find('a');
                $.get(bannerApi + $contentcode + '&width=337&height=250&client_type=web', function(rsdata) {
                    $img.attr('src', rsdata.data.src);
                    $link.attr('href', rsdata.data.url);
                    $title.text(rsdata.data.title);
                }, 'jsonp');
            }
        }
    });
    logolink = $('.cure').find('.name-cn').find('a').attr('href');
    $('.main-link').attr('href', logolink);
}



function closeCover() {
    var $cover = $('#cover');

    $cover.remove();
}
/**
 * 首次进入有弹窗
 * @return {[type]} [description]
 */
function actionCover() {
    var gender = window.cookie('_Gender');
    var newMask = '';
    var windowheight = '';
    var selfheight = '';
    var containertop;
    var length = '';

    if (window.location.href === 'http://www.yohobuy.com/' &&
        (typeof gender === 'undefined' || gender === '' || gender === null)) {
        $.get('http://www.yohobuy.com/index/guide', function(data) {
            newMask = document.createElement('div');
            newMask.id = 'cover';
            newMask.innerHTML = data;
            document.body.appendChild(newMask);
            windowheight = $(window).height();
            selfheight = $('.guide-box').height();
            containertop = windowheight / 2 - selfheight / 2;
            length = $('.guide-box .clear').find('li').length;
            $('.guide-box').css({
                width: (200 * length) + 'px',
                top: containertop + 'px'
            });
            $('#cover').bind('click', function(event) {
                window.setCookie('_Gender', '1,3', {
                    path: '/',
                    domain: '.yohobuy.com',
                    expires: 90
                });
                window.setCookie('_Channel', 'boys', {
                    path: '/',
                    domain: '.yohobuy.com',
                    expires: 7
                });
                closeCover();
            });
            $('#cover .guide-box .close').bind('click', function(event) {
                getSource('弹窗', 'CLOSE', 'homepage_man');
                window.setCookie('_Gender', '1,3', {
                    path: '/',
                    domain: '.yohobuy.com',
                    expires: 90
                });
                window.setCookie('_Channel', 'boys', {
                    path: '/',
                    domain: '.yohobuy.com',
                    expires: 7
                });
                closeCover();
            });
            $('.boys img , .boys .go').bind('click', function(event) {
                getSource('弹窗', 'BOYS', 'homepage_man');
                window.setCookie('_Gender', '1,3', {
                    path: '/',
                    domain: '.yohobuy.com',
                    expires: 90
                });
                window.setCookie('_Channel', 'boys', {
                    path: '/',
                    domain: '.yohobuy.com',
                    expires: 7
                });
                closeCover();
            });
            $('.girls img, .girls .go').bind('click', function(event) {
                getSource('弹窗', 'GIRLS', 'homepage_woman');
                window.setCookie('_Gender', '2,3', {
                    path: '/',
                    domain: '.yohobuy.com',
                    expires: 90
                });
                window.setCookie('_Channel', 'girls', {
                    path: '/',
                    domain: '.yohobuy.com',
                    expires: 7
                });
            });
            $('.lifestyle img, .lifestyle .go').bind('click', function(event) {
                window.setCookie('_Channel', 'lifestyle', {
                    path: '/',
                    domain: '.yohobuy.com',
                    expires: 7
                });
                getSource('弹窗', 'LIEFSTYLE', 'homepage_lifestyle');
            });
            $('#cover .guide-box').bind('click', function(event) {
                event.stopPropagation();
            });
        });
    }
}
/**
 * 查询跳转后保留关键字
 * @return {[type]} [description]
 */
function actionAddKeyWords() {
    var $keywords = $('#nav_keyword').text();
    var defaultsearch = $('#defaultsearch').val();
    var $querykey = $('#query_key');

    if ($keywords !== '') {
        $querykey.css({
            color: '#000'
        });
        $querykey.val($keywords);
    } else {
        $querykey.css({
            color: '#e0e0e0'
        });
        $querykey.val(defaultsearch);
        $querykey.on('focus', function(e) {
            $querykey.css({
                color: '#000'
            });
            $querykey.val('');
        });
    }
}


/**
 * cookie 初始化
 * @return {[type]} [description]
 */
function actionInitCookie() {
    var $cookieGender = window.cookie('_Gender');
    var $target = $('.cure');

    if (typeof $cookieGender !== 'undefined' && $cookieGender !== '') {
        window.setCookie('_Gender', 1, {
            path: '/',
            domain: '.yohobuy.com',
            expires: 7
        });
    }
    if ($target.find('.name-cn a').text() === '男生') {
        window.setCookie('_Gender', '1,3', {
            path: '/',
            domain: '.yohobuy.com',
            expires: 7
        });
        window.setCookie('_Channel', 'boys', {
            path: '/',
            domain: '.yohobuy.com',
            expires: 7
        });
    }
    if ($target.find('.name-cn a').text() === '女生') {
        window.setCookie('_Gender', '2,3', {
            path: '/',
            domain: '.yohobuy.com',
            expires: 7
        });

        // window.setCookie('_Channel', 'girls', {
        //     path: '/',
        //     domain: '.yohobuy.com',
        //     expires: 7
        // });
    }
    if ($target.find('.name-cn a').text() === '创意生活') {
        window.setCookie('_Channel', 'lifestyle', {
            path: '/',
            domain: '.yohobuy.com',
            expires: 7
        });
    }
    if ($target.find('.name-cn a').text() === '潮童') {
        window.setCookie('_Channel', 'kids', {
            path: '/',
            domain: '.yohobuy.com',
            expires: 7
        });
    }
}
/**
 * 提前设置好频道的cookie
 */
function setChannelCookie() {
    $('.first-nav-item').click(function() {
        var _cookieGender = window.cookie('_Gender');

        if (typeof _cookieGender !== 'undefined' && _cookieGender !== '') {
            window.setCookie('_Gender', 1, {
                path: '/',
                domain: '.yohobuy.com',
                expires: 7
            });
        }
        if ($(this).find('.name-cn a').text() === '男生') {
            window.setCookie('_Gender', '1,3', {
                path: '/',
                domain: '.yohobuy.com',
                expires: 7
            });
            window.setCookie('_Channel', 'boys', {
                path: '/',
                domain: '.yohobuy.com',
                expires: 7
            });
        }
        if ($(this).find('.name-cn a').text() === '女生') {
            window.setCookie('_Gender', '2,3', {
                path: '/',
                domain: '.yohobuy.com',
                expires: 7
            });
            window.setCookie('_Channel', 'girls', {
                path: '/',
                domain: '.yohobuy.com',
                expires: 7
            });
        }
        if ($(this).find('.name-cn a').text() === '创意生活') {
            window.setCookie('_Channel', 'lifestyle', {
                path: '/',
                domain: '.yohobuy.com',
                expires: 7
            });
        }
        if ($(this).find('.name-cn a').text() === '潮童') {
            window.setCookie('_Channel', 'kids', {
                path: '/',
                domain: '.yohobuy.com',
                expires: 7
            });
        }
    });

}
/**
 * cookie集合
 * @type {Object}
 */
function actionExeCookieMap() {
    var cookies = document.cookie;
    var cookiearr = cookies.split(';');
    var i;
    var temparr;
    var key;

    for (i = 0; i < cookiearr.length; i++) {
        temparr = cookiearr[i].split('=');
        if (typeof temparr[0] !== 'undefined') {
            key = temparr[0].replace(/\s/g, '');
            cookieMap[key] = temparr[1];
        }
    }
}


/**
 * 购物车商品数量
 * @return {[type]} [description]
 */
function actionUpdateCartNum() {
    $('#miniCartBox').miniCart({
        cartNum: '.ic-infomation'
    });
}
/**
 * 加载购物车数据
 * @return {[type]} [description]
 */
function loadCartData() {
    var shoppingInfo,
        shoppingData,
        strK;

    $.getData(apiDomain, {
        method: 'open.Shoppingcart.getCartData',
        shopping_key: $.getShoppingKey()
    }, function(jsonData) {
        if (cartTpl === '') {
            cartTpl = handlebars.compile($('#mini-cart-tpl').html());
        }
        $('#miniCartBox').children('.gobuy-wrapper').html(cartTpl({
            carData: jsonData
        }));
        if (parseInt($('.ic-infomation').html()) === 0) {
            $('#miniCartBox .gobuy-wrapper').html('<div class="gobuy-empty">' +
                '<h3 class="information">您的购物车暂无商品</h3></div>');
        }
        if ($('#miniCartBox .goods-list li').length < 1) {
            shoppingInfo = window.cookie('_g');
            shoppingData = json2.parse(shoppingInfo);
            if (shoppingData !== null) {
                strK = '{"_k":"' + shoppingData._k + '","_nac":0' + ',"_ac":0,"_r":0}';
                window.setCookie('_g', strK, {
                    path: '/',
                    domain: '.yohobuy.com'
                });
            }
            $('.ic-infomation').html(0);
            $('#miniCartBox .gobuy-wrapper').html('<div class="gobuy-empty">' +
                '<h3 class="information">您的购物车暂无商品</h3></div>');
        }
    });
}
/**
 * 删除购物车数据
 * @param  {[type]}  id        [description]
 * @param  {Boolean} isreduce [description]
 * @return {[type]}            [description]
 */
function delCartGoods(id, isreduce) {
    $.getData(apiDomain, {
        method: 'open.Shoppingcart.delone',
        shopping_key: $.getShoppingKey(),
        id: id,
        isreduce: isreduce
    }, function(jsonData) {
        var shoppingInfo = window.cookie('_g');
        var shoppingData = json2.parse(shoppingInfo);
        var strK = '{"_k":"' + shoppingData._k + '","_nac":' + jsonData.total_goods_num + ',"_ac":0,"_r":0}';

        window.setCookie('_g', strK, {
            path: '/',
            domain: '.yohobuy.com'
        });
        loadCartData();
        actionUpdateCartNum();
    });
}


/**
 * 监听购物车删除
 * @return {[type]} [description]
 */
function actionListenDelCarGoods() {
    var $delcargoods;
    var goodsid,
        cheapest;

    $(document).on('click', '.goodscardelete', function(e) {
        $delcargoods = $(this);
        goodsid = $delcargoods.attr('goodsid');
        cheapest = $delcargoods.attr('cheapest');
        delCartGoods(goodsid, cheapest);
    });
}
/**
 * 监听点击更多打折商品
 * @return {[type]} [description]
 */
function actionListenCartMore() {
    var $morecart;

    $(document).on('click', '.mycart_i_down', function(e) {
        $morecart = $(this);
        $morecart.toggleClass('mycart_i_up');
        $('#mycartmore').slideToggle(300);
    });
}
/**
 * 点击购物车
 * @return {[type]} [description]
 */
function actionClickMiniCartBox() {
    var $target;
    var shopcarurl = 'http://www.yohobuy.com/shopping/cart';

    $('#miniCartBox').on('click', function(e) {
        $target = $(e.target);
        if ($target.hasClass('gobuy')) {
            window.location.href = shopcarurl;
        }
    });
}

/**
 * 显示购物车效果
 * @param  {Boolean} isShow [description]
 * @return {[type]}         [description]
 */
function showMiniCart(isShow) {
    if (isShow === 1) {
        $('#miniCartBox').addClass('list-cur');
        $('.gobuy-wrapper').show();
        if (parseInt($('.ic-infomation').html()) !== 0) {
            $('#miniCartBox .gobuy-wrapper').html('<div class="gobuy-loading">' +
                '<h3 class="information">加载中,请稍后</h3></div>');
            loadCartData();
        } else {
            $('#miniCartBox .gobuy-wrapper').html('<div class="gobuy-empty">' +
                '<h3 class="information">您的购物车暂无商品</h3></div>');
        }
    } else {
        $('#miniCartBox').removeClass('list-cur');
        $('.gobuy-wrapper').hide();
    }
}


/**
 * 鼠标购物车的滑入滑出效果
 * @return {[type]} [description]
 */
function actionGoodsCarMouseEffect() {
    var $target;

    $('#miniCartBox').mouseenter(function(e) {
        $target = $(e.target);
        if ($target.attr('id') === 'miniCartBox' || $target.attr('class') === 'ic-infomation') {
            showMiniCart(1);
        }
    });
    $('#miniCartBox').mouseleave(function(e) {
        showMiniCart(0);
    });
}
/**
 * 获得banner & 异常通知
 * @return {[type]} [description]
 */
function actionGetBannerAndNotice() {
    var INDEXKIDS = 'indexkids',
        INDEXLIFESTYLE = 'indexlifestyle',
        INDEXBOYS = 'indexboys',
        INDEXWOMAN = 'indexgirls',
        UNIQUEBRAND = 'uniquebrand';
    var url = window.location.href;
    var host = window.location.host;
    var code = '';
    var firstarea;

    if (url.indexOf('search') !== -1) {
        code = bannerMap['search' + cookieMap._Channel];
    }
    if (url.indexOf('list') !== -1) {
        code = bannerMap['list' + cookieMap._Channel];
    }
    if (url.indexOf('brands') !== -1) {
        code = bannerMap['brands' + cookieMap._Channel];
    }
    if (url.indexOf('new') !== -1) {
        code = bannerMap['new' + cookieMap._Channel];
    }
    if (url.indexOf('sale') !== -1) {
        code = bannerMap['sale' + cookieMap._Channel];
    }
    if (url.indexOf('home') !== -1) {
        code = bannerMap['home' + cookieMap._Channel];
    }
    if (url.indexOf('kids') !== -1) {
        code = bannerMap[INDEXKIDS];
    }
    if (url.indexOf('woman') !== -1 || url.indexOf('girls') !== -1) {
        code = bannerMap[INDEXWOMAN];
    }
    if (url.indexOf('lifestyle') !== -1) {
        code = bannerMap[INDEXLIFESTYLE];
    }
    if (url.indexOf('www.yohobuy.com') !== -1 && window.location.pathname === '/') {
        code = bannerMap[INDEXBOYS];
    }
    firstarea = host.split('.')[0];
    if (firstarea !== 'list' && firstarea !== 'search' && firstarea !== 'www' &&
        firstarea !== 'new' && firstarea !== 'item' && firstarea !== 'guang') {
        code = bannerMap[UNIQUEBRAND + cookieMap._Channel];
    }

    getBannerData(code); //获得banner信息

}

function brandSwitch(index) {
    $('.hot-brands').find('ul').stop().animate({
        opacity: 0,
        'z-index': 1
    }, 200).eq(index).animate({
        opacity: 1,
        'z-index': 2
    }, 200);
}
/**
 * 品牌左右切换
 * @return {[type]} [description]
 */
function actionBrandChange() {
    var activeIndex = 0,
        swiperLen;

    if ($('.hot-brands').size() > 0) {
        swiperLen = $('.hot-brands').find('ul').size();
        $('.hot-brands').find('ul').eq(0).css({
            opacity: 1,
            'z-index': 2
        });
        $('.brands-control').on('click', '.next', function() {
            if (activeIndex === swiperLen - 1) {
                activeIndex = 0;
            } else {
                activeIndex++;
            }
            brandSwitch(activeIndex);
        });
        $('.brands-control').on('click', '.prev', function() {
            if (activeIndex === 0) {
                activeIndex = swiperLen - 1;
            } else {
                activeIndex--;
            }
            brandSwitch(activeIndex);
        });


    }
}
/**
 * 循环检测购物车数量
 * @return {[type]} [description]
 */
function actionLoopUpdCartNum() {
    setInterval(actionUpdateCartNum, 2000);
}
/**
 * 处理模板
 * @return {[type]} [description]
 */
function actionExeTemplate() {
    var $goodcartempwarpper = $('#goodcartempwarpper');
    var resulthtml = '';

    if ($goodcartempwarpper) {
        if ($goodcartempwarpper.html()) {
            resulthtml = $('#goodcartempwarpper').html().replace(/\\/g, '');
            $('#goodcartempwarpper').html(resulthtml);
            vipInfoCombine = handlebars.compile($('#tmpl-my-login-new').html());
        }
    }
}
/**
 * 执行搜索
 * @return {[type]} [description]
 */
function actionSearch() {
    var searchDomain = 'http://search.yohobuy.com/api/suggest';

    $('#query_key').search(searchDomain);
}
/**
 * 获取登录状态
 * @return {[type]} [description]
 */
function actionLoginState(_data) {
    var timestamp = new Date().getTime();
    var noLoginHtml = '<span>Hi~</span>[<a href="http://www.yohobuy.com/signin.html" class="list-a login-out ">' +
        '请登录</a>]&nbsp;' +
        '[<a href="http://www.yohobuy.com/reg.html" class="list-a login-out" onclick="">免费注册</a>]';
    var loginHtml = '<span>Hi~<a href="http://www.yohobuy.com/home?t=' + timestamp +
        '">{{user_name}}</a></span>&nbsp;' +
        '{{#if islogin}}' +
        '[<a href="{{logout}}" class="list-a login-out">退出</a>]' +
        '{{/if}}{{#unless islogin}}' +
        '[<a href="http://www.yohobuy.com/signin.html" class="list-a login-out">请登录</a>]&nbsp;' +
        '[<a href="http://www.yohobuy.com/reg.html" onclick="" class="list-a login-out">免费注册</a>]' +
        '{{/unless}}';
    var $boxObj = $('#loginBox');
    var info = window.cookie('_UID');
    var name = _data.data.profile_name;
    var _length = 0;
    var t = 0;
    var char = '';
    var user = info.split('::');
    var userName = user[0] || ' ';
    var _logout = 'http://www.yohobuy.com/logout_';
    var islogin = '1';
    var _num = 0;
    var data = {
        user_name: name,
        logout: _logout + _data.data.token + '.html',
        random: Math.random()
    };


    loginInfoCombine = handlebars.compile(loginHtml);
    if (typeof info === 'undefined' || info === null) {
        $boxObj.html(noLoginHtml);
        return false;
    }
    if (typeof user === 'undefined' || user.length < 4) {
        $boxObj.html(noLoginHtml);
        return false;
    }

    for (t; t < userName.length; t++) {
        char = userName.substr(t, 1);
        if (/.*[\u4e00-\u9fa5]+.*$/.test(char)) {
            _length += 2;
        } else {
            _length += 1;
        }
    }
    if (_length <= 10) {
        name = userName;
    } else {
        _num = 0;
        for (t; t < userName.length; t++) {
            if (_num < 10) {
                char = userName.substr(t, 1);
                if (char !== '*') {
                    if (/.*[\u4e00-\u9fa5]+.*$/.test(char)) {
                        _num += 2;
                    } else {
                        _num += 1;
                    }
                }
                name += char;
            }
        }
        if (name.length < userName.length) {
            name += '...';
        }
    }


    if (/http:\/\//.test(user[3])) {
        _logout = user[3].replace('www.yohobuy.com', 'www.yohobuy.com');
    } else {
        _logout = 'http://www.yohobuy.com/logout_' + user[3] + '.html';
    }
    if (_data.result === -1) {
        islogin = '-1';
    }
    data.islogin = islogin;
    $boxObj.html(loginInfoCombine(data));
}
/**
 * 获得vip用户信息
 * @return {[type]} [description]
 */
function actionVipInfo(_data) {
    var vipInfo = _data.data;
    var headUrl = '';

    if (_data.result === 1) {
        if (typeof vipInfo === undefined || vipInfo.length < 1) {
            return false;
        }
        if (vipInfo.vip.curVipInfo.curLevel === '3') {
            vipInfo.vip3 = true;
        }

        $('#myYohoBox').mouseenter(function() {
            $(this).addClass('acttags');
            $('#myYohoBox .myyoho-info').show().html(vipInfoCombine(vipInfo));
            headUrl = $('.myyoho-photo img').attr('data-url');
            if ($._checkUrlState === 1) {
                $('.myyoho-photo').show().find('img').attr('src', headUrl);
                return;
            }
            if (headUrl === '' || $._checkUrl !== '') {
                return;
            }
            $.ajax({
                url: headUrl,
                type: 'GET',
                complete: function(response) {
                    if (response.status === 200 || response.status === 0) {
                        $('.myyoho-photo').show().find('img').attr('src', headUrl);
                        $._checkUrlState = 1;
                    }
                    $._checkUrl = headUrl;
                }
            });
        });
        $('#myYohoBox').mouseleave(function() {
            $(this).removeClass('acttags');
            $('#myYohoBox .myyoho-info').hide();
        });
    }
}
/**
 * 获取登录信息
 * @return {[type]} [description]
 */
function actionLoginInfo() {
    var param = {
        method: 'open.passport.get'
    };

    $.getData(apiDomain, param, function(_data) {
        if (_data.result !== -1) {
            actionLoginState(_data); // 更改登录状态
            actionVipInfo(_data); //获得vip;
        } else {
            window.setCookie('_UID', '', {
                domain: '.yohobuy.com',
                expires: -1
            });
        }
    });
}
/**
 * 初始化函数
 * @return {[type]} [description]
 */
function init() {
    actionNav(); //处理导航
    actionTipPic(); //鼠标移入后查询
    actionExeTemplate(); //处理模板
    actionCover(); //初次登录弹框
    actionInitCookie(); //初始化cookie
    setChannelCookie(); //设置频道缓存
    actionExeCookieMap(); //格式化cookie
    actionGoodsCart(); //初始化购物车插件
    actionYoHoGroup(); // yoho集团鼠标效果
    actionTopTagToggle(); // yoho上部分开关
    actionTopLogoAnimate(); //yoho logo动画
    actionGetBannerAndNotice(); // 获取banner和服务器维护提示
    actionBrandChange(); //切换品牌
    actionAddKeyWords(); //跳转后增加关键字
    actionGoodsCarMouseEffect(); //鼠标滑入滑出效果
    actionUpdateCartNum(); //更新购物车数量
    actionLoopUpdCartNum(); //循环检测购物车数量
    actionSearch(); //搜索执行
    actionClickMiniCartBox(); //点击购物车跳转
    actionListenDelCarGoods(); //监听购物车删除
    actionListenCartMore(); //
    actionLoginInfo(); //获取登录信息
    actionAddKeyWords(); //增加关键字
}
init();
});
define("js/simple-header", ["jquery"], function(require, exports, module){
var $ = require("jquery");

var $apiDom = $('#api-domain');

var apiDomain = $apiDom.val(); //获取数据的地址

$apiDom.remove(); //删除API信息

if ($('.simple-header').size() > 0) {
    $('.tool-options').on('mouseenter', function() {
        $(this).find('.tool-select').fadeIn();
    }).on('mouseleave', function() {
        $(this).find('.tool-select').fadeOut();
    });
}

/**
 * 格式化用户名
 * @return {[type]} [description]
 */
function formatUsernName(userName) {
    var name,
        char,
        _num = 0,
        _length = 0,
        t;

    for (t = 0; t < userName.length; t++) {
        char = userName.substr(t, 1);
        if (/.*[\u4e00-\u9fa5]+.*$/.test(char)) {
            _length += 2;
        } else {
            _length += 1;
        }
    }
    if (_length <= 10) {
        name = userName;
    } else {
        _num = 0;
        name = '';
        for (t = 0; t < userName.length; t++) {
            if (_num < 10) {
                char = userName.substr(t, 1);
                if (char !== '*') {
                    if (/.*[\u4e00-\u9fa5]+.*$/.test(char)) {
                        _num += 2;
                    } else {
                        _num += 1;
                    }
                }
                name += char;
            }
        }
        if (name.length < userName.length) {
            name += '...';
        }
    }
    return name;
}

/**
 * 设置简单头部登陆状态
 * @return {[type]} [description]
 */
function setLoginStatus(data) {
    var info = data.data,
        loginHtml,
        name;

    if (data.result !== -1) {
        name = formatUsernName(info.profile_name);
        loginHtml = '<span>Hi~</span>' +
                    '<a href="http://www.yohobuy.com/home?t=' + info.random + '">' + name + '</a>&nbsp;' +
                    '<a href="http://www.yohobuy.com/logout_' + info.token + '.html">[退出]</a>';
    } else {
        loginHtml = '<span>Hi~</span>&nbsp;' +
                    '<a href="http://www.yohobuy.com/signin.html">[请登录]</a>&nbsp;' +
                    '<a href="http://www.yohobuy.com/reg.html">[免费注册]</a>';
    }
    $('.header-tool li').eq(0).html(loginHtml);
}

/**
 * 获取登录信息
 * @return {[type]} [description]
 */
function actionLoginInfo() {
    var param = {
            return_type: 'jsonp',
            method: 'open.passport.get'
        };

    $.getJSON(apiDomain + '/?callback=?', param, function(_data) {
        if (_data && _data.data) {
            setLoginStatus(_data.data);
        }
    });
}

actionLoginInfo(); //获取登录信息


});
define("js/product/entry", ["jquery","handlebars","source-map","lazyload","index"], function(require, exports, module){
/**
 * 商品页面打包入口文件
 * @auhtor: xuqi<qi.xu@yoho.cn>
 * @date: 2015/12/28
 */

require("js/product/list");

require("js/product/brand");

require("js/product/hotrank");

require("js/product/item");

});
define("js/product/list", ["jquery","handlebars","source-map","lazyload"], function(require, exports, module){
/**
 * 商品列表页
 * @author: xuqi<qi.xu@yoho.cn>
 * @date: 2015/11/23
 */

require("js/product/filter");

require("js/product/sort-pager");

require("js/product/latest-walk");

require("js/product/product");
});
define("js/product/filter", ["jquery","handlebars","source-map"], function(require, exports, module){
/**
 * 商品筛选逻辑
 * @author: xuqi<qi.xu@yoho.cn>
 * @date: 2015/12/4
 */

var $ = require("jquery"),
    Handlebars = require("handlebars");

var checkUnicode = {
    unchecked: '&#xe635;',
    checked: '&#xe636;'
},
moreUnicode = {
    up: '&#xe610;',
    down: '&#xe600;'
};

//品牌相关变量
var $brandDefault = $('.brand .default'),
    $brandInput = $('#brand-search-input'),
    $brandPanel = $('.brand .brand-panel'),
    $brandAttrs = $brandPanel.find('.attr'),
    $brandMore = $('#brand-more'),
    $brandMulti = $('#brand-multi'),
    $brandsIndex = $('.brands-index');

var $brandMoreTxt, $brandMoreIcon;

//价格相关变量
var $udPrice = $('.ud-price-range'),
    interReg = /^\d+$/,
    $limit, $min, $max, $btn;

//分类相关变量
var $sortSub = $('.sort-sub-wrap');

//高级选项相关变量
var $seniorSubWrap = $('.senior-sub-wrap'),
    $seniorAttrWrap = $('.senior-attr-wrap');

var seniorHoverTime, hoveredIndex;

// 尺寸 handlebars 模板
var sizeTmpl = '{{# size}}<a class="attr {{#if checked}}checked{{/if}}" href="{{href}}">{{name}}</a>{{/ size}}',
    sizeCache = {}, // 缓存一下尺寸信息
    $sizeWrap = $('.filter-box .size');

sizeTmpl = Handlebars.compile(sizeTmpl);

//清除checkbox选中状态[页面默认checked不清空]
function clearChecked($checkbox, $checked) {
    $checkbox.each(function() {
        if ($(this).closest('.attr').hasClass('checked')) {
            return;
        }
        $(this).removeClass('checked').html(checkUnicode.unchecked);
    });
    $checked.find('.checkbox').addClass('checked').html(checkUnicode.checked);
}

//显示更多品牌面板
function brandShowMore() {
    $brandDefault.addClass('hide');
    $brandPanel.removeClass('hide');
}

//隐藏更多品牌面板
function brandHideMore() {
    $brandPanel.addClass('hide');
    $brandDefault.removeClass('hide');

    //清除索引状态
    $brandsIndex.children('span').removeClass('hover');
}

//url构造&跳转
function uriLoc(attr, val) {
    var qs = window.queryString(),
        newHref;

    qs[attr] = val;
    newHref = '?' + decodeURIComponent($.param(qs));
    window.location.href = newHref;
}

//隐藏高级选项面板
function hideSeniorPanel(index) {
    $seniorSubWrap.children('.senior-sub:eq(' + hoveredIndex + ')').addClass('hide');
    $seniorAttrWrap.children('.attr:eq(' + hoveredIndex + ')').removeClass('hover');
    hoveredIndex = -1;
}

//屏蔽筛选项双击文字选中
$('.filter-box').on('selectstart', '.attr, .brands-index span', function() {
    return false;
});

//【分类】
$('.sort-pre').on('click', 'li', function() {
    var $this = $(this),
        index = $this.index(),
        id = $this.data('id');

    if ($this.hasClass('active')) {

        // 选中时,再次点击取消选中
        $this.removeClass('active');
        $sortSub.children(':eq(' + index + ')').addClass('hide');
        $sizeWrap.addClass('hide');
        return;
    }

    $this.siblings('.active').removeClass('active');
    $this.addClass('active');

    $sortSub.children(':not(.hide)').addClass('hide');
    $sortSub.children(':eq(' + index + ')').removeClass('hide');

    if (!$sizeWrap.data('load')) {
        if (sizeCache[id]) {
            $sizeWrap.find('.attr-content').html(sizeCache[id]);
            $sizeWrap.removeClass('hide');
        } else {
            $.ajax({
                url: '/product/search/sortSize',
                data: {
                    msort: id
                }
            }).then(function(res) {
                if ($.type(res) === 'array' && res.length) {
                    sizeCache[id] = sizeTmpl({
                        size: res
                    });
                    $sizeWrap.find('.attr-content').html(sizeCache[id]);
                    $sizeWrap.removeClass('hide');
                } else {
                    $sizeWrap.addClass('hide');
                }
            });
        }
    }
});

//【品牌】
if ($brandMore.length > 0) {
    $brandMoreTxt = $brandMore.children('em');
    $brandMoreIcon = $brandMore.children('.iconfont');
}

//【品牌】多选
$brandMulti.click(function() {
    if ($brandPanel.css('display') === 'none') {

        //显示品牌面板
        $brandMore.trigger('click');
    }

    brandShowMore();
    $brandPanel.removeClass('hide').addClass('multi'); //显示出checkbox
    $(this).addClass('hide');

    //隐藏更多按钮
    $brandMore.addClass('hide');
});

//【品牌】更多
$brandMore.click(function() {
    var $this = $(this);

    if ($this.hasClass('more')) {
        brandHideMore();

        $brandMoreTxt.text('更多');
        $brandMoreIcon.html(moreUnicode.down);

        //清空搜索框和搜索结果
        $brandInput.val('').trigger('keyup');
    } else {
        brandShowMore();

        $brandMoreTxt.text('收起');
        $brandMoreIcon.html(moreUnicode.up);
    }

    $(this).toggleClass('more');
});

//【品牌】索引
$brandsIndex.on('mouseenter', 'span', function() {
    var $this = $(this),
        index = $this.data('index');

    if ($this.hasClass('hover')) {
        return;
    }
    setTimeout(function() {
        $this.siblings('span.hover').removeClass('hover');
        $this.addClass('hover');

        if ($this.index() === 0) {

            //全部
            $brandAttrs.removeClass('hide');
        } else {
            $brandAttrs.addClass('hide').filter('[data-index=' + index + ']').removeClass('hide');
        }
    }, 120);
});

//【品牌】搜索
$brandInput.keyup(function() {
    var val = $(this).val().toLowerCase();

    if (val === '') {
        $brandAttrs.removeClass('hide');
    } else {
        $brandAttrs.addClass('hide').filter('[data-key*="' + val + '"]').removeClass('hide');
    }
});

//【品牌】多选确定
$('#brand-multi-ok').click(function() {
    var val = [];

    if ($(this).hasClass('dis')) {
        return;
    }

    $brandPanel.find('span.checked').each(function() {
        val.push($(this).data('id'));
    });

    uriLoc('brand', val.join(','));
});

//【品牌/高级选项】多选取消
$('.multi-select-cancel').click(function() {
    var $panel = $(this).closest('.multi');

    if ($panel.hasClass('brand-panel')) {

        $brandMulti.removeClass('hide'); //显示多选按钮
        $brandMore.trigger('click');

        //显示出更多按钮
        $brandMore.removeClass('hide');

        //清空搜索框和搜索结果
        $brandInput.val('').trigger('keyup');
        brandHideMore();
    }

    $panel.addClass('hide').removeClass('multi');
    clearChecked($panel.find('.checkbox.checked'), $panel.find('.attr.checked')); //清除选中状态

    //确定按钮状态恢复dis
    $(this).siblings('.multi-select-ok').addClass('dis');
});

//【品牌/高级选项】checkbox
$('.check-container').on('click', '.attr', function() {
    var $this = $(this),
        $check = $this.find('.checkbox'),
        $btnOk = $this.closest('.brand-panel, .senior-sub').find('.multi-select-ok');

    $check.toggleClass('checked');

    if ($check.hasClass('checked')) {
        $check.html(checkUnicode.checked);
    } else {
        $check.html(checkUnicode.unchecked);
    }

    //更新按钮状态
    if ($check.hasClass('checked') ||
        $this.siblings('.attr').find('.checked').length > 0) {
        $btnOk.removeClass('dis');
    } else {
        $btnOk.addClass('dis');
    }
});

//【品牌/高级选项】当多选时阻止链接默认跳转
$('.brand, .senior').on('click', '.attr > a', function(e) {
    if ($(this).closest('.multi').length > 0) {
        e.preventDefault();
    }
});

// 已选中的条件,点击不刷新
$('.filter-box').on('click', 'li.checked, a.checked', function(e) {
    e.preventDefault();
});

//【价格】用户定义价格处理
if ($udPrice.length > 0) {
    $limit = $udPrice.find('.limit');
    $min = $limit.filter('.min');
    $max = $limit.filter('.max');
    $btn = $udPrice.find('.price-sure');

    //【价格】输入
    $limit.keyup(function() {
        var thisPrice = $.trim($(this).val()),
            isPriInt = interReg.test(thisPrice),
            intPrice,
            min,
            max;

        if (!isPriInt) {
            intPrice = parseInt(thisPrice, 10);
            $(this).val(isNaN(intPrice) ? '' : intPrice);
        }

        min = $.trim($min.val());
        max = $.trim($max.val());

        if (min !== '' || max !== '') {
            $btn.removeClass('hide');
        } else {
            $btn.addClass('hide');
        }
    });

    //【价格】多项查询
    $btn.click(function() {
        var min = $.trim($min.val()),
            max = $.trim($max.val()),
            tmp;

        //对于min大于max的情况,交换位置
        if (min !== '' && max !== '' && +min > +max) {
            tmp = max;
            max = min;
            min = tmp;
        }

        uriLoc('price', min + ',' + max);
    });
}

//【高级选项】鼠标移入显示子项
$seniorAttrWrap.on('mouseenter', '.attr', function() {
    var $this = $(this);
    var index = $this.index();

    if ($this.hasClass('no-sub')) {
        return;
    }
    $this.addClass('hover').siblings().removeClass('hover');

    $seniorSubWrap.children('.senior-sub:eq(' + index + ')').removeClass('hide').siblings().addClass('hide');
}).on('mouseleave', '.attr', function() {
    var $this = $(this),
        index = $this.index();

    if ($this.hasClass('no-sub')) {
        return;
    }

    hoveredIndex = index;

    seniorHoverTime = setTimeout(function() {
        hideSeniorPanel();
    }, 100);
});

//【高级选项】多选
$('.senior-sub').on('click', '.multi-select', function() {
    $(this).closest('.senior-sub').addClass('multi');
}).on('click', '.multi-select-ok', function() {
    var $btn = $(this),
        $sub = $btn.closest('.senior-sub'),
        val = [];

    if ($btn.hasClass('dis')) {
        return;
    }

    $sub.find('span.checked').each(function() {
        val.push($(this).data('id'));
    });

    uriLoc($sub.data('attr'), val.join(','));
}).on('mouseenter', function() {
    clearTimeout(seniorHoverTime);
}).on('mouseleave', function() {
    hideSeniorPanel();
});

});
define("js/product/sort-pager", ["jquery"], function(require, exports, module){
/**
 * 筛选页和列表页操作banner中的每页N个商品选择逻辑
 * @author: xuqi<qi.xu@yoho.cn>
 * @date: 2015/12/4
 */

var $ = require("jquery");

var $countPerPage = $('#count-per-page'),
    $countChose = $countPerPage.next('ul');

var SLIDETIME = 200;

$(document).click(function(e) {
    if ($(e.target).closest('.page-count').length > 0) {
        return;
    }

    $countChose && $countChose.slideUp(SLIDETIME);
});

$countPerPage.click(function() {
    if ($countChose.css('display') === 'none') {
        $countChose.slideDown(SLIDETIME);
    } else {
        $countChose.slideUp(SLIDETIME);
    }
});
});
define("js/product/latest-walk", ["jquery","handlebars","source-map","lazyload"], function(require, exports, module){
/**
 * 最近浏览取接口渲染模板
 * @author: xuqi<qi.xu@yoho.cn>
 8 @date: 2016/1/20
 */

var $ = require("jquery");
var Handlebars = require("handlebars");
var lazyLoad = require("lazyload");

var $latestWalkCount = $('#latest-walk-count');

(function() {
    var tpl;

    if ($latestWalkCount.length === 0) {
        return;
    }

    tpl = Handlebars.compile($('#latest-walk-tpl').html());

    $.ajax({
        url: 'http://itemapi.yohobuy.com/item/item/recentreview',
        dataType: 'jsonp',
        data: {
            limit: $latestWalkCount.val()
        },
        success: function(data) {
            var latestWalk = [],
                res, i, cur;

            if (data.code === 200) {
                res = data.data;

                //若无最近浏览,请隐藏容器
                if (res.length === 0) {
                    $('.latest-walk').addClass('hide');
                    return;
                }
                for (i = 0; i < res.length; i++) {
                    cur = res[i];

                    latestWalk.push({
                        href: cur.url,
                        img: cur.pic_url,
                        name: cur.product_name,
                        salePrice: cur.price,
                        marketPrice: cur.market_price
                    });
                }

                if (latestWalk.length > 0) {
                    $('#latest-walk-goods').html(tpl({
                        latestWalk: latestWalk
                    }));

                    lazyLoad($('#latest-walk-goods .lazy'));
                }
            }
        }
    });
}());
});
define("js/product/product", ["jquery","lazyload"], function(require, exports, module){
/**
 *Description: 商品列表页
 *Author: chenglong.wang@yoho.cn
 *Date: 2015/12/2
 */

var $ = require("jquery"),
    lazyLoad = require("lazyload"),
    productEvent = require("js/common/product-event");

var $goodsContainer = $('.goods-container'),
    $goodItem = $goodsContainer.find('.good-info'),
    $goodItemWrapper = $goodsContainer.find('.good-item-wrapper'),
    $goodInfoMain = $goodsContainer.find('.good-info-main'),
    $goodSelectColor = $goodsContainer.find('.good-select-color'),
    $productListNav = $('.product-list-nav'),
    productList;

lazyLoad($('img.lazy'));

/**
 * @description 初始化鼠标移入商品列表弹层效果
 * @num 每列存放商品的个数
 */
exports.init = function(num) {

    productList = null;

    $goodItem.unbind();

    productList = productEvent($goodItem, num);

    /**
     * @description 构造商品颜色列表的html结构
     * @param data 商品颜色的数组,[url: '',src: '']
     * @return json {'colorListStr': '', 'ulNum': ''}
     * */
    function createColorList(data, _from) {
        var colorListStr = '',
            len = data.length,
            row = 4, //每列ul放4个li
            col = Math.ceil(len / row), //需要几**列**ul
            i,
            j,
            index,
            ulNum = 0;

        for (i = 0; i < col; i++) {
            colorListStr += '<ul>';
            for (j = 0; j < row; j++) {
                index = i * row + j;
                if (index === len) {
                    break;
                }
                colorListStr +=
                    '<li>' +
                    '<a target="_blank" href="' + data[i * row + j].url + _from + '">' +
                    '<img src="' + data[i * row + j].src + '" data-cover="' + data[i * row + j].coverImg + '" />' +
                    '</a>' +
                    '</li>';

                if (j === row - 1) {
                    colorListStr += '</ul>';
                    ulNum++;
                }
            }
        }
        if (ulNum < col) {
            colorListStr += '</ul>';
        }
        return {
            colorListStr: colorListStr,
            ulNum: col
        };
    }

    function removeHtmlFn() {
        $goodInfoMain.html('');
        $goodSelectColor.html('');
        $goodItemWrapper.css({
            display: 'none'
        });
    }

    productList.addHandler('MouseEnter', function(event) {
        var itemMr = 10, //list的右边距
            itemMb = 35, //list的下边距
            ulStr = '',
            ulNum,
            wrapperWidth,
            diffWidth,
            wrapperX,
            wrapperY,
            wrapperPl, //鼠标移入时弹层的左内边距
            wrapperPt, //鼠标移入时弹层的上内边距
            containerPt, //商品列表容器的上内边距
            _from = event.target.attr('data-from') || '';

        $.ajax({
            type: 'POST',
            url: '/product/list/getProductPic',
            dataType: 'jsonp',
            jsonp: 'callback',
            data: {
                skn: event.target.attr('data-skn')
            }
        }).then(function(res) {
            var data = res.data,
                colorList = createColorList(data.pics, _from);

            removeHtmlFn();

            ulStr = colorList.colorListStr; //ajax请求的颜色列表
            ulNum = colorList.ulNum;//ajax请求的颜色的数量

            $goodInfoMain.append(event.targetDuplicate);
            $goodSelectColor.append($(ulStr));

            // 点击收藏商品不需要了
            // if (data.isFavorite) {
            //     $goodInfoMain.find('.col-btn').addClass('coled');
            // } else {
            //     $goodInfoMain.find('.col-btn').removeClass('coled');
            // }

            wrapperPl = $goodItemWrapper.css('paddingLeft');
            wrapperPt = $goodItemWrapper.css('paddingTop');
            containerPt = $goodsContainer.css('paddingTop');

            wrapperWidth = 10 + (15 + 50) * ulNum + event.targetWidth;

            //wrapperWidth = $goodItemWrapper.width();

            wrapperX = (event.targetX - 1) * (event.targetWidth + itemMr) - (parseInt(wrapperPl) + 1);
            wrapperY = (event.targetY - 1) *
            (event.targetHeight + itemMb) + parseInt(containerPt) - (parseInt(wrapperPt) + 1);

            //todo
            //event.offsetR表示当前列表距离浏览器右侧边缘的距离
            diffWidth = event.offsetR - ((15 + 50) * ulNum + 25);

            if (diffWidth <= 0) {
                wrapperX = wrapperX + diffWidth - 25;
            }
            $goodItemWrapper.css({
                width: wrapperWidth,
                left: wrapperX,
                top: wrapperY,
                display: 'inline-block'
            });

            // 鼠标悬浮获取到商品信息后显示第一张图片
            if (data.pics[0] && data.pics[0].src) {
                $goodInfoMain.find('.good-thumb img').attr('src', data.pics[0].src);
            }
        });
    });

    $goodItemWrapper.mouseleave(function() {

        removeHtmlFn();
    });

};

//鼠标放在颜色列表上效果
$(document).on('hover', '.good-select-color li', function() {
    var coverImg = $(this).find('img').attr('data-cover'),
        $coverImg = $(this).closest('.good-item-wrapper').find('.good-detail-img').find('img');

    $coverImg.attr('src', coverImg);
});

// 后端不做接口,杨阳和产品确认过,点击收藏商品不需要了。2016.2.23
// $goodInfoMain.on('click', '.col-btn', function() {
//     var $this = $(this);
//
//     $.ajax({
//         type: 'POST',
//         url: '/product/list/changeFavorite',
//         dataType: 'jsonp',
//         data: {
//             skn: $this.closest('.good-info').data('skn'),
//             isFavorite: $this.hasClass('coled')
//         }
//     }).then(function(res) {
//         if (res.code === 200) {
//             $this.toggleClass('coled');
//         } else if (res.code === 403) {
//             location.href = 'http://www.yohobuy.com/signin.html?refer=' + encodeURIComponent(location.href);
//         }
//     });
// });

// 左侧导航
$productListNav.find('h3').click(function(event) {
    var $this = $(this).closest('.product-list-nav');

    if ($this.hasClass('active')) {

        $this.find('.sort-child-list').stop(true, true).slideUp();

    } else {

        $this.find('.sort-child-list').stop(true, true).slideDown();
    }

    $this.toggleClass('active');
});

});
define("js/common/product-event", ["jquery"], function(require, exports, module){
/**
 *Description: 商品自定义事件
 *Author: chenglong.wang@yoho.cn
 *Date: 2015/12/3
 */

var $ = require("jquery");

function ProductEvent() {

    this.handlers = {};

}

ProductEvent.prototype = {

    constructor: ProductEvent,

    addHandler: function(type, handler) {
        if (typeof this.handlers[type] === 'undefined') {
            this.handlers[type] = [];
        }
        this.handlers[type].push(handler);
    },

    fire: function(event) {
        var handlers,
            i;

        if (!event.target) {

            event.target = this;
        }
        if (this.handlers[event.type] instanceof Array) {
            handlers = this.handlers[event.type];
            for (i = 0; i < handlers.length; i++) {
                handlers[i](event);
            }
        }
    },

    removeHandler: function(type, handler) {
        var handlers,
            i;

        if (this.handlers[type] instanceof Array) {
            handlers = this.handlers[type];
            for (i = 0; i < handlers.length; i++) {
                if (handlers[i] === handler) {
                    break;
                }
            }
            handlers.splice(i, 1);
        }
    }
};

module.exports = function($o, rowWidth) {

    var pMouseHover = new ProductEvent();

    var targetWidth = $o.eq(0).width(),
        targetHeight = $o.eq(0).height(),
        winW = $(window).width();

    function handleEvent(event) {
        var $target,
            targetX = 0,
            targetY = 0,
            rowW = rowWidth,
            activeIndex = 0,
            $targetDuplicate = '',
            offsetL = 0,
            offsetR = 0;


        switch (event.type) {
            case 'mouseenter':

                $target = $(this);
                $targetDuplicate = $target.clone();
                activeIndex = $target.index() + 1;
                targetX = (activeIndex % rowW) === 0 ? rowW : activeIndex % rowW;
                targetY = Math.ceil(activeIndex / rowW);
                offsetL = $target.offset().left;
                offsetR = winW - (offsetL + targetWidth);

                pMouseHover.fire({
                    type: 'MouseEnter',
                    target: $target,
                    targetWidth: targetWidth,
                    targetHeight: targetHeight,
                    targetX: targetX,
                    targetY: targetY,
                    rowWidth: rowW,
                    activeIndex: activeIndex,
                    targetDuplicate: $targetDuplicate,
                    offsetL: offsetL,
                    offsetR: offsetR
                });
                break;
            case 'mouseleave':
                pMouseHover.fire({
                    type: 'MouseLeave'
                });
                break;
        }
    }

    $o.bind('mouseenter', handleEvent);

    return pMouseHover;
};
});
define("js/product/brand", ["jquery"], function(require, exports, module){
/**
 * 品牌页面
 * @auhtor: bikai<kai.bi@yoho.cn>
 * @date: 2016/1/21
 */

var $ = require("jquery");

var $brandFavor = $('#brand-favor'),
    id = $brandFavor.data('id');

$brandFavor.on('click', function() {
    $.ajax({
        type: 'post',
        url: '/product/index/favoriteBrand',
        data: {
            brandId: id
        }
    }).then(function(res) {
        if (res.code === 200) {
            if (res.message === 'add') {
                $brandFavor.find('i').addClass('coled');
            } else {
                $brandFavor.find('i').removeClass('coled');
            }
        } else if (res.code === 403) {
            location.href = 'http://www.yohobuy.com/signin.html?refer=' + encodeURIComponent(location.href);
        }
    });
});

//页面进入更新收藏状态
$.ajax({
    type: 'POST',
    url: '/product/index/isFavoriteBrand',
    data: {
        brandId: id
    }
}).then(function(data) {
    if (data.code === 200) {

        //已收藏
        $brandFavor.find('i').addClass('coled');
    } else if (data.code === 404) {

        //未收藏
        $brandFavor.find('i').removeClass('coled');
    }
});

});
define("js/product/hotrank", ["jquery","handlebars","source-map","lazyload"], function(require, exports, module){
/**
 * 首页
 * @author: liuyue<yue.liu@yoho.cn>
 * @date: 2015/12/17
 */

var $ = require("jquery"),
    Handlebars = require("handlebars"),
    lazyLoad = require("lazyload");

require("js/common/slider");
require("js/common/logo-brand");

lazyLoad($('img.lazy'));
$('.slide-container').slider();
$('.logo-brand').logoBrand({
    showNum: 10,
    url: $('.logo-brand').data('url')
});

/*
 * 一周热卖
 */
(function($) {
    var floatlayer = $('.hot-week').find('.floatlayer'),
        sid = $('.hot-cate').find('li').eq(0).data('sid'),
        weekOffsetTop,
        source,
        template,
        page = 1,
        hotCateW = 0,
        weekEnd = false;

    source = '\{{# list}}' +
        '<div class="good-info">' +
            '<div class="item-img">' +
                '<a class="good-thumb" target="_blank" href="\{{url}}">' +
                    '<img class="lazy" data-original="\{{thumb}}">' +
                '</a>' +
            '</div>' +
            '<div class="good-detail-text">' +
                '<a target="_blank" href="{{url}}">{{name}}</a>' +
                '<p class="price">' +
                    '{{# marketPrice}}<span class="market-price">¥{{.}}</span>{{/ marketPrice}} ' +
                    '<span class="sale-price{{#unless marketPrice}}prime-cost{{/unless}}">' +
                    '¥{{salePrice}}</span>' +
                '</p>' +
            '</div>' +
        '</div>' +
        '{{/ list}}';

    //监听滚动事件,控制浮层样式及下拉加载更多
    $(window).on('scroll', function() {
        var maxH = weekOffsetTop + $('.hot-week').outerHeight(),
            sid;

        //热卖右侧浮动导航位置
        weekOffsetTop = $('.hot-week').offset().top;
        if ($(this).scrollTop() >= weekOffsetTop - $(window).height() / 2) {
            if (floatlayer.offset().top + floatlayer.outerHeight() >= maxH) {
                floatlayer.css({
                    position: 'absolute',
                    marginTop: 0,
                    top: $('.hot-week').outerHeight() - floatlayer.outerHeight()
                });
            } else {
                floatlayer.css({
                    marginTop: -floatlayer.height() / 2
                }).stop().animate({
                    opacity: 1
                }, 200, function() {
                    floatlayer.show();
                });
            }

        } else {
            floatlayer.stop().animate({
                opacity: 0
            }, 200, function() {
                floatlayer.hide();
            });
        }

        if (floatlayer.offset().top >= $(this).scrollTop() + ($(window).height() - floatlayer.outerHeight()) / 2) {
            floatlayer.css({
                position: 'fixed',
                marginTop: -floatlayer.height() / 2,
                top: '50%'
            });
        }

        //下拉加载
        if ($(this).scrollTop() >= weekOffsetTop + $('.hot-week').height() - $(window).height()) {
            if (!weekEnd) {
                sid = $('.hot-cate').find('li.current').data('sid');
                page++;
                weekEnd = true; //防止多次请求
                weekAjax(sid, page);
            }
        }

    });

    //热卖横导航及竖导航的超出显示控制
    $('.hot-cate').find('li').each(function(i) {
        var maxW = $('.hot-cate').width();

        if (hotCateW <= maxW) {
            hotCateW = hotCateW + $(this).width();
            if (hotCateW >= maxW) {
                $('.floatlayer').find('li').eq(i).hide().nextAll().hide();
            }
        }

    });

    //热卖横导航点击事件处理
    $('.hot-cate').on('click', 'li', function() {
        var nowIndex = $(this).index(),
            sid = $(this).data('sid');

        if ($(this).hasClass('current')) {
            return;
        }

        //处理current样式
        $(this).addClass('current').siblings().removeClass('current');
        $('.floatlayer').find('li').removeClass('current').eq(nowIndex).addClass('current');

        //返回热卖顶部,110为floor-header所占高度
        $('body,html').stop().animate({
            scrollTop: weekOffsetTop - 110
        }, 500);

        //调用ajax请求函数,重置page,weekEnd
        weekAjax(sid);
        page = 1;
    });

    //热卖右侧悬浮导航点击事件处理
    $('.floatlayer').on('click', 'li', function() {
        var nowIndex = $(this).index();

        if ($(this).hasClass('current')) {
            return;
        }

        $('.hot-cate').find('li').eq(nowIndex).trigger('click');

        //处理current样式
        $(this).addClass('current').siblings().removeClass('current');
        $('.hot-cate').find('li').removeClass('current').eq(nowIndex).addClass('current');
    });

    /*
     * 热卖内容ajax请求
     * param: sid(ajax请求的id), page(ajax请求的页码)
     */
    function weekAjax(sid, page) {
        var param = {};

        if (page) {
            param = {
                sid: sid,
                page: page
            };
        } else {
            param = {
                sid: sid
            };
        }
        $.ajax({
            type: 'GET',
            dataType: 'json',
            url: '/product/index/getdata',
            data: param,
            success: function(res) {
                var data;

                if (res.code === 200) {
                    data = {
                        list: res.data
                    };

                    //mustache渲染数据,并替换原内容
                    template = Handlebars.compile(source);
                    if (page) {
                        $('.hot-week-list').append(template(data));
                        floatlayer.css({
                            position: 'fixed',
                            marginTop: -floatlayer.height() / 2,
                            top: '50%'
                        });
                    } else {
                        $('.hot-week-list').html(template(data));
                    }

                    lazyLoad($('img.lazy'));
                    weekEnd = false;
                }
            }
        });
    }

    //热卖中导航current类处理
    $('.hot-cate').find('li').eq(0).addClass('current');
    $('.floatlayer').find('li').eq(0).addClass('current');
})($);

});
define("js/common/slider", ["jquery","lazyload"], function(require, exports, module){
/**
 * 首页banner轮播
 * @author: liuyue(yue.liu@yoho.cn)
 * @date: 2015/12/04
 */

var $ = require("jquery"),
    lazyLoad = require("lazyload");

(function($) {
    var Slider = function(element, options) {
        this.$element = $(element);
        this.options = $.extend({}, $.fn.slider.defaults, options);
        this.bigItem = this.$element.find('.slide-wrapper').find('li');
        this.smallItem = null;
        this.len = this.bigItem.size();
        this.index = 0;
        this.timer = null;
        this.init();
    };

    Slider.prototype = {
        init: function() {
            if (!this.$element) {
                return;
            }

            if (this.len <= 1) {
                lazyLoad(this.$element.find('img.lazy'));
                return;
            }
            if (!!this.options.pagination) {
                this.smallItem = $(this.options.pagination).find('li');
            } else {
                this._createPage();
            }

            if (this.options.orient) {
                this._createOrient();
            }
            this._slideShow();
            this._bindEvent();
            this._autoplay();
        },
        _createOrient: function() {

            var orientHtml = '<div class="slide-switch">' +
                    '<a class="prev" href="javascript:;"><span class="iconfont">&#xe60c;</span></a>' +
                    '<a class="next" href="javascript:;"><span class="iconfont">&#xe60b;</span></a>' +
                '</div>';

            if (this.$element.find('.slide-switch').length > 0) {
                return;
            }

            this.$element.append(orientHtml);
        },
        _createPage: function() {
            var pageHtml = '<div class="slide-pagination"><div class="slide-pagination-inner">' +
                            '<div class="slide-shade"></div><div class="slide-pagination-last">',
                i = 0;

            if (this.len <= 1) {
                return;
            }
            for (i = 0; i < this.len; i++) {
                pageHtml += '<span></span>';
            }
            pageHtml += '</div></div></div>';
            this.$element.append($(pageHtml));
            this.smallItem = this.$element.find('.slide-pagination-inner span');
        },
        _bindEvent: function() {
            var that = this;

            this.$element.find('.slide-switch').on('click', '.next', function() {
                that._nextSlide();
                clearInterval(that.timer);
                that.timer = setInterval(function() {
                    that._nextSlide();
                }, that.options.time);
            }).on('click', '.prev', function() {
                that._prevSlide();
                clearInterval(that.timer);
                that.timer = setInterval(function() {
                    that._nextSlide();
                }, that.options.time);
            });

            this.smallItem.on('mouseenter', function() {
                that.index = $(this).index();
                clearInterval(that.timer);
                that._slideShow();
            }).on('mouseleave', function() {
                that._autoplay();
            });

            this.$element.on('mouseenter', function() {
                $(this).find('.slide-switch').addClass('show');
            }).on('mouseleave', function() {
                $(this).find('.slide-switch').removeClass('show');
            });
        },
        _nextSlide: function() {
            if (this.index === this.len - 1) {
                this.index = 0;
            } else {
                this.index++;
            }
            this._slideShow();
        },
        _prevSlide: function() {
            if (this.index === 0) {
                this.index = this.len - 1;
            } else {
                this.index--;
            }
            this._slideShow();
        },
        _slideShow: function() {
            var $img = this.bigItem.eq(this.index).find('img.lazy');

            //未加载图片的及时显示
            if ($img.attr('src') !== $img.data('original')) {
                lazyLoad($img, {
                    event: 'sporty'
                });
                $img.trigger('sporty');
            }

            this.smallItem.eq(this.index).addClass('focus').siblings().removeClass('focus');
            this.bigItem.eq(this.index).show().stop().animate({
                opacity: 1
            }, function() {

                //修正IE下切换时文字会重叠的问题
                $(this).find('.slide-tips > p').removeClass('hide');
            }).siblings().stop().animate({
                opacity: 0
            }, function() {
                $(this).hide().find('.slide-tips > p').addClass('hide');
            });
        },
        _autoplay: function() {
            var that = this;

            clearInterval(this.timer);
            this.timer = setInterval(function() {
                that._nextSlide();
            }, this.options.time);
        }
    };
    $.fn.slider = function(option) {
        return this.each(function() {
            var $this = $(this),
                data = $this.data('Slider'),
                options = typeof option === 'object' && option;

            if (!data) {
                $this.data('Slider', (data = new Slider(this, options)));
            }
            if (typeof option === 'string') {
                data[option]();
            }
        });
    };
    $.fn.slider.Constructor = Slider;
    $.fn.slider.defaults = {
        time: 5000,
        orient: true, //左右切换箭头的显示
        pagination: null
    };
})($);
});
define("js/common/logo-brand", ["jquery","handlebars","source-map","lazyload"], function(require, exports, module){
/**
 * 首页优选品牌js
 * @author: liuyue(yue.liu@yoho.cn)
 * @date: 2015/12/08
 */

var $ = require("jquery"),
    Handlebars = require("handlebars"),
    lazyLoad = require("lazyload");

(function($) {
    var LogoBrand = function(element, options) {
        this.$element = $(element);
        this.options = $.extend({}, $.fn.logoBrand.defaults, options);

        this.init();
    };

    LogoBrand.prototype = {
        init: function() {
            this.$element.addClass('logos-' + this.options.showNum);
            this._sendRequest();
        },
        _createHelper: function() {
            var showNum = this.options.showNum;

            Handlebars.registerHelper('brandList', function(items, options) {
                var out = '<ul>',
                    i = 0,
                    item = null,
                    fillNum = 0;

                //不是每页显示个数的倍数,填充数据
                if (items.length % showNum !== 0) {
                    fillNum = showNum - (items.length % showNum);
                    for (i = 0; i < fillNum; i++) {
                        items.push({
                            href: 'javascript:;',
                            img: ''
                        });
                    }
                }

                for (i = 0; i < items.length; i++) {
                    item = options.fn(items[i]);

                    if (i % showNum === 5 || i === 5) {

                        //插入切换按钮的位置
                        out = out + '<li class="logo-brand-switch" data-page="' + Math.floor(i / showNum) + '">' +
                                    '<a class="prev iconfont" href="javascript:;">&#xe60f;</a>' +
                                    '<a class="next iconfont" href="javascript:;">&#xe60e;</a></li>' +
                                    '<li data-page="' + Math.floor(i / showNum) + '">' + item + '</li>';
                    } else if (i !== 0 && i % showNum === 0) {

                        //插入more的位置,more占的是下一页第一个brand的位置,所以page是i/17
                        out = out + '<li class="brand-more" data-page="' + Math.floor(i / (showNum + 1)) + '">' +
                                    '<a href="javascript:;" target="_blank">MORE ></a></li>' +
                                    '<li data-page="' + Math.floor(i / showNum) + '">' + item + '</li>';
                    } else {
                        out = out + '<li data-page="' + Math.floor(i / showNum) + '">' + item + '</li>';
                    }
                }

                //加上最后一个more, more占的是下一页第一个brand的位置,这里已经循环不到brand,所以加在末尾
                return out + '<li class="brand-more" data-page="' + Math.floor(i / (showNum + 1)) + '">' +
                            '<a href="javascript:;" target="_blank">MORE ></a></li></ul>';

            });
        },
        _sendRequest: function() {
            var that = this;

            $.ajax({
                type: 'GET',
                url: that.options.url,
                dataType: 'json',
                success: function(data) {
                    var brandTpl,
                        brandHtml;

                    if (!data || data.length === 0) {
                        return;
                    }

                    that._createHelper();
                    brandHtml = '\{{#brandList logoBrand}}' +
                        '<a href="\{{href}}" target="_blank"><img class="lazy" data-original="\{{img}}" alt=""></a>' +
                        '\{{/brandList}}';
                    brandTpl = Handlebars.compile(brandHtml);
                    that.$element.html(brandTpl(data));
                    that.$element.find('.brand-more a').attr('href', data.moreBrand);
                    lazyLoad(that.$element.find('img.lazy'));
                    that._bindEvent();
                }
            });
        },
        _brandShow: function(hidePage, showPage) {
            var that = this;

            lazyLoad($('li[data-page=' + showPage + ']').find('img.lazy').trigger('appear'));
            that.$element.find('li[data-page=' + hidePage + ']').find('img').fadeOut('normal', function() {
                that.$element.find('li').hide();
                that.$element.find('li[data-page=' + showPage + ']').show().find('img').fadeIn();
            });
        },
        _bindEvent: function() {
            var that = this;

            that.$element.on('click', '.next', function() {
                var page = $(this).parent().data('page'),
                    nextPage = 0,
                    totalPage = Math.ceil(that.$element.find('li').size() / (that.options.showNum + 2)) - 1;

                if (page === totalPage) {
                    nextPage = 0;
                } else {
                    nextPage = page + 1;
                }
                that._brandShow(page, nextPage);
            });

            that.$element.on('click', '.prev', function() {
                var page = $(this).parent().data('page'),
                    prevPage = 0,
                    totalPage = Math.ceil(that.$element.find('li').size() / (that.options.showNum + 2)) - 1;

                if (page === 0) {
                    prevPage = totalPage;
                } else {
                    prevPage = page - 1;
                }
                that._brandShow(page, prevPage);
            });
        }
    };
    $.fn.logoBrand = function(option) {
        return this.each(function() {
            var $this = $(this),
                data = $this.data('LogoBrand'),
                options = typeof option === 'object' && option;

            if (!data) {
                $this.data('LogoBrand', (data = new LogoBrand(this, options)));
            }
            if (typeof option === 'string') {
                data[option]();
            }
        });
    };
    $.fn.logoBrand.Constructor = LogoBrand;
    $.fn.logoBrand.defaults = {
        showNum: 16,
        url: '/boys/getBrand'
    };
})($);
});
define("js/product/item", ["jquery","lazyload","handlebars","source-map","index"], function(require, exports, module){
/**
 * 商品详情页
 * @author: xuqi<qi.xu@yoho.cn>
 * @date: 2015/12/23
 */

var $ = require("jquery"),
    lazyLoad = require("lazyload"),
    Handlebars = require("handlebars"),
    JSON2 = require("index");

var $imgShow = $('#img-show'),
    $thumbs = $('#thumbs > .thumb-wrap');

var $size = $('#sizes'),
    $sizes = $size.children('.size'),
    $sizeWarn = $size.find('.size-warn'),
    $colorSizeTip = $size.children('.color-size-tip');

var $num = $('#num'),
    $plusNum = $('#plus-num'),
    $minusNum = $('#minus-num');

var $addToCart = $('#add-to-cart'),
    $soldOut = $('#sold-out');

var $lcContainer = $('.lc-container'),
    $itemBuy = $('.item-buy');

var $descColor = $('#desc-color');

var thumbsLoaded = {};

var $main = $('.main'),
    id = $main.data('id');

var maxStock = -1; //记录当前选中的颜色-尺码的库存量,若为-1,代表未选择尺码

var SLIDETIME = 200;

var colTxt = {
    def: '收藏商品',
    coled: '已收藏',
    hover: '取消收藏'
};

var Alert = require("js/common/dialog").Alert;

require("js/product/latest-walk");

require("js/common/share");

function imgShow(src) {
    $imgShow.attr('src', src);
}

/**
 * 获取当前选择的商品数目
 * @return [Number]
 */
function getNum() {
    return +$num.text();
}

//重置Num显示为1
function resetNum() {
    $num.text('1');

    //+-按钮状态重置
    if (maxStock === 1 || maxStock === 0) {

        //数目为1/0时
        $plusNum.addClass('dis');
        $minusNum.addClass('dis');
    } else {
        $plusNum.removeClass('dis');
        $minusNum.addClass('dis');
    }
}

//加入购物车和已售罄状态控制
function switchBtnStatus($color) {
    if ($itemBuy.length === 0) {

        //全部售罄,按钮状态不变
        return;
    }

    //选中的商品存量为0或者某个颜色的total为0
    if (maxStock === 0 || ($color && ~~$color.data('total') === 0)) {
        $itemBuy.addClass('hide'); //隐藏加入购物车、即将开始、立即购买等相同位置的按钮
        $soldOut.removeClass('hide');
    } else {

        //包括默认的-1情况下
        $itemBuy.removeClass('hide');
        $soldOut.addClass('hide');
    }
}

//size warn
function showSizeWarn() {
    $sizes.not('.hide').children('.size-warn').removeClass('hide');
}

//size title
(function() {
    var $sizeTitleJson = $('#size-title-json'),
        jsonHtml = $sizeTitleJson.html(),
        sizeTitle;

    if (jsonHtml === '') {
        return;
    }

    sizeTitle = JSON2.parse(jsonHtml);

    //数据获取后删除
    $sizeTitleJson.remove();

    $sizes.children('li').each(function() {
        var $this = $(this),
            key = $this.data('name');

        $this.data('title', sizeTitle[key]);
    });
}());

//初始化thumbsLoaded
thumbsLoaded[$('.colors .focus').index()] = true;

//品牌收藏
$('#brand-favour').click(function() {
    var $this = $(this);

    $.ajax({
        type: 'POST',
        url: '/product/index/favoriteBrand',
        data: {
            brandId: $this.data('id')
        }
    }).then(function(data) {
        if (data.code === 200) {
            $this.toggleClass('coled');
        } else if (data.code === 403) {
            location.href = data.data.url;
        }
    });
});

//颜色
$('.colors').on('click', 'li', function() {
    var $this = $(this),
        index = $this.index();

    var $imgs;

    //初始化color-size显示或隐藏
    $colorSizeTip.addClass('hide');

    //隐藏尺码提示
    $sizeWarn.addClass('hide');

    maxStock = -1;

    if ($this.hasClass('focus')) {

        //已获取焦点的颜色再次点击,清除尺码的选中
        $sizes.eq(index).children('li').removeClass('focus');
    } else {

        //未获取焦点,选择尺码
        $this.siblings('.focus').removeClass('focus');
        $this.addClass('focus');

        //切换图片显示
        $thumbs.not('.hide').addClass('hide');
        $imgs = $thumbs.eq(index).removeClass('hide').find('img');

        if (typeof thumbsLoaded[index] === 'undefined') {

            //trigger layLoad
            lazyLoad($imgs, {
                event: 'sporty'
            });

            $imgs.trigger('sporty');

            thumbsLoaded[index] = true;
        }

        imgShow($imgs.first().data('shower'));

        //切换详细信息的颜色显示
        $descColor.text($this.data('color'));

        //切换尺码显示
        $sizes.not('.hide').addClass('hide');
        $sizes.eq(index).removeClass('hide').children('li').removeClass('focus');
    }

    resetNum();
    switchBtnStatus($this);
});

//缩略图鼠标移入显示
$('#thumbs').on('mouseenter', '.thumb', function() {
    imgShow($(this).data('shower'));
});

//尺码
$size.on('click', 'li', function() {
    var $this = $(this);

    if ($this.hasClass('focus')) {
        return;
    }

    maxStock = +$this.data('num');

    $this.siblings('.focus').removeClass('focus');
    $this.addClass('focus');

    $colorSizeTip.html($this.data('title')).removeClass('hide');

    $sizeWarn.addClass('hide');

    switchBtnStatus();

    resetNum();
}).on('click', '.size-ruler', function() {

    //尺码帮助

    $('body,html').animate({
        scrollTop: $('.size-info').offset().top
    }, 300);
});

//数量
$plusNum.click(function() {
    var num = getNum();

    if ($(this).hasClass('dis')) {
        return;
    }

    if (maxStock === -1) {
        showSizeWarn();//显示选择尺码提示
        return;
    }

    //已售罄
    if (maxStock === 0) {
        return;
    }

    if (num === maxStock - 1) {

        //+按钮不可点
        $(this).addClass('dis');
    }

    //数目为1时点+则移除-不可点状态
    if (num === 1) {
        $minusNum.removeClass('dis');
    }

    $num.text(num + 1 > maxStock ? maxStock : num + 1);
}).on('selectstart', function() {
    return false;
});

$minusNum.click(function() {
    var num = getNum();

    if ($(this).hasClass('dis')) {
        return;
    }

    if (num === 2) {
        $(this).addClass('dis');
    }

    if (num === maxStock) {

        //恢复+可点
        $plusNum.removeClass('dis');
    }

    $num.text(num - 1 < 0 ? 0 : num - 1);
}).on('selectstart', function() {
    return false;
});

//限购码
$('.get-lc:not(.dis)').hover(function() {
    $lcContainer.removeClass('hide');
}, function() {
    $lcContainer.addClass('hide');
});

//加入购物车
$addToCart.click(function() {
    if (maxStock === -1) {
        showSizeWarn();
        return;
    }

    $.ajax({
        type: 'POST',
        url: '/cart/index/add',
        data: {
            productSku: $('.size li.focus').data('sku'),
            buyNumber: getNum()
        }
    }).then(function(data) {
        var code = data.code;

        if (code === 200) {
            $('#type-chose').slideUp(SLIDETIME);
            $('#balance').slideDown(SLIDETIME);

            $('#cart-num').text(data.data.goods_count); //更新数目
        }
    });
});

//收藏
$('#collect-product').click(function() {
    var $this = $(this),
        cancel;

    if ($this.hasClass('coled')) {
        cancel = true;
    }

    $.ajax({
        type: 'POST',
        url: '/product/item/togglecollect',
        data: {
            productId: id,
            type: cancel ? 'cancel' : 'add'
        }
    }).then(function(data) {
        var code = data.code;

        if (code === 200) {

            $this.toggleClass('coled');

            if (cancel) {
                $this.find('em').text(colTxt.def);
            } else {
                $this.find('em').text(colTxt.coled);
            }
        } else if (code === 403) {
            location.href = data.data.url;
        }
    });
}).hover(function() {
    var $this = $(this);

    if ($this.hasClass('coled')) {
        $this.find('em').text(colTxt.hover);
    }
}, function() {
    var $this = $(this);

    if ($this.hasClass('coled')) {
        $this.find('em').text(colTxt.coled);
    }
});

//继续购物
$('#keep-shopping').click(function() {
    $('#type-chose').slideDown(SLIDETIME);
    $('#balance').slideUp(SLIDETIME);
});

//立即购买
$('#buy-now').click(function() {
    var sku,
        base,
        myAlert;

    if (maxStock === -1) {
        showSizeWarn();
        return;
    }

    if ($(this).hasClass('dis')) {
        return;
    }

    base = $(this).data('base');

    //潮流尖货
    if (!base) {
        myAlert = new Alert('打开APP可抢购该商品哦~~');
        myAlert.show();
        return;
    }

    sku = $sizes.find('.focus').data('sku');

    if (sku && base) {
        location.href = base + '?product_sku=' + sku;
    }
});

//按钮鼠标移入效果【dis状态的按钮状态不变】
$('.buy-btn').mouseover(function() {
    if ($(this).hasClass('dis')) {
        return;
    }

    $(this).addClass('hover');
}).mouseleave(function() {
    $(this).removeClass('hover');
});

//商品详情/材质洗涤切换
$('.description-material').on('click', '.title', function() {
    var $this = $(this),
        index = $this.index();

    var $description = $('.description-content'),
        $material = $('.material-content');

    if ($this.hasClass('cur')) {
        return;
    }

    $this.addClass('cur');
    $this.siblings('.cur').removeClass('cur');

    if (index === 0) {

        //商品信息
        $description.slideDown(SLIDETIME);
        $material.slideUp(SLIDETIME);
    } else {
        $description.slideUp(SLIDETIME);
        $material.slideDown(SLIDETIME);
    }
});

//售后服务
$('.after-service-switch').click(function() {
    var $this = $(this),
        $content = $this.next('.after-service-content');

    var html = {
        def: '&#xe604;',
        spread: '&#xe603;'
    };

    if ($content.css('display') === 'none') {
        $content.slideDown(SLIDETIME);

        $this.find('.triangle').html(html.spread);
    } else {
        $content.slideUp(SLIDETIME);

        $this.find('.triangle').html(html.def);
    }
});


//商品详情区的热点
$.ajax({
    type: 'GET',
    url: '/product/item/hotarea',
    data: {
        productId: id
    }
}).then(function(html) {
    $('#details-html').prepend(html);

    //Bind Hover event
    $('.hot-point').hover(function() {
        $(this).addClass('hover');
    }, function() {
        $(this).removeClass('hover');
    });
});

//商品详情懒加载
lazyLoad($('#details-html img'));

//只有一个尺码(多个或一个颜色)时默认选中
(function() {
    var hasOnlyOneSize = true,
        i;

    for (i = 0; i < $sizes.length; i++) {
        if ($sizes.eq(i).find('li').length !== 1) {
            hasOnlyOneSize = false;
            break;
        }
    }

    if (hasOnlyOneSize) {
        $sizes.find('li').click();
    }
}());

//咨询和评价
(function() {
    var commentPage = 1,
        consultPage = 1;

    var commentsTpl = Handlebars.compile($('#comments-tpl').html()),
        consultsTpl = Handlebars.compile($('#consults-tpl').html());

    var $commentsUl = $('#comments-ul'),
        $consultsUl = $('#consults-ul');

    var $commentNum = $('.comment-num'),
        $consultNum = $('.consult-num');

    //购买评价
    function loadComments() {
        $.ajax({
            type: 'GET',
            url: '/product/item/comments',
            data: {
                productId: id,
                page: commentPage
            }
        }).then(function(data) {
            var res;

            if (data.code === 200) {
                res = data.data;

                if (res.length === 0) {
                    $commentsUl.next('.more-wrap').addClass('hide');
                    return;
                }

                //更新总数显示
                $commentNum.text(res[0].total);

                $commentsUl.append(commentsTpl({
                    comments: res
                }));
                commentPage++;
            }
        });
    }

    //顾客咨询
    function loadConsults() {
        $.ajax({
            type: 'GET',
            url: '/product/item/consults',
            data: {
                productId: id,
                page: consultPage
            }
        }).then(function(data) {
            var res;

            if (data.code === 200) {
                res = data.data;

                if (res.length === 0) {
                    $consultsUl.next('.more-wrap').addClass('hide');
                    return;
                }

                //更新总数显示
                $consultNum.text(res[0].total);

                $consultsUl.append(consultsTpl({
                    consults: res
                }));
                consultPage++;
            }
        });
    }

    //评价和咨询切换
    $('.consult-comment').on('click', '.title', function() {
        var $this = $(this),
            index = $this.index();

        var $comments = $('.comments'),
            $consults = $('.consults');

        if ($this.hasClass('cur')) {
            return;
        }

        $this.addClass('cur');
        $this.siblings('.cur').removeClass('cur');

        if (index === 0) {

            //咨询
            $consults.slideDown(SLIDETIME);
            $comments.slideUp(SLIDETIME);
        } else {
            $consults.slideUp(SLIDETIME);
            $comments.slideDown(SLIDETIME);
        }
    }).on('click', '.load-more', function() {
        var $this = $(this);

        if ($this.hasClass('load-more-comments')) {
            loadComments();
        } else {
            loadConsults();
        }
    });

    //我要咨询
    $('#consults-btn').click(function() {

        //TODO:点击我要资讯的时候更新验证码显示
        $('.new-consult').removeClass('hide');
        $('.consult-success').addClass('hide');
    });

    //提交咨询
    $('#submit-consult').click(function() {
        var $this = $(this),
            $parent = $this.closest('.new-consult'),
            $textarea = $parent.find('.my-consult'),
            content = $.trim($textarea.val());

        var $consultWarn = $parent.find('.consult-warn');

        var pass = true;

        if (content === '') {
            $textarea.addClass('error');
            $consultWarn.removeClass('hide');

            pass = false;
        } else {
            $textarea.removeClass('error');
            $consultWarn.addClass('hide');
        }

        if (pass === false) {
            return;
        }

        $.ajax({
            type: 'POST',
            url: '/product/item/addconsult',
            data: {
                productId: id,
                content: content
            }
        }).then(function(data) {
            var code = data.code;

            if (code === 200) {
                $parent.addClass('hide');

                $parent.siblings('.consult-success').removeClass('hide');

                //清空输入
                $textarea.val('');
            } else if (code === 403) {

                //跳转登录页
                location.href = data.data.url;
            }
        });
    });

    loadComments();
    loadConsults();
}());
});
define("js/common/dialog", ["jquery","handlebars","source-map"], function(require, exports, module){
/**
 * 弹框公共组件
 * @author: xuqi<qi.xu@yoho.cn>
 * @date: 2016/2/24
 */

var $ = require("jquery"),
    Handlebars = require("handlebars");

var defaultOptions = {
    mask: true,
    closeIcon: true
};

var tpl =
    '<div class="yoho-dialog {{className}} hide">' +
        '{{#if closeIcon}}' +
            '<span class="close">' +
                '<i class="iconfont">&#xe602;</i>' +
            '</span>' +
        '{{/if}}' +
        '<div class="content">' +
            '{{{content}}}' +
        '</div>' +
        '<div class="btns">' +
            '{{# btns}}' +
                '<span {{#if id}}id="dialog-{{id}}"{{/if}} class="btn{{#each btnClass}} {{.}}{{/each}}">' +
                    '{{name}}' +
                '</span>' +
            '{{/ btns}}' +
        '</div>' +
    '</div>';

var tplFn = Handlebars.compile(tpl);

//背景蒙版
function createMask() {
    if ($('.body-mask').length === 0) {
        $('body').append('<div class="body-mask hide"></div>');
    }

    return $('.body-mask').css({
        height: $(document).height(),
        width: $(document).width()
    });
}

function createDialog(data) {
    $('body').append(tplFn(data));

    return $('.yoho-dialog');
}

function Dialog(options) {
    var opt = $.extend({}, defaultOptions, options);
    var that = this,
        i;

    if (opt.mask) {
        that.$mask = createMask();
    }
    that.$el = createDialog(opt);

    //绑定x关闭事件
    that.$el.find('.close').click(function() {
        that.close();
    });

    function bindBtnEvt(index) {
        that.$el.find('#dialog-' + opt.btns[index].id).on('click', function() {
            opt.btns[index].cb && opt.btns[index].cb();
        });
    }

    //绑定按钮事件
    if (!!opt.btns) {
        for (i = 0; i < opt.btns.length; i++) {
            bindBtnEvt(i);
        }
    }
}

Dialog.prototype.close = function() {
    this.$mask && this.$mask.addClass('hide');
    this.$el.remove();
};

Dialog.prototype.show = function() {
    this.$mask && this.$mask.removeClass('hide');
    this.$el.removeClass('hide').css({
        'margin-top': -this.$el.height() / 2,
        'margin-left': -this.$el.width() / 2
    });
};

exports.Dialog = Dialog;

//Alert
function Alert(content) {
    var that = this;
    var option = {
        content: content,
        className: 'alert-dialog',
        btns: [
            {
                id: 'alert-sure',
                btnClass: ['alert-sure'],
                name: '确定',
                cb: function() {
                    that.close();
                }
            }
        ]
    };

    Dialog.call(this, option);
}

Alert.prototype = new Dialog();
Alert.prototype.constructor = Alert;
exports.Alert = Alert;

//Confirm
function Confirm(opt) {
    var that = this;

    var option = {
        content: opt.content,
        className: 'confirm-dialog',
        btns: [
            {
                id: 'confirm-sure',
                btnClass: ['confirm-sure'],
                name: '确定',
                cb: opt.cb
            },
            {
                id: 'confirm-cancel',
                btnClass: ['confirm-cancel'],
                name: '取消',
                cb: function() {
                    that.close();
                }
            }
        ]
    };

    Dialog.call(this, option);
}

Confirm.prototype = new Dialog();
Confirm.prototype.constructor = Confirm;
exports.Confirm = Confirm;
});
define("js/common/share", ["jquery"], function(require, exports, module){
/**
 * 分享
 * @author: xuqi<qi.xu@yoho.cn>
 * @date: 2016/3/1
 */

var $ = require("jquery");

function shareBase(options) {
    var openUrl = '';
    var defOption = {
        title: '',
        url: window.location.href,
        weixinUrl: '',
        image: '',
        desc: '',
        channel: ''
    };
    var shareChannels = ['weibo', 'tweibo', 'qzone', 'renren', 'qq', 'douban','weixin'];
    var sharebox;
    var shareCon = '<em><i></i></em>';

    defOption = $.extend(defOption, options);

    if ($.inArray(defOption.channel, shareChannels) === -1) {
        alert('不存在的分享平台!');
        return false;
    }

    switch (defOption.channel) {
        case 'weibo':
            openUrl = 'http://service.weibo.com/share/share.php?url=' + defOption.url + '&title=' +
                defOption.title + '&appkey=3739328910&searchPic=true&pic=' + defOption.image;
            break;
        case 'tweibo':
            openUrl = 'http://share.v.t.qq.com/index.php?c=share&a=index&url=' + defOption.url + '&title=' +
                defOption.title + '&appkey=c0af9c29e0900813028c2ccb42021792&pic=' + defOption.image;
            break;
        case 'qzone':
            openUrl = 'http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url=' + defOption.url + '&title=' +
                defOption.title + '&desc=&summary=' + defOption.desc + '&site=YOHO!有货&pics=' + defOption.image;
            break;
        case 'renren':
            openUrl = 'http://widget.renren.com/dialog/share?resourceUrl=' + defOption.url + '&srcUrl=' +
                defOption.url + '&desc=' + defOption.desc + '&title=' + defOption.title + '&description=' +
                defOption.desc + '&pic=' + defOption.image;
            break;
        case 'qq':
            openUrl = 'http://connect.qq.com/widget/shareqq/index.html?url=' + defOption.url + '&desc=' +
                defOption.desc + '&title=' + defOption.title.replace('%', '') + '&desc=&summary=' +
                defOption.desc + '&site=YOHO!有货&pics=' + defOption.image;
            break;
        case 'weixin':
            openUrl = 'http://s.jiathis.com/qrcode.php?url=' + defOption.weixinUrl + '&desc=' +
                defOption.desc + '&title=' + defOption.title + '&description=' +
                defOption.desc + '&pic=' + defOption.image;
            break;
        case 'douban':
            openUrl = 'http://www.douban.com/share/service?href=' + defOption.url + '&text=' +
                defOption.desc + '&image=' + defOption.image + '&title=' + defOption.title + '&comment=';
            break;
    }

    if (defOption.channel === 'weixin') {
        if (!defOption.self) {
            return;
        }

        sharebox = defOption.self.closest('.share-to').find('.weixin-share-box');

        if (sharebox.length > 0) {
            shareCon += '<div class="con"><h2>分享到微信朋友圈</h2><p class="pic">' +
            '<img src="' + openUrl + '" /></p><p class="w">打开微信,点击底部得“发现”,使用<br/>“扫一扫“即可将网页分享到我的朋友圈。</p>' +
            '<a href="javascript:void(0)" class="close">x</a></div>';
            sharebox.find('div').length > 0 ? sharebox.show() : sharebox.html(shareCon).show();

            sharebox.find('.close').click(function() {
                $(this).closest('.weixin-share-box').hide();
            });
        }
    } else {
        window.open(encodeURI(openUrl));
    }
}

function share(channel, self) {
    var title = document.title.replace(/(^\s*)|(\s*$)/g, '');
    var desc = $('#share-desc').val();
    var image = $('#share-img').val();
    var weixinUrl = $('#weixin-url').val();


    if (channel === 'weibo' || channel === 'tqq') {
        shareBase({
            channel: channel,
            title: title,
            image: image
        });
    } else {
        shareBase({
            channel: channel,
            title: title,
            desc: desc,
            image: image,
            self: self,
            weixinUrl: weixinUrl
        });
    }
}

$('.share-wrapper').on('click', 'i', function() {
    var $el = $(this),
        type = $el.data('type');

    if (type === 'weixin') {
        share(type, $el);
    } else {
        share(type);
    }
});
});
define("js/index/index", ["jquery","lazyload","handlebars","source-map"], function(require, exports, module){
/**
 * 首页
 * @author: xuqi<qi.xu@yoho.cn>
 * @date: 2015/11/23
 */

var $ = require("jquery"),
    lazyLoad = require("lazyload"),
    homePage = $('.home-page').data('page'),
    brandUrl = $('.logo-brand').data('url');


require("js/common/slider");
require("js/common/slider2");
require("js/common/logo-brand");

require("js/common/accordion");

$(document).on('mouseenter', '.imgopacity a img', function() {
    $(this).css('opacity', 0.8);
});
$(document).on('mouseout', '.imgopacity a img', function() {
    $(this).css('opacity', 1);
});



if ($.inArray(homePage, ['boys','girls','kids','lifestyle']) > -1) {
    require("js/common/new-arrivls")({
        type: homePage,
        url: '/common/getNewArrival',
        count: (homePage === 'boys') || (homePage === 'lifestyle') ? 5 : 4,
        rows: [5,3]
    });
    window.setCookie('_Channel', homePage, {
        domain: '.yohobuy.com',
        path: '/',
        expires: 365
    });
}



lazyLoad($('img.lazy'));
if (homePage === 'boys') {
    $('.slide-container').slider({
        pagination: '.thumb-pagination'
    });
} else {
    $('.center-col').slider();
    $('.slide-container').slider();
}

if (homePage === 'boys') {
    $('.logo-brand').logoBrand({
        url: brandUrl
    });
    $('.img-brand').slider2();
} else {
    $('.logo-brand').logoBrand({
        showNum: 10,
        url: brandUrl
    });
    $('.img-slider-wrapper').slider2();
}



});
define("js/common/slider2", ["jquery"], function(require, exports, module){
/**
 * (品牌优选)图片幻灯片插件
 * @author: wangqing(robin.wang@yoho.cn)
 * @date: 205/7/2
 */
var $ = require("jquery");

(function($) {
    $.fn.slider2 = function(options) {
        function autoplay(index, limit, toright) {
            if (toright === true) {
                $('.next').trigger('click');
                if (index === (limit - 3)) {
                    autoplayrecycle(--index, limit, false);
                } else {
                    autoplayrecycle(++index, limit, true);
                }
            } else {
                $('.prev').trigger('click');
                if (index === 0) {
                    autoplayrecycle(++index, limit, true);
                } else {
                    autoplayrecycle(--index, limit, false);
                }
            }
        }

        function autoplayrecycle(index, limit, toright) {
            window.setTimeout(autoplay, $.fn.slider2.defaults.delaytime, index, limit, toright);
        }

        function changePic(index, width, callback) {
            var offersetleft = -(index * width);

            $('.img-list')
                .animate({
                    'margin-left': offersetleft + 'px'
                }, 'slow', callback);

        }
        $.fn.slider2.defaults = {
            index: 0,
            shownum: 3,
            autoplay: false,
            delaytime: 3000
        };
        return this.each(function() {
            var opts = $.extend({}, $.fn.slider2.defaults, options);
            var mr = parseInt($('.img-item').css('margin-right'));
            var $banneritems = $('.img-item');
            var bannerarr = [];
            var _width = $banneritems.outerWidth() + mr,
                _size = $banneritems.length,
                j = 0;

            if (_size <= 3) {
                $(this).find('.img-brand-switch').hide();
                return;
            }
            for (j = 0; j < $banneritems.length; j++) {
                bannerarr.push($banneritems[j]);
            }
            _size = bannerarr.length;
            $(this).find('.img-list').css({
                width: (_width * _size)
            });
            $(this).find('.next').on('click', function(e) {
                var i = 0,
                    _obj = null;

                e.preventDefault();

                changePic(3, _width, function() {
                    for (i = 0; i < 3; i++) {
                        _obj = bannerarr.shift();

                        $('.img-item').parent().append(_obj.outerHTML);
                        bannerarr.push(_obj);
                    }
                    $('.img-item').first().remove();
                    $('.img-item').first().remove();
                    $('.img-item').first().remove();
                    $('.img-list').css({
                        'margin-left': '0'
                    });
                });
            });
            $(this).find('.prev').on('click', function(e) {
                var i = 0,
                    _obj = null,
                    offersetleft = '';

                e.preventDefault();
                for (i = 0; i < 3; i++) {
                    _obj = bannerarr.pop();

                    $('.img-item').parent().prepend(_obj.outerHTML);
                    bannerarr.unshift(_obj);
                }
                offersetleft = 3 * _width;
                $('.img-item').last().remove();
                $('.img-item').last().remove();
                $('.img-item').last().remove();
                $('.img-list').css({
                    'margin-left': -offersetleft + 'px'
                });
                changePic(0, _width);
            });
            if (opts.autoplay === true) {
                autoplayrecycle(opts.index, _size, true);
            }
        });

    };

}($));
});
define("js/common/accordion", ["jquery"], function(require, exports, module){
var Slide = require("js/common/yohoui/YH.slide");
var $ = require("jquery");

var $contain = $('.slide-accordion');
var $item = $contain.find('li');

var $width = $item.width();
var $spn = parseInt($('.home-page').width()) === 1150 ? (120 + 5) : (102 + 5);
var slide;

function switchfun(to) {
    $item.each(function(index) {
        $(this).css('zIndex', index);
        if (index <= to) {
            $(this).stop().animate({
                left: index * $spn
            }, 400);
        } else {
            $(this).stop().animate({
                left: (to) * $spn + $width + $spn * (index - to - 1)
            }, 400);
        }
    });
}

switchfun(0);

slide = new Slide({
    length: 5,
    loop: false,
    auto: false,
    timeout: 2,
    index: 0
});

slide.on('change', function(data) {
    switchfun(data.to);
});

$item.mouseover(function() {
    slide.go($(this).index());
});

slide.init();
});
define("js/common/yohoui/YH.slide", [], function(require, exports, module){
var me = require("js/common/yohoui/YH.base");

var slide = function(options) {
    this.__lastTime = null;
    this.__isStop = false;
    options = me.extend(this.defaults, options);
    slide.superclass.constructor.call(this, options);
};

me.inherit(slide, me.assembly);

slide.prototype.oninit = function() {
    var __self = this,
        _o = __self.options;

    if (_o.auto) {
        __self.play();
    }
    __self.go(_o.index);
    return this;
};

slide.prototype.go = function(_to, _from) {
    var __self = this,
        _o = __self.options;
    var _direction,_loop,_current,_index,_originalto,o,key,_e;

    if (__self.__lastTime) {
        clearTimeout(__self.__lastTime);
        __self.__lastTime = null;
    }
    _from = 'undefined' === typeof _from ? _o.index : _from;
    _direction = _to === _from ? 0 : _to > _from ? 1 : -1;
    _loop = _o.loop, _index = _o.length - 1, _originalto = _to;
    if (_loop) {
        if (_to > _index) {
            _to = _to - _index - 1;
        } else {
            if (0 > _to) {
                _to = _to + _index + 1;
            } else {
                _to = _to;
            }
        }
    } else {
        if (_to > _index) {
            _to = _index;
        } else {
            if (0 > _to) {
                _to = 0;
            } else {
                _to = _to;
            }
        }
    }
    _current = _o.index = _to;

    o = {
        from: _from,
        to: _to,
        originalto: _originalto,
        direction: _direction
    };

    for (key in __self.registerEvent) {
        if (__self.registerEvent[key].length > 0) {
            for (_e in __self.registerEvent[key]) {
                if (__self.registerEvent[key].hasOwnProperty(_e)) {
                    __self.registerEvent[key][_e](o);
                }
            }
        }
    }

    if (_current !== _index || _to) {
        if (!__self.__isStop && _o.auto) {
            __self.play();
        }
    } else {
        if (__self.__lastTime) {
            clearTimeout(__self.__lastTime);
        }
    }
};

slide.prototype.play = function() {
    var __self = this,
        _o = __self.options;

    __self.__lastTime = setTimeout(function() {
        __self.next();
    }, 1000 * _o.timeout);
    return this;
};

slide.prototype.next = function() {
    var __self = this,
    _o = __self.options;
    var _from = _o.index;
    var _to = _from + _o.step;

    __self.go(_to, _from);
};

slide.prototype.prev = function() {
    var __self = this,
        _o = __self.options;
    var _from = _o.index;
    var _to = _from - _o.step;

    __self.go(_to, _from);
};

slide.prototype.pause = function() {
    var __self = this;

    if (__self.__lastTime) {
        clearTimeout(__self.__lastTime);
    }
    __self.__isStop = true;
};

slide.prototype.resume = function() {
    var __self = this;

    __self.__isStop = false;
    __self.play();
};

slide.prototype.defaults = {
    index: 0,
    timeout: 5,
    step: 1,
    per: 1,
    auto: false,
    loop: false
};

module.exports = slide;
});
define("js/common/yohoui/YH.base", [], function(require, exports, module){
var assembly;
var classtype = {
        '[object Array]': 'array',
        '[object Boolean]': 'boolean',
        '[object Date]': 'date',
        '[object Function]': 'function',
        '[object Number]': 'number',
        '[object Object]': 'object',
        '[object RegExp]': 'regexp',
        '[object String]': 'string'
    };
var me = {
    __Index: 0,
    list: [],
    get: function(id) {
        return id === undefined ? this.list : this.list[id];
    },
    fn: function() { },
    inherit: function(childClass, parentClass) {
        var Constructor = me.fn;

        Constructor.prototype = parentClass.prototype;
        childClass.prototype = new Constructor();

        childClass.prototype.constructor = childClass;
        childClass.superclass = parentClass.prototype;

        if (childClass.prototype.constructor === Object.prototype.constructor) {
            childClass.prototype.constructor = parentClass;
        }
    },
    extend: function(obj, newProperties) {
        var key;

        for (key in newProperties) {
            if (newProperties.hasOwnProperty(key)) {
                obj[key] = newProperties[key];
            }
        }
        return obj;
    },
    copy: function(TargetClass, obj, newProperties) {
        var value,o,key;

        if (typeof obj !== 'object') {
            return obj;
        }
        value = obj.valueOf();
        if (obj !== value) {
            return new obj.constructor(value);
        }
        if (obj instanceof obj.constructor && obj.constructor !== Object) {
            if (TargetClass) {
                o = new TargetClass();
            } else {
                o = me.clone(obj.constructor.prototype);
            }

            for (key in obj) {
                if (TargetClass || obj.hasOwnProperty(key)) {
                    o[key] = obj[key];
                }
            }
        } else {
            o = {};
            for (key in obj) {
                if (o.hasOwnProperty(key)) {
                    o[key] = obj[key];
                }
            }
        }
        if (newProperties) {
            for (key in newProperties) {
                if (o.hasOwnProperty(key)) {
                    o[key] = newProperties[key];
                }
            }
        }

        return o;
    },
    clone: function(obj) {
        me.__cloneFunc.prototype = obj;
        return new me.__cloneFunc();
    },
    __cloneFunc: function() {
    },
    delegate: function(func, scope) {
        var args;

        scope = scope || window;

        if (arguments.length > 2) {
            args = Array.prototype.slice.call(arguments, 2);

            return function() {
                return func.apply(scope, args);
            };
        } else {
            return function() {
                return func.call(scope);
            };
        }
    },
    dom: function($select, classCss) {
        var wrap = $select;
        var name, DOM = {
            wrap: wrap
        },
            els = wrap[0].getElementsByTagName('*'),
            elsLen = els.length;
        var i;

        for (i = 0; i < elsLen; i++) {
            name = els[i].className;
            if (name.indexOf(classCss) > -1) {
                name = name.split(classCss)[1];
            }
            if (name) {
                DOM[name] = wrap.find(els[i]);
            }
        }
        return DOM;
    },

    //模板引擎
    template: function() {
        var result, key, reg,i;
        var args = arguments;

        if (args.length > 0) {
            if (me.isString(args[0])) {
                result = args[0];
                if (args.length === 2 && me.isObject(args[1])) {
                    for (key in args[1]) {
                        if (args[1][key] !== undefined) {
                            reg = new RegExp('({' + key + '})', 'g');

                            result = result.replace(reg, args[1][key]);
                        }
                    }
                } else {
                    for (i = 1; i < args.length; i++) {
                        if (args[i] !== undefined) {
                            reg = new RegExp('({[' + (i - 1) + ']})', 'g');

                            result = result.replace(reg, args[i]);
                        }
                    }
                }
            }
        }
        return result;
    },
    __type: function(obj) {
        return obj == null ? String(obj) : classtype[Object.prototype.toString.call(obj)] || 'object';
    },
    isObject: function(obj) {
        return this.isFunction(obj) || !!(obj && 'object' === typeof obj);
    },
    isFunction: function(obj) {
        return this.__type(obj) === 'function';
    },
    isArray: Array.isArray || function(obj) {
        return this.__type(obj) === 'array';
    },
    isNum: function(obj) {
        return !isNaN(parseFloat(obj)) && isFinite(obj);
    },
    isString: function(obj) {
        return this.__type(obj) === 'string';
    },
    each: function(data, callback, args) {
        var i, len;

        if (me.isArray(data)) {
            for (i = 0, len = data.length; i < len; i++) {
                if (callback.call(data[i], i, data[i], args) === false) {
                    break;
                }
            }
        } else {

            for (i in data) {
                if (callback.call(data[i], i, data[i], args) === false) {
                    break;
                }
            }
        }
    },
    funManager: {
        __loadList: {},
        __loadFun: function(item, callback, win) {

            if (item.methord && me.isFunction(item.methord())) {
                win = win || window;
                item.methord()(item, function() {
                    callback();
                }, win);
            }
        },
        load: function(fns, statechange, win, __index) {
            __index = __index || 0;

            if (fns[__index]) {
                me.funManager.__loadFun(fns[__index], function() {
                    me.funManager.load(fns, statechange, win, __index + 1);
                }, win);
            }
            statechange(__index, win);
        },
        get: function(id) {
            return this.__loadList[id];
        }
    },
    log: function(msg) {
        var console = window.console || {
            log: function() { }
        };

        console.log(msg);
    },
    Event: {
        mousewheel: function(e) {
            var _eoe = e.originalEvent;
            var _de = _eoe.detail ? _eoe.detail * -1 : _eoe.wheelDelta / 40;
            var _direction = _de < 0 ? -1 : 1;

            return {
                direction: _direction,
                unit: _de
            };
        },
        __: function(_e, el, event, handle) {
            var key;

            for (key in _e) {
                if (window[_e[key].validator]) {
                    el[_e[key].validator](_e[key].prefix + event, handle, false);
                    break;
                }
            }
        },
        add: function(el, event, handle) {
            var _e = [
                {
                    validator: 'addEventListener',
                    prefix: ''
                },
                {
                    validator: 'attachEvent',
                    prefix: 'on'
                }
                            ];

            this.__(_e, el, event, handle);
        },
        remove: function(el, event, handle) {
            var _e = [
                {
                    validator: 'removeEventListener',
                    prefix: ''
                },
                {
                    validator: 'detachEvent',
                    prefix: 'on'
                }
                            ];

            this.__(_e, el, event, handle);
        }
    },
    getUid: function(_name) {
        return me.template('me-{0}{1}-{2}', _name, new Date().getTime(), me.__Index++);
    },
    Browser: {
        isTouch: function() {
            var msGesture = window.navigator && window.navigator.msPointerEnabled && window.MSGesture;

            return (('ontouchstart' in window) || msGesture || window.DocumentTouch) ? true : false;
        },
        Prefix: function() {
            var i;

            var props = ['perspectiveProperty', 'WebkitPerspective', 'MozPerspective', 'OPerspective', 'msPerspective'];
            var obj = document.createElement('div');

            for (i in props) {
                if (obj.style[props[i]] !== undefined) {
                    return me.template('-{0}-', props[i].replace('Perspective', '').toLowerCase());
                }
            }
        },
        parseURL: function(url) {
            var a = document.createElement('a');
            var ret,seg,len,i,s;

            a.href = url;
            return {
                source: url,
                protocol: a.protocol.replace(':', ''),
                host: a.hostname,
                port: a.port,
                query: a.search,
                params: (function() {
                    ret = {},
                    seg = a.search.replace(/^\?/, '').split('&'),
                    len = seg.length, i = 0, s;

                    for (; i < len; i++) {
                        if (!seg[i]) {
                            continue;
                        }
                        s = seg[i].split('=');
                        ret[s[0]] = s[1];
                    }
                    return ret;
                })(),
                file: (a.pathname.match(/\/([^\/?#]+)$/i) || [null, ''])[1],
                hash: a.hash.replace('#', ''),
                path: a.pathname.replace(/^([^\/])/, '/$1'),
                relative: (a.href.match(/tps?:\/\/[^\/]+(.+)/) || [null, ''])[1],
                segments: a.pathname.replace(/^\//, '').split('/')
            };
        }
    },
    Array: {
        indexOf: function(array, val) {
            var i;

            for (i = 0; i < array.length; i++) {
                if (this[i] === val) {
                    return i;
                }
            }
            return -1;
        },
        remove: function(array, val) {
            var index = this.indexOf(array, val);

            if (index > -1) {
                array.splice(index, 1);
            }
            return array;
        }
    }
};

assembly = function(options) {
    this.initialized = false;
    this.registerEvent = {
        before: [],
        change: [],
        after: []
    };
    this.options = options;

    this.init(options);
};

assembly.output = function() {
    me.log(me.list);
};
assembly.prototype.oninit = me.fn;

assembly.prototype.init = function(cfg) {
    this.initialized = true;

    // function _getClassName(_constructor, _constr) {
    //     var _constr = _constr || "";
    //     if (_constructor.superclass) {
    //         var args = /(\w+)\.superclass/.exec(_constructor.arguments.callee);
    //         if (args != null) {
    //             _constr += args[1] + "-";
    //             // return _getClassName(_constructor.superclass.constructor, _constr);
    //         }
    //     }
    //     return _constr;
    // }
    this.__Uid = me.getUid('me');
    this.oninit(cfg);
    me.list[this.__Uid] = this;
};
assembly.prototype.destory = function() {
    this.initialized = false;
    delete me.list[this.__Uid];
};
assembly.prototype.getUid = function() {
    return this.__Uid;
};
assembly.prototype.getOptions = function() {
    return this.options;
};
assembly.prototype.config = function() {
    if (arguments.length > 0) {
        if (typeof (arguments[0]) === 'string') {
            if (arguments.length > 1) {
                this.options[arguments[0]] = arguments[1];
            } else {
                return this.options[name];
            }
        }
    } else {
        return this.options;
    }
};
assembly.prototype.on = function(name, callback) {
    var __self = this;
    var _e = __self.registerEvent[name];

    if (_e) {
        _e.push(callback);
    }
    return _e;
};
assembly.prototype.off = function(name, callback) {
    var __self = this;
    var _e = __self.registerEvent[name];
    var e = [];

    me.each(_e, function(name, _callback) {

        if (_callback === callback) {
            e.push(name);
        }
    });

    me.each(e.reverse(), function(name, _callback) {
        _e.splice(_callback, 1);
    });
};
me.assembly = assembly;

module.exports = me;
});
define("js/common/new-arrivls", ["jquery","lazyload","handlebars","source-map"], function(require, exports, module){
var $ = require("jquery"),
        lazyload = require("lazyload");
var Handlebars = require("handlebars");

function InfiniteLoad(options) {
    var defaults = {
        index: 0,
        isload: true,//是否正在加载
        isrun: true,//判断是否执行
        offset: {
            height: null,
            width: null
        }
    };

    this.registerEvent = {
        before: [],
        change: [],
        after: []
    };

    this.options = $.extend(true, {}, defaults, options);

    return this;
}

InfiniteLoad.prototype.on = function(name, callback) {
    var g = this;
    var _e = g.registerEvent[name];

    if (_e) {
        _e.push(callback);
    }
    return _e;
};

InfiniteLoad.prototype.exect = function(key, params) {
    var g = this;
    var e;

    if (g.registerEvent[key] && g.registerEvent[key].length > 0) {
        for (e in g.registerEvent[key]) {
            if (g.registerEvent[key].hasOwnProperty(e)) {
                g.registerEvent[key][e](params);
            }
        }
    }
};

InfiniteLoad.prototype.init = function() {
    var g = this;
    var p = this.options;

    function __loadMore() {

        if (p.isrun && p.isload && g.__directionCalculation()) {
            p.isload = false;
            p.index++;
            g.exect('after', p);
        }

        g.exect('change', p);
    }

    g.exect('before', p);

    $(window).scroll(__loadMore);
};

InfiniteLoad.prototype.emit = function() {
    var p = this.options;

    p.isload = true;
};

InfiniteLoad.prototype.stop = function() {
    var p = this.options;

    p.isrun = false;
    p.isload = false;
};

InfiniteLoad.prototype.__directionCalculation = function() {
    var p = this.options;

    if (p.offset.height && p.offset.height() > 0 && $(window).scrollTop() + $(window).height() >= p.offset.height()) {
        return true;
    }
    return false;
};

module.exports = function(data) {
    var $container = $('#newarrivals .goods-container');
    var $load = $('.loading a');
    var load = new InfiniteLoad({
        index: 1,
        isload: false,
        offset: {
            height: function() {
                return parseFloat($container.offset().top) + parseFloat($container.height()) - 200;
            }
        }
    });
    var loadAjax;
    var url = data.url,
        count = data.count,
        rows = data.rows;

    data.pageIndex = 0;

    delete data.url;
    delete data.count;
    delete data.rows;

    loadAjax = function(url, data, count) {

        var options = {
            type: 'POST',
            url: url,
            success: function(result) {
                var code = result.code;
                var myTemplate,len,pos;

                if (code === 200) {
                    len = result.goods.length % count;
                    pos = result.goods.length - len - 1;

                    result.goods.splice(pos, len);

                    myTemplate = Handlebars.compile(load.tpl);

                    $container.append(myTemplate(result.goods));
                    data.pageIndex = data.pageIndex + result.goods.length;

                    //懒加载插件貌似有点问题,图片先直接展示
                    lazyload($container.find('img.lazy'));

                    load.emit();
                } else {

                    load.stop();
                    $load.html('查看更多');
                }
            },
            error: function() {

                load.stop();
                $load.html('网络断开连接了~');
            }
        };

        options.data = data;
        $.ajax(options);
    };


    load.on('after', function(p) {

        data.pageCount = count * rows[1];

        loadAjax(url, data);
    });

    load.on('before', function(p) {


        load.tpl = '{{#each this}}';
        load.tpl += '<div class="good-info imgopacity" data-skn="{{skn}}">';
        load.tpl += '    <div class="tag-container clearfix">';
        load.tpl += '        {{# tags}}';
        load.tpl += '            {{# isNew}}';
        load.tpl += '                <span class="good-tag new-tag">NEW</span>';
        load.tpl += '            {{/ isNew}}';
        load.tpl += '            {{# isReNew}}';
        load.tpl += '                <span class="good-tag renew-tag">再到着</span>';
        load.tpl += '            {{/ isReNew}}';
        load.tpl += '            {{# isSale}}';
        load.tpl += '                <span class="good-tag sale-tag">SALE</span>';
        load.tpl += '            {{/ isSale}}';
        load.tpl += '            {{# isNewFestival}}';
        load.tpl += '                <span class="good-tag new-festival-tag">新品节</span>';
        load.tpl += '            {{/ isNewFestival}}';
        load.tpl += '            {{# isLimit}}';
        load.tpl += '                <span class="good-tag limit-tag">限量商品</span>';
        load.tpl += '            {{/ isLimit}}';
        load.tpl += '            {{# isYearEndPromotion}}';
        load.tpl += '                <span class="good-tag yep-tag">年终大促</span>';
        load.tpl += '            {{/ isYearEndPromotion}}';
        load.tpl += '            {{# isYearMidPromotion}}';
        load.tpl += '                <span class="good-tag ymp-tag">年中热促</span>';
        load.tpl += '            {{/ isYearMidPromotion}}';
        load.tpl += '        {{/ tags}}';
        load.tpl += '    </div>';
        load.tpl += '    <div class="good-detail-img">';
        load.tpl += '        <a class="good-thumb" href="{{url}}" target= "_blank">';
        load.tpl += '            <img class="lazy" data-original="{{thumb}}">';
        load.tpl += '        </a>';
        load.tpl += '        {{# isFew}}';
        load.tpl += '            <p class="few-tag">即将售罄</p>';
        load.tpl += '        {{/ isFew}}';

        load.tpl += '        {{#if showColBtn}}';
        load.tpl += '            <span class="col-btn iconfont{{#if coled}} coled{{/if}}">&#xe616;</span>';
        load.tpl += '        {{/if}}';
        load.tpl += '    </div>';
        load.tpl += '    <div class="good-detail-text">';
        load.tpl += '        <a href="{{url}}" target= "_blank">{{name}}</a>';
        load.tpl += '        <p class="price">';
        load.tpl += '            <span class="sale-price{{#unless marketPrice}}prime-cost{{/unless}}">';
        load.tpl += '                ¥{{salePrice}}';
        load.tpl += '            </span>';
        load.tpl += '            {{# marketPrice}}';
        load.tpl += '                <span class="market-price">¥{{.}}</span>';
        load.tpl += '            {{/ marketPrice}}';
        load.tpl += '        </p>';
        load.tpl += '    </div>';
        load.tpl += '</div>';
        load.tpl += '{{/each}}';


        data.pageCount = count * rows[0];

        loadAjax(url, data, data.count);

        //load.emit();
    });

    load.init();

};
});
define("js/brand/index", ["jquery","lazyload","handlebars","source-map","dot"], function(require, exports, module){
/**
 * 首页
 * @author: xuqi<qi.xu@yoho.cn>
 * @date: 2015/11/23
 */

var $ = require("jquery"),
    lazyLoad = require("lazyload");


require("js/common/slider");
require("js/brand/brands");

lazyLoad($('img.lazy'));
$('.slide-container').slider({
    orient: true
});
});
define("js/brand/brands", ["jquery","handlebars","source-map","dot"], function(require, exports, module){
var $ = require("jquery"),
    Handlebars = require("handlebars"),
    dot = require("dot");

var $tabs = $('.brands-tabs');
var $list = $('.brands-list');
var $gory = $('.brands-category');
var $news = $('.news-txt ul');
var $clearfix = $list.find('dl.clearfix');
var $brand = $list.find('li>a');
var $category = $gory.find('a');
var $tab = $tabs.find('li>a');
var $arr = $tabs.find('.hoverarr');
var $thisTab;

var categoryHeight = $category.height();
var categoryTop = $category.offset() ? $category.offset().top : 0;
var newsHeight = $news.height();
var newsTop = $news.offset() ? $news.offset().top : 0;
var timeout, _id;


//用于临时存储数据
var tempdata = {};

var templete = '<div class="brands-dialog">';

templete += '    <div class="brands-layer">';
templete += '        <div class="layer-content">';
templete += '            <div class="title">{{title}}</div>';
templete += '            <div class="clearfix desc">';
templete += '                <img src="{{icon}}">';
templete += '                <p class="right">{{content}}</p>';
templete += '            </div> ';
templete += '            <div class="featured">';
templete += '                <p>{{subtitle}}</p> ';
templete += '                <div class="clearfix"> ';
templete += '                    {{#each imgs}}';
templete += '                    <img src="{{src}}">';
templete += '                    {{/each}}';
templete += '                </div>';
templete += '            </div>';
templete += '        </div>';
templete += '    </div>';
templete += '</div>';

dot($('.brand-desc'));

$.easing.easeOutQuint = function(x, t, b, c, d) {
    return c * ((t = t / d - 1) * t * t * t * t + 1) + b;
};

function getQueryString(name) {
    var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)');
    var r = window.location.search.substr(1).match(reg);

    if (r != null) {
        return window.unescape(r[2]);
    }
    return null;
}

// 格式化资讯NEWS标题数量
if ($news.length) {
    $news.find('li').each(function() {
        var $dom = $(this);
        var domHeight = $dom.offset().top - newsTop + $dom.height();

        if (domHeight > newsHeight) {
            $dom.hide();
        }
    });
}

//头部图片TAB切换展示
$tab.eq(0).parent('li').find('.brands-content').css('z-index', '1');

_id = getQueryString('id') ? getQueryString('id') : 0;

// 设置对应TAB选中
$thisTab = $tab.eq(_id);
$thisTab.find('.g-mask').addClass('g-mask-on');

if (_id && $thisTab.length) {
    $arr.css({
        left: parseFloat($thisTab.offset().left) - parseFloat($tabs.offset().left)
    });
}
$tab.hover(function() {
    var $this = $(this);

    clearTimeout(timeout);
    timeout = setTimeout(function() {
        var targetLeft = parseFloat($this.offset().left) - parseFloat($tabs.offset().left);

        $arr.animate({
            left: targetLeft
        }, 200, 'easeOutQuint');
    }, 50);
    $tabs.find('.brands-content').removeAttr('style');
    $this.parent('li').find('.brands-content').css('z-index', '1');

}, function() {
    clearTimeout(timeout);
});

//品牌类别滚动事件
$(window).scroll(function() {
    if ($(this).scrollTop() >= categoryTop) {
        $gory.addClass('category-fix');
    } else {
        $gory.removeClass('category-fix');
    }
});

//点击字母,页面滚动到相关区域
$category.click(function() {
    var name = $(this).attr('href').split('#')[1];
    var targetTop = $list.find('[name=' + name + ']').offset().top - categoryHeight;

    if (!$gory.hasClass('category-fix')) {
        targetTop -= categoryHeight;
    }

    $('html,body').animate({
        scrollTop: targetTop
    }, 200);
    return false;
});


//浮层代码
function bindTemplete($select, data, templete) {
    var $this = $select;
    var offset = {
        width: $this.width(),
        left: $this.offset().left,
        right: parseFloat($(window).width()) - parseFloat($this.offset().left) - parseFloat($this.width())
    };

    var $parent = $this.parent('li');
    var myTemplate;

    $list.find('.brands-dialog').remove();
    myTemplate = Handlebars.compile(templete);
    $parent.append(myTemplate(data));
    dot($parent.find('.right'));

    if (offset.right - 350 < 0) {
        $parent.find('.brands-layer')
                .addClass('brands-layer-right').css('left', -330 - offset.width);
    }
}

//鼠标悬浮品牌,请求数据,并且展示
function bindHoverEvent() {
    $brand.unbind('mouseenter').unbind('mouseleave').hover(function() {
        var $this = $(this);
        var key = $this.attr('data-key');

        var options = {
            url: '/brands/brandinfo',
            type: 'get',
            data: {
                brandId: key
            },
            success: function(_data) {

                if (_data.code === 200 && _data.brand) {
                    if (!tempdata.hasOwnProperty(_data.brand.key)) {
                        tempdata[_data.brand.key] = _data.brand;
                    }
                    bindTemplete($this, tempdata[_data.brand.key], templete);
                }
            }
        };

        clearTimeout(timeout);
        timeout = setTimeout(function() {
            if (!tempdata.hasOwnProperty(key)) {
                $.ajax(options);
            } else {
                bindTemplete($this, tempdata[key], templete);
            }
        }, 200);
    }, function() {
        clearTimeout(timeout);
        $list.find('.brands-dialog').remove();
    });
}

if ($clearfix.length < 26) {
    $.ajax({
        url: '/brands/brandList',
        type: 'POST',
        data: {
            start: $clearfix.length ? ($clearfix.length + 1) : 1
        },
        success: function(_data) {
            if (_data) {
                $list.append(_data);
                $brand = $list.find('li>a');
                bindHoverEvent();
            }
        }
    });
}

bindHoverEvent();
});
define("js/passport/entry", ["jquery","jquery.placeholder"], function(require, exports, module){
/*
 * 密码中心打包入口文件
 */

require("js/passport/reg");
require("js/passport/back");
require("js/passport/login");
require("js/passport/reset");
require("js/passport/vertification");
require("js/passport/thirdlogin");
require("js/passport/third-pwd");
});
define("js/passport/reg", ["jquery","jquery.placeholder"], function(require, exports, module){
/*
 * @description 注册页js
 * @time 2015/12/14
 */

var $ = require("jquery"),
    regValidate = require("js/passport/mail-phone-regx"),
    computeComplex = require("js/passport/pwd-strength");

var $registerPage = $('.register-page'),
    $pwdTips = $('#pwd-tips'),
    $pwdTip1 = $pwdTips.find('#pwd-tip1'),
    $errTip = $('#err-tip'),
    $registerBtn = $('#register-btn'),
    $countDown = $('#count-down'),
    $successBtn = $('.success-btn'),
    countDown = 5,
    clearT;

var $sendCaptcha = $('#send-captcha'),
    caCount = 4,
    validateResult = [];

var $pn = $('#phone-num'),
    $mc = $('#msg-captcha'),
    $pwd = $('#pwd'),
    $repwd = $('#repwd'),
    $ca = $('#captcha'),
    timeResidue = 0;

// 密码强度验证
var $pwdIntensity = $('.pwd-intensity'),
    $pwdParent = $pwdIntensity.closest('.pwd-intensity-container');

//signup验证
var $region = $('#country-code'),
    $regionSelect = $('#region'),
    isPwd = false,
    pwdVal;

var pwdReg = regValidate.pwdValidateRegx;

var $curErrContainer;

var oldPhone = ''; //如果手机号改变时刷新验证码

require("jquery.placeholder");

setTimeout(function() {
    $pn.val('');
    $mc.val('');
    $pwd.val('');
    $repwd.val('');
    $ca.val('');
}, 0);

//验证码位数
$ca.attr('maxlength', caCount);

//密码规则提示
$pwd.focus(function(event) {
    $pwdTips.removeClass('hide');
    isPwd = true;
    pwdVal = $(this).val();
}).blur(function() {
    $pwdTips.addClass('hide');
    isPwd = false;
});


//IE8 placeholder
$('[placeholder]').placeholder();

// 存储校验信息
validateResult = [
    {
        id: 'phone-num',
        message: '', //错误信息
        status: false //当前的状态
    },
    {
        id: 'captcha',
        message: '',
        status: false
    },
    {
        id: 'msg-captcha',
        message: '',
        status: false
    },
    {
        id: 'pwd',
        message: '',
        status: false
    },
    {
        id: 'repwd',
        message: '',
        status: false
    }
];

//刷新图形验证码
function refreshPic() {
    var time = new Date(),
        $captchaImg = $('.captcha-img'),
        captchaImgSrc = $captchaImg.attr('src').split('?')[0];

    $captchaImg.attr('src', captchaImgSrc + '?t=' + time.getTime());
}

//手机号ajax校验
function phoneAjaxFn(page, callback) {
    var url,
        data;

    if (page === 'reg') {
        url = '/passport/register/checkmobile';
        data = {
            mobile: $pn.val(),
            area: $region.text().split('+')[1]
        };
    } else if (page === 'third') {
        url = '/passport/autouserinfo/bindCheck';
        data = {
            mobile: $pn.val(),
            area: $region.text().split('+')[1],
            openId: $('#open-id').val(),
            sourceType: $('#source-type').val()
        };
    }

    validateResult[0].message = 'err';
    validateResult[0].status = false;

    $.ajax({
        url: url,
        type: 'POST',
        data: data
    }).then(function(data) {
        if (!data) {
            return;
        }

        switch (data.code) {
            case 200:

                if ($pn.val() !== oldPhone && oldPhone !== '') {

                    // 如果手机号发生改变则刷新验证码并且更新状态
                    refreshPic();
                    $sendCaptcha.addClass('disable').attr('disabled', 'disabled');
                    validateResult[1].message = '图形验证码错误';
                    validateResult[1].status = false;
                }

                oldPhone = $pn.val();

                validateResult[0].message = '';
                validateResult[0].status = true;
                break;
            case 400:
                refreshPic();
                validateResult[0].message = data.message;
                validateResult[0].status = false;
                break;
        }

        callback();
    });
}

//图形验证码ajax校验
function picCaptchaAjaxFn(page, callback) {
    var url;

    if (page === 'reg') {
        url = '/passport/register/piccaptcha';
    } else if (page === 'third') {
        url = '/passport/autouserinfo/checkPicCode';
    }
    $.ajax({
        type: 'POST',
        url: url,
        data: {
            verifyCode: $ca.val()

            //mobile: $pn.val(),
            //area: $region.text().split('+')[1]
        }
    }).then(function(data) {
        if (!data) {
            return;
        }

        switch (data.code) {
            case 200:
                validateResult[1].message = '';
                validateResult[1].status = true;
                break;
            case 400:
                refreshPic();
                validateResult[1].message = '图形验证码错误';
                validateResult[1].status = false;
                break;
        }
        callback();
    });
}

//短信验证码ajax校验
function msgCaptchaAjaxFn(page, callback) {
    var url;

    if (page === 'reg') {
        url = '/passport/register/msgcaptcha';
    } else if (page === 'third') {
        url = '/passport/autouserinfo/checkBindMsg';
    }
    $.ajax({
        type: 'POST',
        url: url,
        data: {
            code: $mc.val(),
            mobile: $pn.val(),
            area: $region.text().split('+')[1]
        }
    }).then(function(data) {
        if (!data) {
            return;
        }

        switch (data.code) {
            case 200:
                validateResult[2].message = '';
                validateResult[2].status = true;
                break;
            case 400:
                validateResult[2].message = '短信验证码错误';
                validateResult[2].status = false;
                break;
        }

        callback();
    });
}

// 验证
function validateRule(page, $element, callback) {

    var val = $.trim($element.val()),
        regionCode;



    // 根据需求http://redmine.yoho.cn/issues/3117改成上边的正则
    // 对应的错误提示语也改了,感觉要不了多久就会改回来
    // pwdReg = /^([a-zA-Z0-9\-\+_!@\#$%\^&\*\(\)\:\;\.=\[\]\\\',\?]){6,20}$/gi;

    //手机号校验
    if ($element.hasClass('phone-num')) {

        regionCode = $region.text();


        if (val === '') {
            validateResult[0].message = '请输入手机号码';
            validateResult[0].status = false;
            callback();

        } else if (!regValidate.phoneRegx[regionCode].test(val)) {
            validateResult[0].message = '手机号码格式不正确,请重新输入';
            validateResult[0].status = false;
            callback();

        } else {
            phoneAjaxFn(page, callback);
        }

    //图形验证码校验
    } else if ($element.hasClass('captcha')) {
        if (val === '') {
            validateResult[1].message = '请输入图形验证码';
            validateResult[1].status = false;
            callback();

        } else if (val.length <= 3) {
            validateResult[1].message = '图形验证码为4位';
            validateResult[1].status = false;
            callback();

        } else {

            // 并且手机号正确
            if (validateResult[0].status) {
                picCaptchaAjaxFn(page, callback);
            } else {
                validateResult[1].message = '图形验证码错误';
                validateResult[1].status = false;
                callback();
            }

        }

    //短信验证码校验
    } else if ($element.hasClass('msg-captcha')) {

        if (val === '') {
            validateResult[2].message = '请输入短信验证码';
            validateResult[2].status = false;
            callback();

        } else if (val.length <= 3) {
            validateResult[2].message = '短信验证码错误';
            validateResult[2].status = false;
            callback();

        } else {

            // 并且图形验证码正确
            if (validateResult[1].status) {
                msgCaptchaAjaxFn(page, callback);
            } else {
                validateResult[2].message = '短信验证码错误';
                validateResult[2].status = false;
                callback();
            }
        }

    //密码校验
    } else if ($element.hasClass('pwd')) {
        if (val === '') {
            validateResult[3].message = '请输入密码';
            validateResult[3].status = false;

        } else if (val.length < 6 || val.length > 20) {
            validateResult[3].message = '密码只支持6-20位字符';
            validateResult[3].status = false;

        } else if (!pwdReg.test($element.val())) {
            validateResult[3].message = '密码须字母和数字组合';
            validateResult[3].status = false;

        } else {
            validateResult[3].message = '';
            validateResult[3].status = true;
        }
        callback();

    //二次密码校验
    } else if ($element.hasClass('repwd')) {
        if (val === '') {
            validateResult[4].message = '请输入密码确认';
            validateResult[4].status = false;

        } else if ($pwd.val() !== val) {
            validateResult[4].message = '与密码不一致,请重新输入';
            validateResult[4].status = false;

        } else {
            validateResult[4].message = '';
            validateResult[4].status = true;

        }

        callback();
    }
}

function posErrTip() {
    var tipPos = $curErrContainer.offset();

    return $errTip.css({
        top: tipPos.top - 40,
        left: tipPos.left
    });
}

//显示提示信息
function showErrTip() {

    var show = false,
        i,
        validateResultLen = validateResult.length;

    for (i = 0; i < validateResultLen; i++) {
        if (!show) {

            //不可以通过status判断
            if (!!validateResult[i].message && validateResult[i].message !== 'err') {

                //显示错误提示
                $errTip.find('span').text(validateResult[i].message);
                $curErrContainer = $('#' + validateResult[i].id);
                posErrTip().removeClass('hide');

                show = true; //停止判断
            } else {
                $errTip.addClass('hide');
            }
        }
    }
}

//显示红色边框
function showBorder() {

    var $errInput,
        i,
        validateResultLen = validateResult.length;

    for (i = 0; i < validateResultLen; i++) {
        if (!!validateResult[i].message) {

            //显示红色边框
            $errInput = $('#' + validateResult[i].id);
            $errInput.addClass('error');

        } else {

            //去掉红色边框
            $errInput = $('#' + validateResult[i].id);
            $errInput.removeClass('error');
        }
    }
}

// 密码强度验证
function pwdFn($obj) {
    var pwd = $obj.val(),
        pwdStrength = computeComplex(pwd),
        level = 0;

    if (pwdStrength === 0) {
        level = 0;
    } else if (pwdStrength <= 10) {
        level = 1;
    } else if (pwdStrength <= 20) {
        level = 2;
    } else {
        level = 3;
    }

    switch (level) {
        case 0:
            $pwdParent.removeClass('red yellow green');
            $pwdIntensity.removeClass('color');
            break;
        case 1:
            $pwdParent.addClass('red').removeClass('yellow green');
            $pwdIntensity.filter('.low').addClass('color');
            $pwdIntensity.filter('.mid,.high').removeClass('color');
            break;
        case 2:
            $pwdParent.addClass('yellow').removeClass('red green');
            $pwdIntensity.filter('.low,.mid').addClass('color');
            $pwdIntensity.filter('.high').removeClass('color');
            break;
        case 3:
            $pwdParent.addClass('green').removeClass('yellow red');
            $pwdIntensity.addClass('color');
            break;
    }

    //提示框
    if (pwd === '') {
        $pwdTip1.removeClass('red yes no').addClass('default');
    } else if (pwd.length < 6 || pwd.length > 20) {
        $pwdTip1.removeClass('default yes').addClass('no red');
    } else {
        $pwdTip1.removeClass('default no red').addClass('yes');
    }
}

//重新定位错误提示
$(window).resize(function() {
    if ($errTip.hasClass('hide')) {
        return;
    }

    posErrTip();
});

// 失去焦点时开始校验
// Tips: 不可以在获得焦点的时候验证,获得焦点和失去焦点的间隔太小,如果中间存在ajax校验的话会出现问题
// ( ▼-▼ )注册页和信息完善页面接口不同
exports.init = function(page) {

    $('#agree-terms').click(function() {

        var $this = $(this),
            i,
            passI = 0;

        if (!!$this.attr('notchecked')) {

            $this.removeAttr('notchecked');

            //勾选
            for (i = 0; i < validateResult.length; i++) {
                if (validateResult[i].status) {
                    passI++;
                }
            }
            if (passI === 4) {
                $registerBtn.removeClass('disable').removeAttr('disabled');
            }
        } else {

            //取消勾选
            $registerBtn.addClass('disable').attr('disabled', 'disabled');
            $this.attr('notchecked', 'notchecked');
        }
    });

    // 按回车键提交
    $registerPage.on('keydown', function(e) {
        var key = e.which;

        if (key === 13) {
            $registerBtn.click();
        }
    });

    $registerPage.find('.va').keyup(function() {

        var j,
            statusLen = 0,
            vLen = validateResult.length,
            $that = $(this);

        validateRule(page, $(this), function() {
            showErrTip(); // 显示错误提示
            showBorder(); // 显示红色边框

            // 如果validateResult中有4个status为true表示验证通过
            for (j = 0; j < vLen; j++) {

                if (validateResult[j].status) {

                    statusLen++;
                }

            }

            if (statusLen === 4 && !$('#agree-terms').attr('notchecked')) {
                $registerBtn.removeClass('disable').removeAttr('disabled');
            } else {
                $registerBtn.addClass('disable').attr('disabled', 'disabled');
            }

            // 图形验证通过时,发送短信按钮可点击
            if (validateResult[1].status && timeResidue <= 0) {
                $sendCaptcha.removeClass('disable').removeAttr('disabled');
            } else {
                $sendCaptcha.addClass('disable').attr('disabled', 'disabled');
            }

            //图形验证通过时,发送短信按钮可点击 end

        });

        // 如果是密码则校验强度
        if (($that).hasClass('pwd')) {
            pwdFn($that);
        }

    }).blur(function() {

        /*validateRule($(this), function() {
            showErrTip();
            showBorder(); // 显示红色边框
        });*/
    });

    $regionSelect.change(function() {

        $region.text($('#region').val());

        validateRule(page, $pn, showErrTip); //验证
    });

    // 点击发送验证码
    $sendCaptcha.click(function() {
        var t,
            url;

        if ($(this).hasClass('disable')) {
            return;
        }

        timeResidue = 60;

        $('#msg-tip').removeClass('hide');

        $sendCaptcha.addClass('disable').attr('disabled', 'disabled');

        t = setInterval(function() {
            if (timeResidue <= 0) {
                $sendCaptcha.removeClass('disable').removeAttr('disabled').val('获取短信验证码');
                clearInterval(t);
                return;
            }
            $sendCaptcha.val(timeResidue-- + '秒可重新发送');
        }, 1000);

        if (page === 'reg') {
            url = '/passport/register/sendBindMsg';
        } else if (page === 'third') {
            url = '/passport/autouserinfo/sendBindMsg';
        }

        //todo ajax 发送验证码
        $.ajax({
            type: 'POST',
            url: url,
            data: {
                area: $region.text().split('+')[1],
                mobile: $pn.val(),
                verifyCode: $ca.val()
            }
        });
    });

    // 防止粘贴密码
    if ($('.success-box').length <= 0) {
        $pwd[0].onpaste = function() {
            return false;
        };
    }

    //ajax表单提交
    $registerBtn.click(function() {
        var url;

        if (page === 'reg') {
            url = '/passport/register/mobileregister';
        } else if (page === 'third') {
            url = '/passport/autouserinfo/bindMobile';
        }

        if ($(this).hasClass('disable')) {
            return;
        } else {

            //ajax提交
            $.ajax({
                type: 'POST',
                url: url,
                data: {
                    area: $region.text().split('+')[1],
                    mobile: $pn.val(),
                    verifyCode: $ca.val(),
                    code: $mc.val(),
                    password: $pwd.val()
                }
            }).then(function(data) {

                var time = 0,
                    t,
                    refer;

                if (data.code === 200) {

                    refer = data.data.href;

                    t = setTimeout(function() {
                        time++;
                    }, 1000);

                    $.ajax({
                        type: 'GET',
                        url: data.data.session
                    }).then(function(data) {

                        if (data.code === 200 && t < 3) {
                            clearInterval(t);
                            location.href = refer;
                        }
                    });

                    if (t >= 3) {
                        clearInterval(t);
                        location.href = refer;
                    }
                } else {

                    //todo
                    console.log('网络超时~');
                }

            });
        }
    });

    $('.change-captcha').click(function() {
        refreshPic();
    });

    //注册成功页面5秒后跳转
    if ($('.success-box').length > 0) {
        clearT = setInterval(function() {

            if (countDown === 0) {

                window.location.href = $successBtn.attr('data-url');

                clearInterval(clearT);
            }
            $countDown.text(countDown--);
        }, 1000);
    }
};
});
define("js/passport/mail-phone-regx", [], function(require, exports, module){
/**
 * 国家区号Map手机号码以及邮箱验证正则
 * @author: xuqi<qi.xu@yoho.cn>
 * @date: 2015/12/11
 */

var countryPhoneRegx = {
    '+86': /^1[35847]{1}[0-9]{9}$/,
    '+852': /^[965]{1}[0-9]{7}$/,
    '+853': /^[0-9]{8}$/,
    '+886': /^[0-9]{10}$/,
    '+65': /^[98]{1}[0-9]{7}$/,
    '+60': /^1[1234679]{1}[0-9]{8}$/,
    '+1': /^[0-9]{10}$/,
    '+82': /^01[0-9]{9}$/,
    '+44': /^7[789]{1}[0-9]{8}$/,
    '+81': /^0[9|8|7][0-9]{9}$/,
    '+61': /^[0-9]{11}$/
};

var emailRegx = /^[.\-_a-zA-Z0-9]+@[\-_a-zA-Z0-9]+\.[a-zA-Z0-9]/;

var pwdValidateRegx = /^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,20}$/;

exports.phoneRegx = countryPhoneRegx;

exports.emailRegx = emailRegx;

exports.pwdValidateRegx = pwdValidateRegx;
});
define("js/passport/pwd-strength", [], function(require, exports, module){
/*
 * 计算密码复杂度
 */

function gettype(str, i) {
    if (str.charCodeAt(i) >= 48 && str.charCodeAt(i) <= 57) {
        return 1;
    } else if (str.charCodeAt(i) >= 97 && str.charCodeAt(i) <= 122) {
        return 2;
    } else if (str.charCodeAt(i) >= 65 && str.charCodeAt(i) <= 90) {
        return 3;
    }

    return 4;
}

function isregular(cur, pre, type) {
    var curCode = cur.charCodeAt(0);
    var preCode = pre.charCodeAt(0);

    if (curCode - preCode === 0) {
        return true;
    }

    if (type !== 4 && (curCode - preCode === 1 || curCode - preCode === -1)) {
        return true;
    }

    return false;
}

function getcomplex(curType, preType) {
    if (preType === 0 || curType === preType) {
        return 0;
    } else if (curType === 4 || preType === 4) {
        return 2;
    } else {
        return 1;
    }
}

function computeComplex(password) {
    var complex = 0,
        length = password.length,
        pre = '',
        preType = 0,
        i = 0,
        cur,
        curType;


    for (i = 0; i < length; i++) {
        cur = password.charAt(i);
        curType = gettype(password, i);

        if (preType !== curType || !isregular(cur, pre, curType)) {
            complex += curType + getcomplex(curType, preType);
        }

        pre = cur;
        preType = curType;
    }

    return complex;
}

module.exports = computeComplex;
});
define("js/passport/back", ["jquery","jquery.placeholder"], function(require, exports, module){
/**
 * 找回密码
 * @author: xuqi<qi.xu@yoho.cn>
 * @date: 2015/12/14
 */

var $ = require("jquery"),
    regx = require("js/passport/mail-phone-regx"),
    emailReg = regx.emailRegx,
    phoneRegx = regx.phoneRegx;

var emailAc = require("js/passport/ac-email"); //邮箱自动完成

var $cr = $('#country-code-hide'),
    $phoneNum = $('#phone-num'),
    $ca = $('#captcha'),
    $ccList = $('#country-code-list'),
    $cc = $('#country-code'),
    $btn = $('#find-btn'),
    $accErr = $('#account-err'),
    $caErr = $('#captcha-err'),
    caCount = 4, //验证码位数
    hasPh = false,
    hasCa = false;


require("jquery.placeholder");

function imgcode() {
    var time = new Date(),
        $captchaImg = $('#captcha-img'),
        captchaImgSrc = $captchaImg.attr('src').split('?')[0];

    $('#captcha-img').attr('src', captchaImgSrc + '?t=' + time.getTime());
}

function enableBtn() {
    if (hasPh && hasCa) {
        $btn.removeClass('disable').prop('disabled', false);
    } else {
        $btn.addClass('disable').prop('disabled', true);
    }
}

function authcode() {
    if (!hasPh || !hasCa) {
        enableBtn();
        return;
    }

    $.ajax({
        type: 'POST',
        url: '/passport/back/authcode',
        data: {
            verifyCode: $.trim($ca.val()),
            phoneNum: $phoneNum.val(),
            area: $cr.val()
        }

    }).then(function(data) {
        if (data.code === 200) {
            hasCa = true;
        } else if (data.code === 402) {
            hasPh = false;
            hasCa = true;
            $accErr.removeClass('hide').find('em').text('该账号不存在');
            $phoneNum.addClass('error');
        } else if (data.code === 400) {
            hasCa = false;
            imgcode();
        }
        enableBtn();
    });
}

function vaPn(v) {
    var pass = true,
        errTxt = '';

    v = $.trim(v);
    if (v !== '') {
        if (/^[0-9]+$/.test(v)) {
            if (phoneRegx[$cr.val()].test(v)) {
                pass = true;
            } else {
                errTxt = '手机号码格式不正确, 请重新输入';
                pass = false;
            }
        } else {
            if (emailReg.test(v)) {
                pass = true;
            } else {
                errTxt = '邮箱格式不正确, 请重新输入';
                pass = false;
            }
        }
    } else {
        errTxt = '账户名不能为空';
        pass = false;
    }
    hasPh = pass;
    authcode();

    return {
        pass: pass,
        errTxt: errTxt
    };
}

function vaCa() {
    var v = $.trim($ca.val());

    if (v === '' || v.length < caCount) {
        hasCa = false;
        enableBtn();
        return;
    }

    hasCa = true;

    authcode();
}

emailAc($phoneNum, function() {
        var pnVa = vaPn($phoneNum.val());

        if (pnVa.pass) {
            $accErr.addClass('hide');
            $phoneNum.removeClass('error');
        } else {
            $accErr.removeClass('hide').find('em').text(pnVa.errTxt);
            $phoneNum.addClass('error');
        }
    }
);

$ca.attr('maxlength', caCount);

//IE8 placeholder
$('input').placeholder();

$('#change-captcha, #captcha-img').on('click', function() {
    imgcode();
});

$cc.on('click', function(e) {
    e.stopPropagation();
    if ($ccList.css('style') === 'block') {
        $ccList.slideUp('fast');
    } else {
        $ccList.slideDown('fast');
    }
});

$ccList.delegate('li', 'click', function(e) {
    var $cur = $(this),
        code = $cur.data('cc'),
        pnVa;

    e.stopPropagation();
    $cr.val(code);
    $cc.find('em').html($cur.text());

    //切换后验证手机号码
    if ($.trim($phoneNum.val()) !== '') {
        pnVa = vaPn($phoneNum.val());
        enableBtn();
        if (hasPh) {
            $accErr.addClass('hide');
            $phoneNum.removeClass('error');
        } else {
            $accErr.removeClass('hide').text(pnVa.errTxt);
            $phoneNum.addClass('error');
        }
    }
    $ccList.slideUp('fast');
});

$(document).click(function() {
    if ($ccList.css('display') === 'block') {
        $ccList.slideUp();
    }
});

$phoneNum.keyup(function() {
    vaPn($.trim($(this).val()));
}).focus(function() {
    $(this).removeClass('error');

    //focus隐藏错误提示
    $accErr.addClass('hide');
});

//验证码在鼠标移开后验证, keyup时不再验证
$ca.blur(function() {
    var errTxt = $.trim($ca.val()) === '' ? '验证码不能为空' : '验证码不正确';

    if (hasCa) {
        $caErr.addClass('hide');
        $ca.removeClass('error');
    } else {
        $caErr.removeClass('hide').find('em').text(errTxt);
        $ca.addClass('error');

        //验证码错误则刷新验证码
        if ($ca.val() < caCount) {

            //防止重复刷新验证码
            imgcode();
        }
    }
}).focus(function() {
    $(this).removeClass('error');

    //focus隐藏错误提示
    $caErr.addClass('hide');
}).keyup(function() {
    vaCa();
});

$('#find-btn').click(function(e) {

    if (/^[0-9]+$/.test($.trim($phoneNum.val()))) {
        $('#find-form').attr('action', '/passport/back/mobile');
    }
    if ($(this).hasClass('disable')) {
        return;
    }
    if (!hasCa || !hasPh) {
        e.preventDefault();
        return true;
    }
});
});
define("js/passport/ac-email", ["jquery"], function(require, exports, module){
/**
 * 邮箱自动补全
 * @author:xuqi<qi.xu@yoho.cn>
 * @date: 2016/2/22
 */
var $ = require("jquery");

var mailPostfix = {
    num: ['qq.com', '163.com', '126.com', 'sina.com', 'gmail.com', 'sohu.com', 'hotmail.com', '139.com', '189.com'],
    other: ['gmail.com', 'qq.com', '163.com', '126.com', 'sina.com', 'sohu.com', 'hotmail.com', '139.com', '189.com']
};

var emailAcTime;

/**
 * @param $input 需要自动完成的$对象
 * @param cb 鼠标移开/点击自动完成项后需要执行的操作(验证等)
 */
module.exports = function($input, cb) {
    var ulHtml = '<ul id="email-autocomplete" class="email-autocomplete hide"></ul>';

    var $emailAutoComplete;

    $input.parent().append(ulHtml);

    $emailAutoComplete = $('#email-autocomplete');

    $input.on('keyup', function() {
        var account = $.trim($(this).val()),
            html = '',
            accountMatch,
            matchStr,
            postfix,
            i;

        //输入@时自动补全邮箱后缀
        //此处>0非错误,用于避免输入的第一个字符为@被识别为邮箱
        if (account.indexOf('@') > 0) {
            accountMatch = account.match(/^[0-9]+@(.*)/);
            if (accountMatch) {

                //数字邮箱补全
                postfix = mailPostfix.num;
                matchStr = accountMatch[1];
            } else {
                postfix = mailPostfix.other;
                matchStr = account.match(/@(.*)/)[1];
            }

            for (i = 0; i < postfix.length; i++) {
                if (postfix[i].indexOf(matchStr) > -1) {
                    html += '<li>' + account.slice(0, account.indexOf('@')) + '@' + postfix[i] + '</li>';
                }
            }

            if (html !== '' && /.com$/.test(account) === false) {
                $emailAutoComplete.html(html).removeClass('hide');
            } else {

                //隐藏autocomplete
                $emailAutoComplete.html('').addClass('hide');
            }
        }
    }).on('blur', function() {
        emailAcTime = setTimeout(function() {

            //未点击自动完成项
            $emailAutoComplete.addClass('hide');

            cb && cb();
        }, 200);
    });

    //邮箱自动完成列表项点击
    $emailAutoComplete.on('click', 'li', function() {
        clearTimeout(emailAcTime); //清空默认关闭

        //点击自动完成项后进行验证
        $input.val($(this).text()).focus();

        $emailAutoComplete.addClass('hide');

        cb && cb();
    });
};
});
define("js/passport/login", ["jquery","jquery.placeholder"], function(require, exports, module){
/**
 * 登录
 * @author: xuqi<qi.xu@yoho.cn>
 * @date: 2015/12/11
 */
var $ = require("jquery");

var $account = $('#account'),
    $password = $('#password'),
    $captcha = $('#captcha');

var $accountTip = $account.siblings('.err-tip'),
    $passwordTip = $password.siblings('.err-tip'),
    $captchaTip = $captcha.siblings('.err-tip'),
    $capsLock = $('#caps-lock');

var $countryCodeHide = $('#country-code-hide'),
    $countryCodeEm = $('#country-code > em'),
    $countryList = $('#country-list');

var $emailAutoComplete = $('#email-autocomplete');

var mailPhoneRegx = require("js/passport/mail-phone-regx");
var mailAc = require("js/passport/ac-email"); //邮箱自动完成

var $remember = $('.remember-me');

var captchaUrl = '/passport/images?t='; // /passport/images?t=1454464125

var $captchaWrap = $('.captcha-wrap'),
    $captcha = $captchaWrap.find('#captcha'),
    $captchaImg = $captchaWrap.find('#captcha-img'),
    $captchaTip = $captchaWrap.find('.err-tip');

//checkbox status unicode
var checkbox = {
    checked: '&#xe612;',
    unchecked: '&#xe613;'
};

var authing = false;

var emailAcTime;

require("jquery.placeholder");

//验证账户名
function validateAccount() {
    var pass = false,
        account = $.trim($account.val()),
        err;

    if (account !== '') {
        if (/^[0-9]+$/.test(account)) {

            //如果是纯数字,则作为手机号码处理
            if (mailPhoneRegx.phoneRegx[$countryCodeHide.val()].test(account)) {
                pass = true;
            } else {
                pass = false;
                err = '手机号码不正确,请重新输入';
            }
        } else {
            if (mailPhoneRegx.emailRegx.test(account)) {
                pass = true;
            } else {
                pass = false;
                err = '邮箱格式不正确,请重新输入';
            }
        }
    } else {
        err = '请输入账户名';
    }

    if (pass) {
        $accountTip.addClass('hide');
        $account.removeClass('error');
    } else {
        $accountTip.removeClass('hide').children('em').text(err);
        $account.addClass('error');
    }
    return pass;
}

//验证密码
function validatePassword() {
    var pass = false,
        password = $.trim($password.val()),
        err;

    if (password !== '') {
        if (password.length < 6) {
            err = '请输入长度为6-20字符的密码';
        } else {
            pass = true;
        }
    } else {
        err = '请输入密码';
    }

    if (pass) {
        $passwordTip.addClass('hide');
        $password.removeClass('error');
    } else {
        $passwordTip.removeClass('hide').children('em').text(err);
        $password.addClass('error');
    }
    return pass;
}

//验证验证码
function validateCaptcha() {
    var pass = false,
        captcha = $.trim($captcha.val()),
        err;

    // 验证码不可见的时候不验证
    if ($captchaWrap.is(':hidden')) {
        return true;
    }

    if (captcha !== '') {
        if (captcha.length !== 4) {
            err = '请输入长度为4字符的验证码';
        } else {
            pass = true;
        }
    } else {
        err = '请输入验证码';
    }

    if (pass) {
        $captchaTip.addClass('hide');
        $captcha.removeClass('error');
    } else {
        $captchaTip.removeClass('hide').children('em').text(err);
        $captcha.addClass('error');
    }
    return pass;
}

//验证
function validate() {
    var pass = true,
        account = $.trim($account.val()),
        password = $.trim($password.val());

    if (account !== '') {
        pass = validateAccount() && validatePassword() && validateCaptcha();
    } else {
        pass = false;
        $account.addClass('error');

        if (password === '') {

            //账户名和密码都为空的情况下点击登陆,只在账户输入框后显示错误提示
            $accountTip.addClass('both-error').removeClass('hide').children('em').text('请输入账户名和密码');
            $passwordTip.addClass('hide');
            $password.addClass('error');
        } else {
            $accountTip.removeClass('hide').children('em').text('请输入账户名');
        }
    }

    return pass;
}

//密码错误次数,超过三次显示验证码
function vaAccountErrTimes() {
    $captchaImg.attr('src', captchaUrl + $.now());
    $captcha.val('');
    $captchaWrap.removeClass('hide');
}

//登录
function login() {
    var pass = validate();

    if (pass && authing === false) {
        authing = true;

        $.ajax({
            url: '/passport/login/auth',
            type: 'POST',
            data: {
                areaCode: $countryCodeHide.val().replace('+', ''),
                account: $.trim($account.val()),
                password: $.trim($password.val()),
                captcha: $.trim($captcha.val()),
                isRemember: $remember.hasClass('checked') ? true : false
            },
            success: function(res) {
                if (res.code === 200) {
                    if (res.data) {

                        //防止data.data为undefined时下行语句执行出错而导致脚本不能走到complete去处理authing
                        location.href = res.data.session;
                    }
                } else {
                    if (res.data.errorType === 'captcha') {
                        $captchaTip.removeClass('hide').children('em').html(res.message);
                        $captcha.addClass('error').val('');
                    } else {
                        $passwordTip.removeClass('hide').children('em').html(res.message);
                        $password.addClass('error').val('');
                    }

                    //验证错误次数
                    if (res.data && res.data.needCaptcha) {
                        vaAccountErrTimes();
                    }
                }
            },
            complete: function() {
                authing = false;
            }
        });
    }
}

mailAc($account, function() {
        if (validateAccount()) {
            $.ajax({
                url: '/passport/login/account',
                type: 'GET',
                data: {
                    account: $.trim($account.val())
                }
            }).then(function(res) {
                if (res.data && res.data.needCaptcha) {
                    vaAccountErrTimes();
                }
            });
        }
    }
);

$('[placeholder]').placeholder();

//展开地区列表
$('#country-code').on('click', function() {
    if ($countryList.css('display') === 'none') {
        $countryList.slideDown();
    }
});

//选中地区列表项
$countryList.on('click', 'li', function() {
    var $this = $(this),
        cc = $this.data('cc');

    $countryCodeEm.html($this.html());

    $countryCodeHide.val(cc);

    $countryList.slideUp();
});

//点击其他区域,收起区域列表
$(document).on('click', function(e) {
    if ($(e.target).closest('#country-code').length > 0) {
        return;
    }

    if ($countryList.css('display') === 'block') {
        $countryList.slideUp();
    }
});

//密码
$password.on('blur', function() {
    validatePassword();

    if ($capsLock.hasClass('hide')) {
        return;
    }

    $capsLock.addClass('hide');
}).on('keypress', function(e) {
    var code = e.which;

    //CapsLock检测
    if (code >= 65 && code <= 90) {
        $capsLock.removeClass('hide');
        return;
    }
    $capsLock.addClass('hide');
});

// 验证码
$captcha.on('blur', function() {
    validateCaptcha();
});

//邮箱自动完成列表项点击
$emailAutoComplete.on('click', 'li', function() {
    clearTimeout(emailAcTime); //清空默认关闭

    $account.val($(this).text()).focus();

    $emailAutoComplete.addClass('hide');
});

//记住登录状态
$remember.on('click', function() {
    var $this = $(this);

    $this.toggleClass('checked');

    if ($this.hasClass('checked')) {
        $this.children('i').html(checkbox.checked);
    } else {
        $this.children('i').html(checkbox.unchecked);
    }
});

//focus到输入框则隐藏错误提示和样式
$('.va').on('focus', function() {
    var $this = $(this);

    $this.removeClass('error');

    $this.siblings('.err-tip').addClass('hide');
});

// 验证码刷新
$captchaWrap.on('click', '.change-captcha, .captcha-img', function() {
    $captchaImg.attr('src', captchaUrl + $.now());
});

//登录
$('#login-btn').on('click', login);

//Enter登录
$('input.va').on('keypress', function(e) {
    if (e.which === 13) {
        login();
    }
});

// 初始:只带账户名的页面,密码输入获得焦点
if (($account.val() !== '' || $account.val() === $account.attr('placeholder')) &&
    $password.val() === '') {
    $password.focus();
}
});
define("js/passport/reset", ["jquery","jquery.placeholder"], function(require, exports, module){
/**
 * 找回密码
 * @author: xuqi<qi.xu@yoho.cn>
 * @date: 2015/12/14
 */

var $ = require("jquery");

var $pwd = $('#pwd'),
    $repwd = $('#re-input'),
    $next = $('#reset-pwd-btn'),
    $pwdErr = $('#pwd-err'),
    $repwdErr = $('#repwd-err'),
    $pwdTips = $('#pwd-tips');

var hasNoErrPw = false;

var $pwdIntensity = $('.pwd-intensity'),
    $pwdParent = $pwdIntensity.closest('.pwd-intensity-container'),
    $pwdTip1 = $('#pwd-tip1');

var pwdRegx = require("js/passport/mail-phone-regx").pwdValidateRegx;

require("jquery.placeholder");


/*
 * 计算密码复杂度
 */

function gettype(str, i) {
    if (str.charCodeAt(i) >= 48 && str.charCodeAt(i) <= 57) {
        return 1;
    } else if (str.charCodeAt(i) >= 97 && str.charCodeAt(i) <= 122) {
        return 2;
    } else if (str.charCodeAt(i) >= 65 && str.charCodeAt(i) <= 90) {
        return 3;
    }

    return 4;
}

function isregular(cur, pre, type) {
    var curCode = cur.charCodeAt(0);
    var preCode = pre.charCodeAt(0);

    if (curCode - preCode === 0) {
        return true;
    }

    if (type !== 4 && (curCode - preCode === 1 || curCode - preCode === -1)) {
        return true;
    }

    return false;
}

function getcomplex(curType, preType) {
    if (preType === 0 || curType === preType) {
        return 0;
    } else if (curType === 4 || preType === 4) {
        return 2;
    } else {
        return 1;
    }
}

function computeComplex(password) {
    var complex = 0,
        length = password.length,
        pre = '',
        preType = 0,
        i = 0,
        cur,
        curType;


    for (i = 0; i < length; i++) {
        cur = password.charAt(i);
        curType = gettype(password, i);

        if (preType !== curType || !isregular(cur, pre, curType)) {
            complex += curType + getcomplex(curType, preType);
        }

        pre = cur;
        preType = curType;
    }

    return complex;
}

function pwdKeyupEvt() {
    var pwd = $pwd.val(),
        pwdStrength = computeComplex(pwd),
        level = 0;

    //TODO:自定义密码强度规则,需要修正
    if (pwdStrength === 0) {
        level = 0;
    } else if (pwdStrength <= 10) {
        level = 1;
    } else if (pwdStrength <= 20) {
        level = 2;
    } else {
        level = 3;
    }
    switch (level) {
        case 0:
            $pwdParent.removeClass('red yellow green');
            $pwdIntensity.removeClass('color');
            break;
        case 1:
            $pwdParent.addClass('red').removeClass('yellow green');
            $pwdIntensity.filter('.low').addClass('color');
            $pwdIntensity.filter('.mid,.high').removeClass('color');
            break;
        case 2:
            $pwdParent.addClass('yellow').removeClass('red green');
            $pwdIntensity.filter('.low,.mid').addClass('color');
            $pwdIntensity.filter('.high').removeClass('color');
            break;
        case 3:
            $pwdParent.addClass('green').removeClass('yellow red');
            $pwdIntensity.addClass('color');
            break;
    }

    //提示框
    if (pwd === '') {
        $pwdTip1.removeClass('red yes no').addClass('default');
    } else if (pwd.length < 6 || pwd.length > 20) {
        $pwdTip1.removeClass('default yes').addClass('no red');
    } else {
        $pwdTip1.removeClass('default no red').addClass('yes');
    }

    if (pwdRegx.test(pwd)) {
        hasNoErrPw = true;
    } else {
        hasNoErrPw = false;
    }
}

//IE8 placeholder
$('input').placeholder();

$('.va').keyup(function() {
    var pass = true;

    if ($(this).hasClass('pwd')) {
        pwdKeyupEvt();
    } else {
        if ($(this).val() === '') {
            pass = false;
        }
    }
    if (pass && hasNoErrPw && $pwd.val() === $repwd.val()) {
        pass = true;
    } else {
        pass = false;
    }
    if (pass) {
        $next.removeClass('disable').prop('disabled', false);
    } else {
        $next.addClass('disable').prop('disabled', true);
    }
}).blur(function() {
    var $this = $(this),
        v = $this.val();

    if ($this.hasClass('pwd')) {
        if (v === '') {
            $this.addClass('error');
            $pwdErr.removeClass('hide').find('em').text('请输入密码');
        } else if (v.length < 6 || v.length > 20) {
            $this.addClass('error');
            $pwdErr.removeClass('hide').find('em').text('密码只支持6-20位');
        } else if (!pwdRegx.test(v)) {
            $this.addClass('error');
            $pwdErr.removeClass('hide').find('em').text('密码须字母和数字组合');
        } else {
            $pwdErr.addClass('hide');
            if ($repwd.val() !== '') {
                if (v !== $repwd.val()) {
                    $repwd.addClass('error');
                    $repwdErr.removeClass('hide').find('em').text('两次密码输入不一致,请重新输入');
                } else {
                    $repwd.removeClass('error');
                    $repwdErr.addClass('hide');
                }
            }
        }
    } else {
        if (v === '') {
            $this.addClass('error');
            $repwdErr.removeClass('hide').find('em').text('请输入密码确认');
        } else {
            if ($pwd.val() !== '' && v !== $pwd.val()) {
                $this.addClass('error');
                $repwdErr.removeClass('hide').find('em').text('两次密码输入不一致,请重新输入');
            } else {
                $this.removeClass('error');
                $repwdErr.addClass('hide');
            }
        }
    }
}).focus(function() {
    $(this).removeClass('error');

    //focus后错误提示隐藏
    if ($(this).hasClass('pwd')) {
        $pwdErr.addClass('hide');
    } else {
        $repwdErr.addClass('hide');
    }
});

$pwd.focus(function() {
    $pwdErr.addClass('hide');
    $pwdTips.removeClass('hide');
}).blur(function() {
    $pwdTips.addClass('hide');
});

$('#pwd, #repwd').keydown(function(e) {
    var code = e.keyCode || e.which;

    //空格输入过滤
    if (code === 32) {
        e.preventDefault();
        return;
    }
});

});
define("js/passport/vertification", ["jquery"], function(require, exports, module){
/**
 * 验证手机
 * @author: xuqi<qi.xu@yoho.cn>
 * @date: 2015/12/14
 */

var $ = require("jquery");

var $sc = $('#send-captcha'),
    $msgTip = $('#captcha-tip'),
    $errTip = $('#err-tip'),
    $next = $('#next-step'),
    seconds,
    itime;

$sc.click(function() {
    $.post('/passport/back/sendbackmobile', {
        mobile: $('#mobile').val(),
        area: $('#area').val(),
        verifyCode: $('#captchaPic').val()
    }, function(jsonData) {
        if (jsonData.code === 200) {
            $errTip.hide();
            if ($(this).hasClass('disable')) {
                return;
            }
            seconds = 60;

            //$sc.addClass('disable').prop('disabled', true);
            $sc.addClass('disable').attr('disabled', true);
            $msgTip.removeClass('hide');

            $sc.val(seconds-- + '秒后可重新操作');
            itime = setInterval(function() {
                if (seconds === 0) {
                    clearInterval(itime);

                    //$sc.val('发送验证码').removeClass('disable').prop('disabled', false);
                    $sc.val('发送验证码').removeClass('disable').removeAttr('disabled');
                } else {
                    $sc.val(seconds-- + '秒后可重新操作');
                }
            }, 1000);
        } else {
            $(this).addClass('error');
            $errTip.removeClass('hide').text('发送失败');
        }
    });
});

if ($(this).hasClass('disable')) {
    return;
}
seconds = 60;

//$sc.addClass('disable').prop('disabled', true);
$sc.addClass('disable').attr('disabled', true);
$msgTip.removeClass('hide');

$sc.val(seconds-- + '秒后可重新操作');
itime = setInterval(function() {
    if (seconds === 0) {
        clearInterval(itime);

        //$sc.val('发送验证码').removeClass('disable').prop('disabled', false);
        $sc.val('发送验证码').removeClass('disable').removeAttr('disabled');
    } else {
        $sc.val(seconds-- + '秒后可重新操作');
    }
}, 1000);


$('#captcha').keyup(function() {
    var v = $.trim($(this).val()),
        that = this;

    if (v.length === 4) {
        $.ajax({
            type: 'POST',
            url: '/passport/back/backmobile',
            dataType: 'json',
            data: {
                code: $('#captcha').val(),
                verifyCode: $("#captchaPic").val(),
                area: $('#area').val(),
                mobile: $('#mobile').val()
            },
            success: function(res) {
                if (res.code === 200) {

                    //添加验证码正确验证
                    $next.removeClass('disable').attr('href', res.data);
                    $errTip.addClass('hide');
                    $(that).removeClass('error');
                } else {
                    $next.addClass('disable');
                    $errTip.removeClass('hide').find('em').text('验证码输入错误');
                    $(that).addClass('error');
                }
            }
        });
    }
}).blur(function() {
    var v = $.trim($(this).val());

    if (v === '') {

        //添加验证码正确验证
        $(this).addClass('error');
        $errTip.removeClass('hide').text('请输入验证码');
    }
}).focus(function() {
    $(this).removeClass('error');
});
});
define("js/passport/thirdlogin", ["jquery"], function(require, exports, module){
/**
 * 第三方登录首页
 * @author: wq
 * @date: 2016/1/21
 */
var $ = require("jquery");
var phoneRegx = require("js/passport/mail-phone-regx").phoneRegx;

var nopermissionoption = $('#nopermissionmessage').html(); //倒计时dom
var sendmessagehtml = $('.validatewrapper').html(); //发送短信dom
var second = +$('.second').text(); //倒计时秒数
var dovalidate = false; //校验验证码标识
var validatecode = false; //验证码是否通过
var choosedpic = 'http://cdn.yoho.cn/yohobuy/assets/img/passport/choosed.png';//已选择图片

var $wrapper = $('.bindwrapper'),
    $phoneTip = $wrapper.find('.phone-err-tip'),
    $nextBtn = $wrapper.find('.yohobindbtn');

/**
 * 选择协议
 * @return {[type]} [description]
 */
function chooseProtocol() {
    $('.choosetag').on('change', function() {
        var btnColor = '#f02200';

        if ($(this).attr('checked') === 'checked') {
            $('.choosewrapper').css({
                'background-image': 'url("' + choosedpic + '")'
            });
        } else {
            $('.choosewrapper').css({
                'background-image': 'none'
            });
            btnColor = '#CCCCCC';
        }
        $nextBtn.css({
            'background-color': btnColor
        });
    });
}
/**
 * 判断是否同意协议
 * @return {[type]} [description]
 */
function isagree() {
    return $('.choosetag').attr('checked') === 'checked';
}
/**
 * 选择区域的开关
 * @return {[type]} [description]
 */
function chooseAreaToogle() {
    $('.optionshow').on('click', function() {
        $('.optionslist').toggleClass('hide');
    });
}

/**
 * 验证码校验
 * @return {[type]} [description]
 */
function codeValidate() {
    var validatenum = '';

    $(document).on('keyup', '#validatenum', function() {
        validatenum = $(this).val();
        if (validatenum.length === 4) {
            if (!dovalidate) {
                dovalidate = true;
                $.ajax({
                    type: 'POST',
                    url: '/passport/autouserinfo/checkBindMsg',
                    data: {
                        code: validatenum,
                        mobile: $('#mobile').val(),
                        area: $('#areacode').val()
                    }
                }).then(function(data) {
                    dovalidate = false;
                    if (data.code === 200) {
                        validatecode = true;
                    } else {
                        alert(data.message);
                    }
                });
            }
        }
    });

    $('#validatenum').focus(function() {
        $(this).removeAttr('placeholder');
    }).blur(function() {
        $(this).attr('placeholder', '验证码');
    });
}

/**
 * 选择区域
 * @return {[type]} [description]
 */
function chooseArea() {
    $('.optionitem').on('click', function() {
        var $option = $(this);
        var areanum = $option.attr('areanum');
        var areaname = $option.text();

        $('#areaname').text(areaname);
        $('#areanum').text(areanum);
        $('#areacode').val(areanum);
        $('.optionslist').addClass('hide');
    });
}
/**
 * 取消选择区域
 * @return {[type]} [description]
 */
function cancelChooseArea() {
    $(document).on('click', 'body', function(e) {
        var $target = $(e.target);

        if ($target.hasClass('yohoselectarea') ||
            $target.hasClass('areaname') ||
            $target.hasClass('righttag') ||
            $target.hasClass('optionslist') ||
            $target.hasClass('optionitem')) {
            return;
        } else {
            $('.optionslist').addClass('hide');
        }
    });
}
/**
 * 去掉区域号的加号
 * @return {[type]} [description]
 */
function fixAreaNum() {
    var $opitem = '';
    var itemarecode = '';

    $('.optionitem').each(function() {
        $opitem = $(this);
        itemarecode = $opitem.attr('areanum').replace(/\+/g, '');
        $opitem.attr('areanum', itemarecode);
    });
}

/**
 * 关闭蒙层
 * @return {[type]} [description]
 */
function closeMask() {
    var $target;

    $(document).on('click', '#alreayregist', function(e) {
        $target = $(e.target);
        if ($target.hasClass('mask') || $target.hasClass('backdrop')) {
            $('#alreayregist').hide();
            $('.backdrop').hide();
        }
    });
    $(document).on('click', '#bindconfirm', function(e) {
        $target = $(e.target);
        if ($target.hasClass('mask') || $target.hasClass('backdrop')) {
            $('#bindconfirm').hide();
            $('.backdrop').hide();
        }
    });
}
/**
 * 绑定其他手机号
 * @return {[type]} [description]
 */
function yohoBindBtn() {
    $(document).on('click', '#yohobindbtn', function(e) {
        $('.phonenum').val('');
        $('#bindconfirm').hide();
        $('.backdrop').hide();
    });
    $(document).on('click', '#yohobindbtn2', function(e) {
        $('.phonenum').val('');
        $('#alreayregist').hide();
        $('.backdrop').hide();
    });
}
/**
 * 发送短信的时间变换动画
 * @return {[type]} [description]
 */
function changeSecond() {
    second -= 1;
    if (second < 0) {
        second = 60;
        $('.validatewrapper').html(sendmessagehtml);
        return;
    } else {
        $('.second').text(second);
        window.setTimeout(changeSecond, 1000);
    }

}
/**
 * 时间循环
 * @param  {[type]} phonenum [description]
 * @return {[type]}          [description]
 */
function circleTime(phonenum) {
    $('.validatewrapper').html(nopermissionoption);
    window.setTimeout(changeSecond, 1000);
}
/**
 * 发送短信
 * @return {[type]} [description]
 */
function sendMessageValidate() {
    $(document).on('click', '#sendmessage', function() {
        if ($('#sendmessage').attr('disabled') === 'disabled') {
            return;
        }
        circleTime($('#mobile').val());
        $.ajax({
            type: 'POST',
            url: '/passport/autouserinfo/sendBindMsg',
            data: {
                mobile: $('#mobile').val(),
                area: $('#areacode').val()
            }
        }).then(function(data) {
            if (data.code !== 200) {
                alert(data.message);
            }
        });

    });
}

/**
 * 最终提交表单
 */
function actionSubmit() {
    var mobile = '';
    var area = '';

    area = $('#areacode').val();
    mobile = $('#mobile').val();
    $.ajax({
        type: 'POST',
        url: '/passport/autouserinfo/bindMobile',
        data: {
            area: area,
            openId: $('#openId').val(),
            sourceType: $('#sourceType').val(),
            mobile: mobile,
            code: $('#validatenum').val()
        }
    }).then(function(data) {
        if (data.code === 200) {
            if (data.data && data.data.refer) {
                window.location.href = data.data.refer;
            } else {
                window.location.href = '/passport/thirdlogin/bindsuccess';
            }
        } else {
            alert(data.message);
        }
    });
}

/**
 * 确认去绑定
 * @return {[type]} [description]
 */
function goToBindPhone() {
    $(document).on('click', '#gotobindphone', function() {
        if (validatecode === true) {
            $('#inarea').val($('#areacode').val());
            $('#inmobile').val($('#mobile').val());
            actionSubmit();
        } else {
            alert('请输入正确验证码');
        }
    });
}
/**
 * 点击下一步
 * @return {[type]} [description]
 */
function nextStep() {
    var openId = '';
    var sourceType = '';
    var mobile = '';
    var areaCode = '';
    var username = '';
    var headImg = '';

    $('#bindfirststep').on('click', function(e) {
        var regx;

        e.preventDefault();
        mobile = $('.phonenum').val();
        areaCode = $('#areanum').text();
        regx = phoneRegx['+' + areaCode];

        if (!isagree()) {
            return;
        }
        if (mobile === '' || !regx || !regx.test(mobile)) {
            $phoneTip.find('em').text('手机格式错误');
            $phoneTip.removeClass('hide');
            return;
        }
        openId = $('#openId').val() || '29803EC6D4AAC3AAB8ABDB6AE829D579';
        sourceType = $('#sourceType').val() || 'qq';
        $.ajax({
            type: 'post',
            url: '/passport/autouserinfo/bindCheck',
            data: {
                mobile: mobile,
                area: areaCode,
                openId: openId,
                sourceType: sourceType
            },
            dataType: 'json',
            success: function(data) {
                var winHeight = $(window).height();

                if (data.code === 200) {
                    $('#bindmobileform').attr('action', '/passport/thirdlogin/noregist');
                    $('#bindmobileform').submit();
                }
                if (data.code === 400 || data.code === 402) {
                    $phoneTip.find('em').text('手机格式错误');
                    $phoneTip.removeClass('hide');
                }
                if (data.code === 506) {
                    username = data.data.user.username;
                    headImg = data.data.user.headImg;
                    $('#registphone').text(mobile);
                    $('#username').text(username);
                    if (headImg === '') {
                        $('#userphoto').attr('src', 'http://img10.static.yhbimg.com/headimg/2013/11/28/09/' +
                            '01cae078abe5fe320c88cdf4c220212688.gif?imageView/2/w/100/h/100');
                    } else {
                        $('#userphoto').attr('src', headImg);
                    }
                    $('#logindirectly2').attr('href', data.data.user.bindLogin);
                    $('.backdrop').show();
                    $('#sendmessage').click();
                    $('#alreayregist .mask').css({
                        'padding-top': winHeight > 440 ? winHeight / 2 : 217
                    });
                    $('#alreayregist').show();
                }
                if (data.code === 505) {
                    username = data.data.user.username;
                    headImg = data.data.user.headImg;
                    $('#registphonetwo').text(mobile);
                    $('#username1').text(username);
                    if (headImg === '') {
                        $('#userphoto1').attr('src', 'http://img10.static.yhbimg.com/headimg/2013/11/28/09/' +
                            '01cae078abe5fe320c88cdf4c220212688.gif?imageView/2/w/100/h/100');
                    } else {
                        $('#userphoto1').attr('src', headImg);
                    }
                    $('#logindirectly').attr('href', data.data.user.bindLogin);
                    $('.backdrop').show();
                    $('#bindconfirm .mask').css({
                        'padding-top': winHeight > 440 ? winHeight / 2 : 217
                    });
                    $('#bindconfirm').show();
                }
            }
        });
    });
}

function init() {
    fixAreaNum(); //去掉所有区域的+
    sendMessageValidate(); //有交互的发送短信
    chooseProtocol(); //选择协议
    chooseArea(); //选择区域
    chooseAreaToogle(); //选择区域展示或关闭
    cancelChooseArea(); //取消选择区域
    nextStep();  //下一步
    closeMask(); //关闭蒙层
    yohoBindBtn(); //绑定其他手机号点击
    goToBindPhone(); //绑定手机
    codeValidate(); //验证码校验
}
init();
});
define("js/passport/third-pwd", ["jquery"], function(require, exports, module){
/**
 * 第三方绑定完善个人信息
 * @author: wq
 * @date: 2016/1/27
 */
var $ = require("jquery");
var dovalidate = false; //校验验证码的标识
var isvalidatecode = false; //是否验证成功的标识
var isvalidatepwd = false; //密码验证是否通过的标识
var second = ''; //倒计时时间
var nopermissionoption = ''; //倒计时的dom
var sendmessagehtml = ''; //发送短信的dom
var submitStatus = false; //信息提交状态

var $wrapper = $('.bindwrapper'),
    $codeTip = $wrapper.find('.code-err-tip'),
    $pwdTip = $wrapper.find('.pwd-err-tip'),
    $pwdTip2 = $('#pwd-tip2'),
    $sendMsgBtn = $('#sendmessage');
var $pwd,
    $pwdParent,
    $pwdTip1,
    $pwdIntensity;

var pwdRegx = require("js/passport/mail-phone-regx").pwdValidateRegx;
var mobile = $('#mobile').val(),
    area = $('#area').val();

nopermissionoption = $('#nopermissionmessage').html();
sendmessagehtml = $('.validatewrapper').html();
second = +$('.second').text();


function gettype(str, i) {
    if (str.charCodeAt(i) >= 48 && str.charCodeAt(i) <= 57) {
        return 1;
    } else if (str.charCodeAt(i) >= 97 && str.charCodeAt(i) <= 122) {
        return 2;
    } else if (str.charCodeAt(i) >= 65 && str.charCodeAt(i) <= 90) {
        return 3;
    }

    return 4;
}

function isregular(cur, pre, type) {
    var curCode = cur.charCodeAt(0);
    var preCode = pre.charCodeAt(0);

    if (curCode - preCode === 0) {
        return true;
    }

    if (type !== 4 && (curCode - preCode === 1 || curCode - preCode === -1)) {
        return true;
    }

    return false;
}


function getcomplex(curType, preType) {
    if (preType === 0 || curType === preType) {
        return 0;
    } else if (curType === 4 || preType === 4) {
        return 2;
    } else {
        return 1;
    }
}


/**
 * @desc: 计算密码复杂度(from:http://www.oschina.net/code/snippet_127301_17269)
 * @author: xuqi(qi.xu@yoho.cn)
 * @date: 2015/5/6
 */
function computeComplex(password) {
    var complex = 0;
    var length = password.length;
    var pre = '';
    var preType = 0;
    var i = 0;
    var cur = '';
    var curType = '';

    for (i; i < length; i++) {
        cur = password.charAt(i);
        curType = gettype(password, i);
        if (preType !== curType || !isregular(cur, pre, curType)) {
            complex += curType + getcomplex(curType, preType);
        }
        pre = cur;
        preType = curType;
    }

    return complex;
}

function showErrTip($dom, info) {
    $dom.find('em').text(info);
    $dom.removeClass('hide');
}

function changeSecond() {
    second -= 1;
    if (second < 0) {
        second = 60;
        $('.validatewrapper').html(sendmessagehtml);
        return;
    } else {
        $('.second').text(second);
        window.setTimeout(changeSecond, 1000);
    }

}
/**
 * 启动倒计时
 * @return {[type]} [description]
 */
function circleTime() {
    $('.validatewrapper').html(nopermissionoption);
    window.setTimeout(changeSecond, 1000);
}

function sendMessageValidate() {
    $(document).on('click', '#sendmessage', function() {
        circleTime();
        $.ajax({
            type: 'POST',
            url: '/passport/autouserinfo/sendBindMsg',
            data: {
                mobile: mobile,
                area: area
            }
        }).then(function(data) {
            if (data.code !== 200) {
                alert(data.message);
            }
        });

    });
}



function codeValidate() {
    var validatenum = '';

    $(document).on('keyup', '#validatenum', function() {
        $('#err-info').hide();
        validatenum = $(this).val();
        if (validatenum.length === 4) {
            if (!dovalidate) {
                dovalidate = true;
                $.ajax({
                    type: 'POST',
                    url: '/passport/autouserinfo/checkBindMsg',
                    data: {
                        code: validatenum,
                        mobile: mobile,
                        area: area
                    }
                }).then(function(data) {
                    dovalidate = false;
                    if (data.code !== 200) {
                        $('#err-info').show();
                    } else {
                        isvalidatecode = true;
                    }
                });
            }
        }
    });
}

function pwdKeyupEvt() {
    var pwd = $pwd.val(),
        pwdStrength = computeComplex(pwd),
        level = 0;

    if (pwdStrength === 0) {
        level = 0;
    } else if (pwdStrength <= 10) {
        level = 1;
    } else if (pwdStrength <= 20) {
        level = 2;
    } else {
        level = 3;
    }
    switch (level) {
        case 0:
            $pwdParent.removeClass('red yellow green');
            $pwdIntensity.removeClass('color');
            break;
        case 1:
            $pwdParent.addClass('red').removeClass('yellow green');
            $pwdIntensity.filter('.low').addClass('color');
            $pwdIntensity.filter('.mid,.high').removeClass('color');
            break;
        case 2:
            $pwdParent.addClass('yellow').removeClass('red green');
            $pwdIntensity.filter('.low,.mid').addClass('color');
            $pwdIntensity.filter('.high').removeClass('color');
            break;
        case 3:
            $pwdParent.addClass('green').removeClass('yellow red');
            $pwdIntensity.addClass('color');
            break;
    }
    if (pwd === '') {
        isvalidatepwd = false;
        $pwdTip1.removeClass('red yes no').addClass('default');
    } else {
        if (pwd.length < 6 || pwd.length > 20) {
            isvalidatepwd = false;
            $pwdTip1.removeClass('default yes').addClass('no red');
        } else {
            isvalidatepwd = true;
            $pwdTip1.removeClass('default no red').addClass('yes');
        }
        if (/^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]*$/.test(pwd)) {
            $pwdTip2.removeClass('default no red').addClass('yes');
        } else {
            $pwdTip2.removeClass('default yes').addClass('no red');
        }
    }
}

function validatePwd() {
    $(document).on('keyup', '.pwdcontent', function() {
        pwdKeyupEvt($(this));
    });
    $(document).on('focus', '.pwdcontent', function() {
        $('#pwd-tips').removeClass('hide');
    });
    $(document).on('blur', '.pwdcontent', function() {
        $('#pwd-tips').addClass('hide');
    });
}

/**
 * 最终提交表单
 */
function actionSubmit() {
    var pwd = '';
    var code = '';

    // 查看提交状态,避免重复提交
    if (submitStatus) {
        return;
    }
    submitStatus = true;
    setTimeout(function() {
        submitStatus = false;
    }, 50000);

    pwd = $('#pwd').val();
    code = $('#validatenum').val();
    $.ajax({
        type: 'POST',
        url: '/passport/autouserinfo/bindMobile',
        data: {
            area: area,
            openId: $('#openId').val(),
            sourceType: $('#sourceType').val(),
            mobile: mobile,
            password: pwd,
            code: code
        }
    }).then(function(data) {
        submitStatus = false;
        if (data.code === 200) {
            if (data.data && data.data.refer) {
                window.location.href = data.data.refer;
            } else {
                window.location.href = '/passport/thirdlogin/bindsuccess';
            }
        } else {
            alert(data.message);
        }
    });
}
/**
 * 确定完善信息
 * @return {[type]} [description]
 */
function actionConfirm() {
    var validatenum = '';
    var pwd = '';

    $('#confirmsubmit').on('click', function() {
        var isAssess = true;

        validatenum = $('#validatenum').val();
        pwd = $('#pwd').val();

        if (validatenum === '') {
            showErrTip($codeTip, '短信验证码不能为空');
            isAssess = false;
        } else if (isvalidatecode === false) {
            showErrTip($codeTip, '请输入正确的验证码');
            isAssess = false;
        }

        if (pwd === '') {
            showErrTip($pwdTip, '密码不能为空');
            isAssess = false;
        } else if (pwd.length < 6 || pwd.length > 20) {
            showErrTip($pwdTip, '密码只支持6-20位字符');
            isAssess = false;
        } else if (!pwdRegx.test(pwd)) {
            showErrTip($pwdTip, '密码须由字母和数字组合');
            isAssess = false;
        } else if (isvalidatepwd === false) {
            showErrTip($pwdTip, '请输入符合强度的密码');
            isAssess = false;
        }

        if (!isAssess) {
            return;
        }

        actionSubmit();
    });
}



function init() {
    $pwd = $('#pwd');
    $pwdParent = $('.safelevel');
    $pwdIntensity = $('.pwd-intensity');
    $pwdTip1 = $('#pwd-tip1');
    sendMessageValidate();
    codeValidate();
    validatePwd();
    actionConfirm();
    if (mobile && area) {
        $sendMsgBtn.click();
    }
}

init();

});
define("js/cart/cart", ["jquery","handlebars","source-map"], function(require, exports, module){
/**
 * @description:  购物车
 * @author: chenglong.wang@yoho.cn
 * @tips: 购物车的商品计价在服务端处理,客户端只要在每次操作后刷新页面重新渲染就可以了
 */

var $ = require("jquery");
var Handlerbars = require("handlebars");
var dialog = require("js/common/dialog");

var Confirm = dialog.Confirm;
var Alert = dialog.Alert;

var $cartnewSum = $('.cartnew-sum'),
    $cartnewTips = $('.cartnew-tips'),
    $payWapper = $('.pay-wapper'),
    $goodsDetail = $('.goods-detail'),
    $histroy = $('.histroy'),
    $together = $('.together'),
    $shopCart = $('.shop-cart'),
    $detailBigpic = $('.detail-bigpic'),
    togetherProductSource,
    togetherProductTemplate,
    togetherProductStr,
    subjoinPage,
    subjoinPageNum,
    subjoinPageAll,
    pageDom,
    selected,
    pageNum = 1,
    productNum,
    goodstype,
    delUrl,
    count,
    countJSON,
    id,
    dataJSON,
    pacList = 0,
    shopNum = 1,
    shopNumAll,
    productSku,
    promotionId,
    promotionPrice,
    yetCollect,
    collect,
    isClass,
    content,
    productId,
    shopName,
    delNum,
    understock,
    selectArray = [];


// 关闭温馨提示
$cartnewTips.find('.btn_close').click(function() {
    $cartnewTips.fadeOut();
});

// checkbox提交ajax
function choiceOut(data) {
    dataJSON = {
        skuList: JSON.stringify(data)
    };
    $.ajax({
        type: 'POST',
        dataType: 'json',
        url: '/cart/index/select',
        data: dataJSON,
        beforeSend: function() {
            $('.loading').css({
                top: $(document).scrollTop() + 200
            });
            $('.loading').show();
        }
    }).then(function(d) {
        if (d.code === 200) {
            window.history.go(0);
        }
    });
}

//单选提交
$payWapper.on('click', '.common-sell-box input[type="checkbox"], .pre-sell-box input[type="checkbox"]', function() {
    selectArray = [];
    selected = $(this).attr('checked') ? 'Y' : 'N';
    id = $(this).parents('tr').data('id');
    productNum = $(this).parents('tr').data('productnum');
    goodstype = $(this).data('goodstype');
    selectArray.push({
        product_sku: id,
        selected: selected,
        buy_number: productNum,
        goods_type: goodstype
    });
    choiceOut(selectArray);
});

//多选提交
$cartnewSum.on('click', 'input[type="checkbox"]', function() {
    selectArray = [];
    selected = $(this).attr('checked') ? 'Y' : 'N';
    $('.pay-wapper:first tr').each(function() {
        if ($(this).data('id')) {
            selectArray.push({
                product_sku: $(this).data('id'),
                selected: selected,
                buy_number: $(this).data('productnum'),
                goods_type: $(this).find('input[type="checkbox"]').data('goodstype')
            });
        }
    });
    choiceOut(selectArray);
});

// 凑单商品,最近浏览异步加载
togetherProductSource = $('#togetherProduct').html();
togetherProductTemplate = Handlerbars.compile(togetherProductSource);

function getTogetherProduct($obj, url, page) {
    $.ajax({
        type: 'GET',
        dataType: 'json',
        url: url,
        data: page
    }).then(function(d) {
        if (d.code === 200) {
            if (d.data.item) {
                if (d.data.item.length > 0) {
                    $obj.html(' ');
                    togetherProductStr = togetherProductTemplate(d.data);
                    $obj.append($(togetherProductStr));
                    $('#orderProduct li:last').addClass('end');
                    $('.gift').removeClass('none');
                }
            }
        }
    });
}

// 最近浏览
getTogetherProduct($histroy, '/cart/index/getHistroyProduct');

// 凑单商品
getTogetherProduct($together, '/cart/index/getTogetherProduct');

//凑单商品翻页
$together.on('click', '.pagenext, .pageprev', function() {
    getTogetherProduct($together, '/cart/index/getTogetherProduct', {
        page: Math.ceil(Math.random() * 100) + 1
    });

});

//凑单商品,历史商品商品折叠
$shopCart.on('click', '.icon-minus, .icon-add', function() {
    if ($(this).hasClass('icon-minus')) {
        $(this).parents('.title').next('.main').hide();
        $(this).parents('h2').next('.right').hide();
    } else {
        $(this).parents('.title').next('.main').show();
        $(this).parents('h2').next('.right').show();
    }
    $(this).siblings('i').toggleClass('none');
    $(this).toggleClass('none');

});

// 最近浏览翻页
$histroy.on('click', '.pagenext, .pageprev', function() {
    if ($(this).hasClass('pagenext')) {
        pageNum++;
    } else {
        --pageNum > 0 || (pageNum = 1);
    }
    getTogetherProduct($histroy, '/cart/index/getHistroyProduct', {
        page: pageNum
    });

});


//根据id获取商品信息
function productInfo(data) {
    $.ajax({
        type: 'GET',
        dataType: 'html',
        url: '/cart/index/getProductInfo',
        data: data
    }).then(function(d) {
        $goodsDetail.html(' ');
        $goodsDetail.append(d);
        $('.bigpic :not(:first)').hide();
        $('.detail-bigpic:first .con li:first').addClass('active');
        if ($('.showSizeBox:not(.none) span:first').data('num') > 0) {
            $('.showSizeBox:not(.none) span:first').addClass('atcive');
        } else {
            $('.addcart').addClass('none');
            $('.btn_sellout').removeClass('none');
        }
        $.each($('.showSizeBox span'), function() {
            if ($(this).data('num') <= 0) {
                $(this).addClass('nullAtcivec');
            }
        });

        if (typeof promotionPrice !== 'undefined') {
            $('.oldprice').html('现价:<del>' + $('.oldprice del').html() + '</div>');
            $('.newprice').html('活动价<b class="promotion-price">' + promotionPrice + '</b>');
        }
        $goodsDetail.show();
    });
}

function removeInfo() {
    $goodsDetail.html(' ');
    $goodsDetail.css({
        top: $(document).scrollTop() + 30,
        left: $(document).width() / 2 - $goodsDetail.width() / 2
    });

}

//显示加价购商品信息
$payWapper.on('click', '.cart-add-btn', function() {
    productId = $(this).data('id');
    promotionId = $(this).parents('table').data('promotion');
    promotionPrice = $(this).parents('table').find('.subjoin-price').html();
    removeInfo();
    productInfo({
        productId: productId
    });
});

//凑单商品,历史商品商品记录
$('.clearfix').on('click', '.btn_view_s', function() {
    productId = $(this).data('id');
    promotionId = $(this).parents('table').data('promotion');
    promotionPrice = $(this).parents('table').find('.subjoin-price').html();
    removeInfo();
    productInfo({
        productId: productId
    });
});

//关闭商品信息窗口
$goodsDetail.on('click', '.colse', function() {
    $goodsDetail.hide();
    $goodsDetail.html(' ');
    shopNum = 1;
});

//展开加价购商品列表
function fold(icon) {
    icon.addClass('none').siblings('i').removeClass('none');
    icon.parents('.cart-product-num').siblings('div').toggleClass('fold');
    icon.siblings('.unfold-color').toggleClass('none');
    icon.siblings('.cart-page').toggleClass('none');
}

$payWapper.on('click', '.icon-minusCart, .icon-addCart', function() {
    fold($(this));
});


$payWapper.on('click', '.unfold-color', function() {
    fold($(this));
    $(this).siblings('.icon-minusCart').removeClass('none');
    $(this).siblings('.icon-addCart').addClass('none');
});

//加价购商品分页
$payWapper.on('click', '.cart-btn-next', function() {
    subjoinPage = $(this).siblings('p').find('.f-red');
    subjoinPageAll = Number($(this).siblings('p').find('.subjoinPageNum').html());
    subjoinPageNum = Number(subjoinPage.html());
    subjoinPage.html(subjoinPageNum + 1);
    if (subjoinPageNum >= subjoinPageAll - 1) {
        $(this).hide();
    } else {
        $(this).siblings('i').show();
    }
    pageDom = $(this).parents('.cart-product-num').siblings('div').find('table');
    pageDom.addClass('none').eq(subjoinPageNum).removeClass('none');
});

$payWapper.on('click', '.cart-btn-pre', function() {
    subjoinPage = $(this).siblings('p').find('.f-red');
    subjoinPageAll = Number($(this).siblings('p').find('.subjoinPageNum').html());
    subjoinPageNum = Number(subjoinPage.html());
    subjoinPage.html(subjoinPageNum - 1);
    if (subjoinPageNum <= 2) {
        $(this).hide();
    } else {
        $(this).siblings('i').show();
    }
    pageDom = $(this).parents('.cart-product-num').siblings('div').find('table');
    pageDom.addClass('none').eq(subjoinPageNum - 2).removeClass('none');
});

//删除购物车商品,把删除的商品移入cookie中
function cartDel(data, delUrl, cookieList) {
    dataJSON = {
            skuList: JSON.stringify(data)
        };
    $.ajax({
        type: 'POST',
        dataType: 'json',
        url: delUrl,
        data: dataJSON,
        beforeSend: function() {
            $('.loading').css({
                top: $(document).scrollTop() + 200
            });
            $('.loading').show();
        }
    }).then(function(d) {
        if (d.code === 200) {
            if (cookieList) {
                window.setCookie('cart-del-list', JSON.stringify(cookieList), {
                    domain: '.yohobuy.com',
                    path: '/'
                });
            }
            window.history.go(0);
        } else if (d.code === 300) {
            $('.loading').hide();
            new Alert(d.message).show();
        } else if (d.code === 403) {
            if (d.data.url) {
                window.location = d.data.url;
            }
        }
    });
}

//商品信息弹出框,加入收藏夹
$goodsDetail.on('click', '.fav_count', function() {
    $.ajax({
        type: 'POST',
        dataType: 'json',
        url: '/product/item/togglecollect',
        data: {
            productId: productId,
            type: 'add'
        }
    }).then(function(d) {
        if (d.code === 200) {
            new Alert(d.message).show();
        } else if (d.code === 403) {
            if (d.data.url) {
                window.location = d.data.url;
            }
        } else {
            new Alert(d.message).show();
        }
    });
});

//删除商品
$payWapper.on('click', '.cart-del-btn', function() {
    id = {};
    countJSON = {};
    isClass = $(this).attr('class');
    productNum = $(this).parents('tr').data('productnum');
    id['' + $(this).parents('tr').data('id')] = productNum;

    content = '<div><span></span>删除商品</div>' +
              '<p>确定从购物车中删除此商品?</p>';
    if (!$(this).data('gift')) {
        countJSON = {
            productPrice: $(this).parents('tr').find('.productPrice').text(),
            productTitle: $(this).parents('tr').find('.pay-pro-info a').text(),
            link: $(this).parents('tr').find('.pay-pro-info a').attr('href'),
            productNum: $(this).parents('tr').data('productnum'),
            productSku: $(this).parents('tr').data('id')
        };
    }
    delUrl = '/cart/index/remove';
    new Confirm({
        content: content,
        cb: function() {
                cartDel(id, delUrl, countJSON);
            }
    }).show();
});

//移入收藏夹
$payWapper.on('click', '.cart-remove-btn', function() {
    id = {};
    isClass = $(this).attr('class');
    productNum = $(this).parents('tr').data('productnum');
    id['' + $(this).parents('tr').data('id')] = productNum;
    cartDel(id, '/cart/index/fav');
});

//批量删除商品
$cartnewSum.on('click', '.delAll', function() {
    id = {};
    selectArray = [];
    $('.pay-wapper:first tr').each(function() {
        if ($(this).data('id')) {
            if ($(this).find('input[type="checkbox"]').attr('checked')) {
                id['' + $(this).data('id')] = $(this).data('productnum');
                countJSON = {
                    productPrice: $(this).find('.productPrice').text(),
                    productTitle: $(this).find('.pay-pro-info a').text(),
                    link: $(this).find('.pay-pro-info a').attr('href'),
                    productNum: $(this).data('productnum'),
                    productSku: $(this).data('id')
                };
                selectArray.push(countJSON);
            }
        }
    });
    delUrl = '/cart/index/remove';
    content = '<div><span></span>删除商品</div>' +
              '<p>确定从购物车中删除所有选中商品?</p>';
    if (!$.isEmptyObject(id)) {
        new Confirm({
            content: content,
            cb: function() {
                    cartDel(id, delUrl, selectArray);
                }
        }).show();
    } else {
        new Alert('请至少选择一件商品').show();
    }
});

//批量移入收藏夹商品
$cartnewSum.on('click', '.removeAll', function() {
    id = {};
    $('.pay-wapper:first tr').each(function() {
        if ($(this).data('id')) {
            if ($(this).find('input[type="checkbox"]').attr('checked')) {
                id['' + $(this).data('id')] = $(this).data('productnum');
            }
        }
    });
    if (!$.isEmptyObject(id)) {
        cartDel(id, '/cart/index/fav');
    } else {
        new Alert('请至少选择一件商品').show();
    }
});

//购物车商品增减
function countAJAX(data) {
    $.ajax({
        type: 'POST',
        dataType: 'json',
        url: '/cart/index/modify',
        data: data
    }).then(function(d) {
        if (d.code === 200) {
            window.history.go(0);
        }
    });
}

$payWapper.on('click', '.minus, .plus', function() {
    countJSON = {};
    count = $(this).hasClass('minus') ? 'decreaseNum' : 'increaseNum';
    countJSON['' + count] = 1;
    if ($(this).siblings('input').val() === '1' && $(this).hasClass('minus')) {
        id = {};
        isClass = $(this).attr('class');
        productNum = $(this).parents('tr').data('productnum');
        id['' + $(this).parents('tr').data('id')] = productNum;

        content = '<div><span></span>删除商品</div>' +
                  '<p>确定从购物车中删除此商品?</p>';
        countJSON = {
            productPrice: $(this).parents('tr').find('.productPrice').text(),
            productTitle: $(this).parents('tr').find('.pay-pro-info a').text(),
            link: $(this).parents('tr').find('.pay-pro-info a').attr('href'),
            productNum: $(this).parents('tr').data('productnum'),
            productSku: $(this).parents('tr').data('id')
        };
        delUrl = '/cart/index/remove';

        // new Confirm({
        //     content: content,
        //     cb: function() {
        //             cartDel(id, delUrl);
        //         }
        // }).show();
        return false;
    }

    countAJAX($.extend(countJSON,
        {
            sku: $(this).parents('tr').data('id')
        }
    ));
});



$('.gift').on('click', '.up, .down', function() {
    $(this).siblings('i').toggleClass('none');
    $(this).toggleClass('none');
});

//加入购物车

function addcart(data, cookieList) {
    $.ajax({
        type: 'POST',
        url: '/cart/index/add',
        data: data
    }).then(function(d) {
        if (d.code === 200) {
            window.history.go(0);
            if (cookieList) {
                window.setCookie('cart-del-list', JSON.stringify(cookieList), {
                    domain: '.yohobuy.com',
                    path: '/'
                });
            }
        } else if (d.code === 500) {
            new Alert(d.message).show();
        }
    });
}

$goodsDetail.on('click', '.addcart', function() {
    shopNumAll = $('.showSizeBox:not(.none) .atcive').data('num');
    productSku = $('.showSizeBox:not(.none) .atcive').data('sku');
    dataJSON = {
        productSku: productSku,
        buyNumber: $('#mnum').val(),
        promotionId: promotionId
    };

    if ($('#mnum').val() > shopNumAll) {
        new Alert('库存不足,目前还有' + shopNumAll + '个库存').show();
    } else {
        addcart(dataJSON);
    }
});

$goodsDetail.on('click', '.cut, .add', function() {
    count = $(this).hasClass('minus') ? 'decreaseNum' : 'increaseNum';
    if (promotionId) {
        if ($(this).hasClass('cut')) {
            new Alert('-_-,已经是最后一件,不能在减了!').show();
        } else {
            new Alert('最多只能购买1,您好像购买的太多了!').show();
        }
    } else {
        if ($(this).hasClass('add')) {
            shopNum++;
        } else {
            shopNum--;
        }
        if (shopNum < 1) {
            new Alert('-_-,已经是最后一件,不能在减了!').show();
            return false;
        }

        $('#mnum').val(shopNum);
    }

});

$goodsDetail.on('click', '.color', function() {
    $('.color').find('p').removeClass('atcive');
    $(this).find('p').addClass('atcive');
    $('.showSizeBox').addClass('none').eq($(this).index()).removeClass('none');
    if ($('.showSizeBox:not(.none) span:first').data('num') > 0) {
        $('.showSizeBox:not(.none) span:first').addClass('atcive');
        $('.addcart').removeClass('none');
        $('.btn_sellout').addClass('none');
    } else {
        $('.showSizeBox:not(.none) span:first').addClass('atcivec');
        $('.addcart').addClass('none');
        $('.btn_sellout').removeClass('none');
    }
    $detailBigpic.addClass('none').eq($(this).index()).removeClass('none');
    $detailBigpic.eq($(this).index()).find('.bigpic:first').show();
    $detailBigpic.eq($(this).index()).find('.con li:first').addClass('active');

});

$goodsDetail.on('click', '.showSizeBox span', function() {
    shopNumAll = $(this).data('num');
    if ($(this).data('num') > 0) {
        $('.showSizeBox:not(.none) span').removeClass('atcivec atcive').eq($(this).index()).addClass('atcive');
        $('.addcart').removeClass('none');
        $('.btn_sellout').addClass('none');
    } else {
        $('.showSizeBox:not(.none) span').removeClass('atcivec atcive').eq($(this).index()).addClass('atcivec');
        $('.addcart').addClass('none');
        $('.btn_sellout').removeClass('none');
    }
});

//撤销删除
$('.goBack').on('click', function() {
    delNum = $('.dev-revocation .goBack').index(this);
    selectArray = [];
    $('.dev-revocation tr').each(function(index) {
        if (delNum !== index) {
            countJSON = {
                productPrice: $(this).find('.productPrice').text(),
                productTitle: $(this).find('.title').text(),
                link: $(this).find('.title').attr('href'),
                productNum: $(this).data('productnum'),
                productSku: $(this).data('productsku')
            };
            selectArray.push(countJSON);
        }
    });
    dataJSON = {
        productSku: $(this).parents('tr').data('productsku'),
        buyNumber: $(this).parents('tr').data('productnum')
    };

    addcart(dataJSON, selectArray);
});

$goodsDetail.on('click', '.piclist li', function() {
    pacList = $(this).index();
    $('.detail-bigpic:not(.none) .piclist li').removeClass('active');
    $(this).addClass('active');
    $('.detail-bigpic:not(.none) .bigpic').hide().eq($(this).index()).show();
});

function isSollect() {
    $('.gift-wrapper .fold').show();
    if ($('.pre-sell-box input:checked').length === $('.pre-sell-box input[type="checkbox"]').length) {
        $('.per-list input[type="checkbox"]').attr('checked', true);
    }

    if ($('.common-sell-box input:checked').length === $('.common-sell-box input[type="checkbox"]').length) {
        $('.common-list input[type="checkbox"]').attr('checked', true);
    }

    $('.cart-page').each(function() {
        if ($(this).data('pageall') === 1) {
            $('.cart-btn-pre', this).hide();
            $('.cart-btn-next', this).hide();
        } else {
            $('.cart-btn-pre', this).hide();
        }
    });

    if ($('.pre-sell-box input:checked').length > 0 && $('.common-sell-box input:checked').length > 0) {
        $('.go_cash_tips').show();
        $('.btn_account_disabled').show();
        $('.btn_account').hide();
    } else {
        $('.go_cash_tips').hide();
        $('.btn_account').show();
        $('.btn_account_disabled').hide();
    }

    $('.pay-wapper tr').each(function() {
        if ($(this).data('pid')) {
            selectArray.push($(this).data('pid') + '');
        }

    });
    $.ajax({
        type: 'POST',
        url: '/cart/index/checkFav',
        data: {
            pidList: JSON.stringify(selectArray)
        }
    }).then(function(d) {
        yetCollect = '<span class="cart-yetremove-btn">已收藏</span>';
        collect = '<a href="javascript:void(0);" class="cart-remove-btn"><span>移入收藏</span></a>';
        $.each(d.data, function(key, val, index) {
            $('.pay-wapper tr').each(function() {
                if (Number($(this).data('pid')) === Number(key)) {
                    if (val) {
                        $(this).find('.cart-operation').append(yetCollect);
                    } else {
                        $(this).find('.cart-operation').append(collect);
                    }
                }
            });
        });
    });
}

isSollect();

$goodsDetail.on('click', '.pre, .next', function() {
    if ($(this).hasClass('next')) {
        if (pacList > $(this).siblings('.con').find('li').length - 2) {
            return false;
        }
        pacList++;
    } else {
        if (pacList < 1) {
            return false;
        }
        pacList--;
    }

    $(this).siblings('.con').find('li').removeClass('active').eq(pacList).addClass('active');
    $('.bigpic').hide().eq(pacList).show();
});

//结算
$('.btn_account').on('click', function() {
    understock = '';
    if ($('.pay-wapper input:checked').parents('tr').find('.tipNoStore').length > 0) {
        shopName = $('.pay-wapper input:checked').parents('tr').find('.tipNoStore');
        $.each(shopName.parents('.common-sell-box').find('.pay-pro-info a'), function() {
            understock += $(this).html();
        });
        new Alert(understock + '库存不足').show();
    } else {
        if ($('.zp').length > 0 && !$(this).attr('title')) {
            $(this).attr('title', '1');
            new Alert('您有赠品没有选择,请选择完再结算!').show();
        } else {
            if ($('input:checked').length > 0) {
                if ($('.pre-sell-box input:checked').length > 0) {
                    window.location.href = '/cart/index/orderEnsure?type=2';
                } else {
                    window.location.href = '/cart/index/orderEnsure?type=1';
                }
            } else {
                new Alert('请至少选择一件商品').show();
            }
        }
    }
});

function isCheck(obj, className) {
    selectArray = [];
    selected = obj.attr('checked') ? 'Y' : 'N';
    $('.' + className).each(function() {
        if ($(this).data('id')) {
            selectArray.push({
                product_sku: $(this).data('id'),
                selected: selected,
                buy_number: $(this).data('productnum'),
                goods_type: $(this).find('input[type="checkbox"]').data('goodstype')
            });
        }
    });
    choiceOut(selectArray);
}

$('.per-list').on('click', 'input[type="checkbox"]', function() {
    isCheck($(this), 'pre-sell-box');
});

$('.common-list').on('click', 'input[type="checkbox"]', function() {
    isCheck($(this), 'common-sell-box');
});
});
define("js/home/entry", ["jquery","handlebars","source-map"], function(require, exports, module){
/**
 * 个人中心页js打包入口文件
 * @author: zhaobiao<bill.zhao@yoho.cn>
 * @date: 2016/02/17
 */

require("js/home/index");
require("js/home/orders");
require("js/home/favorite");

require("js/home/returns");
require("js/home/comment");

require("js/home/edit");
require("js/home/gift");
require("js/home/validate");
require("js/home/address");
require("js/home/common-address");
});
define("js/home/index", ["jquery"], function(require, exports, module){
/**
 * 个人中心首页
 * @author: xuqi<qi.xu@yoho.cn>
 * @date: 2016/2/17
 */

var $ = require("jquery");

//关闭消息提示
$('#close-message').click(function() {
    $('.message-tip').slideUp(200);
});

//新品上架
(function() {
    var $naPager = $('.na-pager'),
        $naUl = $('.new-arrival ul'),
        naPage = Math.ceil($naUl.children('li').length / 5),
        naItemWith = $naUl.children('li:last-child').outerWidth(),
        naCurPage = 1;

    $naUl.width($naUl.width() * naPage);

    //最新上架翻页
    $naPager.click(function() {
        var $this = $(this),
            left;

        if ($this.hasClass('next')) {

            //后翻
            ++naCurPage;

            //第2页显示前翻按钮
            if (naCurPage === 2) {
                $this.siblings().removeClass('no-visible');
            }

            //最后一页隐藏后翻按钮
            if (naCurPage === naPage) {
                $this.addClass('no-visible');
            }
        } else {

            //前翻
            --naCurPage;

            //倒数第2页显示后翻按钮
            if (naCurPage === naPage - 1) {
                $this.siblings().removeClass('no-visible');
            }

            //第1页隐藏前翻按钮
            if (naCurPage === 1) {
                $this.addClass('no-visible');
            }
        }

        left = -5 * (naCurPage - 1) * naItemWith;

        $naUl.animate({
            marginLeft: left
        }, 400);
    });
}());
});
define("js/home/orders", ["jquery","handlebars","source-map"], function(require, exports, module){
/**
 * 我的订单
 * @author: xuqi<qi.xu@yoho.cn>
 * @date: 2016/2/17
 */

require("js/home/order-block");
});
define("js/home/order-block", ["jquery","handlebars","source-map"], function(require, exports, module){
/**
 * 订单
 * @author: xuqi<qi.xu@yoho.cn>
 * @date: 2016/2/17
 */

var $ = require("jquery");

var dialog = require("js/common/dialog");

var Dialog = dialog.Dialog;
var Confirm = dialog.Confirm;

var $tpl = $('#cancel-dialog-tpl');

var html = $tpl.html();

var active;

function dialogFactory(id) {
    var options = {
        mask: false,
        btns: [
            {
                id: 'cancel-sure',
                name: '确定并取消订单',
                btnClass: ['cancel-sure'],
                cb: function() {
                    var $checked = $('.cancel-dialog :checked');

                    $.ajax({
                        type: 'POST',
                        url: '/home/orders/cancelorder',
                        data: {
                            orderCode: id,
                            reason: $checked.length > 0 ? $checked.val() : ''
                        }
                    }).then(function(data) {
                        if (data.code === 200) {
                            active.close();
                            history.go(0);
                        } else {
                            $('.cancel-dialog .cancel-tip').html(data.message);
                        }
                    });
                }
            },
            {
                id: 'cancel-no',
                name: '取消',
                btnClass: ['cancel-no'],
                cb: function() {
                    active.close();
                }
            }
        ],
        content: html,
        className: 'cancel-dialog'
    };

    return new Dialog(options);
}

$tpl.remove();

//查看物流
$('.check-logistics').click(function() {
    $(this).parent().siblings('.logistics').removeClass('hide');
});

$('.close-logistics').click(function() {
    $(this).closest('.logistics').addClass('hide');
});

$('.me-orders').on('click', '.cancel-order', function(e) {

    //取消订单
    active = dialogFactory($(this).closest('.order').data('id'));
    active.show();
}).on('click', '.confirm-received', function(e) {
    var id = $(this).closest('.order').data('id');

    //确认收货
    active = new Confirm({
        cb: function() {
            $.ajax({
                type: 'POST',
                url: '/home/orders/confirmorder',
                data: {
                    orderCode: id
                }
            }).then(function(data) {
                if (data.code === 200) {
                    active.close();
                    history.go(0);
                }
            });
        },
        content: '您确定要确认收货吗?'
    });
    active.show();
});
});
define("js/home/favorite", ["jquery"], function(require, exports, module){
/**
 * 我的收藏
 * @author: xuqi<qi.xu@yoho.cn>
 * @date: 2016/2/23
 */

var $ = require("jquery");

var phoneReg = require("js/passport/mail-phone-regx").phoneRegx['+86'];

var clockTxt = {
    on: '[ 降价通知 ]',
    off: '[ 取消通知 ]'
};

var favType;

var curSkn;

var $curClock;

//商品收藏
(function() {
    var $defaultSorts,
        $allSorts;

    var $bodyMask,
        $priceNotice,
        $noticeContent,
        $noticeSuccess,
        $noticeSubOrCancel;

    //关闭价格订阅弹窗和蒙层
    function closeNoticeBox() {
        $bodyMask.addClass('hide');
        $priceNotice.addClass('hide');

        //重置头部文字
        $noticeSubOrCancel.text('订阅成功');
    }

    //显示价格订阅弹窗和蒙层
    function showNoticeBox() {
        if (typeof $bodyMask === 'undefined') {
            $('body').append('<div class="body-mask hide"></div>');
            $bodyMask = $('.body-mask');
        }

        $bodyMask.css({
            height: $(document).height(),
            width: $(document).width()
        }).removeClass('hide');

        if ($curClock.hasClass('noticed')) {

            //取消降价通知
            $.ajax({
                type: 'GET',
                url: '/home/favorite/cancelnotice',
                data: {
                    skn: curSkn
                }
            }).then(function(data) {
                if (data.code === 200) {
                    $noticeContent.addClass('hide');
                    $noticeSuccess.removeClass('hide').find('.notice-num').text(data.data.num);
                    $noticeSubOrCancel.text('取消成功');

                    if ($curClock.closest('.reduction-products').length > 0) {
                        $curClock.closest('.fav-good').remove();
                    } else {
                        $curClock.text(clockTxt.on);
                    }
                }
            });
        }

        $priceNotice.removeClass('hide');
    }

    if ($('.fav-products').length === 0) {
        return;
    }

    favType = 'products';

    $defaultSorts = $('.default-sorts');
    $allSorts = $('.all-sorts');

    $priceNotice = $('.price-notice');

    $noticeContent = $('#price-notice .content');
    $noticeSuccess = $('#price-notice .success');
    $noticeSubOrCancel = $noticeSuccess.find('.subscribe-or-cancel');

    //展开分类
    $('#spread-sort').click(function() {
        $defaultSorts.slideUp(function() {
            $allSorts.slideDown();
        });
    });

    //收起分类
    $('#retract-sort').click(function() {
        $allSorts.slideUp(function() {
            $defaultSorts.slideDown();
        });
    });

    //降价通知
    $('.price-down-clock').click(function() {
        $curClock = $(this),

        showNoticeBox();

        curSkn = $curClock.closest('.fav-good').data('skn');
    });

    //降价通知确定按钮
    $('#price-notice').on('click', '.close', function() {
        closeNoticeBox();
    }).on('click', '.price-notice-sure', function() {
        var $phone = $('#notice-phone-num'),
            phone,
            errTxt;

        if ($noticeSuccess.hasClass('hide')) {

            //订阅到手机号
            phone = $.trim($phone.val());

            if (phone === '' || !phoneReg.test(phone)) {
                errTxt = phone === '' ? '请输入手机号码' : '手机号码格式不正确';

                $phone.addClass('error');
                $('#price-notice .err-text').removeClass('hide').find('em').html(errTxt);
                return;
            } else {
                $phone.removeClass('error');
                $('#price-notice .err-text').addClass('hide');
            }

            $.ajax({
                type: 'GET',
                url: '/home/favorite/notice',
                data: {
                    phone: phone,
                    skn: curSkn
                }
            }).then(function(data) {
                if (data.code === 200) {
                    $noticeSuccess.removeClass('hide');
                    $noticeContent.addClass('hide');
                    $noticeSuccess.find('.notice-num').html(data.data.num);

                    //切换商品通知文字
                    $curClock.toggleClass('noticed').text(clockTxt.off);
                }
            });
        } else {

            //关闭窗口
            closeNoticeBox();
        }
    });

    //商品可参加活动
    $('.has-activity').click(function() {
        var $this = $(this),
            $activites = $this.next('.activites'),
            $li = $this.closest('li');

        if ($activites.hasClass('hide')) {

            //显示
            $activites.removeClass('hide');
            $li.css('padding-bottom', $activites.outerHeight());
        } else {

            //隐藏
            $activites.addClass('hide');
            $li.css('padding-bottom', '');
        }
    });
}());


//品牌收藏
(function() {

    if ($('.fav-brands').length === 0) {
        return;
    }

    // 新品到着
    $('.na-not-zero').click(function() {
        var $this = $(this),
            $naList = $this.next('.na-list'),
            $li = $this.closest('li');

        if (!$naList.hasClass('hide')) {
            $naList.addClass('hide');
            $li.css('padding-bottom', '');
            return;
        }

        $.ajax({
            type: 'GET',
            url: '/home/newproduct'
        }).then(function(html) {
            $naList.removeClass('hide').find('.na-content').html(html);
            $li.css('padding-bottom', $naList.outerHeight() + 10);
        });
    });

    $('.na-content').on('click', '.na-pre, .na-next', function() {
        var $this = $(this),
            url = $this.data('url');

        $.ajax({
            type: 'GET',
            url: url
        }).then(function(html) {
            $this.closest('.na-content').html(html);
        });
    });
}());

//全选【通用】
$('#me-checkall').click(function() {
    $('.checkbox input[type="checkbox"]').prop('checked', $(this).prop('checked'));
});

//删除多个商品/品牌/文章【通用】
$('#me-del-checked').click(function() {
    var ids = [],
        url;

    $('.checkbox input[type="checkbox"]:checked').each(function() {
        ids.push($(this).closest('.fav-row').data('id'));
    });

    if (ids.length === 0) {
        return;
    }

    switch (favType) {
        case 'products':
            url = '/home/favorite/multidelgoods';
            break;
        case 'brands':
            url = '/home/favorite/multidelbrands';
            break;
        case 'articles':
            url = '/home/favorite/multidelarticles';
            break;
    }

    $.ajax({
        type: 'GET',
        url: url,
        data: {
            ids: ids
        }
    }).then(function(data) {
        if (data.code === 200) {
            window.history.go(0);
        }
    });
});
});
define("js/home/returns", ["jquery","handlebars","source-map"], function(require, exports, module){
/**
 * 我的退/换货
 * @author: yyqing<yanqing.yang@yoho.cn>
 * @date: 2016/2/26
 */

require("js/home/returns-detail");
require("js/home/returns-apply");
});
define("js/home/returns-detail", ["jquery"], function(require, exports, module){
/**
 * 退换货详情
 * @author: yyqing<yanqing.yang@yoho.cn>
 * @date: 2016/2/26
 */

var $ = require("jquery");

var $detail = $('.detail-container'),
    $courierCode = $('.courier-code'),
    $expressCompany = $('#express-company'),
    $expressNumber = $('#express-number'),
    $expressViewBox = $('.express-view-box > span');

var returnId = $('#return-id').val(),
    expId = $('#express-old-id').val(),
    expNumber = $expressNumber.val(),
    expCompany = '',
    expList = {},
    isChange = false;

function syncExpressInfo() {
    expCompany = expList[expId] ? expList[expId] : '';
    $expressViewBox.html(expCompany + ' 快递单号:' + expNumber);
    $expressCompany.val(expId);
    $expressNumber.val(expNumber);
}

function validateExpress() {
    var send = {};

    send.number = $expressNumber.val();
    send.id = $expressCompany.val() * 1;

    if (!send.id) {
        alert('请选择快递公司');
    } else if (!send.number) {
        alert('请填入快递单号');
    } else {
        return send;
    }

    return false;
}

function sendExpressCode() {
    var sendParm = validateExpress();

    if (!sendParm) {
        return;
    }

    $.ajax({
        type: 'POST',
        url: '/home/returns/setExpressNumber',
        data: {
            id: returnId,
            isChange: isChange,
            expressId: sendParm.id,
            expressNumber: sendParm.number,
            expressCompany: expList[sendParm.id]
        }
    }).then(function(jsonData) {
        if (jsonData.code === 200) {
            expId = sendParm.id;
            expNumber = sendParm.number;
        } else {
            alert(jsonData.message);
        }
        syncExpressInfo();
        $courierCode.removeClass('in-edit');
    });
}

if ($detail.parent().hasClass('exchange-detail')) {
    isChange = true;
}

$expressCompany.val(expId);

$detail.find('.company-list').each(function() {
    var data = $(this).data();

    expList[data.id] = data.name;
});

$('#modify').click(function() {
    $courierCode.addClass('in-edit');
});

$('#submit-btn').click(function() {
    sendExpressCode();
});
});
define("js/home/returns-apply", ["jquery","handlebars","source-map"], function(require, exports, module){
/**
 * 退换货申请
 * @author: yyqing<yanqing.yang@yoho.cn>
 * @date: 2016/2/29
 */
var $ = require("jquery"),
    Addr = require("js/home/common-address");

var $goosTable = $('#goods-table'),
    $reasons = $goosTable.find('.return-reason'),
    $file = $goosTable.find('input[type=file]');

var $exchange = $('.exchange-detail'),
    defaultArea = $exchange.find('input[name="hide-area"]').val();

require("plugin/jquery.upload");

defaultArea = defaultArea ? defaultArea : '';
Addr.loadAllData(defaultArea, {
    areaDomId: 'area'
});

$reasons.change(function() {
    var $par = $(this).parent().parent(),
        type = $(this).val() * 1;

    if (type === 4 || type === 6 || type === 8) {
        $par.next().show();
    } else {
        $par.next().hide();
    }
});

$goosTable.find('.up-image-list li').on('click', '.btn-del', function() {
    $(this).parent().empty();
});

$file.each(function(e) {
    $('#upload-img-' + e).upload({
        auto: true,
        buttonClass: 'upload-img-btn',
        fileType: 'image/*',
        uploadScript: '/home/suggestimgUpload',
        fileObjName: 'fileData',
        fileSizeLimit: 5000,
        buttonText: '上传图片',
        height: 34,
        width: 116,
        multi: false,
        onUploadComplete: function(file, data) {
            var $par = $(this).closest('.problem-description'),
                $imgList = $par.find('li'),
                isShow = false,
                img, _html;

            img = JSON.parse(data).imgList[0];
            _html = '<span class="btn-del" title="删除"></span>' +
                '<img src="' + img.imgUrl + '" width="126" height="126">';
            $imgList.each(function() {
                if (!isShow && !$(this).find('img').length) {
                    isShow = true;
                    $(this).html(_html);
                }
            });
        },
        onError: function(info, fileType, data) {
            var msg = '图片上传失败!';

            if (info === 'FILE_SIZE_LIMIT_EXCEEDED') {
                msg = '图片大小超出限制!';
            }
            alert(msg);
        }
    });
});

});
define("js/home/common-address", ["jquery","handlebars","source-map"], function(require, exports, module){
/**
 * 个人中心页-地址管理
 * @author: wsl<shuiling.wang@yoho.cn>
 * @date: 2016/02/24
 */

var $ = require("jquery"),
    dialog = require("js/common/dialog"),
    Alert = dialog.Alert;

var address = {

    // 省的控件ID
    provinceDomId: 'province',

    // 城市的控件ID
    cityDomId: 'city',

    // 地区的控件ID
    areaDomId: 'areaCode',

    initDomIds: function(domOptions) {
        var the = this;

        if (domOptions.provinceDomId !== undefined) {
            the.provinceDomId = domOptions.provinceDomId;
        }
        if (domOptions.cityDomId !== undefined) {
            the.cityDomId = domOptions.cityDomId;
        }
        if (domOptions.areaDomId !== undefined) {
            the.areaDomId = domOptions.areaDomId;
        }
    },

    // 初始化地址数据
    loadAreaData: function(pCode, toDomId, defaultValue, allCode) {
        var $toDom = $('#' + toDomId),
            i = 0,
            point = '';

        var active,
            val,
            nId,
            selecter;

        $toDom.empty();

        if (pCode < 91) {
            $('#areaCode').empty();
            $('#county').attr('disabled', 'disabled');
        }

        $.ajax({
            type: 'GET',
            url: '/home/address/area',
            data: 'id=' + pCode,

            success: function(jsonData) {
                jsonData.code = 200;

                if (jsonData.code !== 200) {
                    active = new Alert('暂无数据');
                    active.show();
                    return false;
                }

                $toDom.append('<option value="0">' + defaultValue + '</option>');
                for (i in jsonData.options) {
                    if (jsonData.options[i]) {
                        val = jsonData.options[i];
                        point = (toDomId === 'areaCode' && val.is_support === 'Y') ? '*' : '';
                        nId = val.value;
                        selecter = '';

                        if (typeof (allCode) !== 'undefined' && allCode !== 0 &&
                            nId === allCode.substr(0, nId.length)) {
                            selecter = 'selected';
                        }
                        $toDom.append('<option value="' + nId + '" ' + selecter + '>' + point + val.text + '</option>');
                    }
                }
            }
        });
    },
    bindAreaChange: function(domOptions) {
        var the = this;

        if ($('#' + the.provinceDomId).data('events') !== undefined) {
            return;
        }

        // 初始化
        $('#' + the.provinceDomId).change(function() {
            var pCode = $('#' + the.provinceDomId).val();

            if (pCode === '0') {
                return;
            }

            the.loadAreaData(pCode, the.cityDomId, '请选择城市', pCode);
            $('#' + the.areaDomId).hide();
            the.showAreaSel(domOptions.dispDomId);
        });

        $('#' + this.cityDomId).change(function() {
            var pCode = $('#' + the.cityDomId).val();

            if (pCode === '0') {
                return;
            }

            the.loadAreaData(pCode, the.areaDomId, '请选择区县', pCode);
            $('#' + the.areaDomId).show();
            the.showAreaSel(domOptions.dispDomId);
        });

        $('#' + the.areaDomId).change(function() {
            the.showAreaSel(domOptions.dispDomId);
        });

        the.showAreaSel(domOptions.dispDomId);
    },

    /**
     * 显示地区选择
     */
    showAreaSel: function(dispDomId) {
        var the = this,
            strAddr = '',
            strProvince = $('#' + the.provinceDomId).find('option:selected').text(),
            strCity = $('#' + the.cityDomId).find('option:selected').text(),
            strArea = $('#' + the.areaDomId).find('option:selected').text();

        if (dispDomId !== undefined && dispDomId !== '') {
            if (strProvince.indexOf('选择') < 0) {
                strAddr = strProvince;
            }

            if (strCity !== '' && strCity.indexOf('选择') < 0) {
                strAddr += ',' + strCity;
            }

            if (strArea !== '' && strArea.indexOf('选择') < 0) {
                strAddr += ',' + strArea;
            }
            $('#' + dispDomId).html(strAddr);
        }
    },

    loadAllData: function(areaCode, domOptions) {
        var the = this;

        the.initDomIds(domOptions);
        areaCode += '';

        if (areaCode < 91) {
            the.loadAreaData(0, the.provinceDomId, '请选择省份', '');
            $('#' + the.areaDomId).hide();
            $('#' + the.cityDomId).html('<option value="0">请选择市</option>');
        } else if (areaCode.length === 4) {
            the.loadAreaData(0, the.provinceDomId, '请选择省份', areaCode);
            the.loadAreaData(areaCode.substr(0, 2), the.cityDomId, '请选择城市', areaCode);
            the.loadAreaData(areaCode, the.areaDomId, '请选择区县', areaCode);
            $('#' + the.areaDomId).show();
        } else if (areaCode.length === 6) {
            the.loadAreaData(0, the.provinceDomId, '请选择省份', areaCode);
            the.loadAreaData(areaCode.substr(0, 2), the.cityDomId, '请选择城市', areaCode);
            the.loadAreaData(areaCode.substr(0, 4), the.areaDomId, '请选择区县', areaCode);
            $('#' + this.areaDomId).show();
        }
        the.bindAreaChange(domOptions);
    }
};

module.exports = address;

});
define("plugin/jquery.upload", ["jquery"], function(require, exports, module){
/*
UploadiFive 1.2.2
Copyright (c) 2012 Reactive Apps, Ronnie Garcia
Released under the UploadiFive Standard License <http://www.uploadify.com/uploadifive-standard-license>
*/

var jQuery = require("jquery");

;(function($) {

    var methods = {

        init : function(options) {
            
            return this.each(function() {

                // Create a reference to the jQuery DOM object
                var $this = $(this);
                    $this.data('uploadifive', {
                        inputs     : {}, // The object that contains all the file inputs
                        inputCount : 0,  // The total number of file inputs created
                        fileID     : 0,
                        queue      : {
                                         count      : 0, // Total number of files in the queue
                                         selected   : 0, // Number of files selected in the last select operation
                                         replaced   : 0, // Number of files replaced in the last select operation
                                         errors     : 0, // Number of files that returned an error in the last select operation
                                         queued     : 0, // Number of files added to the queue in the last select operation
                                         cancelled  : 0  // Total number of files that have been cancelled or removed from the queue
                                     },
                        uploads    : {
                                         current    : 0, // Number of files currently being uploaded
                                         attempts   : 0, // Number of file uploads attempted in the last upload operation
                                         successful : 0, // Number of files successfully uploaded in the last upload operation
                                         errors     : 0, // Number of files returning errors in the last upload operation
                                         count      : 0  // Total number of files uploaded successfully
                                     }
                    });
                var $data = $this.data('uploadifive');

                // Set the default options
                var settings = $data.settings = $.extend({
                    'auto'            : true,               // Automatically upload a file when it's added to the queue
                    'buttonClass'     : false,              // A class to add to the UploadiFive button
                    'buttonText'      : 'Select Files',     // The text that appears on the UploadiFive button
                    'checkScript'     : false,              // Path to the script that checks for existing file names 
                    'dnd'             : true,               // Allow drag and drop into the queue
                    'dropTarget'      : false,              // Selector for the drop target
                    'fileObjName'     : 'Filedata',         // The name of the file object to use in your server-side script
                    'fileSizeLimit'   : 0,                  // Maximum allowed size of files to upload
                    'fileType'        : false,              // Type of files allowed (image, etc), separate with a pipe character |
                    'formData'        : {},                 // Additional data to send to the upload script
                    'height'          : 30,                 // The height of the button
                    'itemTemplate'    : false,              // The HTML markup for the item in the queue
                    'method'          : 'post',             // The method to use when submitting the upload
                    'multi'           : true,               // Set to true to allow multiple file selections
                    'overrideEvents'  : [],                 // An array of events to override
                    'queueID'         : false,              // The ID of the file queue
                    'queueSizeLimit'  : 0,                  // The maximum number of files that can be in the queue
                    'removeCompleted' : false,              // Set to true to remove files that have completed uploading
                    'simUploadLimit'  : 0,                  // The maximum number of files to upload at once
                    'truncateLength'  : 0,                  // The length to truncate the file names to
                    'uploadLimit'     : 0,                  // The maximum number of files you can upload
                    'uploadScript'    : 'uploadifive.php',  // The path to the upload script
                    'width'           : 100                 // The width of the button

                    /*
                    // Events
                    'onAddQueueItem'   : function(file) {},                        // Triggered for each file that is added to the queue
                    'onCancel'         : function(file) {},                        // Triggered when a file is cancelled or removed from the queue
                    'onCheck'          : function(file, exists) {},                // Triggered when the server is checked for an existing file
                    'onClearQueue'     : function(queue) {},                       // Triggered during the clearQueue function
                    'onDestroy'        : function() {}                             // Triggered during the destroy function
                    'onDrop'           : function(files, numberOfFilesDropped) {}, // Triggered when files are dropped into the file queue
                    'onError'          : function(file, fileType, data) {},        // Triggered when an error occurs
                    'onFallback'       : function() {},                            // Triggered if the HTML5 File API is not supported by the browser
                    'onInit'           : function() {},                            // Triggered when UploadiFive if initialized
                    'onQueueComplete'  : function() {},                            // Triggered once when an upload queue is done
                    'onProgress'       : function(file, event) {},                 // Triggered during each progress update of an upload
                    'onSelect'         : function() {},                            // Triggered once when files are selected from a dialog box
                    'onUpload'         : function(file) {},                        // Triggered when an upload queue is started
                    'onUploadComplete' : function(file, data) {},                  // Triggered when a file is successfully uploaded
                    'onUploadFile'     : function(file) {},                        // Triggered for each file being uploaded
                    */
                }, options);

                // Calculate the file size limit
                if (isNaN(settings.fileSizeLimit)) {
                    var fileSizeLimitBytes = parseInt(settings.fileSizeLimit) * 1.024
                    if (settings.fileSizeLimit.indexOf('KB') > -1) {
                        settings.fileSizeLimit = fileSizeLimitBytes * 1000;
                    } else if (settings.fileSizeLimit.indexOf('MB') > -1) {
                        settings.fileSizeLimit = fileSizeLimitBytes * 1000000;
                    } else if (settings.fileSizeLimit.indexOf('GB') > -1) {
                        settings.fileSizeLimit = fileSizeLimitBytes * 1000000000;
                    }
                } else {
                    settings.fileSizeLimit = settings.fileSizeLimit * 1024;
                }

                // Create a template for a file input
                $data.inputTemplate = $('<input type="file">')
                .css({
                    'font-size' : settings.height + 'px',
                    'opacity'   : 0,
                    'position'  : 'absolute',
                    'right'     : '-3px',
                    'top'       : '-3px',
                    'z-index'   : 999 
                });

                // Create a new input
                $data.createInput = function() {

                    // Create a clone of the file input
                    var input     = $data.inputTemplate.clone();
                    // Create a unique name for the input item
                    var inputName = input.name = 'input' + $data.inputCount++;
                    // Set the multiple attribute
                    if (settings.multi) {
                        input.attr('multiple', true);
                    }
                    // Set the accept attribute on the input
                    if (settings.fileType) {
                        input.attr('accept', settings.fileType);
                    }
                    // Set the onchange event for the input
                    input.bind('change', function() {
                        $data.queue.selected = 0;
                        $data.queue.replaced = 0;
                        $data.queue.errors   = 0;
                        $data.queue.queued   = 0;
                        // Add a queue item to the queue for each file
                        var limit = this.files.length;
                        $data.queue.selected = limit;
                        if (($data.queue.count + limit) > settings.queueSizeLimit && settings.queueSizeLimit !== 0) {
                            if ($.inArray('onError', settings.overrideEvents) < 0) {
                                alert('The maximum number of queue items has been reached (' + settings.queueSizeLimit + ').  Please select fewer files.');
                            }
                            // Trigger the error event
                            if (typeof settings.onError === 'function') {
                                settings.onError.call($this, 'QUEUE_LIMIT_EXCEEDED');
                            }
                        } else {
                            for (var n = 0; n < limit; n++) {
                                file = this.files[n];
                                $data.addQueueItem(file);
                            }
                            $data.inputs[inputName] = this;
                            $data.createInput();
                        }
                        // Upload the file if auto-uploads are enabled
                        if (settings.auto) {
                            methods.upload.call($this);
                        }
                        // Trigger the select event
                        if (typeof settings.onSelect === 'function') {
                            settings.onSelect.call($this, $data.queue);
                        }
                    });
                    // Hide the existing current item and add the new one
                    if ($data.currentInput) {
                        $data.currentInput.hide();
                    }
                    $data.button.append(input);
                    $data.currentInput = input;
                }

                // Remove an input
                $data.destroyInput = function(key) {
                    $($data.inputs[key]).remove();
                    delete $data.inputs[key];
                    $data.inputCount--;
                }

                // Drop a file into the queue
                $data.drop = function(e) {
                    $data.queue.selected = 0;
                    $data.queue.replaced = 0;
                    $data.queue.errors   = 0;
                    $data.queue.queued   = 0;

                    var fileData = e.dataTransfer;

                    var inputName = fileData.name = 'input' + $data.inputCount++;
                    // Add a queue item to the queue for each file
                    var limit = fileData.files.length;
                    $data.queue.selected = limit;
                    if (($data.queue.count + limit) > settings.queueSizeLimit && settings.queueSizeLimit !== 0) {
                        // Check if the queueSizeLimit was reached
                        if ($.inArray('onError', settings.overrideEvents) < 0) {
                            alert('The maximum number of queue items has been reached (' + settings.queueSizeLimit + ').  Please select fewer files.');
                        }
                        // Trigger the onError event
                        if (typeof settings.onError === 'function') {
                            settings.onError.call($this, 'QUEUE_LIMIT_EXCEEDED');
                        }
                    } else {
                        // Add a queue item for each file
                        for (var n = 0; n < limit; n++) {
                            file = fileData.files[n];
                            $data.addQueueItem(file);
                        }
                        // Save the data to the inputs object
                        $data.inputs[inputName] = fileData;
                    }

                    // Upload the file if auto-uploads are enabled
                    if (settings.auto) {
                        methods.upload.call($this);
                    }

                    // Trigger the onDrop event
                    if (typeof settings.onDrop === 'function') {
                        settings.onDrop.call($this, fileData.files, fileData.files.length);
                    }

                    // Stop FireFox from opening the dropped file(s)
                    e.preventDefault();
                    e.stopPropagation();
                }

                // Check if a filename exists in the queue
                $data.fileExistsInQueue = function(file) {
                    for (var key in $data.inputs) {
                        input = $data.inputs[key];
                        limit = input.files.length;
                        for (var n = 0; n < limit; n++) {
                            existingFile = input.files[n];
                            // Check if the filename matches
                            if (existingFile.name == file.name && !existingFile.complete) {
                                return true;
                            }
                        }
                    }
                    return false;
                }

                // Remove an existing file in the queue
                $data.removeExistingFile = function(file) {
                    for (var key in $data.inputs) {
                        input = $data.inputs[key];
                        limit = input.files.length;
                        for (var n = 0; n < limit; n++) {
                            existingFile = input.files[n];
                            // Check if the filename matches
                            if (existingFile.name == file.name && !existingFile.complete) {
                                $data.queue.replaced++;
                                methods.cancel.call($this, existingFile, true);
                            }
                        }
                    }
                }

                // Create the file item template
                if (settings.itemTemplate == false) {
                    $data.queueItem = $('<div class="uploadifive-queue-item">\
                        <a class="close" href="#">X</a>\
                        <div><span class="filename"></span><span class="fileinfo"></span></div>\
                        <div class="progress">\
                            <div class="progress-bar"></div>\
                        </div>\
                    </div>');
                } else {
                    $data.queueItem = $(settings.itemTemplate);
                }

                // Add an item to the queue
                $data.addQueueItem = function(file) {
                    if ($.inArray('onAddQueueItem', settings.overrideEvents) < 0) {
                        // Check if the filename already exists in the queue
                        $data.removeExistingFile(file);
                        // Create a clone of the queue item template
                        file.queueItem = $data.queueItem.clone();
                        // Add an ID to the queue item
                        file.queueItem.attr('id', settings.id + '-file-' + $data.fileID++);
                        // Bind the close event to the close button
                        file.queueItem.find('.close').bind('click', function() {
                           methods.cancel.call($this, file);
                           return false;
                        });
                        var fileName = file.name;
                        if (fileName.length > settings.truncateLength && settings.truncateLength != 0) {
                            fileName = fileName.substring(0, settings.truncateLength) + '...';
                        }
                        file.queueItem.find('.filename').html(fileName);
                        // Add a reference to the file
                        file.queueItem.data('file', file);
                        $data.queueEl.append(file.queueItem);
                    }
                    // Trigger the addQueueItem event
                    if (typeof settings.onAddQueueItem === 'function') {
                        settings.onAddQueueItem.call($this, file);
                    }
                    // Check the filesize
                    if (file.size > settings.fileSizeLimit && settings.fileSizeLimit != 0) {
                        $data.error('FILE_SIZE_LIMIT_EXCEEDED', file);
                    } else {
                        $data.queue.queued++;
                        $data.queue.count++;
                    }
                }

                // Remove an item from the queue
                $data.removeQueueItem = function(file, instant, delay) {
                    // Set the default delay
                    if (!delay) delay = 0;
                    var fadeTime = instant ? 0 : 500;
                    if (file.queueItem) {
                        if (file.queueItem.find('.fileinfo').html() != ' - Completed') {
                            file.queueItem.find('.fileinfo').html(' - Cancelled');
                        }
                        file.queueItem.find('.progress-bar').width(0);
                        file.queueItem.delay(delay).fadeOut(fadeTime, function() {
                           $(this).remove();
                        });
                        delete file.queueItem;
                        $data.queue.count--;
                    }
                }

                // Count the number of files that need to be uploaded
                $data.filesToUpload = function() {
                    var filesToUpload = 0;
                    for (var key in $data.inputs) {
                        input = $data.inputs[key];
                        limit = input.files.length;
                        for (var n = 0; n < limit; n++) {
                            file = input.files[n];
                            if (!file.skip && !file.complete) {
                                filesToUpload++;
                            }
                        }
                    }
                    return filesToUpload;
                }

                // Check if a file exists
                $data.checkExists = function(file) {
                    if ($.inArray('onCheck', settings.overrideEvents) < 0) {
                        // This request needs to be synchronous
                        $.ajaxSetup({
                            'async' : false
                        });
                        // Send the filename to the check script
                        var checkData = $.extend(settings.formData, {filename: file.name});
                        $.post(settings.checkScript, checkData, function(fileExists) {
                            file.exists = parseInt(fileExists);
                        });
                        if (file.exists) {
                            if (!confirm('A file named ' + file.name + ' already exists in the upload folder.\nWould you like to replace it?')) {
                                // If not replacing the file, cancel the upload
                                methods.cancel.call($this, file);
                                return true;
                            }
                        }
                    }
                    // Trigger the check event
                    if (typeof settings.onCheck === 'function') {
                        settings.onCheck.call($this, file, file.exists);
                    }
                    return false;
                }

                // Upload a single file
                $data.uploadFile = function(file, uploadAll) {
                    if (!file.skip && !file.complete && !file.uploading) {
                        file.uploading = true;
                        $data.uploads.current++;
                        $data.uploads.attempted++;

                        // Create a new AJAX request
                        xhr = file.xhr = new XMLHttpRequest();

                        // Start the upload
                        // Use the faster FormData if it exists
                        if (typeof FormData === 'function' || typeof FormData === 'object') {

                            // Create a new FormData object
                            var formData = new FormData();

                            // Add the form data
                            formData.append(settings.fileObjName, file);

                            // Add the rest of the formData
                            for (i in settings.formData) {
                                formData.append(i, settings.formData[i]);
                            }

                            // Open the AJAX call
                            xhr.open(settings.method, settings.uploadScript, true);

                            // On progress function
                            xhr.upload.addEventListener('progress', function(e) {
                                if (e.lengthComputable) {
                                    $data.progress(e, file);
                                }
                            }, false);

                            // On complete function
                            xhr.addEventListener('load', function(e) {
                                if (this.readyState == 4) {
                                    file.uploading = false;
                                    if (this.status == 200) {
                                        if (file.xhr.responseText !== 'Invalid file type.') {
                                            $data.uploadComplete(e, file, uploadAll);
                                        } else {
                                            $data.error(file.xhr.responseText, file, uploadAll);
                                        }
                                    } else if (this.status == 404) {
                                        $data.error('404_FILE_NOT_FOUND', file, uploadAll);
                                    } else if (this.status == 403) {
                                        $data.error('403_FORBIDDEN', file, uploadAll);
                                    } else {
                                        $data.error('Unknown Error', file, uploadAll);
                                    }
                                }
                            });

                            // Send the form data (multipart/form-data)
                            xhr.send(formData);

                        } else {

                            // Send as binary
                            var reader = new FileReader();
                            reader.onload = function(e) {

                                // Set some file builder variables
                                var boundary = '-------------------------' + (new Date).getTime(),
                                    dashes   = '--',
                                    eol      = '\r\n',
                                    binFile  = '';

                                // Build an RFC2388 String 
                                binFile += dashes + boundary + eol;
                                // Generate the headers
                                binFile += 'Content-Disposition: form-data; name="' + settings.fileObjName + '"';
                                if (file.name) {
                                    binFile += '; filename="' + file.name + '"';
                                }
                                binFile += eol;
                                binFile += 'Content-Type: application/octet-stream' + eol + eol;
                                binFile += e.target.result + eol;

                                for (key in settings.formData) {
                                    binFile += dashes + boundary + eol;
                                    binFile += 'Content-Disposition: form-data; name="' + key + '"' + eol + eol;
                                    binFile += settings.formData[key] + eol;
                                }

                                binFile += dashes + boundary + dashes + eol;

                                // On progress function
                                xhr.upload.addEventListener('progress', function(e) {
                                    $data.progress(e, file);
                                }, false);

                                // On complete function
                                xhr.addEventListener('load', function(e) {
                                    file.uploading = false;
                                    var status = this.status;
                                    if (status == 404) {
                                        $data.error('404_FILE_NOT_FOUND', file, uploadAll);
                                    } else {
                                        if (file.xhr.responseText != 'Invalid file type.') {    
                                            $data.uploadComplete(e, file, uploadAll);
                                        } else {
                                            $data.error(file.xhr.responseText, file, uploadAll);
                                        } 
                                    }
                                }, false);

                                // Open the ajax request
                                var url = settings.uploadScript;
                                if (settings.method == 'get') {
                                    var params = $(settings.formData).param();
                                    url += params;
                                }
                                xhr.open(settings.method, settings.uploadScript, true);
                                xhr.setRequestHeader("Content-Type", "multipart/form-data; boundary=" + boundary);

                                // Trigger the uploadFile event
                                if (typeof settings.onUploadFile === 'function') {
                                    settings.onUploadFile.call($this, file);
                                }

                                // Send the file for upload
                                xhr.sendAsBinary(binFile);
                            }
                            reader.readAsBinaryString(file);

                        }
                    }
                }

                // Update a file upload's progress
                $data.progress = function(e, file) {
                    if ($.inArray('onProgress', settings.overrideEvents) < 0) {
                        if (e.lengthComputable) {
                            var percent = Math.round((e.loaded / e.total) * 100);
                        }
                        file.queueItem.find('.fileinfo').html(' - ' + percent + '%');
                        file.queueItem.find('.progress-bar').css('width', percent + '%');
                    }
                    // Trigger the progress event
                    if (typeof settings.onProgress === 'function') {
                        settings.onProgress.call($this, file, e);
                    }
                }

                // Trigger an error
                $data.error = function(errorType, file, uploadAll) {
                    if ($.inArray('onError', settings.overrideEvents) < 0) {
                        // Get the error message
                        switch(errorType) {
                            case '404_FILE_NOT_FOUND':
                                errorMsg = '404 Error';
                                break;
                            case '403_FORBIDDEN':
                                errorMsg = '403 Forbidden';
                                break;
                            case 'FORBIDDEN_FILE_TYPE':
                                errorMsg = 'Forbidden File Type';
                                break;
                            case 'FILE_SIZE_LIMIT_EXCEEDED':
                                errorMsg = 'File Too Large';
                                break;
                            default:
                                errorMsg = 'Unknown Error';
                                break;
                        }

                        // Add the error class to the queue item
                        file.queueItem.addClass('error')
                        // Output the error in the queue item
                        .find('.fileinfo').html(' - ' + errorMsg);
                        // Hide the 
                        file.queueItem.find('.progress').remove();
                    }
                    // Trigger the error event
                    if (typeof settings.onError === 'function') {
                        settings.onError.call($this, errorType, file);
                    }
                    file.skip = true;
                    if (errorType == '404_FILE_NOT_FOUND') {
                        $data.uploads.errors++;
                    } else {
                        $data.queue.errors++;
                    }
                    if (uploadAll) {
                        methods.upload.call($this, null, true);
                    }
                }

                // Trigger when a single file upload is complete
                $data.uploadComplete = function(e, file, uploadAll) {
                    if ($.inArray('onUploadComplete', settings.overrideEvents) < 0) {
                        file.queueItem.find('.progress-bar').css('width', '100%');
                        file.queueItem.find('.fileinfo').html(' - Completed');
                        file.queueItem.find('.progress').slideUp(250);
                        file.queueItem.addClass('complete');
                    }
                    // Trigger the complete event
                    if (typeof settings.onUploadComplete === 'function') {
                        settings.onUploadComplete.call($this, file, file.xhr.responseText);
                    }
                    if (settings.removeCompleted) {
                        setTimeout(function() { methods.cancel.call($this, file); }, 3000);
                    }
                    file.complete = true;
                    $data.uploads.successful++;
                    $data.uploads.count++;
                    $data.uploads.current--;
                    delete file.xhr;
                    if (uploadAll) {
                        methods.upload.call($this, null, true);
                    }
                }

                // Trigger when all the files are done uploading
                $data.queueComplete = function() {
                    // Trigger the queueComplete event
                    if (typeof settings.onQueueComplete === 'function') {
                        settings.onQueueComplete.call($this, $data.uploads);
                    }
                }

                // ----------------------
                // Initialize UploadiFive
                // ----------------------

                // Check if HTML5 is available
                if (window.File && window.FileList && window.Blob && (window.FileReader || window.FormData)) {
                    // Assign an ID to the object
                    settings.id = 'uploadifive-' + $this.attr('id');

                    // Wrap the file input in a div with overflow set to hidden
                    $data.button = $('<div id="' + settings.id + '" class="uploadifive-button">' + settings.buttonText + '</div>');
                    if (settings.buttonClass) $data.button.addClass(settings.buttonClass);

                    // Style the button wrapper
                    $data.button.css({
                        'height'      : settings.height,
                        'line-height' : settings.height + 'px', 
                        'overflow'    : 'hidden',
                        'position'    : 'relative',
                        'text-align'  : 'center', 
                        'width'       : settings.width
                    });

                    // Insert the button above the file input
                    $this.before($data.button)
                    // Add the file input to the button
                    .appendTo($data.button)
                    // Modify the styles of the file input
                    .hide();

                    // Create a new input
                    $data.createInput.call($this);

                    // Create the queue container
                    if (!settings.queueID) {
                        settings.queueID = settings.id + '-queue';
                        $data.queueEl = $('<div id="' + settings.queueID + '" class="uploadifive-queue" />');
                        $data.button.after($data.queueEl);
                    } else {
                        $data.queueEl = $('#' + settings.queueID);
                    }

                    // Add drag and drop functionality
                    if (settings.dnd) {
                        var $dropTarget = settings.dropTarget ? $(settings.dropTarget) : $data.queueEl.get(0);
                        $dropTarget.addEventListener('dragleave', function(e) {
                            // Stop FireFox from opening the dropped file(s)
                            e.preventDefault();
                            e.stopPropagation();
                        }, false);
                        $dropTarget.addEventListener('dragenter', function(e) {
                            // Stop FireFox from opening the dropped file(s)
                            e.preventDefault();
                            e.stopPropagation();
                        }, false);
                        $dropTarget.addEventListener('dragover', function(e) {
                            // Stop FireFox from opening the dropped file(s)
                            e.preventDefault();
                            e.stopPropagation();
                        }, false);
                        $dropTarget.addEventListener('drop', $data.drop, false);
                    }

                    // Send as binary workaround for Chrome
                    if (!XMLHttpRequest.prototype.sendAsBinary) {
                        XMLHttpRequest.prototype.sendAsBinary = function(datastr) {
                            function byteValue(x) {
                                return x.charCodeAt(0) & 0xff;
                            }
                            var ords = Array.prototype.map.call(datastr, byteValue);
                            var ui8a = new Uint8Array(ords);
                            this.send(ui8a.buffer);
                        }
                    }

                    // Trigger the oninit event
                    if (typeof settings.onInit === 'function') {
                        settings.onInit.call($this);
                    }

                } else {

                    // Trigger the fallback event
                    if (typeof settings.onFallback === 'function') {
                        settings.onFallback.call($this);
                    }
                    return false;

                }

            });

        },


        // Write some data to the console
        debug : function() {

            return this.each(function() {

                console.log($(this).data('uploadifive'));

            });

        },

        // Clear all the items from the queue
        clearQueue : function() {

            this.each(function() {

                var $this    = $(this),
                    $data    = $this.data('uploadifive'),
                    settings = $data.settings;

                for (var key in $data.inputs) {
                    input = $data.inputs[key];
                    limit = input.files.length;
                    for (i = 0; i < limit; i++) {
                        file = input.files[i];
                        methods.cancel.call($this, file);
                    }
                }
                // Trigger the onClearQueue event
                if (typeof settings.onClearQueue === 'function') {
                    settings.onClearQueue.call($this, $('#' + $data.settings.queueID));
                }

            });

        },

        // Cancel a file upload in progress or remove a file from the queue
        cancel : function(file, fast) {

            this.each(function() {

                var $this    = $(this),
                    $data    = $this.data('uploadifive'),
                    settings = $data.settings;

                // If user passed a queue item ID instead of file...
                if (typeof file === 'string') {
                    if (!isNaN(file)) {
                        fileID = 'uploadifive-' + $(this).attr('id') + '-file-' + file;
                    }
                    file = $('#' + fileID).data('file');
                }

                file.skip = true;
                $data.filesCancelled++;
                if (file.uploading) {
                    $data.uploads.current--;
                    file.uploading = false;
                    file.xhr.abort();
                    delete file.xhr;
                    methods.upload.call($this);
                }
                if ($.inArray('onCancel', settings.overrideEvents) < 0) {
                    $data.removeQueueItem(file, fast);
                }

                // Trigger the cancel event
                if (typeof settings.onCancel === 'function') {
                    settings.onCancel.call($this, file);
                }
                
            });
            
        },

        // Upload the files in the queue
        upload : function(file, keepVars) {

            this.each(function() {

                var $this    = $(this),
                    $data    = $this.data('uploadifive'),
                    settings = $data.settings;

                if (file) {

                    $data.uploadFile.call($this, file);

                } else {

                    // Check if the upload limit was reached
                    if (($data.uploads.count + $data.uploads.current) < settings.uploadLimit || settings.uploadLimit == 0) {
                        if (!keepVars) {
                            $data.uploads.attempted   = 0;
                            $data.uploads.successsful = 0;
                            $data.uploads.errors      = 0;
                            var filesToUpload = $data.filesToUpload();
                            // Trigger the onUpload event
                            if (typeof settings.onUpload === 'function') {
                                settings.onUpload.call($this, filesToUpload);
                            }
                        }

                        // Loop through the files
                        $('#' + settings.queueID).find('.uploadifive-queue-item').not('.error, .complete').each(function() {
                            _file = $(this).data('file');
                            // Check if the simUpload limit was reached
                            if (($data.uploads.current >= settings.simUploadLimit && settings.simUploadLimit !== 0) || ($data.uploads.current >= settings.uploadLimit && settings.uploadLimit !== 0) || ($data.uploads.count >= settings.uploadLimit && settings.uploadLimit !== 0)) {
                                return false;
                            }
                            if (settings.checkScript) {
                                // Let the loop know that we're already processing this file
                                _file.checking = true;
                                skipFile = $data.checkExists(_file);
                                _file.checking = false;
                                if (!skipFile) {
                                    $data.uploadFile(_file, true);
                                }
                            } else {
                                $data.uploadFile(_file, true);
                            }
                        });
                        if ($('#' + settings.queueID).find('.uploadifive-queue-item').not('.error, .complete').size() == 0) {
                            $data.queueComplete();
                        }
                    } else {
                        if ($data.uploads.current == 0) {
                            if ($.inArray('onError', settings.overrideEvents) < 0) {
                                if ($data.filesToUpload() > 0 && settings.uploadLimit != 0) {
                                    alert('The maximum upload limit has been reached.');
                                }
                            }
                            // Trigger the onError event
                            if (typeof settings.onError === 'function') {
                                settings.onError.call($this, 'UPLOAD_LIMIT_EXCEEDED', $data.filesToUpload());
                            }
                        }
                    }

                }

            });

        },

        // Destroy an instance of UploadiFive
        destroy : function() {

            this.each(function() {

                var $this    = $(this),
                    $data    = $this.data('uploadifive'),
                    settings = $data.settings;
            
                // Clear the queue
                methods.clearQueue.call($this);
                // Destroy the queue if it was created
                if (!settings.queueID) $('#' + settings.queueID).remove();
                // Remove extra inputs
                $this.siblings('input').remove();
                // Show the original file input
                $this.show()
                // Move the file input out of the button
                .insertBefore($data.button);
                // Delete the button
                $data.button.remove();
                // Trigger the destroy event
                if (typeof settings.onDestroy === 'function') {
                    settings.onDestroy.call($this);
                }

            });

        }

    }

    $.fn.upload = function(method) {

        if (methods[method]) {
            return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
        } else if (typeof method === 'object' || !method) {
            return methods.init.apply(this, arguments);
        } else {
            $.error('The method ' + method + ' does not exist in $.uploadify');
        }

    }

})(jQuery);
});
define("js/home/comment", ["jquery"], function(require, exports, module){
/**
 * 退换货申请
 * @author: yyqing<yanqing.yang@yoho.cn>
 * @date: 2016/3/1
 */
var $ = require("jquery");

var $comment = $('.comment-table'),
    $remarkBtn = $comment.find('.remark-btn');

var $dialog = $('#comment-dialog-widget'),
    $titleBar = $dialog.find('.dialog-titlebar'),
    $commentArea = $dialog.find('textarea'),
    $closeBtn = $dialog.find('.dialog-close-btn');

var pageW = $(document).width(),
    pageH = $(document).height(),
    winH = $(window).height();

var dialog = {
    padding: 12,
    canmove: false,
    offset: {},
    maxtop: 0,
    maxleft: 0
};

$remarkBtn.click(function() {
    var scrollTop = $(document).scrollTop();

    $commentArea.val('');
    $dialog.removeClass('hide').css({
        top: scrollTop + (winH - $dialog.height() - dialog.padding) / 2,
        left: (pageW - $dialog.width() - dialog.padding) / 2
    });
});

// 评论弹窗
$titleBar.bind('mousedown', function(e) {
    if ($(e.target).hasClass('dialog-close-btn')) {
        return;
    }

    dialog.canmove = true;
    dialog.offset = {
        x: e.offsetX,
        y: e.offsetY
    };
    dialog.maxtop = pageH - $dialog.height() - dialog.padding;
    dialog.maxleft = pageW - $dialog.width() - dialog.padding;
});

$(document).mousemove(function(e) {
    var mtop, mleft;

    if (!dialog.canmove) {
        return;
    }

    mtop = e.pageY - dialog.offset.y;
    mleft = e.pageX - dialog.offset.x;
    mtop = mtop < dialog.maxtop ? mtop : dialog.maxtop;
    mleft = mleft < dialog.maxleft ? mleft : dialog.maxleft;
    $dialog.css({
        top: mtop > 0 ? mtop : 0,
        left: mleft > 0 ? mleft : 0
    });
}).mouseup(function(e) {
    dialog.canmove = false;
});

$closeBtn.click(function() {
    $dialog.addClass('hide');
});
});
define("js/home/edit", ["jquery","handlebars","source-map"], function(require, exports, module){
/**
 * 个人中心页-个人资料编辑
 * @author: zhaobiao<bill.zhao@yoho.cn>
 * @date: 2016/02/17
 */
var $ = require("jquery");

var $allEditForms = $('.userinfo-edit form');

var address = require("js/home/common-address");

var date = {
    init: function(year, month, day) {
        var $year = $('#year'),
            $month = $('#month'),
            $day = $('#day');

        var that = this;

        this.createDay($year.val(), $month.val(), $day.val());

        $year.on('change', function() {
            that.update();
        });

        $month.on('change', function() {
            that.update();
        });
    },
    update: function() {
        this.createDay($('#year').val(), $('#month').val(), $('#day').val());
    },
    createDay: function(year, month, day) {
        var html = '<select name="day" id="day">',
            monthArray = new Array(4, 6, 9, 11),
            dayNum = 31;

        var select,
            i;

        year = parseInt(year);
        month = parseInt(month);

        if (year === 0) {
            year = 0;
        }

        if (month === 0) {
            month = 0;
        }

        $('#year').val(year.toString());
        $('#month').val(month.toString());

        html += '<option value="0">日</option>';

        if (year > 0 && month > 0) {
            if ($.inArray(month, monthArray) !== -1) {
                dayNum = 30;
            } else if (month === 2) {
                dayNum = 28;
                if (0 === year % 4 && (year % 100 !== 0 || year % 400 === 0)) {
                    dayNum = 29;
                }
            }

            for (i = 1; i <= dayNum; i++) {
                select = '';

                if (parseInt(day) === i) {
                    select = 'selected';
                }
                html += '<option value="' + i + '" ' + select + '>' + i	+ '</option>';
            }
        }
        html += '</select>';

        $('#day').replaceWith(html);
    }
};


$('.userinfo-edit h2').on('click', function() {
    var $form = $(this).next();

    $allEditForms.slideUp('fast');
    $form.css('display') === 'none' ? $form.slideDown('slow') : null;

});

function checkBaseForm() {
    var nicknameLength = $('#nickname').val().length,
        usernameLength = $('#username').val().length,
        $gender = $('input[name="gender"]'),
        $year = $('#year'),
        $month = $('#month'),
        $day = $('#day');

    if (nicknameLength === 0) {
        alert('请输入昵称');
        return false;
    }

    if (usernameLength === 0) {
        alert('请输入用户名');
        return false;
    }

    if (nicknameLength >= 20) {
        alert('昵称最长为20个字符');
        return false;
    }


    if (!$gender.is(':checked')) {
        alert('请选择性别');
        return false;
    }

    if ($year.val() === '0' || $month.val() === '0' || $day.val() === '0') {
        alert('请选择出生年月日');
        return false;
    }

    return true;
}

function checkContactForm() {
    if ($('#province').val() === '0' || $('#city').val() === '0' || $('#areaCode').val() === '0') {
        alert('请选择所在区域');
        return false;
    }

    if ($('#province').val() === null || $('#city').val() === null || $('#areaCode').val() === null) {
        alert('请选择所在区域');
        return false;
    }

    if ($('#phone').val().length === 0 && $('#mobile').val().length === 0) {
        alert('电话和手机号码不能同时为空,请填写!');
        return false;
    }


    if ($('#fullAddress').val().length === 0) {
        alert('请填写地址');
        return false;
    }

    if ($('#zipCode').val().length === 0 || $('#zipCode').val().length < 2) {
        alert('请填写邮编');
        return false;
    }

    return true;
}

function checkHabbitForm() {
    if (!$('.user-habbit-info input').is(':checked')) {
        alert('请填写购物&着装习惯');
        return false;
    }

    return true;
}

function checkFavoriteForm() {
    if ($('#likebrand').val() === '') {
        alert('请选择品牌');
        return false;
    }

    return true;
}

function delBrand(brandId) {
    var brand = $('#likebrand').val();

    if (parseInt(brandId) === 0) {
        return false;
    }

    $('#likebrand').val(brand.replace(',' + brandId + ',', ','));
    $('#pp-' + brandId).attr('checked', false);
    $('#brand-' + brandId).remove();
}



function addBrand(domObj, brandId, brandName) {
    var html = '<li id="brand-' + brandId + '">' +
                brandName + '<a href="javascript:void(0);" class="btn-del"></a></li>';

    var brandInfo = $('#brand-' + brandId).html(),
        brandStr = $('#likebrand').val();

    var $brandBox = $('#brand-box');

    if (parseInt(brandId) === 0) {
        return false;
    }

    if (typeof domObj !== 'undefined' && domObj !== '' && domObj.checked === false) {
        delBrand(brandId);
        return false;
    }
    if (brandInfo) {
        alert('您已经选择了该品牌.');
        return false;
    }
    $brandBox.append(html);

    $brandBox.find('li>a').off('click').on('click', function() {
        delBrand($(this).closest('li').attr('id').substr(6));
    });

    brandStr += brandId + ',';
    $('#likebrand').val(brandStr);
}

function checkBrand() {
    var postData = {
            brandName: $('#keywords').val()
        };

    $.post('/home/user/isbrandname', postData, function(data) {
        if (data.code === 200) {
            if (data.data.id && data.data.brand_name) {
                addBrand('', data.data.id, data.data.brand_name);
                $('#keywords').val('');
                return true;
            } else {
                alert('网络异常,请重试');
                return false;
            }
        }
        alert(data.message);
        return false;
    }, 'json');
}

function save(postUrl, btnId) {
    var $form = $('#' + btnId).closest('form');

    $.post(postUrl, $form.serialize(), function(data) {
        if (data.code === 200) {
            alert(data.message);
            setTimeout(function() {
                $form.closest('div').next().find('h2').click();
            }, 100);
            return true;
        }
        alert(data.message);
        return false;
    }, 'json');
}


$('#base-info').on('click', function() {
    if (checkBaseForm()) {
        save('/home/user/edituserinfo/', 'base-info');
    }
});

$('#contact-info').on('click', function() {
    if (checkContactForm()) {
        save('/home/user/editusercontactinfo/', 'contact-info');
    }
});

$('#shopping-info').on('click', function() {
    if (checkHabbitForm()) {
        save('/home/user/edituserhabitsinfo/', 'shopping-info');
    }
});

$('#favorite-brand').on('click', function() {
    if (checkFavoriteForm()) {
        $.ajax({
            url: '/home/user/edituserlikebrand/',
            type: 'post',
            datatype: 'json',
            data: {
                brand: $('#likebrand').val()
            },
            success: function(data) {
                if (data.code === 200) {
                    alert(data.message);
                    return true;
                }
                alert(data.message);
                return false;
            },
            error: function(err) {
                alert('网络异常');
            }
        });
    }
});

$('#add-brand-btn').on('click', function() {
    checkBrand();
});

$('.user-favorite-info input[type="checkbox"]').on('click', function() {
    var $this = $(this);

    addBrand(this, $this.attr('id').substr(3), $this.parent().text());
});

(function() {
    var $brands = $('#brand-box li');

    if ($brands.length > 0) {
        $brands.find('a').on('click', function() {
            delBrand($(this).closest('li').attr('id').substr(6));
        });
    }
})();

date.init();

(function() {
    if (!$('#province').val()) {
        address.loadAllData(0, {
            provinceDomId: 'province',
            cityDomId: 'city',
            areaDomId: 'areaCode'
        });
    } else {
        address.bindAreaChange({
            provinceDomId: 'province',
            cityDomId: 'city',
            areaDomId: 'areaCode'
        });
    }
})();

});
define("js/home/gift", ["jquery"], function(require, exports, module){
/**
 * 个人中心页-兑换礼品卡
 * @author: wsl<shuiling.wang@yoho.cn>
 * @date: 2016/02/22
 */
var $ = require("jquery");

var $giftError = $('.giftCardCode').find('.gift-error'),
    $codeError = $('.captchaCode').find('.gift-error'),
    reg = '',
    code = '';

var Gift = {
    suc1: false,
    suc2: false,
    suc3: false,
    suc4: false,
    bindGiftCardForm: function() {
        $('#giftCardCode1').bind('blur keyup', function() {
            reg = /^[0-9a-zA-Z]{4,4}$/;

            if (!reg.test($('#giftCardCode1').val())) {
                $giftError.html('您输入的兑换码有误,兑换码必须为数字或字母,每个文本框里只能输入四个兑换码!');
                Gift.suc1 = false;
            } else {
                $giftError.html('');
                $('#giftCardCode2').focus();
                Gift.suc1 = true;
            }
        });

        $('#giftCardCode2').bind('blur keyup', function() {
            reg = /^[0-9a-zA-Z]{4,4}$/;

            if (!reg.test($('#giftCardCode2').val())) {
                $giftError.html('您输入的兑换码有误,兑换码必须为数字或字母,每个文本框里只能输入四个兑换码!');
                Gift.suc2 = false;
            } else {
                $giftError.html('');
                $('#giftCardCode3').focus();
                Gift.suc2 = true;
            }
        });

        $('#giftCardCode3').bind('blur keyup', function() {
            reg = /^[0-9a-zA-Z]{4,4}$/;

            if (!reg.test($('#giftCardCode3').val())) {
                $giftError.html('您输入的兑换码有误,兑换码必须为数字或字母,每个文本框里只能输入四个兑换码!');
                Gift.suc3 = false;
            } else {
                $giftError.html('');
                Gift.suc3 = true;
            }
        });

        $('#captchaCode').bind('blur keyup', function() {
            code = $('#captchaCode').val();

            if (code.length <= 0) {
                $codeError.html('请输入验证码!');
                Gift.suc4 = false;
            } else {
                $codeError.html('');
                Gift.suc4 = true;
            }
        });
    },

    checkForm: function() {
        if ($.trim($('#giftCardCode1').val()) === '' || $.trim($('#giftCardCode2').val()) === '' ||
            $.trim($('#giftCardCode3').val()) === '') {
            $giftError.html('您输入的兑换码有误,兑换码必须为数字或字母,每个文本框里只能输入四个兑换码!');
            return false;
        }

        if ($.trim($('#captchaCode').val()) === '') {
            $codeError.html('请输入验证码!');
            return false;
        }

        return true;
    }
};

//更换验证码
function refreshCaptcha() {
    var dt = new Date();

    $('#imgcode').attr('src', '/home/gift/captcha?t=' + dt.getTime());
    return false;
}

$('#sub-gift').on('click', function() {
    if (Gift.checkForm()) {
        $('#giftCardForm').submit();
    } else {
        return false;
    }
});

$(document).on('click', '#imgcode,.check-img', function() {
    refreshCaptcha();
});

$(function() {
    refreshCaptcha();
    Gift.bindGiftCardForm();
});
});
define("js/home/validate", ["jquery"], function(require, exports, module){
/**
 * 个人中心页-账号安全验证
 * @author: wsl<shuiling.wang@yoho.cn>
 * @date: 2016/02/23
 */
var $ = require("jquery");

var $checkUser = $('.check-user'),
    $checkInput = $checkUser.find('input').not('input[type=button],input[type=hidden]'),
    canSend = true,
    stime = 60,
    sInt;

// 身份校验
function checkForm(dom) {
    var val = dom.val(),
        len = val.length,
        $domParent = dom.parent(),
        $checkInfo = $domParent.find('.check-info'),
        inputName = dom.attr('name'),
        regular = '';

    $checkInfo.html('');

    if (inputName === 'oldpassword') {
        if (len === 0) {
            $checkInfo.html('<div class="form-error">密码不能为空!</div>');
            dom.addClass('input-error');
            return false;
        } else {
            $.get('/home/account/pass?pass=' + encodeURIComponent(val), function(data) {
                if (typeof data.code !== 'undefined' && data.code === 200) {
                    $checkInfo.html('<div class="form-success">&nbsp;</div>');
                    dom.removeClass('input-error');
                    return true;
                } else {
                    $checkInfo.html('<div class="form-error">密码错误!</div>');
                    dom.addClass('input-error');
                    return false;
                }
            });
        }
    }

    if (inputName === 'code') {
        $.get('/home/account/review?code=' + val, function(data) {
            if (typeof data.code !== 'undefined' && data.code === 200) {
                $checkInfo.html('<div class="form-success">&nbsp;</div>');
                dom.removeClass('input-error');
                return true;
            } else {
                $checkInfo.html('<div class="form-error">验证码错误!</div>');
                dom.addClass('input-error');
                return false;
            }
        });
    }

    if (inputName === 'newmail') {
        regular = '([a-zA-Z0-9]+)@([a-zA-Z0-9]+)[\.]([a-zA-Z0-9]+)';

        if (val.match(regular) === null) {
            $checkInfo.html('<div class="form-error">邮箱错误!</div>');
            dom.addClass('input-error');
            return false;
        } else {
            $.get('/home/account/mail?mail=' + val, function(data) {
                if (typeof data.code !== 'undefined' && data.code === 200) {
                    $checkInfo.html('<div class="form-success">&nbsp;</div>');
                    dom.removeClass('input-error');
                    return true;
                } else {
                    $checkInfo.html('<div class="form-error">邮箱已存在!</div>');
                    dom.addClass('input-error');
                    return false;
                }
            });

        }
    }

    if (inputName === 'mobile') {
        regular = '^1[35847]{1}[0-9]{9}';

        if (len === 0) {
            $checkInfo.html('<div class="form-error">手机号不能为空!</div>');
            dom.addClass('input-error');
            return false;
        } else if (val.match(regular) === null) {
            $checkInfo.html('<div class="form-error">手机号错误!</div>');
            dom.addClass('input-error');
            return false;
        } else {
            $.get('/home/mobile/exmobi?mobile=' + val, function(data) {
                if (typeof data.code !== 'undefined' && data.code !== 200) {
                    dom.addClass('input-error');
                    $checkInfo.html('<div class="form-error">手机号已经存在!</div>');
                    return false;
                } else {
                    dom.removeClass('input-error');
                    $checkInfo.html('<div class="form-success">&nbsp;</div>');
                    return true;
                }
            });
        }
    }

    if (inputName === 'password') {
        if (len < 6 || len > 20) {
            dom.addClass('input-error');
            $checkInfo.html('<div class="form-error">密码长度为6-20字符</div>');
            return false;
        } else {
            dom.removeClass('input-error');
            $checkInfo.html('<div class="form-success">&nbsp;</div>');
            return true;
        }
    }

    if (inputName === 'confirm_password') {
        if ($('#password').val() !== val) {
            dom.addClass('input-error');
            $checkInfo.html('<div class="form-error">两次密码不一致!</div>');
            return false;
        } else if ($('#password').val() !== '') {
            dom.removeClass('input-error');
            $('#password').next().html('<div class="form-success">&nbsp;</div>');
            $checkInfo.html('<div class="form-success">&nbsp;</div>');
            return true;
        }
    }

    return true;
}

// 校验表单
function checkAllForm() {
    var arr = [];

    $.each($checkInput, function(key, item) {
        arr.push(checkForm($(item)));
    });

    if (arr.indexOf(false) >= 0) {
        return false;
    } else {
        return true;
    }
}

// 切换验证码
function changeCode() {
    var timestamp = (new Date()).getTime();

    $('#the-code-img').attr('src', '/home/account/code?g=email_auth&time=' + timestamp);
}

// 重新发送倒计时
function code() {
    var sstring = '';

    if (stime > 0) {
        sstring = '重新发送' + stime + '秒';
        $('#sendButton').text(sstring);
        stime = stime - 1;
    } else {
        stime = 60;
        $('#sendButton').text('发送验证码');
        clearInterval(sInt);
        canSend = true;
    }
}

// 发送手机验证码
function sendcode() {
    var $mobile = $('#mobilevalue'),
        $code = $('#inputcode'),
        $mcheckInfo = $mobile.next(),
        mobileV = $mobile.val(),
        $ccheckInfo = $code.parent().find('check-info');

    if (canSend) {
        if (mobileV.match('^1[35847]{1}[0-9]{9}') === null) {
            $mcheckInfo.html('<div class="form-error">手机号错误!</div>');
            $mobile.addClass('input-error');
            return false;
        }
        $.get('/home/mobile/sendcode?mobile=' + mobileV, function(data) {
            if (typeof data.code !== 'undefined' && data.code === 200) {
                canSend = false;
                sInt = setInterval(function() {
                    code();
                }, 1000);
                $ccheckInfo.html('');
            } else {
                $ccheckInfo.html('<div class="form-error">验证码发送失败</div>');
            }
        });
    } else {
        return false;
    }
}

//验证完成后倒计时跳转
function toHome() {
    window.location.href = '/home/account';
}

$checkInput.blur(function() {
    checkForm($(this));
});

$('.sub-btn').on('click', function() {
    if (checkAllForm()) {
        $('#pwdform').submit();
    } else {
        return false;
    }
});

$('.the-code').on('click', function() {
    changeCode();
});

$('#send-mobile-code').on('click', function() {
    sendcode();
});

$('#inputcode').change(function() {
    var code = $('#inputcode').val();

    if (code !== '') {
        $.get('/home/mobile/review?code=' + code, function(data) {
            if (typeof data.code !== 'undefined' && data.code === 200) {
                $('#codetip').html('<div class="form-success">&nbsp;</div>');
            } else {
                $('#codetip').html('<div class="form-error">验证码错误!</div>');
            }
        });
    }
});

$(function() {
    var t = null;

    if ($('.res-info').length > 0) {
        t = setTimeout(function() {
            toHome();
        }, 5000);
    }

    changeCode();
});
});
define("js/home/address", ["jquery","handlebars","source-map"], function(require, exports, module){
/**
 * 个人中心页-地址管理
 * @author: wsl<shuiling.wang@yoho.cn>
 * @date: 2016/02/24
 */
var $ = require("jquery"),
    regionCode = require("js/home/common-address"),
    dialog = require("js/common/dialog"),
    Alert = dialog.Alert;

var active;

var $del = $('.address-del'),
    $edit = $('.address-modify'),
    $input = $('.input-1');

var address = {

    evil: function(fn) {
        var Fn = Function;

        return new Fn('return ' + fn)();
    },

    clearAddrForm: function() {
        $('#addressName').val('');
        $('#address').val('');
        $('#zipCode').val('');
        $('#phone').val('');
        $('#mobile').val('');
        $('#email').val('');
        $('#addrId').val(0);
        $('#btn-reset').hide();
        $('#form-status').html('添加新地址');
    },

    editAddr: function(id) {
        $.getJSON('/home/address/editAddress?id=' + id, function(jsonData) {
            if (jsonData.code === 200) {
                $('#form-status').html('修改地址');
                $('#addressName').val(jsonData.data.consignee);

                regionCode.loadAllData(jsonData.data.area_code, {});
                $('#address').val(jsonData.data.address);
                $('#email').val(jsonData.data.email);
                $('#phone').val(jsonData.data.phone);
                $('#mobile').val(jsonData.data.mobile);
                $('#zipCode').val(jsonData.data.zip_code);
                $('#addrId').val(jsonData.data.address_id);
                $('#btn-reset').show();
            }
        });
    },

    saveAddr: function(callbackFunc) {
        $.post('/home/address/saveAddress', $('#address-form').serialize(), function(data) {
            if (data.code === 200) {
                location.reload();
            } else {
                active = new Alert(data.message);
                active.show();
            }
        }, 'json');
    },

    // 删除地址
    delAddr: function(addrId) {
        $.getJSON('/home/address/delAddress?id=' + addrId, function(jsonData) {
            if (jsonData.code === 200) {
                $('.address-list').find('li[addressId=' + addrId + ']').remove();
            } else {
                active = new Alert('删除失败');
                active.show();
            }
        });
    },

    setDefaultAddr: function(addrId) {
        var oldBtn = $('.address-list').find('.default-btn'),
            oldLi = $('.address-list').find('.default-btn').parents('li'),
            curLi = $('.address-list').find('li[addressId=' + addrId + ']'),
            curBtn = curLi.find('.set-default-btn');

        $.getJSON('/home/address/defaultAddress?id=' + addrId, function(jsonData) {
            if (jsonData.code === 200) {
                oldBtn.attr('class', 'btn-c3 set-default-btn');
                oldLi.removeClass('preferred');
                oldBtn.html('<span>设为常用地址</span>');
                curBtn.attr('class', 'btn-c2 default-btn');
                oldBtn.html('<span>设为常用地址</span>');
                curLi.addClass('preferred');
            } else {
                active = new Alert('设置失败');
                active.show();
            }
        });
    }
};

if (!Array.prototype.indexOf) {
    Array.prototype.indexOf = function(obj, start) {
        var i,
            j;

        for (i = (start || 0), j = this.length; i < j; i++) {
            if (this[i] === obj) {
                return i;
            }
        }

        return -1;
    };
}

// 获取地址id
function getAddressId(dom) {
    var li = dom.parents('.address-content'),
        id = li.attr('addressId');

    return id;
}

//表单焦点显示
function focusAction(opt) {
    var msg = '';

    if (opt.inputName === 'addressName') {
        msg = '真实姓名在2到5个汉字之间';
    }

    if (opt.inputName === 'address') {
        msg = '请填写详细地址';
    }

    if (opt.inputName === 'zipCode') {
        msg = '请输入收货人所在地邮编号';
    }

    if (opt.inputName === 'phone') {
        msg = '格式例如:0577-88888888';
    }

    if (opt.inputName === 'mobile') {
        msg = '请输入手机号,如1360000000';
    }

    if (opt.inputName === 'email') {
        msg = '用来接收订单提醒邮件,便于您及时了解订单状态';
    }

    opt.$checkInfo.removeClass('form-prompt').addClass('form-focus').html(msg);
}

//表单失去焦点显示
function blurAction(opt) {
    var regular = '',
        res = true,
        msg = '输入正确',
        domClass = 'form-info form-success',
        value = opt.val;

    if (opt.inputName === 'addressName') {
        regular = /^[\u4e00-\u9fa5]{2,5}$/;

        if (opt.len < 1 || opt.len > 12) {
            msg = '真实姓名在2到5个汉字之间,请确认';
            res = false;
            domClass = 'form-info form-error';
        } else if (regular.test(opt.val) === false) {
            msg = '真实姓名至少2个中文,最多5个中文';
            res = false;
            domClass = 'form-info form-error';
        }
    }

    if (opt.inputName === 'address') {
        if (opt.len < 2) {
            msg = '请填写详细地址';
            res = false;
            domClass = 'form-info form-error';
        }
    }

    if (opt.inputName === 'zipCode') {
        regular = /^[0-9]{6}$/;

        if (opt.len === 0) {
            msg = '请输入收货人所在地邮编号';
            res = false;
            domClass = 'form-info form-error';
        } else if (regular.test(opt.val) === false) {
            msg = '你输入的邮编式不正确';
            res = false;
            domClass = 'form-info form-error';
        }
    }

    if (opt.inputName === 'phone') {
        regular = /^(0[0-9]{2,3}\-)?([2-9][0-9]{6,7})+(\-[0-9]{1,4})?$/;

        if (opt.len === 0) {
            msg = '你真的不想留联系电话了吗?';
            res = true;
            domClass = 'form-info form-success';
        } else if (regular.test(opt.val) === false) {
            msg = '你输入的联系电话格式不正确';
            res = false;
            domClass = 'form-info form-error';
        }
    }

    if (opt.inputName === 'mobile') {
        regular = /^1[3|4|5|8|7][0-9]{9}$/;

        if (opt.len !== 11) {
            msg = '手机号码必须是11位的,请确认';
            res = false;
            domClass = 'form-info form-error';
        } else if (regular.test(opt.val) === false) {
            msg = '您输入的手机号格式不正确';
            res = false;
            domClass = 'form-info form-error';
        }
    }

    if (opt.inputName === 'email') {
        regular = '^[a-z0-9_\-]+(\.[_a-z0-9\-]+)*@([_a-z0-9\-]+\.)+([a-z]{2}|aero|arpa|biz|com|coop|' +
                    'edu|gov|info|int|jobs|mil|museum|name|nato|net|org|pro|travel)$';

        if (value.match(regular) === null || opt.len === 0) {
            msg = '你输入的邮件地址格式不正确';
            res = false;
            domClass = 'form-info form-error';
        }
    }

    opt.$checkInfo.removeClass().addClass(domClass).html(msg);
    return res;
}


// 地址表单验证
function checkAddressForm(dom, action) {
    var val = dom.val(),
        $domParent = dom.parent(),
        opt = {
            val: val,
            len: val.length,
            $domParent: dom.parent(),
            $checkInfo: $domParent.find('span'),
            inputName: dom.attr('name')
        };

    if (action === 'focus') {
        focusAction(opt);
    }

    if (action === 'blur') {
        return blurAction(opt);
    }
}

function fullOneValidator() {
    var phone = $('#phone').next(),
        mobile = $('#mobile').next();

    if (mobile.hasClass('form-success') && !phone.hasClass('form-error') && $('#phone').val().length === 0) {
        phone.removeClass().addClass('form-prompt form-info').html('请输入你的联系电话,可以为空哦');
        return true;
    } else if (phone.html() === '输入正确' && !mobile.hasClass('form-error') && $('#mobile').val().length === 0) {
        mobile.removeClass().addClass('form-prompt form-info').html('填写手机号便于接收发货和收货通知');
        return true;
    } else if (!mobile.hasClass('form-success') && phone.html() !== '输入正确') {
        phone.removeClass().addClass('form-success form-info').html('你真的不想留联系电话了吗?');
        mobile.removeClass().addClass('form-prompt form-info').html('填写手机号便于接收发货和收货通知');
        $('#mobile').focus();
        return false;
    }
}

//校验所有内容
function checkAllForm() {
    var arr = [];

    $.each($input, function(key, item) {
        arr.push(checkAddressForm($(item), 'blur'));
    });

    arr.push(fullOneValidator());

    $.each($('.form-info'), function(key, item) {
        if ($(item).hasClass('form-error')) {
            $(item).prev().focus();
            return false;
        }
    });


    if (arr.indexOf(false) === -1) {
        return true;
    } else {
        return false;
    }
}

$(document).on('click', '.set-default-btn', function() {
    var id = getAddressId($(this));

    address.setDefaultAddr(id);
});

$del.on('click', function() {
    var id = getAddressId($(this));

    address.delAddr(id);
});

$edit.on('click', function() {
    var id = getAddressId($(this));

    address.editAddr(id);
    $('#btn-reset').show();
});

$input.on('focus', function() {
    checkAddressForm($(this), 'focus');
});

$input.on('blur', function() {
    checkAddressForm($(this), 'blur');
});

$('#address-info').on('click', function() {
    if (checkAllForm()) {
        address.saveAddr();
    }
});

$(document).ready(function() {
    regionCode.loadAllData(
        0,
        {
            provinceDomId: 'province',
            cityDomId: 'city',
            areaDomId: 'areaCode'
        }
    );

    address.clearAddrForm();

    $('#btn-reset').click(function() {
        address.clearAddrForm();
    });
});
});
define("js/order/ensure", ["jquery","handlebars","source-map"], function(require, exports, module){
/**
 * @description: 订单保存
 * @time: 2015/12/21
 */

var $ = require("jquery");

var address = require("js/order/address");

var dialog = require("js/common/dialog");

var Order = {
    /*业务数据(人民币)*/
    Data: {
        product: 0,//商品价格
        activity: 0,//活动
        carriage: 0,//邮费
        juan: 0,//优惠卷
        yohocoin: 0//YOHO币
    },
    /*view 交互*/
    UI: {
        e: {
            $pan: $('.pan'),
            $jc: $('#juancode'),
            $bp: $('#biprice'),
            $statistics: $('li', '.play-total'),
            $tobi: $('p em', '.play-bi-pan .play-pan'),
            $cancel: $('.cancel', '.btn-group'),
            $total: $('em', '.to-play'),
            $tbody: $('table tbody', '.pay-wapper'),

            //请填写并核对一下信息
            $orderSelectionSave: $('.address-list h2 span'),
            $addAddress: $('.add-address'),
            $addressManage: $('.address-manage'),
            $spanPayTypeLegend: $('span.pay-type-legend'),
            $supportType: $('.support-type'),
            $existAddressListWrap: $('.exist-address-list'),
            $existAddressList: $('.exist-address-list').find('li'),
            $existAddress: $('.exist-address-list').find('input[name="exist-address"]'),
            $payTimeModify: $('.pay-time-modify'),
            $switchPayModify: $('.switch-pay-modify'),
            $modityPayInfo: $('.modity-pay-info'),
            $payTotal: $('.play-total'),
            $toPay: $('.to-play em')
        },
        init: function() {
            var e = this.e,
            d = Order.Data,
            c = Order.Common;

            //初始化产品价格(表格中的价格)
            e.$tbody.find('tr').each(function(index) {

                var td = $(this).find('td');
                var len = e.$tbody.find('tr').length;
                var subtotal = parseFloat(td.eq(1).html()) * parseInt(td.eq(3).html());

                td.eq(1).html('¥' + td.eq(1).html());

                if (td.hasClass('xforone')) {
                    td.eq(4).find('del').html('¥' + c.strFixed(subtotal));
                    subtotal = 0;
                } else {
                    td.eq(4).html('¥' + c.strFixed(subtotal));
                }
                d.product += subtotal;
                if (!index) {
                    td.last().attr('rowspan', len);
                } else {
                    td.last().remove();
                }
                if (index === len - 1) {
                    e.$tbody.find('tr').eq(0).find('td').last().html('<strong>¥' + c.strFixed(d.product) + '</strong>');
                }
            });

            // 使用优惠券、使用yoho币点击展开
            e.$pan.find('dt').click(function() {

                var pan = $(this).parent('dl.pan');

                if (pan.find('dd').is(':hidden')) {
                    c.winShow(pan);

                    $(this).addClass('active');
                } else {
                    c.winHide(pan);

                    $(this).removeClass('active');
                }

            });

            //请填写并核对一下信息
            e.$orderSelectionSave.click(function() {
                var i = 0,
                    $addressLi = $('.exist-address-list li'),
                    liLen = $addressLi.length,
                    notSelect = 0;

                if (!$(this).attr('expand')) {

                    $(this).attr('expand', 'expand').text('[不保存并关闭]');

                    $('.exist-address-list li').removeClass('hide');

                    $('.save-btn').removeClass('hide');

                    e.$existAddressListWrap.addClass('address-expand');

                    if (liLen === 1) {
                        e.$addressManage.removeClass('hide');
                    }

                } else {

                    for (i = 0; i < liLen; i++) {

                        if ($addressLi.eq(i).hasClass('address_select')) {
                            notSelect++;
                        }

                        if (!$addressLi.eq(i).hasClass('address_select')) {
                            $addressLi.eq(i).addClass('hide');
                        }
                    }

                    if (notSelect === 0) {
                        $('.exist-address-list li:not(".use-new-address")').removeClass('hide');
                    }

                    $(this).removeAttr('expand').text('[修改]');

                    $('.save-btn').addClass('hide');

                    e.$existAddressListWrap.removeClass('address-expand');

                    e.$addressManage.addClass('hide');
                }

            });


            //支付及送货时间
            e.$switchPayModify.click(function() {
                console.log(1);
                if (e.$payTimeModify.hasClass('hide')) {
                    e.$payTimeModify.removeClass('hide');
                    e.$modityPayInfo.addClass('hide');
                    $(this).text('[不保存并关闭]');
                } else {
                    e.$payTimeModify.addClass('hide');
                    e.$modityPayInfo.removeClass('hide');
                    $(this).text('[修改]');

                    e.$payTimeModify.find('input[name="pay-type"]').filter('.checked').attr('checked', 'checked');
                    e.$payTimeModify.find('input[name="pay-time-radio"]').filter('.checked').attr('checked', 'checked');
                    e.$payTimeModify.find('input[name="call-me"]').filter('.checked').attr('checked', 'checked');
                }
            });

            e.$spanPayTypeLegend.click(function() {
                $(this).toggleClass('active');

                e.$supportType.toggleClass('hide');
            });

            $(document).on('click', '.exist-address-list li', function() {

                $('.exist-address-list li').removeClass('active');

                $(this).addClass('active');

                $(this).find('input').attr('checked', 'checked');

                if ($(this).hasClass('use-new-address')) {
                    e.$addressManage.removeClass('hide');

                    $('.address-manage input').val('');

                    $('.save-btn').removeAttr('data-id');

                    // 0表示获取所有省的列表,'000000'表示无匹配的区域码
                    address.newAddress(0, '000000');
                }
            });
        },

        //渲染价格明细
        render: function(data, tips) {

            // 下面这段是在服务端算价格
            var e = this.e,
                i,
                dArr = data.promotion_formula_list,
                str = '',
                isExpress = '';

            for (i = 0; i < dArr.length; i++) {

                if (dArr[i].promotion === '优惠券:') {
                    dArr[i].promotion = tips + '<span class="juan-modify">[修改]</span>:';
                }

                if (dArr[i].promotion === 'YOHO币:') {
                    dArr[i].promotion = 'YOHO币<span class="bi-modify">[修改]</span>:';
                }

                if (dArr[i].isExpress) {
                    isExpress = 'total-express-w';
                } else {
                    isExpress = '';
                }

                str += '<li class="' + isExpress + '">' +
                    '<label>' + dArr[i].promotion + '</label>' +
                    '<em>' + dArr[i].promotion_amount + '</em>' +
                    '</li>';
            }

            e.$payTotal.html(str);
            e.$toPay.html((data.last_order_amount).toFixed(2));
        }
    },
    /*公共方法*/
    Common: {
        enterNUM: function(str1, str2) {
            str1 = str1.replace(/[^\d]/g, '');
            if (str1 && str2) {
                str1 = parseInt(str1);
                str2 = parseInt(str2);
                if (str1 > str2) {
                    str1 = str2;
                }
            }
            return str1;
        },
        calucate: function() {
            var p = Order.Data;

            $.each(Order.Data, function(key, index) {
                p[key] = parseFloat(Order.Data[key]);
            });
            return p.product - p.activity + p.carriage - p.juan - p.yohocoin;
        },
        winShow: function(pan) {
            pan.find('dt').show();
            pan.find('dd').show();
            if (pan.attr('class').match(/(-bi-)|(-juan-)/g)) {
                pan.find('dt').hide();
            }
        },
        winHide: function(pan) {
            pan.find('dt').show();
            pan.find('dd').hide();

            /*if (pan.hasClass('play-juan-pan') && $('.juan-modify').length > 0) {
                pan.find('dt').hide();
            }

            if (pan.hasClass('play-bi-pan') && $('.bi-modify').length > 0) {
                pan.find('dt').hide();
            }*/
        },
        strFixed: function(str) {
            return parseFloat(str).toFixed(2);
        }
    },
    /*业务逻辑*/
    Bll: {
        e: {
            $juanok: $('#juansubmit'),
            $juantip: $('.errtip', '.play-juan-pan'),
            $biok: $('#bisubmit'),
            $carriageGroup: $('input[name="carriagegroup"]'),
            $selectExpress: $('.express-list input'),
            $bp: $('#biprice'),
            $errorTip: $('.errbitip'),
            $useEnvelopes: $('.use-envelopes'),
            $hasEnvelopes: $('.has-envelopes span'),
            $redEnvelopes: $('.red-envelopes'),
            $loading: $('.loading')
        },
        init: function() {
            var e = this.e,
                u = Order.UI,
                options,
                c = Order.Common;

            function getSelectData(callback) {

                var $juangroupInput = $('.play-juan.is-select input[name="juangroup"]:checked');
                var expressVal = $('.express-list input[name="carriagegroup"]').val();
                var biVal = $('#biprice.is-select').val();
                var codeVal = $juangroupInput.val();
                var cartType = $('.address-manage').attr('cart-type');
                var redEnvelopes = $('.use-envelopes input:checked').attr('data-use');
                var resultData;

                codeVal = !!codeVal ? codeVal : $juangroupInput.closest('li').find('#juancode').val();

                resultData = {
                    cartType: cartType,
                    deliveryWay: expressVal,
                    couponCode: codeVal,
                    yohoCoin: biVal
                };

                if (!!redEnvelopes) {
                    resultData.redEnvelopes = redEnvelopes;
                }

                callback(resultData);

            }

            // 选择快递
            e.$selectExpress.click(function() {

                var expressId = $(this).val();

                e.$loading.show();

                getSelectData(function(d) {

                    d.deliveryWay = expressId;

                    options = {
                        type: 'POST',
                        url: '/cart/index/orderCompute',
                        data: d,
                        success: function(data) {

                            console.log(data);

                            e.$loading.hide();

                            if (data.code === 200) {
                                u.render(data.data);

                                if (expressId === '1') {

                                    $('.express-list.sf').addClass('hide');
                                } else if (expressId === '2') {
                                    $('.express-list.sf').removeClass('hide');
                                }

                            } else {
                                new dialog.Alert(data.message).show();
                            }
                        }
                    };

                    $.ajax(options);
                });
            });

            //点击 优惠卷支付 确认按钮
            e.$juanok.click(function() {

                var pan = $(this).parents('dl.pan');

                var juanText = '';

                $('.play-juan').addClass('is-select');

                getSelectData(function(d) {

                    var code = d.couponCode;

                    if (!code) {

                        e.$juantip.html('请选择或填写一个优惠券');
                        $('.play-juan').removeClass('is-select');

                    } else {

                        e.$loading.show();

                        options = {
                            type: 'POST',
                            url: '/cart/index/orderCompute',
                            data: d,
                            success: function(data) {

                                e.$loading.hide();

                                if (data.code === 200) {

                                    juanText = $('.play-juan input[value="' + code + '"]').next().text();
                                    u.render(data.data, juanText);

                                    //$('#juancode').val(code);

                                    c.winHide(pan);
                                    e.$juantip.html('');

                                    //$('.play-juan-pan dt').hide();

                                } else {
                                    e.$juantip.html(data.message);
                                    $('.play-juan').removeClass('is-select');
                                }
                            }
                        };

                        $.ajax(options);
                    }
                });

            });

            // 优惠券修改
            $(document).on('click', '.juan-modify', function() {


                var $pan = $('.play-juan-pan');

                c.winShow($pan);
            });

            e.$biok.click(function() {

                var pan = $(this).parents('dl.pan');
                var juanText;

                $('#biprice').addClass('is-select');

                getSelectData(function(d) {

                    if (!!d.couponCode) {
                        juanText = $('.play-juan input[value="' + d.couponCode + '"]').next().text();
                    }

                    if (d.yohoCoin * 1 === 0) {

                        $('.errbitip').html('请填写一个正整数');
                        $('#biprice').removeClass('is-select');

                    } else if (d.yohoCoin * 1 > $('.play-pan em').text() * 1) {

                        $('.errbitip').html('您的YOHO币不足');
                        $('#biprice').removeClass('is-select');

                    } else {
                        e.$loading.show();

                        options = {
                            type: 'POST',
                            url: '/cart/index/orderCompute',
                            data: d,
                            success: function(data) {

                                e.$loading.hide();

                                if (data.code === 200) {
                                    u.render(data.data, juanText);
                                    c.winHide(pan);

                                    //$('.play-bi-pan dt').hide();

                                } else {
                                    $('.errbitip').html(data.message);
                                    $('#biprice').removeClass('is-select');
                                }
                            }
                        };

                        $.ajax(options);
                    }

                });
            });

            // 修改yoho币
            $(document).on('click', '.bi-modify', function() {


                var $pan = $('.play-bi-pan');

                c.winShow($pan);
            });

            e.$bp.keyup(function() {

                var val = $(this).val();

                if (val * 1 < 0 || val.indexOf('.') > 0) {
                    e.$errorTip.html('请输入一个正整数');
                } else if (val * 1 > $(this).data('bi') * 1) {
                    e.$errorTip.html('您的YOHO币不足');
                } else {
                    e.$errorTip.html('抵扣' + (val / 100).toFixed(2) + '元');
                }
            });

            // 取消yoho 币
            $('.cancel-bi').click(function() {


                var $pan = $('.play-bi-pan');
                var juanText;

                if ($('#biprice').hasClass('is-select')) {

                    e.$loading.show();

                    getSelectData(function(d) {

                        d.yohoCoin = 0;

                        if (!!d.couponCode) {
                            juanText = $('.play-juan input[value="' + d.couponCode + '"]').next().text();
                        }

                        options = {
                            type: 'POST',
                            url: '/cart/index/orderCompute',
                            data: d,
                            success: function(data) {

                                e.$loading.hide();

                                if (data.code === 200) {
                                    u.render(data.data, juanText);
                                    c.winHide($pan);

                                    $('#biprice').val('0');

                                    //$('.play-bi-pan dt').hide();
                                    $('#biprice').removeClass('is-select');

                                    $('.errbitip').html('');

                                } else {
                                    $('.errbitip').html(data.message);
                                }
                            }
                        };

                        $.ajax(options);
                    });

                } else {
                    c.winHide($pan);
                    $('#biprice').val('0');
                }

            });

            // 取消优惠券
            $('.cancel-code').click(function() {

                var $pan = $('.play-juan-pan');

                if ($('.play-juan').hasClass('is-select')) {

                    e.$loading.show();

                    getSelectData(function(d) {

                        d.couponCode = '';

                        options = {
                            type: 'POST',
                            url: '/cart/index/orderCompute',
                            data: d,
                            success: function(data) {

                                e.$loading.hide();

                                if (data.code === 200) {
                                    u.render(data.data);

                                    c.winHide($pan);
                                    $('.play-juan').removeClass('is-select');

                                    $('#juancode').val('')
                                        .siblings('input[name="juangroup"]').attr('checked', 'checked');

                                } else {
                                    e.$juantip.html(data.message);
                                }
                            }
                        };

                        $.ajax(options);
                    });
                } else {
                    c.winHide($pan);
                }
            });


            // 红包
            e.$useEnvelopes.find('input').click(function() {

                var $this = $(this);

                e.$loading.show();

                getSelectData(function(d) {

                    if (!!$this.attr('checked')) {

                        d.redEnvelopes = $this.val();

                    } else {

                        d.redEnvelopes = 0;
                    }

                    options = {
                        type: 'POST',
                        url: '/cart/index/orderCompute',
                        data: d,
                        success: function(data) {

                            e.$loading.hide();

                            if (data.code === 200) {
                                u.render(data.data);

                                if (!!$this.attr('checked')) {
                                    e.$redEnvelopes.addClass('active');
                                    e.$useEnvelopes.find('span').html('-¥' + ($this.val() * 1).toFixed(2));
                                    e.$hasEnvelopes.html('¥0.00');

                                    $this.attr('data-use', $this.val());
                                    $this.val(0);

                                } else {
                                    e.$useEnvelopes.find('span').html('-¥0.00');
                                    e.$hasEnvelopes.html('¥' + ($this.attr('data-use') * 1).toFixed(2));
                                    e.$redEnvelopes.removeClass('active');

                                    $this.val($this.attr('data-use'));
                                    $this.attr('data-use', 0);
                                }
                            } else {

                                new dialog.Alert(data.message).show();
                            }
                        }
                    };

                    $.ajax(options);
                });

            });


            //发票抬头和备注字数限制
            function limitStrLen($obj, len) {

                var $this = $obj;

                $this.keyup(function() {

                    if ($this.val().length > len) {

                        $this.val($this.val().substr(0, len));
                    }
                });
            }

            limitStrLen($('#piaodesc'), 30);
            limitStrLen($('#notedesc'), 100);
        }
    }
};

Order.Data.activity = 0;
Order.Data.carriage = 0;

Order.UI.init();
Order.Bll.init();


address.getUserAddressList();

// 0表示获取所有省的列表,'000000'表示无匹配的区域码
address.newAddress(0, '000000');
address.modifyAddress();
address.saveAddress();

});
define("js/order/address", ["jquery","handlebars","source-map"], function(require, exports, module){
/**
 * @description: 地址管理
 * @author: chenglong.wang@yoho.cn
 */

var $ = require("jquery");
var dialog = require("js/common/dialog");


var isProvinceChecked = false;

var $addressManage = $('.address-manage'),
    $province = $addressManage.find('.text-input[name="province"]'),
    $city = $addressManage.find('.text-input[name="city"]'),
    $county = $addressManage.find('.text-input[name="county"]'),
    $selectList = $addressManage.find('.text-input[name="province"], .text-input[name="city"]'),
    $addressList = $('.address-list'),
    $name = $addressManage.find('.text-input[name="name"]'),
    $phone = $addressManage.find('.text-input[name="phone"]'),
    $mail = $addressManage.find('.text-input[name="mail"]'),
    $address = $addressManage.find('.text-input[name="address"]'),
    $code = $addressManage.find('.text-input[name="code"]'),
    $saveBtn = $('.save-btn'),
    $telCode = $addressManage.find('.text-input[name="tel-code"]'),
    $tel = $addressManage.find('.text-input[name="tel"]'),
    $useNewAddress = $('.use-new-address'),
    $existAddressList = $('.exist-address-list'),
    $loading = $('.loading');

var cartType = $addressManage.attr('cart-type');

// 构建select下拉选项
function structureOption($obj, data, selectId) {

    var i,
        optionHtml = '',
        defaultOption;

    for (i = 0; i < data.length; i++) {

        if (data[i].id === selectId) {
            optionHtml += '<option selected value="' + data[i].id + '">' + data[i].caption + '</option>';
        } else {
            optionHtml += '<option value="' + data[i].id + '">' + data[i].caption + '</option>';
        }
    }


    if ($obj.attr('name') === 'province') {
        defaultOption = '<option value="0">请选择省份</option>';
    } else if ($obj.attr('name') === 'city') {
        defaultOption = '<option value="0">请选择城市</option>';

    } else if ($obj.attr('name') === 'county') {
        defaultOption = '<option value="0">请选择区县</option>';
    }

    $obj.html(defaultOption + optionHtml);
}
/**
 * @description: 改函数会返回地址信息
 * d {Object} type: 'getProvince'获取省 type: 'getCity'获取城市 type: 'getCounty'获取县
 * id: 0 && type: 'getProvince' 获取所有省,默认没有选中项
 * id !== 0 && type: 'getProvince' 获取所有省,默认选中用户所在的省
 */
function getAddress(d, callback) {

    var $obj;
    var selectId = d.selectId;

    if (d.type === 'getProvince') {

        //url = 'getProvince';
        $obj = $province;
    } else if (d.type === 'getCity') {

        //url = 'getCity';
        $obj = $city;
    } else if (d.type === 'getCounty') {

        //url = 'getCounty';
        $obj = $county;
    }

    $.ajax({
        type: 'GET',
        url: '/cart/index/getAreaList',
        dataType: 'json',
        data: {
            id: d.id * 1
        }
    }).then(function(d) {

        structureOption($obj, d.data, selectId);

        if (typeof callback === 'function') {
            callback();
        }

    }).fail(function() {

        //todo
    });
}

// 修改地址时把用户信息带过来
function getUserInfo($obj) {

    $name.val($obj.attr('data-name'));
    $name.attr('data-id', $obj.attr('data-id'));
    $address.val($obj.attr('data-addressDesc'));
    $phone.val($obj.attr('data-mobile'));
    $mail.val($obj.attr('data-email'));
    $code.val($obj.attr('data-zipcode'));
    $telCode.val($obj.attr('data-phoneCode'));
    $tel.val($obj.attr('data-codeNum'));
}

// 更新地址列表状态
function refreshAddressStatus() {
    $useNewAddress.removeClass('active');
    $existAddressList.find('li:not(".active")').addClass('hide');
    $existAddressList.find('li.active').addClass('address_select');
    $addressManage.addClass('hide');
    $saveBtn.addClass('hide');
    $existAddressList.removeClass('address-expand');
    $('.order-selection h2 span').text('[修改]');
}

//获取用户已经存在的地址列表
exports.getUserAddressList = function() {

    var addressData,
        i,
        addressStr = '',
        isChecked = '',
        isHide = '',
        addressText = '',
        hasDefault = 0;

    $.ajax({
        type: 'GET',
        url: '/cart/index/getAddress',
        dataType: 'json'
    }).then(function(d) {

        if (d.code === 200) {

            addressData = d.data.list;

            if (!addressData) {

                $addressList.find('>h2').find('span').click();

                $('.exist-address-list li').click();

                $('.use-new-address').removeClass('active');

                return;

            }

            for (i = 0; i < addressData.length; i++) {

                if (addressData[i].checked) {

                    isChecked = 'checked';
                    isHide = 'active address_select';
                    hasDefault++;
                    addressText = '默认地址';

                } else {
                    isChecked = '';
                    isHide = 'hide';
                    addressText = '设为默认地址';
                }

                addressStr +=
                    '<li data-id="' + addressData[i].id + '" class="' + isHide +
                    '" data-express="' + addressData[i].isSupport + '">' +
                    '<input data-name="' + addressData[i].user +
                    '" data-areaCode="' + addressData[i].areaCode +
                    '" data-addressDesc="' + addressData[i].addressDesc +
                    '" data-mobile="' + addressData[i].mobile +
                    '" data-phoneNum="' + addressData[i].phoneNum +
                    '" data-phoneCode="' + addressData[i].phoneCode +
                    '" data-zipCode="' + addressData[i].zipCode +
                    '" data-email="' + addressData[i].email +
                    '" class="radio" type="radio" name="address" ' + isChecked + ' />' +
                    '<label for="">' +
                    '<strong>' + addressData[i].user + '</strong>' + addressData[i].address +
                    '<a href="javascript:void(0);" class="default-address">' + addressText + '</a>' +
                    '<div class="order-modify-btn">' +
                    '<span class="address-modify">[修改]</span>' +
                    '<span class="address-del">[删除]</span>' +
                    '</div>' +
                    '</label>' +
                    '</li>';
            }

            $('.use-new-address').before($(addressStr));

            //说明用户的地址列表没有默认地址
            if (hasDefault === 0) {

                //没有默认地址则把所有地址都显示出来
                //$('.exist-address-list li:not(".use-new-address")').removeClass('hide');
                $('.address-list h2 span').click();
            }

            if ($('.active.address_select').attr('data-express') === 'N') {
                $('.express-list input[name="carriagegroup"][value="2"]').attr('disabled', 'disabled');
                $('.express-list input[name="carriagegroup"][value="1"]').attr('checked', 'checked');
                $('.express-list.sf').addClass('hide');
                $('.is-sup').removeClass('hide');
            } else {
                $('.express-list input[name="carriagegroup"][value="2"]').removeAttr('disabled');
                $('.express-list.sf').removeClass('hide');
                $('.is-sup').addClass('hide');
            }

        }

    });
};

/*
 * 添加地址&修改地址
 * id: 根据id获取省市区列表
 * code: 根据code确定是否选中省市区
 */
exports.newAddress = function(id, code) {

    var pId = id || 0; //如果没有传id则获取所有省列表

    var addressCodeReg = /[0-9]{2}/gi;

    var codeId = !!code && code.match(addressCodeReg);

    //获取省
    getAddress({
        id: pId,
        type: 'getProvince',
        selectId: codeId[0]
    }, function() {

        var provinceId = $province.val();

        if (provinceId !== '0') {

            //如果获取的省有默认选中项则获取市
            getAddress({
                id: provinceId,
                type: 'getCity',
                selectId: '' + codeId[0] + codeId[1]
            }, function() {

                var cityId = $city.val();

                //如果获取的市有默认选中项则获取县
                if (cityId !== '0') {
                    getAddress({
                        id: cityId,
                        type: 'getCounty',
                        selectId: code
                    });
                }
            });
        } else {
            $addressManage.find('select[name="city"]').html('<option value="0">请选择城市</option>');
            $addressManage.find('select[name="county"]').html('<option value="0">请选择区县</option>');
        }
    });

    // 发生change事件时获取下一级地址
    $selectList.change(function() {

        var $this = $(this);

        if ($this.attr('name') === 'province') {

            if ($this.val() === '0') {
                $addressManage.find('select[name="city"]').html('<option value="0">请选择城市</option>');
                $addressManage.find('select[name="county"]').html('<option value="0">请选择区县</option>');
            } else {
                getAddress({
                    id: $this.val(),
                    type: 'getCity'
                }, function() {
                    isProvinceChecked = true;
                });
                $addressManage.find('select[name="county"]').html('<option value="0">请选择区县</option>');
            }
        }

        if ($this.attr('name') === 'city' && isProvinceChecked) {

            if ($this.val() === '0') {
                $addressManage.find('select[name="county"]').html('<option value="0">请选择区县</option>');
            } else {
                getAddress({
                    id: $this.val(),
                    type: 'getCounty'
                });
            }
        }
    });
};

//修改地址
exports.modifyAddress = function() {

    $addressList.click(function(event) {

        var $this = $(event.target),
            id = $this.closest('li').attr('data-id'),
            areaCode = $this.closest('li').find('.radio').attr('data-areaCode');

        if ($this.hasClass('address-modify')) {
            $addressManage.removeClass('hide');
            exports.newAddress(0, areaCode);
            getUserInfo($this.closest('li').find('.radio'));
            $('.address-list-inner .save-btn').removeClass('hide');
            $saveBtn.attr('data-id', id);
            isProvinceChecked = true;
        } else if ($this.hasClass('address-del')) {

            $loading.show();

            $.ajax({
                type: 'POST',
                url: '/cart/index/delAddress',
                data: {
                    id: id
                }
            }).then(function(d) {

                $loading.hide();

                if (d.code === 200) {

                    $this.closest('li').remove();
                } else {
                    new dialog.Alert(d.message).show();
                }
            }).fail(function() {

                //todo
            });
        } else if ($this.hasClass('default-address') && !$this.parents('li').hasClass('address_select')) {

            $loading.show();

            // 设为默认地址
            $.ajax({
                type: 'post',
                url: '/cart/index/setDefaultAddress',
                data: {
                    id: id
                }
            }).then(function(d) {

                $loading.hide();

                if (d.code === 200) {

                    $('.exist-address-list li').removeClass('address_select')
                        .find('.default-address').text('设为默认地址');
                    $this.parents('li').addClass('address_select');
                    $this.text('默认地址');

                } else {
                    new dialog.Alert(d.message).show();
                }
            });
        }
    });
};

// 保存地址并送到这个地址
exports.saveAddress = function() {
    $saveBtn.click(function() {

        var $this = $(this);

        var name = $name.val(),
            province = $province.val(),
            city = $city.val(),
            county = $county.val(),
            address = $address.val(),
            phone = $phone.val(),
            telCode = $telCode.val(),
            tel = $tel.val(),
            mail = $mail.val(),
            code = $code.val();

        var provinceText = $province.find('option[value="' + province + '"]').text(),
            cityText = $city.find('option[value="' + city + '"]').text(),
            countyText = $county.find('option[value="' + county + '"]').text();


        var postData = {
            consignee: name,
            areaCode: county,
            address: address,
            email: mail,
            mobile: phone,
            zipCode: code,
            phoneCode: telCode,
            phoneNum: tel
        };

        var addressStr;
        var $modifyLi;
        var hasCheckedAddress;

        var nameReg = /^[\u4e00-\u9fa5]{2,5}$/;
        var addressReg = /^[\s\S]{3,100}$/;
        var phoneReg = /^(13[0-9]|15[012356789]|17[678]|18[0-9]|14[57])[0-9]{8}$/;
        var codeReg = /^[0-9]{6}$/;
        var emailReg = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
        var telCodeReg = /^[0-9]{3,5}$/;
        var telReg = /^[0-9]{5,10}$/;


        function hasText(val) {

            if (val === telCode) {

                if (!!val) {
                    return val + '-';
                } else {
                    return ' ';
                }

            } else {
                if (!!val) {
                    return val + ' ';
                } else {
                    return ' ';
                }
            }
        }

        hasCheckedAddress = $('.exist-address-list li:not(".use-new-address")')
            .find('input[name="address"]:checked').length > 0;

        // 说明是送货到这个地址
        if (!$('.add-address').attr('checked') && hasCheckedAddress && !$('.save-btn').attr('data-id')) {

            $('.exist-address-list li').removeClass('address_select');
            $('.exist-address-list li.active').addClass('address_select')
                .find('input[name="address"]').attr('checked', 'checked');

            $('.address-list span').removeAttr('expand');

            refreshAddressStatus();

        }

        //if (!!$('.add-address').attr('checked')) {
        if (!$('.address-manage').hasClass('hide')) {

            if (!nameReg.test(name)) {
                new dialog.Alert('真实姓名至少2个中文,最多5个中文').show();
                return;
            }
            if (!addressReg.test(address)) {
                new dialog.Alert('你输入的地址格式不正确').show();
                return;
            }
            if (!phoneReg.test(phone)) {
                new dialog.Alert('你输入的联系电话格式不正确').show();
                return;
            }

            if ((!!telCode && !telCodeReg.test(telCode)) || (!!tel && !telReg.test(tel)) ||
                (telCodeReg.test(telCode) && !telReg.test(tel)) ||
                (!telCodeReg.test(telCode) && telReg.test(tel))) {
                new dialog.Alert('你输入的电话格式不正确').show();
                return;
            }

            if (!!mail && !emailReg.test(mail)) {
                new dialog.Alert('你输入的邮箱格式不正确').show();
                return;
            }

            if (!!code && !codeReg.test(code)) {
                new dialog.Alert('你输入的邮编格式不正确').show();
                return;
            }

            // 如果存在data-id说明是修改,否则是新增
            if (!!$saveBtn.attr('data-id')) {
                postData.id = $saveBtn.attr('data-id');
            }

            $.ajax({
                type: 'post',
                url: '/cart/index/saveAddress',
                data: postData
            }).then(function(d) {

                var addressData;

                if (d.code === 200) {

                    addressData = d.data;

                    console.log(addressData);

                    if (addressData.is_support === 'Y') {
                        $('.express-list input[name="carriagegroup"][value="2"]').removeAttr('disabled');
                        $('.express-list.sf').removeClass('hide');
                        $('.is-sup').addClass('hide');

                    } else {

                        $('.express-list input[name="carriagegroup"][value="2"]').attr('disabled', 'disabled');
                        $('.express-list.sf').addClass('hide');
                        $('.is-sup').removeClass('hide');
                    }

                    if (!!postData.id) {

                        // 修改操作接口没有返回id
                        addressStr = '<li class="active" data-id="' + postData.id +
                        '" data-express="' + addressData.is_support + '">' +
                        '<input data-name="' + postData.consignee +
                        '" data-areaCode="' + postData.areaCode +
                        '" data-addressDesc="' + postData.address +
                        '" data-mobile="' + postData.mobile +
                        '" data-phoneNum="' + postData.phoneNum +
                        '" data-phoneCode="' + postData.phoneCode +
                        '" data-zipCode="' + postData.zipCode +
                        '" data-email="' + postData.email +
                        '" checked="checked" class="radio" type="radio" name="address" />' +
                        '<label>' +
                        '<strong>' + name + '</strong>' +
                        '<span>' + provinceText + ' ' + cityText + ' ' + countyText + ' ' + address +
                        ' ' + hasText(code) + hasText(phone) + hasText(telCode) + hasText(tel) + '</span>' +
                        '<a href="javascript:void(0);" class="default-address">设为默认地址</a>' +
                        '<div class="order-modify-btn">' +
                        '<span class="address-modify">[修改]</span>' +
                        '<span class="address-del">[删除]</span>' +
                        '</div>' +
                        '</label>' +
                        '</li>';
                    } else {

                        //添加操作接口有返回id
                        addressStr = '<li class="active" data-id="' + addressData.id +
                        '" data-express="' + addressData.is_support + '">' +
                        '<input data-name="' + addressData.consignee +
                        '" data-areaCode="' + addressData.area_code +
                        '" data-addressDesc="' + addressData.address +
                        '" data-mobile="' + addressData.mobile +
                        '" data-phoneNum="' + addressData.a +
                        '" data-phoneCode="' + addressData.b +
                        '" data-zipCode="' + addressData.zip_code +
                        '" data-email="' + addressData.email +
                        '" checked="checked" class="radio" type="radio" name="address" />' +
                        '<label>' +
                        '<strong>' + name + '</strong>' +
                        '<span>' + provinceText + ' ' + cityText + ' ' + countyText + ' ' + address +
                        ' ' + hasText(code) + hasText(phone) + hasText(telCode) + hasText(tel) + '</span>' +
                        '<a href="javascript:void(0);" class="default-address">设为默认地址</a>' +
                        '<div class="order-modify-btn">' +
                        '<span class="address-modify">[修改]</span>' +
                        '<span class="address-del">[删除]</span>' +
                        '</div>' +
                        '</label>' +
                        '</li>';
                    }



                    // 如果dataID存在说明是修改操作
                    if (!!$this.attr('data-id')) {

                        $modifyLi = $('.exist-address-list li[data-id="' + $this.attr('data-id') + '"]');

                        $modifyLi.after($(addressStr)).remove();
                    } else {
                        $('.use-new-address').before($(addressStr));
                    }

                    $('.address-list span').removeAttr('expand');

                    refreshAddressStatus();
                } else {
                    new dialog.Alert(d.message).show();
                }
            });
        }

        if ($('.exist-address-list li').find('input[name="address"]:checked').length === 0) {
            new dialog.Alert('请选择一个地址').show();
            return;
        }
    });
};



// 支付及送货时间选择
$('.pay-time-modify .pay-btn').click(function() {

    var $payInfoBox = $('.modity-pay-info'),
        $payTime = $('.pay-time-modify'),
        payTypeVal = $payTime.find('input[name="pay-type"]:checked').val(),
        payTypeText = $payTime.find('input[name="pay-type"]:checked').next('label').text(),
        payTimeText = $payTime.find('input[name="pay-time-radio"]:checked').next('label').text(),
        payTimeVal = $payTime.find('input[name="pay-time-radio"]:checked').val(),
        isCall = $payTime.find('input[name="call-me"]:checked').next('label').text(),
        callMeVal = $payTime.find('input[name="call-me"]:checked').val();


    $loading.show();

    $.ajax({
        type: 'POST',
        url: '/cart/index/orderCompute',
        dataType: 'json',
        data: {
            cartType: cartType,
            paymentType: payTypeVal
        }
    }).then(function(d) {

        $loading.hide();

        if (d.code === 200) {

            $payInfoBox.find('li').eq(0).find('span').text(payTypeText);
            $payInfoBox.find('li').eq(1).find('span').text(payTimeText);
            $payInfoBox.find('li').eq(2).find('span').text(isCall);

            $('.pay-time-modify').addClass('hide')
                .find('input[name="pay-type"][value=' + payTypeVal + ']').addClass('checked')
                .end().find('input[name="pay-time-radio"][value=' + payTimeVal + ']').addClass('checked')
                .end().find('input[name="call-me"][value=' + callMeVal + ']').addClass('checked');

            $('.modity-pay-info').removeClass('hide');

            $('.switch-pay-modify').text('[修改]');

        } else {
            new dialog.Alert(d.message).show();
        }
    });
});

function getYohoBiList() {

    var $juanUl = $('.play-juan ul'),
        juanStr = '',
        dLen,
        data,
        i;

    $.ajax({
        type: 'GET',
        dataType: 'json',
        url: '/cart/index/getCouponList'
    }).then(function(d) {

        if (d.code === 200) {
            data = d.data;
            dLen = data.length;

            for (i = 0; i < dLen; i++) {
                juanStr += '<li>' +
                '<input name="juangroup" type="radio" value="' + data[i].code + '">' +
                '<label>' + data[i].desc + '</label>' +
                '</li>';
            }

            $juanUl.prepend($(juanStr));

        }
    });
}
getYohoBiList();

// 把Y、N转换成bool

function ytoTrue(val) {

    if (val === 'N') {
        return false;
    } else {
        return true;
    }
}


// 去支付
$('.to-play input.submit').click(function() {

    var addressId = $('.exist-address-list input[name="address"]:checked').closest('li').attr('data-id'),
        deliveryTimeId = $('.pay-time-modify input[name="pay-time-radio"]:checked').val(),
        deliveryWayId = $('.pay-time-modify input[name="carriagegroup"]:checked').val(),
        invoiceTitle = $('#piaodesc').val(),
        invoiceId = $('#piaotype').val(),
        paymentType = $('.pay-time-modify input[name="pay-type"]:checked').val(),
        paymentId = $('.pay-time-modify input[name="pay-type"]:checked').data('pay'),
        remark = $('#notedesc').val(),
        yohoCoin = $('#biprice').val(),
        isPreContact = $('.pay-time-modify input[name="call-me"]:checked').val(),
        isPrintPrice = $('.pay-time-modify input[name="isPP"]:checked').val(),
        redEnvelopes = $('.use-envelopes input:checked').attr('data-use'),
        $juangroupInput = $('.play-juan.is-select input[name="juangroup"]:checked'),
        codeVal = $juangroupInput.val(),
        juanCode = !!codeVal ? codeVal : $juangroupInput.closest('li').find('#juancode').val();

    $loading.show();

    $.ajax({
        type: 'POST',
        dataType: 'json',
        url: '/cart/index/orderSub',
        data: {
            addressId: addressId,
            cartType: cartType,
            deliveryTimeId: deliveryTimeId,
            deliveryWayId: deliveryWayId,
            invoiceTitle: invoiceTitle,
            invoiceId: invoiceId,
            paymentId: paymentId,
            paymentType: paymentType,
            remark: remark,
            couponCode: juanCode,
            yohoCoin: yohoCoin,
            isPreContact: ytoTrue(isPreContact),
            isPrintPrice: ytoTrue(isPrintPrice),
            redEnvelopes: redEnvelopes
        }
    }).then(function(d) {

        $loading.hide();

        if (d.code === 200) {
            window.location.href = d.data.payUrl;
        } else {
            new dialog.Alert(d.message).show();
        }
    });
});
});