index.js 43.9 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
var e = function (e) {
  return e && e.__esModule ? e : {
    default: e
  };
}(require("../../../utils/LoadMore.js")),
  t = getApp(),
  a = t.request,
  o = t.globalData.setting,
  os = o,
  i = require("../../../utils/util.js"),
  ut = i,
  s = require("../../../utils/common.js"),
  n = new e.default();
var regeneratorRuntime = require('../../../utils/runtime.js');
var api = require('../../../api/api.js');
var d = getApp().globalData;

var full_screen = require('full_screen.js');


Page({
  data: {
    url: o.imghost,
    swiperimage: [{
      image: "/miniapp/images/title.png",
      nav_url: 0
    }],
    resourceUrl: o.resourceUrl,
    logo: o.appLogo,
    homeData: null,
    saleGoods: null,
    sale: {
      countTime: {
        hour: 0,
        minute: 0,
        second: 0
      },
      diffTime: 0,
      good: null,
    },
    timer: null,
    recommend: null,
    scrollTop: 0,
    currentPage: 1,
    banner: null,

    appdata: null,
    saleGoods: null, //秒杀数据
    pindGoods: null, //拼单数据
    newGoods: null, //新商品
    hotGoods: null, //hot商品
    preGoods: null, //预售商品
    //----控制是是否显示计时器---
    is_timer: 1,
    ishow: 0,
    //是不是显示自定义模板
    isTemplate: 0,
    template_arr: null,
    bgcolor_t: '',

    banner_index: 0,
    flash_index: 0,
    pt_index: 0,

    pt_timer_item: null,
    pt_timer_arr: null,
    pt_timer: null,
    pt_timer_active: 0,
    //看下商家是否开通会员权益
    is_boot: 0,
    gd_category: null,
    is_no_more: 0,
    max_sw_height: 0, //banner的最大高度
    is_disgraceful: 0, //是否显示新人广告
    new_image: "", //新人有礼弹窗图片
    new_nav: "", //新人页面跳转地址
    w_holiday_pop: 0,

    showHongbao: false,
    showHongbaoSmall: false,
    goodsGroupArr: [], //商品模块列表
    is_full_screen_show: 0,  //全屏显示
    sec_show: 3,    //倒计时的秒数
    full_ad: null,  //全屏广告
    full_screen: 0, //全屏广告
    is_ok_h5: 0,  //判断要不要显示关注二维码
    mb_banner: {},//首页广告
    container: null,
    is_retail_price: 0,
    //满屏顶部导航参数------------
    is_full_screen_navigation: false, //是否满屏
    is_full_screen_navigation_index: -1, //广告轮播满屏下标
    nav_title: '首页',
    nav_frontColor: "#000",
    old_nav_frontColor: "",
    nav_backgroundColor: "#fff",
    nav_type: 1,  //导航类型
    searchbox_transparent: 1, //搜索框背景是否透明
    is_show_top:0, //是否置顶显示
    right_floating_length:0, //右边悬浮窗的个数,用于当抢红包和右边悬浮同时存在时,红包定位用
    // nav_but_color: '#32ACF9', //导航按钮颜色
    // sele_pickup: null, //默认门店
    // nav_bg_color:'#e823e8', //导航按钮颜色
    //----------------
  },


  onLoad: async function (tt) {
    wx.offCopyUrl()
    wx.showShareMenu({
      withShareTicket: true,
      menus: ['shareAppMessage', 'shareTimeline']
    })
    var th = this;
    var first_leader = tt.first_leader;
    //群id
    if (tt && tt.groupchat_id && tt.groupchat_id != 'undefined' && tt.groupchat_id != 'null') {
      getApp().globalData.groupchat_id = tt.groupchat_id
    }
    if (!first_leader && tt.scene) {
      var first_leader_str = decodeURIComponent(tt.scene);
      var f_arr = first_leader_str.split("_");
      first_leader = f_arr[0] && parseFloat(f_arr[0]) > 0 ? f_arr[0] : null;
      //注册门店
      if (f_arr[1] && parseFloat(f_arr[1]) > 0) {
        getApp().globalData.store_number = f_arr[1];
      }
      //企业微信群id
      if (f_arr[2] && parseFloat(f_arr[2]) > 0) {
        getApp().globalData.groupchat_id = f_arr[2];
      }

    }
    // console.error('群id------------------------------------------');
    // console.error(getApp().globalData.groupchat_id);
    // console.error('群id------------------------------------------2222222222222222222222');
    // getApp().globalData.groupchat_id=1

    console.log("first_leader:" + first_leader, "onload");


    getApp().getConfig(function (e) {
      //--首页的问题--
      if (getApp().globalData.config && getApp().globalData.config.store_name != undefined && getApp().globalData.config.store_name != null) {
        wx.setNavigationBarTitle({
          title: getApp().globalData.config.store_name,
        });
      } else {
        wx.setNavigationBarTitle({
          title: getApp().globalData.setting.appName,
        });
      };
      th.setData({
        nav_title:getApp().globalData.config.store_name
      })
    });


    var th = this;
    getApp().getConfig2(function (config2) {
      var swithc_list = config2.switch_list;
      var sw_arr = JSON.parse(swithc_list);
      if (sw_arr.is_retail_price) {
        th.setData({ is_retail_price: 1 });
      }

      if (config2 && config2.is_overdue == 1) {
        getApp().promiseGet("/store/storemoduleendtime/page?store_id=" + os.stoid + "&type=5", {}).then(res => {
          var o = res;
          if (o.data.code == 0) {
            var ob = { isout: 0, isbuy: 1 };
            var arr = o.data.data.pageData;
            var isbuy = 0;
            //----如果数组不为空----
            if (arr.length > 0) {
              arr.forEach(function (val, ind) {
                if (val.is_sy == 0 && val.type == 5) {
                  isbuy = 1;
                  var now = ut.gettimestamp();
                  if (now > val.end_time) ob.isout = 1;
                  return false;
                }
              })
            }
            ob.isbuy = isbuy;

            var pages = getCurrentPages();             //获取加载的页面
            var currentPage = pages[pages.length - 1];  //获取当前页面的对象

            // console.log("当前路由");
            // console.log(currentPage.route);


            th.setappdata(ob);

            if (ob.isbuy && !ob.isout) {
              th.onload_init();
            }
          } else {
            th.onload_init();
          }
        })
      }
      else {
        th.onload_init();
      }
    })

    if (first_leader) {
      //--  user_id代过来免登录 --
      getApp().globalData.first_leader = first_leader;
      //调用接口判断是不是会员
      getApp().request.promiseGet("/api/weshop/shoppingGuide/get/" + os.stoid + "/" + first_leader, {}).then(res => {
        if (res.data.code == 0) {
          getApp().globalData.guide_id = res.data.data.id;
          getApp().globalData.guide_pick_id = res.data.data.pickup_id
        }
      })

      //先查看一下是不是系统会员
      getApp().waitfor_login(()=> {
        if (!getApp().globalData.user_id) {
          ut.new_user_go(os.stoid, first_leader);
        }
      })

    }

    // 判断是否有红包活动
    getApp().request.promiseGet('/api/weshop/redmoney/redConfig/get/' + getApp().globalData.setting.stoid, {
      data: {}
    }).then(function (data) {

      let code = data.data.code;
      let resdata = data.data.data;
      if (code == 0 && resdata.is_index) {

        th.setData({
          showHongbao: true,
        });
      } else if (code == -1) {
        th.setData({
          showHongbao: false,
        });
      };
    });


    // console.log(9090909);
    //看一下商家是否开通了权益
    //--初始化是否有打勾--
    getApp().request.promiseGet("/api/weshop/users/grade/vip/init/get", {
      data: {
        storeId: os.stoid
      }
    }).then(res => {
      if (res.data.data) {
        var is_init = res.data.data.isBool;
        th.setData({
          is_boot: is_init
        });

        if (!is_init) {
          th.setData({
            swiperimage: []
          });
        }
      }
    })


    var share_openid = tt.share_openid;
    if (share_openid) {
      this.get_room_share_guide(share_openid);
    }

    //调用底部导航
    //getApp().globalData.url=th.data.url
    //t.editTabBar(th,o.stoid,th.data.url);

  },


  async get_room_share_guide(share_openid) {

    var url = "/api/weshop/users/page";
    var first_leader = 0;

    //调用接口判断是不是会员
    await getApp().request.promiseGet(url, {
      data: { stoid: os.stoid, weapp_openid: share_openid }
    }).then(res => {
      if (ut.ajax_ok(res)) {
        first_leader = res.data.data.pageData[0].user_id;
        // getApp().globalData.guide_id = res.data.data.id;
      }
    })
    if (!first_leader) return false;

    getApp().globalData.first_leader = first_leader;
    //调用接口判断是不是会员
    await getApp().request.promiseGet("/api/weshop/shoppingGuide/get/" + os.stoid + "/" + first_leader, {}).then(res => {
      if (res.data.code == 0) {
        getApp().globalData.guide_id = res.data.data.id;
        getApp().globalData.guide_pick_id = res.data.data.pickup_id
      }
    })

  },


  async onload_init() {
    var th = this;
    //显示的时候要开启计时器
    this.data.is_timer = 1;

    //先查看一下是不是系统会员,要等一下会员默认登录
    getApp().waitfor_login(async ()=> {
      await this.init_load();
      //如果是自定义模板
      if (this.data.isTemplate) {
        //---先获取会员---
        //t.getUserFir(function () {
        if (getApp().globalData.user_id) {
          th.is_festival();
          var new_nav = th.data.new_nav;
          if (new_nav == "") {
            th.is_new();
          }
          // sty
          setTimeout(function () {
            if (getApp().globalData.user_id) getApp().requestCardNum(th);
          }, 500)
        }

        //});
      } else {
        await this.init_fir();
        wx.setNavigationBarColor({
          frontColor: '#ffffff', // 必写项
          backgroundColor: '#ff7295', // 必写项
        })
        this.setData({
          nav_frontColor: '#000', // 必写项
          nav_backgroundColor: '#fff', // 必写项
        })
      }
    })

    //--正再拼团中的处理--
    var url = "/api/weshop/order/pageTuanNew?pt_status=2&is_pt=1&store_id=" + os.stoid + "&pageSize=6&page=1"
    await getApp().request.promiseGet(url, {}).then(res => {
      if (res.data.code == 0 && res.data.data && res.data.data.pageData) {
        th.data.pt_timer_arr = res.data.data.pageData;
      }
    })
    if (th.data.pt_timer_arr && th.data.pt_timer_arr.length > 0) {
      for (var i in th.data.pt_timer_arr) {
        var p_item = th.data.pt_timer_arr[i];
        await getApp().request.promiseGet("/api/weshop/users/get/" + os.stoid + "/" + p_item.user_id, {
          1: 1
        }).then(res => {
          th.data.pt_timer_arr[i].head_pic = res.data.data.head_pic;
          th.data.pt_timer_arr[i].nickname = res.data.data.nickname;
        })
      }
      th.Interval_pt();
    }

    //---处理正在6个分类----
    await getApp().request.promiseGet("/api/weshop/goodscategory/page", {
      data: {
        store_id: os.stoid,
        pageSize: 5,
        is_show: 1,
        level: 1
      }
    }).then(res => {
      if (res.data.data) {
        var gd_category = res.data.data.pageData;
        th.setData({
          gd_category: gd_category
        });
      }
    })
  },
  onReady() {
    console.log('渲染完成----')
    console.log(this.data.template_arr);
    console.log('....................');
  },

  //获取商品模块实例 
  newGoodsGroup() {
    let arr = []
    if (this.data.template_arr.length == 0) {
      return
    }
    this.data.template_arr.map((item, index) => {
      if (item.ename == 'goodsGroup') {
        arr.push(`goodsGroup${index}`)
      }
      if (item.ename == 'goodsGroupNew') {
        arr.push(`goodsGroup${index}`)
      }
    })
    if (arr.length > 0) {
      this.setData({
        goodsGroupArr: arr
      })
      arr.map(item => {
        let a = '.' + item
        this[item] = this.selectComponent(a);
      })
    }
  },

  //关闭新用户领取广告
  close_disgraceful: function () {
    var th = this;
    th.setData({
      is_disgraceful: 0
    })
  },

  async onShow() {

    //-- 看一下隐私政策要不要显示 --
    var privacy_pop = this.selectComponent("#privacy_pop"); //组件的id
    if (privacy_pop) {
      privacy_pop.check_pri_show();
    }
    var th = this;


    //要等一下会员默认登录
    getApp().waitfor_login(async ()=> {

      getApp().check_can_share(th);
      if (typeof this.getTabBar === 'function' && this.getTabBar()) {
        this.getTabBar().setData({
          cartGoodsNum: getApp().globalData.cartGoodsNum
        })
      }

      //-- 登录回来判断弹框 --
      var user_id = getApp().globalData.user_id;

      if (!user_id) {
        var userinfo = wx.getStorageSync('userinfo');
        if (userinfo) user_id = userinfo.user_id
      }

      if (user_id) {
        th.is_festival();
        var new_nav = th.data.new_nav;
        if (new_nav == "") {
          th.is_new();
        }
      }

      console.log(this.data.isTemplate, '首页');

      if (!this.data.isTemplate) {
        //timetype: 1 仅查询已预售 置空查询全部,
        var pre_data = {store_id: os.stoid, is_end: 0, isuse: 1, timetype: 3};
        if (user_id) {
          pre_data.user_id = user_id;
        }

        getApp().request.get("/api/weshop/marketing/marketingPresellList/page", {
          data: pre_data,
          success: function (e) {
            if (e.data.code == 0 && e.data.data.pageData && e.data.data.pageData.length > 0) {
              var pre_data = e.data.data.pageData;
              //当前时间戳
              var st = ut.gettimestamp();

              pre_data.forEach(function (val, ind) {

                if (val.user_price) val.price = val.user_price;
                if (val.start_time > st) {
                  pre_data[ind].status = 0;
                } else if (val.end_time > st) {
                  pre_data[ind].status = 1;
                } else {
                  pre_data[ind].status = 2;
                }

                // if (val.buy_num >= val.goods_num) {
                //   pre_data[ind].status = 2;
                // }
              });
              var arr = new Array();
              //--三个三个一组---
              for (var i = 0; i < pre_data.length; i += 3) {
                arr.push(pre_data.slice(i, i + 3));
              }
              th.setData({
                preGoods: arr
              });
            } else {
              th.setData({
                preGoods: null
              });
            }
          }
        })

        // 获取幸运购活动列表
        getApp().request.promiseGet('/api/weshop/prom/luckyActivity/page', {
          data: {
            store_id: getApp().globalData.setting.stoid,
            is_end: 0,
            timetype: 1,
            user_id:getApp().globalData.user_id?getApp().globalData.user_id:0 
          }
        }).then(res => {
          if (res.data.code == 0) {
            th.setData({
              luckGo_list: res.data.data.pageData.slice(0, 3),
            });
          }
        });

        //-----秒杀-----
        var flash_data = null;
        var f_req = {
          store_id: os.stoid,
          timetype: 2,
          is_end: 0,
          is_show: 1,
          pageSize: 9,
          user_id: 0
        };
        if (user_id) f_req.user_id = user_id;
        //--获取活动--
        await getApp().request.promiseGet("/api/ms/flash_sale/spikepage", {
          data: f_req,
        }).then(res => {
          var e = res;
          if (e.data.code == 0) {
            flash_data = e.data.data.pageData;
            if (flash_data == null || flash_data.length <= 0) return false;

            //当前时间戳
            var nt = ut.gettimestamp();

            flash_data.forEach(function (val, ind) {

              if (val.user_price) val.price = val.user_price;
              if (val.start_time > nt) {
                flash_data[ind].status = 0;
              } else if (val.end_time > nt) {
                flash_data[ind].status = 1;
              }

              if (val.buy_num >= val.goods_num) {
                flash_data[ind].status = 2;
              }
            });

            var promisies = [];
            for (const key in flash_data) {
              if (Object.hasOwnProperty.call(flash_data, key)) {
                const val = flash_data[key];
                promisies[key] = getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" +
                    os.stoid + "/1/" + val.id,
                    {}
                ).then(res => {
                  if (res.data.code == 0) {
                    if (res.data.data <= 0) flash_data[key].status = 2;
                  }
                  ;
                });
              }
            }

            Promise.all(promisies).then(() => {
              var arr = new Array();
              //--三个三个一组---
              for (var i = 0; i < flash_data.length; i += 3) {
                arr.push(flash_data.slice(i, i + 3));
              }

              th.setData({
                saleGoods: arr
              });
            });


          }
        });

      }

    })




    //优惠券要实时更新
    getApp().getConfig2(function (e) {
      var json_d = JSON.parse(e.switch_list);
      th.setData({ is_closecoupon: json_d.is_closecoupon })
      th.setData({ is_topstore: json_d.is_show_storeselect })
      if (json_d.is_gz_h5) th.setData({ is_gz_h5: json_d.is_gz_h5 })
    }, 1)

    if (typeof this.getTabBar === 'function' && this.getTabBar()) {
      var index = getApp().getPageIndex(this);
      this.getTabBar().setData({
        active: index //数字是当前页面在tabbar的索引
      })


      getApp().requestCardNum(this);
    }

    var th = this;

    var show = getApp().globalData.isLoad_ad;

    if (!show) {
      setTimeout(function () {
        full_screen.get_the_full_screen(th);
      }, 800);
      getApp().globalData.isLoad_ad = 1;
      if (!th.data.f_hidden) {
        setTimeout(function () {
          th.setData({ f_hidden: 1 })
          wx.hideLoading();
        }, 960)
      }
    } else {
      th.setData({ f_hidden: 1 })
    }

    setTimeout(function () {
      const query = wx.createSelectorQuery();
      query.select('#off_top').boundingClientRect();
      query.exec((res) => {
        if (res && res[0] && res[0].height > 0) {
          th.setData({ is_ok_h5: 1 });
        }
      })
    }, 3600);

  },
  //当隐藏的时候就关闭计时器
  onHide: function () {
    this.data.is_timer = 0;
    if (this.data.pt_timer) clearInterval(this.data.pt_timer);
    if (this.data.w_holiday_pop) clearInterval(this.data.w_holiday_pop);
    if (this.data.full_screen) clearInterval(this.data.full_screen);
    this.data.w_holiday_pop = 0;

  },

  //同步初始加载
  async init_load() {
    var th = this;
    //因为营销版本的功能包含了自定义模板的功能,是同时的
    //读取全局是否有弄自定义模板
    await api.get_template_fir(o.stoid).then(res => {
      var data = res.data.data;
      if (data && data.length > 0) {
        var temp_data = data[0];
        var t_arr = JSON.parse(temp_data.json_str);

        //增加判断是否是满屏
        let is_full_screen_navigation = false
        let is_full_screen_navigation_index = -1
        let nav_but_color = "#32ACF9"
        let left_arr = [] //左边悬浮
        let right_arr=[] //右边悬浮
        let floatw=null //悬浮窗口
        if (t_arr) {
          t_arr.map((item, index) => {
            if (item && item.content && item.content.full_screen == 1 && !is_full_screen_navigation) {
              is_full_screen_navigation = true
              is_full_screen_navigation_index = index
              try {
                nav_but_color = item.content.data[0].but_color
              } catch (error) { }
            }
            if (item.ename=='floatingWindow') {
              floatw = item
            }
            if (item.ename=='backTop' || item.ename=='onlineService' || item.ename=='scan' || item.ename=='floatingWindow') {
              right_arr.push(item)
            }
          })
        }
        let right_floating_length = 0
        if (floatw && floatw.content) {
          let fi = right_arr.findIndex(ite=>ite.ename=='floatingWindow')
          let datas={}
          if (!floatw.content.data) { //兼容旧的悬浮窗口
            datas.AppId= floatw.content.AppId
           datas.feedId= floatw.content.feedId
           datas.finderUserName= floatw.content.finderUserName
           datas.img=floatw.content.img
           datas.video_type= floatw.content.video_type
           datas.wxapp_url= floatw.content.wxapp_url
           datas.wxapp_url_title=floatw.content.wxapp_url_title
           floatw.content.data=[datas]
          }
          if (floatw.content.loaction_index==1) {
            right_arr.splice(fi,1,floatw)
            // right_arr.unshift(floatw)
            if (floatw.content.data && floatw.content.data.length>0) {           
              right_floating_length+=floatw.content.data.length
              right_floating_length--; //减去一个
            }
          }else{
            left_arr.unshift(floatw)
            right_arr.splice(fi,1)
          }
        }
        if (left_arr.length>0) {
          let obj={
            ename:'floatingBox',
            content:left_arr,
            loaction_index:0
          }
          t_arr.push(obj)
        }
        if (right_arr.length>0) {
          right_floating_length+= right_arr.length
          let obj={
            ename:'floatingBox',
            content:right_arr,
            loaction_index:1
          }
          t_arr.push(obj)
        }


        th.setData({
          right_floating_length,
          nav_but_color,
          is_full_screen_navigation,
          is_full_screen_navigation_index,
          template_arr: t_arr,
          isTemplate: 1,
          bgcolor_t: temp_data.bkcolor
        });
        setTimeout(() => {
          th.newGoodsGroup()
        }, 1000)
        //---如果有设定顶部的颜色的时候--
        if (temp_data.top_color && temp_data.top_color != 'null') {

          var top_w_color = "#ffffff";
          if (temp_data.top_word_color && temp_data.top_word_color == 'black') {
            top_w_color = "#000000";
          }
          wx.setNavigationBarColor({
            frontColor: top_w_color, // 必写项
            backgroundColor: temp_data.top_color, // 必写项
          })
          th.setData({
						nav_frontColor: top_w_color, // 必写项
						nav_backgroundColor: temp_data.top_color, // 必写项
          })
        }
      }
    })


  },
  //---读取数据内容---
  async init_fir() {
    console.log('init_fir');
    var th = this;
    //----广告----
    var e = this;
    await getApp().request.promiseGet("/api/weshop/ad/page?pid=2&store_id=" + o.stoid, {
      data: {
        enabled: 1
      }
    }).then(res => {

      if (res.data.code == 0 && res.data.data.pageData && res.data.data.pageData.length > 0) {
        var a = res.data.data.pageData;
        var arr = new Array();
        for (var i = 0; i < a.length; i++) {
          var tt = {
            'ad_code': o.imghost + a[i].ad_code,
            'media_link': '',
            'ad_weapplink': a[i].ad_weapplink
          };
          arr.push(tt);
        }
        if (arr.length > 0) e.setData({
          banner: arr,
        });

        wx.stopPullDownRefresh();
      }
    })
    let user_id = getApp().globalData.user_id;

    //---首页广告-------
    await getApp().request.promiseGet("/api/weshop/ad/page?pids=300,301,302,303,304&store_id=" + o.stoid, {
      data: {
        enabled: 1
      }
    }).then(res => {
      console.log('首页广告--------------------------');
      console.log(res);
      if (res.data.code == 0 && res.data.data.pageData && res.data.data.pageData.length > 0) {
        var a = res.data.data.pageData;
        var obj = {};
        for (var i = 0; i < a.length; i++) {
          var tt = {
            'ad_code': o.imghost + a[i].ad_code,
            'media_link': '',
            'ad_weapplink': a[i].ad_weapplink,
            'pid': a[i].pid
          };
          // arr.push(tt);
          obj[a[i].pid] = tt
        }
        if (a.length > 0) e.setData({
          mb_banner: obj,
        });

        wx.stopPullDownRefresh();
      }
    })


    //----拼单-----
    await getApp().request.promiseGet("/api/weshop/teamlist/pageteam/2", {
      data: {
        store_id: os.stoid,
        is_end: 0,
        is_show: 1,
        pageSize: 6,
        user_id,
      }
    }).then(res => {
      var e = res;
      if (e.data.code == 0) {
        var pd_data = e.data.data.pageData;

        if (pd_data.length == 0) return;

        //获取当前
        var nt = ut.gettimestamp();
        pd_data.forEach(function (val, ind) {
          if (val.start_time > nt) pd_data[ind].status = 0;
          else if (val.end_time > nt) pd_data[ind].status = 1;
          if (val.buy_num >= val.goods_num) pd_data[ind].status = 2;
        });

        //获取当前时间,比较拼团中还在未开始
        var timestamp = new Date().getTime();
        var is_team_tepy;
        for (var j = 0; j < pd_data.length; j++) {
          pd_data[j].is_team_tepy = 1;
          if (timestamp < pd_data[j].start_time * 1000) {
            var is_team_tepy;
            pd_data[j].is_team_tepy = 0;
          }
        }

        var arr = new Array();
        //--2个2个一组---
        for (var i = 0; i < pd_data.length; i += 2) {

          arr.push(pd_data.slice(i, i + 2));
        }

        th.setData({
          pindGoods: arr
        });
        th.countDown2();
      }
    })

    //------新品-------
    await getApp().request.promiseGet("/api/weshop/goods/page?page=1", {
      data: {
        is_mainshow: 1,
        isonsale: 1,
        is_on_sale: 1,
        store_id: o.stoid,
        pageSize: 9,
        is_new: 1,
        orderField: "sort"
      }
    }).then(res => {
      var e = res;
      if (e.data.code == 0) {
        var new_data = e.data.data.pageData;
        var arr = new Array();
        //--三个三个一组---
        for (var i = 0; i < new_data.length; i += 3) {
          arr.push(new_data.slice(i, i + 3));
        }
        th.setData({
          newGoods: arr,
        });
      }
    })

    //------热卖-------
    await getApp().request.promiseGet("/api/weshop/goods/page?page=1", {
      data: {
        is_mainshow: 1,
        isonsale: 1,
        is_on_sale: 1,
        store_id: o.stoid,
        pageSize: 9,
        is_hot: 1,
        orderField: "sort"
      }
    }).then(res => {
      var e = res;
      if (e.data.code == 0) {
        var new_data = e.data.data.pageData;
        var arr = new Array();
        //--三个三个一组---
        for (var i = 0; i < new_data.length; i += 3) {
          arr.push(new_data.slice(i, i + 3));
        }
        console.log(arr);
        th.setData({
          hotGoods: arr,
        });
      }
    })

    //---调用信息---
    // this.requestRecommend();
    this.setData({
      ishow: 1
    });

    //---先获取会员---
    //t.getUserFir(function () {
    if (getApp().globalData.user_id) {
      th.is_festival();
      var new_nav = th.data.new_nav;
      if (new_nav == "") {
        th.is_new();
      }

      // sty
      setTimeout(function () {
        if (getApp().globalData.user_id) getApp().requestCardNum(th);
      }, 500)
    }
    //});

    setTimeout(function () {
      var goods_list = th.selectComponent("#goods_list"); //组件的id
      goods_list.init();
      goods_list.get_list();
    }, 2000)
  },

  //--判断小程序是否过期--
  setappdata: function (t) {
    if (t && t.isout == 1)
      wx.reLaunch({
        url: "/packageD/pages/error/error?msg=该商城已到期,暂停浏览!\r\n可联系:" + getApp().globalData.config.store_tel,
      });
    if (t && t.isbuy == 0)
      wx.reLaunch({
        url: "/packageD/pages/error/error?msg=还未购买小程序",
      });
  },
  //---加载更多是靠这个函数----
  onReachBottom: function () {
    console.log('下拉加载2');

    var goods_list = this.selectComponent("#goods_list"); //组件的id
    if (goods_list) goods_list.get_list();

    if (getApp().globalData.func_list) {
      for (let i in getApp().globalData.func_list) {
        let item = getApp().globalData.func_list[i];
        item.re_show();
      }
    }


    //自定义时商品自动加载更多
    let goodsGroupArr = this.data.goodsGroupArr
    if (this.data.isTemplate && goodsGroupArr.length > 0) {
      goodsGroupArr.map(item => {
        if (this[item]) this[item].automore()
      })
    }

  },

  onPullDownRefresh: function (e) {
    this.data.recommend = null, this.data.currentPage = 1, n.resetConfig(), this.requestHomePage(),
      this.requestRecommend();
  },
  requestRecommend() { },
  requestHomePage() { },

  onUnload: function () {
    this.destroyActivityTimer();
  },
  setCountTime: function (e) {
    e.diffTime || (e.diffTime = new Date().getTime() - 1e3 * e.server_time), this.setData({
      "sale.diffTime": e.diffTime
    }), this.setData({
      "sale.good": e.flash_sale_goods[0]
    }), this.destroyActivityTimer(), this.createActivityTimer();
  },
  createActivityTimer: function () {
    var e = this.data.sale,
      t = this;
    this.data.timer = setInterval(function () {
      var a = 1e3 * e.good.end_time - new Date().getTime() + e.diffTime,
        o = i.transTime(a);
      a <= 0 ? t.requestHomePage() : t.setData({
        "sale.countTime": o
      });
    }, 1e3);
  },
  destroyActivityTimer: function () {
    this.data.timer && (clearInterval(this.data.timer), this.data.timer = null);
  },
  onPageScroll: function (e) {
    //满屏模式监听
    let num = e.scrollTop
    if (!this.data.old_nav_frontColor) {
      this.setData({
        old_nav_frontColor:this.data.nav_frontColor
      })
    }
    if (this.data.is_full_screen_navigation) {
      let nav_type = this.data.nav_type
      if (num >= 100 && nav_type) {
        this.setData({
          nav_type: 0,
          searchbox_transparent: 0,
          nav_frontColor: '#000'
        })
        // this.data.nav_type = 0
      }
      if (num < 100 && !nav_type) {
        this.setData({
          nav_type: 1,
          searchbox_transparent: 1,
          nav_frontColor: this.data.old_nav_frontColor
        })
        // this.data.nav_type = 1
      }
    }
    
    //-----------end-------
    //是否显示置顶
    if (num > 400) {
      this.setData({
        is_show_top:1
      })
    }else{
      this.setData({
        is_show_top:0
      })
    }
    //----end------

    this.data.scrollTop = e.scrollTop;
    var t = getCurrentPages();
    "pages/index/index/index" == t[t.length - 1].route;
    /*--(e.scrollTop > 10 ? wx.setNavigationBarColor({
      frontColor: "#ffffff",
      backgroundColor: "#f95959"
    }) : wx.setNavigationBarColor({
      frontColor: "#000000",
      backgroundColor: "#eeeeee"
    }));--*/
  },
  jumpSearch: function () {
    wx.navigateTo({
      url: "/packageG/pages/goods/search/search"
    });
  },
  onShareAppMessage: function (e) {
    getApp().globalData.no_clear = 1;
    var url = "/pages/index/index/index";
    var userInfo = getApp().globalData.userInfo;
    //是分销商才带
    if (userInfo) {
      url += "?first_leader=" + userInfo.user_id;
      //群id分享
      if (getApp().globalData.groupchat_id) {
        url += "&groupchat_id=" + getApp().globalData.groupchat_id
      }
    } else {
      //群id分享
      if (getApp().globalData.groupchat_id) {
        url += "?groupchat_id=" + getApp().globalData.groupchat_id
      }
    }
    console.log("---首页---分享--");
    var title = "商城首页"
    //分享
    if (getApp().globalData.config && getApp().globalData.config.store_name) {
      title = getApp().globalData.config.store_name;
    } else if (getApp().globalData.setting.appName) {
      title = getApp().globalData.setting.appName;
    }



    var ob = {
      title: title,
      path: url,
    };
    console.log(ob);
    return ob;
  },

  //图片失败,默认图片
  bind_bnerr: function (e) {
    var _errImg = e.target.dataset.errorimg;
    var _errObj = {};
    _errObj[_errImg] = this.data.url + "/miniapp/images/del/logo.jpg";
    this.setData(_errObj) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ;
  },

  //图片失败,默认图片
  bind_bnerr2: function (e) {
    var _errImg = e.target.dataset.errorimg;
    var _errurl = e.target.dataset.url;
    var _errObj = {};
    _errObj[_errImg] = "/miniapp/images/default_g_img.gif";
    this.setData(_errObj); //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ;

  },
  //图片失败,默认图片
  bind_bnerr3: function (e) {
    var _errImg = e.target.dataset.errorimg;
    var _Img = e.target.dataset.img;
    if (_Img != undefined) {
      var _errObj = {};
      _errObj[_errImg] = "/public/images/default_goods_image_240.gif";
      this.setData(_errObj) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ;
    }
  },


  //秒杀倒计时
  //---小于10的格式化函数----
  timeFormat(param) {
    return param < 10 ? '0' + param : param;
  },

  //----秒杀倒计时函数-----
  countDown() {
    if (!this.data.is_timer) return false;
    var th = this;
    // 获取当前时间,同时得到活动结束时间数组
    var newTime = ut.gettimestamp();
    var List = this.data.saleGoods;
    for (var j = 0; j < List.length; j++) {
      var endTimeList = List[j];
      // 对结束时间进行处理渲染到页面
      for (var i = 0; i < endTimeList.length; i++) {
        var o = endTimeList[i];
        var endTime = o.end_time
        if (o.status == 0) endTime = o.start_time

        var obj = null;
        // 如果活动未结束,对时间进行处理
        if (endTime - newTime > 0) {
          var time = (endTime - newTime);
          // 获取天、时、分、秒
          var day = parseInt(time / (60 * 60 * 24));
          var hou = parseInt(time % (60 * 60 * 24) / 3600);
          var min = parseInt(time % (60 * 60 * 24) % 3600 / 60);
          var sec = parseInt(time % (60 * 60 * 24) % 3600 % 60);
          obj = {
            day: this.timeFormat(day),
            hou: this.timeFormat(hou),
            min: this.timeFormat(min),
            sec: this.timeFormat(sec)
          }
        } else {
          //活动已结束,全部设置为'00'
          obj = {
            day: '00',
            hou: '00',
            min: '00',
            sec: '00'
          }
        }
        var txt = "saleGoods[" + j + "][" + i + "].djs";
        th.setData({
          [txt]: obj
        });
      }

    }
    setTimeout(th.countDown, 1000);
  },

  //----拼单倒计时函数-----
  countDown2() {
    if (!this.data.is_timer) return false;

    var th = this;
    // 获取当前时间,同时得到活动结束时间数组
    var newTime = ut.gettimestamp();
    var List = this.data.pindGoods;
    for (var j = 0; j < List.length; j++) {
      var endTimeList = List[j];
      // 对结束时间进行处理渲染到页面
      for (var i = 0; i < endTimeList.length; i++) {
        var o = endTimeList[i];
        var endTime = o.end_time;
        if (o.status == 0) endTime = o.start_time;

        let obj = null;
        // 如果活动未结束,对时间进行处理
        if (endTime - newTime > 0) {
          let time = (endTime - newTime);
          // 获取天、时、分、秒
          let day = parseInt(time / (60 * 60 * 24));
          let hou = parseInt(time % (60 * 60 * 24) / 3600);
          let min = parseInt(time % (60 * 60 * 24) % 3600 / 60);
          let sec = parseInt(time % (60 * 60 * 24) % 3600 % 60);
          obj = {
            day: this.timeFormat(day),
            hou: this.timeFormat(hou),
            min: this.timeFormat(min),
            sec: this.timeFormat(sec)
          }
        } else {
          //活动已结束,全部设置为'00'
          obj = {
            day: '00',
            hou: '00',
            min: '00',
            sec: '00'
          }
        }
        var txt = "pindGoods[" + j + "][" + i + "].djs";
        th.setData({
          [txt]: obj
        });
      }
    }
    setTimeout(th.countDown2, 1000);
  },

  bannerSwiperChange: function (e) {
    var index = e.detail.current;
    this.setData({
      banner_index: index
    });
  },
  flashSwiperChange: function (e) {
    var index = e.detail.current;
    this.setData({
      flash_index: index
    });
  },
  ptSwiperChange: function (e) {
    var index = e.detail.current;
    this.setData({
      pt_index: index
    });
  },

  Interval_pt() {
    var th = this;
    this.data.pt_timer = setInterval(function () {
      var item = ut.get_rand_item(th.data.pt_timer_arr);
      th.setData({
        pt_timer_active: 1,
        pt_timer_item: item
      });
      setTimeout(function () {
        th.setData({
          pt_timer_active: 0
        });
      }, 1500)
    }, 4000);
  },


  //---扫一扫的函数---
  getScancode: function () {
    var _this = this;
    getApp().globalData.no_clear = 1;
    // 允许从相机和相册扫码
    wx.scanCode({
      success: (res) => {
        var result = res.result;
        wx.navigateTo({
          url: "/packageG/pages/goods/search/search?s_key=" + result,
        });
      }
    })
  },
  //广告跳转
  go_mb(e) {
    let url = e.currentTarget.dataset.url
    getApp().goto(url);
  },

  //跳转到分类
  go_cate: function () {
    getApp().goto("/pages/goods/categoryList/categoryList");
  },

  // 幸运购跳转
  go_url: function (e) {

    var url = e.currentTarget.dataset.url;
    getApp().goto(url);

  }, //

  bind_bnerr_icon: function (e) {
    var def = "/miniapp/images/no_cate_def.png";
    var _err = e.currentTarget.dataset.err;
    var ob = {};
    ob[_err] = def;
    this.setData(ob);
  },

  //跳转到分类的商品列表
  go_cate2: function (t) {
    var cid = t.currentTarget.dataset.cid;
    var pid = t.currentTarget.dataset.pid;
    var lurl = "/pages/goods/goodsList/goodsList?cat_id=" + cid + "&pid=" + pid;
    wx.navigateTo({
      url: lurl
    });
  },
  new_nav: function (e) {
    var th = this;
    var new_nav = th.data.new_nav;
    getApp().goto(new_nav);
  },
  //跳转到权益
  go_quanyi: function (t) {
    var user_info = getApp().globalData.userInfo;
    if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) {
      wx.navigateTo({
        url: '/packageE/pages/togoin/togoin',
        //url: '/pages/getphone/getphone',
      })
      return false;
    }
    getApp().goto("/pages/user/userqy/userqy");
  },

  imageLoad: function (e) {
    var imgwidth = e.detail.width;
    var imgheight = e.detail.height;
    //宽高比
    var ratio = imgwidth / imgheight;
    //计算的高度值
    var viewHeight = 715 / ratio;
    if (this.data.max_sw_height < viewHeight) this.setData({
      max_sw_height: viewHeight
    });
  },
  //判断该用户是否是新会员
  is_new: function () {
    var th = this;
    wx.hideLoading();
    getApp().request.promiseGet("/api/weshop/marketing/newpeople/act/judge", {
      data: {
        storeId: os.stoid,
        userId: d.user_id
      }
    }).then(res => {
      if (res.data.code == 0) {
        var actid = res.data.data.id; //活动id
        var giftBagId = res.data.data.giftBagId; //礼包id
        var new_nav = "/pages/giftpack/newvipgift/newvipgift?actId=" + actid + '&' + 'actType=' + 1 + '&' + 'giftBagId=' + giftBagId;
        var new_image = res.data.data.imageurl;
        var swiperimage = th.data.swiperimage;
        var img = {
          image: "/miniapp/images/newpeople/newpeople.png",
          nav_url: new_nav
        }
        swiperimage.unshift(img);
        th.setData({
          swiperimage: swiperimage,
          new_image: new_image,
          new_nav: new_nav
        })

        getApp().request.promiseGet("/api/weshop/marketing/newpeople/act/bound/judge", {
          data: {
            storeId: o.stoid,
            userId: d.user_id
          }
        }).then(res => {
          if (res.data.code == 0) {
            th.setData({
              is_disgraceful: 1
            })
          } else {
            th.check_holiday_pop(); //节日的弹窗
          }

        })
      } else {
        th.check_holiday_pop(); //节日的弹窗
      }

    })

  },

  is_festival: function (e) {
    var th = this;
    var url = "/api/weshop/marketing/holiday/act/judge";
    getApp().request.promiseGet(url, {
      data: {
        storeId: os.stoid,
        userId: d.user_id
      }
    }).then(res => {
      if (res.data.code == 0) {
        var actid = res.data.data.id; //活动id
        var giftBagId = res.data.data.gifBagId; //礼包id
        var nav_url = "/pages/giftpack/festival/festival?actId=" + actid + '&' + 'actType=' + 3 + '&' + 'giftBagId=' + giftBagId;
        var swiperimage = th.data.swiperimage;
        var actBoundImg = res.data.data.actBoundImg ? res.data.data.actBoundImg : '/miniapp/images/default_g_img.gif';

        th.data.holiday_image = res.data.data.actImg;
        th.data.holiday_url = nav_url;

        var img = {
          image: actBoundImg,
          nav_url: nav_url,
          id: res.data.data.id,
          type: 'festival'
        }

        for (var i in swiperimage) {
          var item = swiperimage[i];
          if (item.id == img.id && item.type == img.type) {
            return false;
          }
        }

        swiperimage.unshift(img);
        th.setData({
          swiperimage: swiperimage,
          new_nav: nav_url
        })
      }
    })
  },

  //弹出节日有礼
  check_holiday_pop: function () {
    var th = this;
    getApp().waitfor2(th, 'w_holiday_pop', 'holiday_image', function () {
      //等到结果才显示
      if (th.data.holiday_image) {
        th.setData({
          new_image: th.data.holiday_image,
          new_nav: th.data.holiday_url,
          is_disgraceful: 1
        })
      }
    })
  },

  go_ad: function (e) {
    var url = e.currentTarget.dataset.url;
    if (!url || url == '') return;
    if (url[0] != '/') url = '/' + url;
    getApp().goto(url);
  },

  //导航跳转
  nav_goto: function (e) {
    var url = e.currentTarget.dataset.url;
    if (!url || url == '') return;
    if (url[0] != '/') url = '/' + url;
    getApp().goto(url);
    if (this.data.showHongbao) {
      this.setData({
        showHongbao: false,
        showHongbaoSmall: true, //显示抢红包小图标
      });
    }
  },

  //----跳转到搭配购买----
  go_test: function () {
    wx.navigateTo({ url: "/packageA/pages/goods_share/goods_share", })
  },
  onShareTimeline() {
    getApp().globalData.no_clear = 1;
    var store_name = getApp().globalData.config ? getApp().globalData.config.store_name : '';
    if (!store_name) {
      store_name = getApp().globalData.setting.appName;
    }
    var user_id = getApp().globalData.user_id;
    if (!user_id) user_id = 0;
    var url = ''
    //群id分享
    if (getApp().globalData.groupchat_id) {
      url += "&groupchat_id=" + getApp().globalData.groupchat_id
    }
    return {
      title: '首页-' + '-' + store_name,
      query: 'first_leader=' + user_id + url
    }
  },

  // 关闭首页抢红包主弹窗,显示侧边栏抢红包小图标
  closeHongbao() {
    this.setData({
      showHongbao: false, //关闭抢红包主弹窗
      showHongbaoSmall: true, //显示抢红包小图标
    });
  },

  /*-- 全屏广告 --*/
  close_full_screen() {
    this.setData({ is_full_screen_show: 0, sec_show: 0 });
  },
  //-- 跳转到满屏广告的链接 --
  go_full_ad() {
    if (!this.data.full_ad) return false;
    if (!this.data.full_ad.ad_weapplink) return false;
    getApp().goto(this.data.full_ad.ad_weapplink);
    this.close_full_screen();
  },

  go_pre: function (e) {
    // var userInfo = getApp().globalData.userInfo;
    // if (!userInfo) {
    //   getApp().goto("/packageE/pages/togoin/togoin");
    //   return false;
    // }
    var url = e.currentTarget.dataset.url;
    getApp().goto(url);
  },

  //视频号跳转
  nv_void() {
    // getApp().openChannelsActivity()
    wx.getChannelsLiveInfo({
      finderUserName: 'sphYA5FuPCZxHaw',
      success: (res) => {
        console.log(res)
      },
      fail: (error) => {
        console.log(error)
      }
    })
  },
  getchir() {
    const child = this.selectComponent('.goodsg');
    console.log('子组件--------111111------')
    console.log(child)
    console.log('子组件----------2222----')

  },


});