index.js 25.6 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906
var app = getApp();
var animation = wx.createAnimation({
  duration: 1000,
  timingFunction: "ease",
})
Page({
  data: {
    winHeight: "",//窗口高度
    currentTab: 0, //预设当前项的值
    scrollLeft: 0, //tab标题的滚动条位置
    expertList: [{}],
    imgUrls: [],
    indicatorDots: true,
    autoplay: true,
    interval: 3000,
    duration: 1000,
    // 筛选 ------------
    winWidth: 0,
    winHeight: 0,
    // tab切换  
    currentTabT: 0,
    // 筛选框状态
    screenModel: false,
    tabBarIndex: [],
    // 动画状态
    animation: false,
    animations: false,
    moudelOne: true,
    authorization: false,

    // 首页数据
    allData: [],
    // 自提点列表
    sinceList: [],
    // 堂食店铺列表
    hallListh: [],
    // 就近自提
    nearest_spot: "",
    // 到店堂食
    nearest_store: "", 
    stateShop: false,
    // 是否开启调研按钮
    diaoyan: false,

    // 判断设备活动快距离
    rpx: 0,
    // 递减cart_id
    cart_id:null,
    menu: false,
    canaction: false //阻止快速点击事件
  },
  // 没有门口
  sisi() {
    wx.navigateTo({
      url: '../expectLocation/expectLocation',
    })
  },
  // 选择到店堂食
  arriveShop(e) {
    wx.showLoading({
      title: '地址切换中。。。',
    }) 
    console.log(app.globalData.nearest_store)
    var data = e.currentTarget.dataset.data;
    var params = new Object; 
    params.store_id = data.store_id; 
    params.store_name = data.store_name + data.store_address + ",距您" + data.distance_text
    app.globalData.nearest_store = params;
    console.log(app.globalData.nearest_store)
    this.setData({ 
      moudelOne: true,
      stateShop: true,
      nearest_store: app.globalData.nearest_store
    }) 
    wx.showToast({
      title: '切换完成',
      icon: 'success',
      duration: 2000
    })
  },
  // 选择就近自提
  setLocation(e) {
    wx.showLoading({
      title: '地址切换中。。。',
    })
    var spot_id = e.currentTarget.dataset.spot_id;
    var spot_name = e.currentTarget.dataset.spot_name;
    var distance_text = e.currentTarget.dataset.distance_text;
    var params = new Object;
    params.spot_id = spot_id; 
    params.spot_name = spot_name + distance_text;
    app.globalData.nearest_spot = params;
    console.log(app.globalData.nearest_spot)
    this.setData({
      screenModel: false,
      nearest_spot: app.globalData.nearest_spot
    })
    wx.showToast({
      title: '切换完成',
      icon: 'success',
      duration: 2000
    })
  },
  // 判断是否新人能否领取优惠券
  justy(){
    app.ajax("Index/isFirst", {
      unique_id: app.globalData.unique_id
    }, (res) => {
      console.log(res)
      if (res.statusCode == '200'){
        this.setData({
          card: res.data.status,
          cardInfo: res.data.data
        })
      }
    })
  },
  // 授权登陆
  bindGetUserInfo(e) {
    var that = this
    console.log(e)
    console.log(e.detail.userInfo)
    app.globalData.userInfo = e.detail.userInfo
    wx.login({
      success: (res) => {
        if (res.code) {
          //发起网络请求
          console.log(res)
          app.ajax("Index/auth", {
            code: res.code,
            iv: e.detail.iv,
            encryptedData: e.detail.encryptedData,
            nickname: app.globalData.userInfo.nickName,
            head_img: app.globalData.userInfo.avatarUrl,
          }, (res) => {
            this.onShow()
            if (res.data.data.is_auth == 1) {
              app.globalData.unique_id = res.data.data.unique_id
              if (that.data.from) {
                app.ajax("DiscountCoupon/shareGetCoupon", {
                  from: that.data.from,
                  to: app.globalData.unique_id
                }, (res) => {
                  console.log(res)
                })
              }
              this.setData({
                authorization: false
              })
            }
          })
        } else {
          console.log('获取用户登录态失败!' + res.errMsg)
        }
      }
    });

  },
  hideCard(){
    this.setData({
      card: false
    })
  },
  getCard(event){
    let that = this
    let info = this.data.cardInfo
    var params = Object.assign({},info)
    params.unique_id = app.globalData.unique_id
    app.ajax("Index/receivePledge", params, (res) => {
      console.log(res)
      if(res.data.state == 'success'){
        that.hideCard()
        wx.showToast({
          title: res.data.msg,
          icon: 'success'
        })
      }
    })
  },
  // 递增操作
  addCount(e) {
    wx.showLoading({
      title: '加载中',
      mask: true
    })
    var index = e.currentTarget.dataset.index;
    var id = e.currentTarget.dataset.id;
    var num = parseInt(e.currentTarget.dataset.num);
    num++
    app.ajax("Cart/add", {
      unique_id: app.globalData.unique_id,
      goods_id: id,
      goods_num: 1,
    }, (res) => {
      console.log(res)
      wx.hideLoading()
      if (res.data.status == true) {
        var data = this.data.allData.goods_list;
        data[index].chacke = true;
        data[index].num = num;
        this.setData({
          "allData.goods_list": data
        })
        // 获取购物车数量
        app.ajax("CountNum/countCart", {
          unique_id: app.globalData.unique_id
        }, (res) => {
          console.log(res)
          if (res.data.status == true) {
            app.globalData.tabBar[1].num = res.data.data[0].count
            this.setData({
              tabBarIndex: app.globalData.tabBar
            })
          }
        }, (res) => { }) 
      }else{
        wx.showToast({
          title: res.data.msg,
          icon: 'none'
        })
      }
    })
  },
  // 递减操作
  minusCount(e) {
    wx.showLoading({
      title: '加载中',
      mask:true
    })
    var index = e.currentTarget.dataset.index;
    var id = e.currentTarget.dataset.id;
    var num = parseInt(e.currentTarget.dataset.num);
    var cart_id = e.currentTarget.dataset.cart_id
    if(num<=1){
      app.ajax("Cart/del", {
        cart_id: cart_id
      }, (res) => {
        console.log(res)
        if (res.data.status == true) {
          // this.getShopCar()
          var data = this.data.allData.goods_list;
          data[index].chacke = false;
          this.setData({
            "allData.goods_list": data
          })
          // 获取购物车数量
          app.ajax("CountNum/countCart", {
            unique_id: app.globalData.unique_id
          }, (res) => {
            console.log(res)
            wx.hideLoading()
            if (res.data.status == true) {
              app.globalData.tabBar[1].num = res.data.data[0].count
              this.setData({
                tabBarIndex: app.globalData.tabBar
              })
              //  console.log(res.data.data[0].count)
            }

          }, (res) => { })
        }
      }, (res) => { })
    }else{
      num--
      app.ajax("Cart/add", {
        unique_id: app.globalData.unique_id,
        goods_id: id,
        goods_num: -1,
      }, (res) => {
        console.log(res)
        wx.hideLoading()
        if (res.data.status == true) {
          var data = this.data.allData.goods_list;
          data[index].chacke = true;
          data[index].num = num;
          this.setData({
            "allData.goods_list": data,
            cart_id: res.data.cart_id
          })
          // 获取购物车数量
          app.ajax("CountNum/countCart", {
            unique_id: app.globalData.unique_id
          }, (res) => {
            console.log(res)
            if (res.data.status == true) {
              app.globalData.tabBar[1].num = res.data.data[0].count
              this.setData({
                tabBarIndex: app.globalData.tabBar
              })
            }
          }, (res) => { })
        }
      })
    }
    // if (num < 1) {

    // } else {
    //   num--
    //   app.ajax("Cart/editNum", {
    //     goods_num: -1
    //   }, (res) => {
    //     console.log(res)
    //     if (res.data.status == true) {
    //       this.getShopCar()
    //       // 获取购物车数量
    //       app.ajax("CountNum/countCart", {
    //         unique_id: app.globalData.unique_id
    //       }, (res) => {
    //         console.log(res)
    //         if (res.data.status == true) {
    //           if (parseInt(res.data.data[0].count) == 0) {
    //             wx.showModal({
    //               title: '提示',
    //               content: '是否删除该商品',
    //               success: (res) => {
    //                 if (res.confirm) {
    //                   console.log('用户点击确定')
    //                   app.ajax("Cart/del", {
    //                     cart_id: cart_id
    //                   }, (res) => {
    //                     console.log(res)
    //                     if (res.data.status == true) {
    //                       this.getShopCar()
    //                       // 获取购物车数量
    //                       app.ajax("CountNum/countCart", {
    //                         unique_id: app.globalData.unique_id
    //                       }, (res) => {
    //                         console.log(res)
    //                         if (res.data.status == true) {
    //                           app.globalData.tabBar[1].num = res.data.data[0].count
    //                           this.setData({
    //                             tabBarIndex: app.globalData.tabBar
    //                           })
    //                         }
    //                       }, (res) => { })
    //                     }
    //                   }, (res) => { })
    //                 } else if (res.cancel) {
    //                   console.log('用户点击取消')
    //                 }
    //               }
    //             })
    //           }
    //           app.globalData.tabBar[1].num = res.data.data[0].count
    //           this.setData({
    //             tabBarIndex: app.globalData.tabBar
    //           })
    //         }
    //       }, (res) => { })
    //     }
    //   }, (res) => { })
    // }

    
  },
  // 商品列表加入购物车
  openShopCar(e) {
    var index = e.currentTarget.dataset.index;
    var id = e.currentTarget.dataset.id;
    var num = e.currentTarget.dataset.num;
    app.ajax("Cart/add", {
      unique_id: app.globalData.unique_id,
      goods_id: id,
      goods_num: num,
    }, (res) => {
      console.log(res)
      if (res.data.status == true) {
        var data = this.data.allData.goods_list;
        data[index].chacke = true;
        data[index].cart_id = res.data.cart_id
        this.setData({
          "allData.goods_list": data
        })

        // 获取购物车数量
        app.ajax("CountNum/countCart", {
          unique_id: app.globalData.unique_id
        }, (res) => {
          console.log(res)
          if (res.data.status == true) {
            app.globalData.tabBar[1].num = res.data.data[0].count
            this.setData({
              tabBarIndex: app.globalData.tabBar
            })
          }
        }, (res) => { })
        // 获取购物车
        app.ajax("Cart/index", {
          unique_id: app.globalData.unique_id
        }, (res) => {
          console.log("获取购物车")
          console.log(res)
          if (res.data.status == true) {
            app.globalData.shoppingCart = res.data.data
            console.log(app.globalData.tabBar)
          }
        }, (res) => { })
      }else{
        wx.showToast({
          title: '库存不足',
          icon: 'none'
        })
      }
    })
  },
  // 引导页
  guidance() {
    wx.navigateTo({
      url: '../guidance/guidance',
    })
  },
  // 门店详情
  shopDetails(e) {
    var store_id = e.currentTarget.dataset.store_id;
    var store_name = e.currentTarget.dataset.store_name;
    var open_start = e.currentTarget.dataset.open_start;
    var open_end = e.currentTarget.dataset.open_end;
    var store_address = e.currentTarget.dataset.store_address;
    var distance_text = e.currentTarget.dataset.distance_text;
    wx.navigateTo({
      url: '../shopDetails/shopDetails?store_id=' + store_id + "&store_name=" + store_name + "&open_start=" + open_start + "&open_end=" + open_end + "&store_address=" + store_address + "&distance_text=" + distance_text,
    })
  },
  // 下导航
  tabBar(e) {
    var index = e.currentTarget.dataset.index;
    var tabBar = app.globalData.tabBar
    for (let n in tabBar) {
      tabBar[n].state = false
    }
    tabBar[index].state = !tabBar[index].state
    app.globalData.tabBar = tabBar
    wx.reLaunch({
      url: tabBar[index].url,
    })
  },
  // 列表详情
  detailsGoods(e) {
    var id = e.currentTarget.dataset.id;
    wx.navigateTo({
      url: '../detailsGoods/detailsGoods?id=' + id,
    })
  },
  // 取货点详情
  getGoodsDetails(e) {
    let spot_id = e.currentTarget.dataset.spot_id;
    wx.navigateTo({
      url: '../getGoodsDetails/getGoodsDetails?spot_id=' + spot_id,
    })
  },
  // 防止穿透
  cat() { },
  // 点击收起筛选
  model() {
    console.log(1)
    this.setData({
      screenModel: !this.data.screenModel
    })
  },
  // 滚动切换标签样式
  switchTab: function (e) {
    this.setData({
      currentTab: e.detail.current
    });
    this.checkCor();
  },
  // 点击标题切换当前页时改变样式
  swichNav: function (e) {
    console.log(e)
    if (!this.data.canaction){
      return false
    }else{
      this.setData({
        canaction: false
      })
      var cur = e.target.dataset.current;
      var t_id = e.currentTarget.dataset.t_id;
      if (this.data.currentTaB == cur) { 
        return false; 
      }else {
        this.setData({
          currentTab: cur
        })
      }
      wx.showLoading({
        title: '加载中',
      })
      var params = new Object
      if (cur == 0){
        params.unique_id = app.globalData.unique_id
      }else if(cur == '-1'){
        params.unique_id = app.globalData.unique_id
        app.ajax("Index/newGoodsList", params, (res) => {
          wx.hideLoading()
          if (res.statusCode == '200') {
            var mes = res.data.data
            var data = mes;
            for (let n in data) {
              data[n].chacke = false
              data[n].num = 1
            }
            for (let n in data) {
              if (data[n].goods_num != null) {
                data[n].chacke = true
                data[n].num = parseInt(data[n].goods_num)
              }
            }
            this.setData({
              'allData.goods_list': mes,
              canaction: true
            })
            // this.setData({
            //   allData: res.data.data,
            //   imgUrls: res.data.data.banner
            // })
          } else {
            wx.showLoading({
              title: '暂无商品',
              duration: 1000
            })
            this.setData({
              "allData.goods_list": [],
              canaction: true
            })
          }
        }, (res) => { })

        return  false
      }else{
        params.t_id = t_id
        params.unique_id = app.globalData.unique_id
      }
      app.ajax("Index/index",params, (res) => {
        wx.hideLoading()
        console.log("获取首页数据")
        console.log(res)
        if (res.data.status == true) {
          var mes = res.data.data
          var data = mes.goods_list;
          for (let n in data) {
            data[n].chacke = false
            data[n].num = 1
          }
          for (let n in data) {
            if (data[n].goods_num != null) {
              data[n].chacke = true
              data[n].num = parseInt(data[n].goods_num)
            }
          }
          app.globalData.nearest_spot = mes.nearest_spot
          app.globalData.nearest_store = mes.nearest_store
          this.setData({
            allData: mes,
            menu: true,
            imgUrls: res.data.data.banner,
            nearest_spot: app.globalData.nearest_spot,
            nearest_store: app.globalData.nearest_store,
            canaction: true
          })

        } else {
          wx.showLoading({
            title: '暂无商品',
            duration: 1000
          })
          this.setData({
            "allData.goods_list": [],
            canaction: true
          })
        }
      }, (res) => { })

    }
  },
  //判断当前滚动超过一屏时,设置tab标题滚动条。
  checkCor: function () {
    if (this.data.currentTab > 4) {
      this.setData({
        scrollLeft: 300
      })
    } else {
      this.setData({
        scrollLeft: 0
      })
    }
  },
  /** 
    * 滑动切换tab 
    */
  bindChangeT: function (e) {

    var that = this;
    that.setData({ currentTabT: e.detail.current });

  },
  /** 
   * 点击tab切换 
   */
  swichNavT: function (e) {

    var that = this;

    if (this.data.currentTabT === e.target.dataset.current) {
      return false;
    } else {
      that.setData({
        currentTabT: e.target.dataset.current
      })
    }
    var area_id = e.target.dataset.area_id;

    app.ajax("Spot/index", {
      area_id: area_id,
      unique_id: app.globalData.unique_id
    }, (res) => {
      console.log("获取自提点数据")
      console.log(res)
      if (res.data.status == true) {
        this.setData({
          sinceList: res.data.data
        })
        if (res.data.data.spot == null) {
          wx.showLoading({
            title: '空空如也',
            duration: 1000,
            mask: true
          })

        }
      }
    }, (res) => { })
  },
  // 动画
  animations(e) {
    var state = e.currentTarget.dataset.state;
    var type = e.currentTarget.dataset.type
    console.log(this.data.animation)
    console.log(state)
    if (this.data.animations == false && state == false) {
      console.log(1)
      this.setData({
        screenModel: !this.data.screenModel,
      })
    } else if (this.data.animations == true && state == true) {
      if (this.data.moudelOne){
        this.setData({
          moudelOne: false
        })
      }else{
        this.setData({
          moudelOne: true
        })
      }
      // this.setData({
      //   animation: true,
      //   stateShop: true
      // })
    } else if (this.data.animations == false && state == true) {
      console.log(3)
      console.log(this.data.rpx)
      animation.translate((96 * 1.8) * this.data.rpx).step();
      app.globalData.btnStart = false
      this.setData({
        animationData: animation.export(),
        animations: true,
        moudelOne: false,
        stateShop: !this.data.stateShop,
        screenModel: false
      })
    } else if (this.data.animations == true && state == false) {
      console.log(4)
      animation.translate(0).step();
      app.globalData.btnStart = true
      this.setData({
        animationData: animation.export(),
        animations: false,
        moudelOne: true,
        stateShop: !this.data.stateShop,
        screenModel:true
      })
    }

  },

  onLoad: function (options) {
    if (options.from) {
      this.setData({
        from: options.from
      })
    }
    var that = this;
    //  高度自适应
    wx.getSystemInfo({
      success: function (res) {
        var clientHeight = res.windowHeight,
          clientWidth = res.windowWidth,
          rpxR = 750 / clientWidth;
        var calc = clientHeight * rpxR - 180;
        console.log(calc)
        that.setData({
          winHeight: calc
        });
      }
    });

  },
  footerTap: app.footerTap,
  onShow() {
    let that = this
    console.log(app.globalData.userInfo)
    app.globalData.btnStart = true
    
    wx.showLoading({
      title: '加载中',
      mask: true
    })

    // 设备判断滑动距离
    wx.getSystemInfo({
      success: (res) => {
        let rpx = 1 * (res.windowWidth * res.pixelRatio) / (750 * res.pixelRatio);
        this.setData({
          rpx: rpx
        })
      }
    })
    // 获取用户是否需要授权
    wx.login({
      success: (res) => {
        if (res.code) {
          //发起网络请求
          console.log(res)
          app.ajax("Index/auth0", {
            code: res.code
          }, (res) => {
            console.log(res)
            wx.hideLoading()
            if (res.data.data.is_auth == 1) {
              app.globalData.unique_id = res.data.data.unique_id
              if (that.data.from){
                app.ajax("DiscountCoupon/shareGetCoupon", {
                  from: that.data.from,
                  to: app.globalData.unique_id
                }, (res) => {
                  console.log(res)
                })
              }
              wx.getUserInfo({
                success: function (res) {
                  var userInfo = res.userInfo
                  console.log(userInfo)
                  app.globalData.userInfo = userInfo
                }
              })
              this.justy()
              // 检测该用户是否参与了调研
              app.ajax("Inquiry/isInquiry", {
                unique_id: app.globalData.unique_id
              }, (res) => {
                console.log("检测该用户是否参与了调研")
                console.log(res)
                if (res.data.data.is_inquiry != 1) {
                  //  wx.navigateTo({
                  //     url: '../guidance/guidance',
                  //  })
                  this.setData({
                    diaoyan: true
                  })
                } else {
                  this.setData({
                    diaoyan: false
                  })
                }
              }, (res) => { })
              // 获取堂食店铺列表
              app.ajax("Store/storeList", {
                unique_id: app.globalData.unique_id
              }, (res) => {
                console.log("堂食店铺列表")
                console.log(res)
                if (res.data.status == true) {
                  this.setData({
                    hallListh: res.data.data
                  })
                }
              }, (res) => { })
              // 获取自提列表
              app.ajax("Spot/index", {
                unique_id: app.globalData.unique_id
              }, (res) => {
                console.log("获取自提列表")
                console.log(res)
                if (res.data.status == true) {
                  this.setData({
                    sinceList: res.data.data
                  })
                  if (res.data.data.spot == null) {
                    wx.showLoading({
                      title: '空空如也',
                      duration: 1000,
                      mask: true
                    })
                  }
                }
              }, (res) => { })
              // 自提点列表
              app.ajax("Spot/index", {
                area_id: "",
                unique_id: app.globalData.unique_id
              }, (res) => {
                console.log("自提点列表")
                console.log(res)
              }, (res) => { })
              // 首页数据
              app.ajax("Index/index", {
                t_id: "",
                unique_id: app.globalData.unique_id
              }, (res) => {
                console.log("获取首页数据")
                console.log(res)
                if (res.data.status == true) {
                  wx.hideLoading()
                  var mes = res.data.data
                  var data = mes.goods_list;
                  for (let n in data) {
                    data[n].chacke = false
                    data[n].num = 1
                  }
                  for (let n in data) {
                    if (data[n].goods_num != null) {
                      data[n].chacke = true
                      data[n].num = parseInt(data[n].goods_num)
                    }
                  }
                  app.globalData.nearest_spot = mes.nearest_spot
                  app.globalData.nearest_store = mes.nearest_store
                  this.setData({
                    allData: mes,
                    menu: true,
                    canaction: true,
                    imgUrls: res.data.data.banner,
                    nearest_spot: app.globalData.nearest_spot,
                    nearest_store: app.globalData.nearest_store
                  })
                }
              }, (res) => { })
              // 获取购物车数量
              app.ajax("CountNum/countCart", {
                unique_id: app.globalData.unique_id
              }, (res) => {
                console.log(res)
                if (res.data.status == true) {
                  app.globalData.tabBar[1].num = res.data.data[0].count
                  this.setData({
                    tabBarIndex: app.globalData.tabBar
                  })
                }
              }, (res) => { })
              // 获取购物车
              app.ajax("Cart/index", {
                unique_id: app.globalData.unique_id
              }, (res) => {
                console.log("获取购物车")
                console.log(res)
                if (res.data.status == true) {
                  var data = res.data.data
                  for (let n in data.cartList){
                    data.cartList[n].checked = true
                  }
                  app.globalData.shoppingCart = data
                  console.log(app.globalData.tabBar)

                }
              }, (res) => { })
            } else if (res.data.data.is_auth == 0) {
              this.setData({
                authorization: true,
              })
            }

          })
        } else {
          console.log('获取用户登录态失败!' + res.errMsg)
        }
      }
    });



    // 获取经纬度
    wx.getLocation({
      type: 'wgs84',
      success: (res) => {
        var latitude = res.latitude
        var longitude = res.longitude
        app.ajax("Index/updateLatLng", {
          unique_id: app.globalData.unique_id,
          lat: latitude,
          lng: longitude
        }, (res) => {
          console.log(res)
        })
      }
    })
  }
})