PromotionList.js 22 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
// PromotionList.js
import { API_HOST, SERVICE_HOST } from '../../libs/config';
import { GET, POST } from '../../libs/request';
import { parseBrandListData, cancelFilterSelectState } from '../../utils/productList';
import objectAssign from '../../vendors/object-assign';
import { shouldDiscardTap } from '../../utils/util';
import {
  logEvent,
  YB_PAGE_OPEN_L,
  YB_GDS_ADD_TO_CART_C,
} from '../../libs/analytics.js'

var Picker = require('../goodsDetail/picker/picker.js')

//获取应用实例
let app = getApp();

const screenHeight = app.globalData.systemInfo.screenHeight;
const windowWidth = app.globalData.systemInfo.windowWidth;
const windowHeight = app.globalData.systemInfo.windowHeight;

let PV_ID = new Date().getTime() + '';

Page({

  /**
   * 页面的初始数据
   */
  data: {
    title: "",
    promotionTitle: "",
    promotion_id: "",
    keyword: "",
    showAddShopCartBtn: 1,

    //picker 需要的数据
    //选中的sku
    selectedSKU: 0,
    //选中sku的库存
    storageNumber: 0,
    //判断是否选择了颜色
    colorSelected: false,
    pickerData: {
      view: {
        isShow: false,
        isSoldOutSoon: false, //是否显示即将售罄
        goodsList: [],
        sizeList: [],
        image: '',
        goodPrice: '',
        price: '',
        buyNumber: 1,
        minusButtonEnable: false,
        plusButtonEnable: true,
        buyButtonEnable: true,
        skcTitle: '',
        skuTitle: ''
      },
      sourceType: 'promotionProductList',
    },
    

    lastTapTimeStamp: 0,

    screenHeight,
    windowHeight,

    from_page_name: '',
    from_page_param: '',
    current_page_name: 'goodsList',

    gender: '',

    order: '',

    filter: {
      item1: {
        key: 'item1',
        name: '默认',
        asc: '',
        isRadio: true,
        selected: true,
      },
      item2: {
        key: 'item2',
        name: '新品',
        asc: 's_t_desc',
        isRadio: true,
        selected: false,
      },
      item3: {
        key: 'item3',
        name: '价格',
        defaults: 'asc',
        asc: 's_p_asc',
        desc: 's_p_desc',
        isRadio: false,
        isAsc: true,
        selected: false,
      },
      item4: {
        key: 'item4',
        name: '折扣',
        defaults: 'desc',
        asc: 'p_d_desc',
        desc: 'p_d_asc',
        isRadio: false,
        isAsc: false,
        selected: false,
      }
    },
    filterGenderItem: {
      key: 'filterGenderItem',
      name: '男生',
      isRadio: true,
      selected: true,
      hiddenGenderSelectView: true,
    },
    genderFilter: {
      item1: {
        key: 'item1',
        name: '男生/BOYS',
        selected: true,
        value: '1',
        title: '男生',
      },
      item2: {
        key: 'item2',
        name: '女生/GIRLS',
        selected: false,
        value: '2',
        title: '女生',
      }
    },
    list: {
      isLoading: false,
      error: null,
      data: null,
      pageSize: 60,
      currentPage: 0,
      pageCount: 0,
      total: 0,
      endReached: false,
    },
    _placeholder: '搜索该促销活动适用的商品',
    coupon_id: '',
    coupon_code: '',
    coupon_title: '',
    isShowIndicator: false,
    scrollTop: 0
  },
  resetChannelFilterInfo: function (gender) {
    let filterGenderItem = this.data.filterGenderItem;
    let genderFilter = this.data.genderFilter;
    filterGenderItem.name = gender;
    for (let itemKey in genderFilter) {
      if (genderFilter.hasOwnProperty(itemKey)) {
        if (genderFilter[itemKey].title == gender) {
          genderFilter[itemKey].selected = true;
        } else {
          genderFilter[itemKey].selected = false;
        }
      }
    }
    this.setData({ filterGenderItem, genderFilter });
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    // console.log(options);
    var that = this;
    Picker.init(that);

    new app.WeToast();

    let title = options.title;
    let promotionTitle = options.promotionTitle;
    let promotion_id = options.promotion_id;

    this.setData({
      title, promotionTitle, promotion_id
    });


    let gender = options.gender;

    let from_page_name = options.page_name ? options.page_name : '';
    let from_page_param = options.page_param ? options.page_param : '';
    this.setData({
      title, gender, from_page_name, from_page_param
    });
    this.resetChannelFilterInfo(app.globalData.selectedChannel == 'boy' ? '男生' : '女生');

    var pages = getCurrentPages()
    var currentPage = pages[pages.length - 1]
    var url = currentPage.route

    let params = {
      PAGE_NAME: this.data.current_page_name,
      FROM_PAGE_NAME: this.data.from_page_name,
      FROM_PAGE_PARAM: this.data.from_page_param,
      PV_ID: PV_ID,
      PAGE_PATH: url        
    };
    logEvent(YB_PAGE_OPEN_L, params);

    if (from_page_name == 'coupon') {
      let _coupon_id = options.coupon_id;
      let _coupon_code = options.coupon_code;
      let _coupon_title = options.coupon_title;
      /** coupon_id:'',
    coupon_code:'',
    coupon_title:'', */
      this.setData({
        coupon_id: _coupon_id,
        coupon_code: _coupon_code,
        coupon_title: _coupon_title,
        _placeholder: '搜索该优惠活动适用的商品'
      })
    };

    this.fetchListData();

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    wx.setNavigationBarTitle({
      title: this.data.title,
    });
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  },

  onPullDownRefresh: function () {
    // 页面相关事件处理函数--监听用户下拉动作
    let params = {
      PAGE_NAME: this.data.current_page_name,
      FROM_PAGE_NAME: this.data.from_page_name,
      FROM_PAGE_PARAM: this.data.from_page_param,
      PV_ID: PV_ID,
    };
    logEvent(YB_PAGE_OPEN_L, params);
  },
  loadMore: function () {
    // 页面上拉触底事件的处理函数

    this.fetchListData();
  },

  //品牌商品列表
  fetchListData: function () {
    if (this.data.list.isLoading || this.data.list.endReached) {
      return;
    }

    let page = this.data.list.currentPage + 1;
    let param;
    if (this.data.from_page_name == 'coupon') {
      // console.log('来自优惠券页面');
      param = {
        method: 'app.search.coupon.productList',
        coupon_id: this.data.coupon_id,
        coupon_code: this.data.coupon_code,
        order: this.data.order,
        gender: this.data.gender,
        page,
        limit: this.data.list.pageSize,
        query: this.data.keyword,
      }
    } else {
      param = {
        method: 'app.search.promotion.productList',
        gender: this.data.gender,
        order: this.data.order,
        promotion_id: this.data.promotion_id,
        page,
        limit: this.data.list.pageSize,
        query: this.data.keyword,
      }
    }

    let list = objectAssign(this.data.list, { isLoading: true, });
    this.setData({ list });

    GET(API_HOST, param)
      .then(json => {
        if (!json || !json.code || json.code != 200) {
          let list = objectAssign(this.data.list, { isLoading: false, error: { code: json.code, message: json.message } });
          this.setData({ list });
          return;
        }

        json = json.data;

        let currentPage = json && json.page ? json.page : 1;
        let pageCount = json && json.page_total ? json.page_total : 0;
        let total = json && json.total ? json.total : 0;
        let endReached = currentPage == pageCount;

        let data = json.product_list;
        data = parseBrandListData(data);

        if (currentPage > 1) {
          let oldList = this.data.list.data;
          data = [...oldList, ...data];
        }

        let newList = {
          isLoading: false,
          data,
          currentPage,
          pageCount,
          total,
          endReached,
        };
        let list = objectAssign(this.data.list, newList);
        this.setData({ list });
      })
      .catch(error => {
        let list = objectAssign(this.data.list, { isLoading: false, error, });
        this.setData({ list });
      });
  },

  //点击筛选
  filterTapped: function (event) {
    let data = event.currentTarget.dataset;
    let key = data.key;

    let item = this.data.filter[key];
    // 单选
    if (item.isRadio) {
      // 已选中 结束
      if (item.selected) {
        return;
      }

      // 选中当前filter
      item.selected = true;

      // 遍历所有filter,设置非当前filter为不选中
      let newFilters = cancelFilterSelectState(this.data.filter, key);
      newFilters[key] = item;

      let newList = objectAssign(this.data.list, { currentPage: 0, pageCount: 0, total: 0, endReached: false, });
      this.setData({ filter: newFilters, order: item.asc, list: newList });

      this.fetchListData();
      // 多选
    } else {

      // 已选中
      if (item.selected) {

        // 修改当前filter排序
        item.isAsc = !item.isAsc;
        let order = item.isAsc ? item.asc : item.desc;
        let newFilters = this.data.filter;
        newFilters[key] = item;

        let newList = objectAssign(this.data.list, { currentPage: 0, pageCount: 0, total: 0, endReached: false, });
        this.setData({ order, filter: newFilters, list: newList });

        this.fetchListData();
        // 未选中
      } else {

        // 选中当前filter
        item.selected = true;
        // 读取当前filter默认排序
        let defaultKey = item.defaults;
        let order = item[defaultKey];

        item.isAsc = defaultKey == 'asc';

        // 遍历所有filter,设置非当前filter为不选中
        let newFilters = cancelFilterSelectState(this.data.filter, key);
        newFilters[key] = item;

        let newList = objectAssign(this.data.list, { currentPage: 0, pageCount: 0, total: 0, endReached: false, });
        this.setData({ order, filter: newFilters, list: newList });

        this.fetchListData();
      }
    }
  },

  hiddenGenderFilter: function (event) {
    let filterGenderItem = this.data.filterGenderItem;
    filterGenderItem.hiddenGenderSelectView = true;
    this.setData({ filterGenderItem });
  },
  filterGenderItemTapped: function (event) {
    let filterGenderItem = this.data.filterGenderItem;
    filterGenderItem.hiddenGenderSelectView = !filterGenderItem.hiddenGenderSelectView;
    this.setData({ filterGenderItem });
  },

  maskTouchStart: function (event) {
    this.hiddenGenderFilter();
  },
  genderFilterTapped: function (event) {
    let data = event.currentTarget.dataset;
    let key = data.key;
    let item = this.data.genderFilter[key];

    if (item.selected) {
      this.hiddenGenderFilter();
      return;
    }

    let filterGenderItem = this.data.filterGenderItem;
    filterGenderItem.name = item.title;
    // 选中当前filter
    item.selected = true;
    // 遍历所有filter,设置非当前filter为不选中
    let newFilters = cancelFilterSelectState(this.data.genderFilter, key);
    newFilters[key] = item;

    let newList = objectAssign(this.data.list, { currentPage: 0, pageCount: 0, total: 0, endReached: false, });
    this.setData({ filterGenderItem, genderFilter: newFilters, list: newList, gender: item.value });
    this.hiddenGenderFilter();
    this.fetchListData();

  },

  navToShopCartAction: function() {
    wx.switchTab({
      url: '../shopCart/shopCart',
    })
  },

  //搜索框文字改变
  inputChanged: function (event) {
    let keyword = event.detail.value;
    this.setData({ keyword });
  },

  //搜索框获取焦点焦点
  focusChanged: function (event) {

  },

  //搜索框键盘点击确定
  inputConfirmed: function (event) {
    let keyword = event.detail.value;
    let newList = objectAssign(this.data.list, { currentPage: 0, pageCount: 0, total: 0, endReached: false, });
    let newFilter = {
      item1: objectAssign(this.data.filter.item1, { selected: true }),
      item2: objectAssign(this.data.filter.item2, { selected: false }),
      item3: objectAssign(this.data.filter.item3, { selected: false }),
      item4: objectAssign(this.data.filter.item4, { selected: false }),
    };

    this.setData({ keyword, list: newList, filter: newFilter, order: '' });

    this.fetchListData();
  },

  addToShopCartAction: function(event) {
    let product = event.currentTarget.dataset.item;
    // console.log(product);
    let product_skn = product.product_skn;

    Picker.promotion_id = this.data.promotion_id;
    // console.log(product_skn);
    let param = {
      method: 'app.product.data',
      uid: app.getUid(),
      product_skn,
      promotion_id: this.data.promotion_id,
    };
    var that = this

    GET(API_HOST, param)
      .then(data => {
        // console.log(data);
        if (!data || data.code != 200)
          return;

        data.data.goods_list = (data.data.goods_list || []).filter(item => {
          return item.status;
        });

        let color_length = 0;
        if (data.data.goods_list) {
          color_length = data.data.goods_list.length;
        }
        let ImgUrls = [];
        data.data.goods_list && data.data.goods_list.map((item, index) => {
          let images = item.color_image.replace(/{width}/g, 144).replace(/{height}/g, 192).replace('{mode}', 2);
          ImgUrls = [...ImgUrls, images];
          if (index == 0 && color_length == 1) {
            item.selected = true;
            that.data.colorSelected = true;
          }
        });

        let isSoldOutSoon = false;
        let tags = data.data.tags;
        if (tags) {
          tags.map((item) => {
            if (item == "is_soon_sold_out") {
              isSoldOutSoon = true;
            }
          });
        }

        //pickerData
        var temData = that.data.pickerData;
        temData.view.goodsList = data.data.goods_list;
        temData.view.isSoldOutSoon = isSoldOutSoon;
        temData.view.skuTitle =  data.data.skuTitle;
        temData.view.skcTitle = data.data.skcTitle
        //默认显示第一种颜色的尺码
        temData.view.sizeList = data.data.goods_list.length > 0 ? data.data.goods_list[0].size_list : [];

        let plusButtonEnable = false;
        let minusButtonEnable = false;
        //根据库存设置该尺码是否可以选择
        let size_length = 0;
        if (temData.view.sizeList) {
          size_length = temData.view.sizeList.length;
        }
        temData.view.sizeList && temData.view.sizeList.map((item, index) => {
          item.enable = item.storage_number > 0 ? true : false;
          if (index == 0 && size_length == 1 && that.data.colorSelected) {
            //当颜色被选中 并且只有一个size 时 才会自动 做选中尺码操作
            temData.view.buyButtonEnable = item.enable;
            if (item.enable) {
              item.selected = true;
              plusButtonEnable = item.storage_number > 1;
              that.setData({
                selectedSKU: item.product_sku,
                storageNumber: item.storage_number,
              });
            }
          }
        });

        temData.view.plusButtonEnable = plusButtonEnable;
        temData.view.minusButtonEnable = minusButtonEnable;
        temData.view.image = ImgUrls.length > 0 ? ImgUrls[0] : '';
        temData.view.price = data.data.format_market_price;
        temData.view.goodPrice = data.data.format_sales_price;

        that.setData({
          pickerData: temData,
        });

        Picker.pickerShow(event, that);
      })
      .catch(error => {
        that.wetoast.toast({
          title: error.code + error.message + '',
          titleClassName: 'wetoast-title',
          duration: 1000
        });
      });
  },

  //减少购买数量
  bindMinus: function (event) {
    let pickerData = this.data.pickerData;
    let buyNumber = parseInt(pickerData.view.buyNumber);
    if (buyNumber > 1) {
      buyNumber = buyNumber - 1;
    }

    pickerData.view.buyNumber = buyNumber;

    if (buyNumber == 1) {
      pickerData.view.minusButtonEnable = false;
    } else {
      pickerData.view.minusButtonEnable = true;
    }

    if (buyNumber < this.data.storageNumber) {
      pickerData.view.plusButtonEnable = true;
    }
    this.setData({ pickerData });
  },

  //增加购买数量
  bindPlus: function (event) {
    if (!this.data.colorSelected) {
      this.wetoast.toast({
        title: '请选择颜色',
        titleClassName: 'wetoast-title',
        duration: 1000
      });

      return;
    }

    if (!this.data.selectedSKU) {
      this.wetoast.toast({
        title: '请选择尺码',
        titleClassName: 'wetoast-title',
        duration: 1000
      });

      return;
    }

    let pickerData = this.data.pickerData;
    let buyNumber = pickerData.view.buyNumber;

    if (buyNumber >= this.data.storageNumber) {
      this.plusReachedMaxAction();
      return;
    }

    if (buyNumber < this.data.storageNumber) {
      pickerData.view.plusButtonEnable = true;
      buyNumber = parseInt(buyNumber) + 1;
    }

    if (buyNumber >= this.data.storageNumber) {
      pickerData.view.plusButtonEnable = false;
    }

    if (buyNumber > 1) {
      pickerData.view.minusButtonEnable = true;
    }

    pickerData.view.buyNumber = buyNumber;
    this.setData({ pickerData });
  },

  plusReachedMaxAction: function () {
    this.wetoast.toast({
      title: '对不起,没有更多库存了',
      titleClassName: 'wetoast-title',
      duration: 1000
    });
  },

  //点击背景,隐藏picker
  pickerTap: function (event) {
    if (event.target.id == "picker-bg") {
      var that = this
      Picker.pickerHide(event, that);
      this.resetPickerData();
    }
  },

  //点击选择颜色
  colorTap: function (event) {
    //更新各个颜色的选中状态
    var that = this
    var tempData = that.data.pickerData;
    //先遍历将所有颜色、尺码置为未选中状态
    // console.log('color')
    // console.log(tempData.view.goodsList)

    tempData.view.goodsList && tempData.view.goodsList.map((item, index) => {
      item.selected = false
      item.size_list.map((subItem, index) => {
        subItem.selected = false
        subItem.enable = subItem.storage_number > 0 ? true : false
      });
    });

    //将当前颜色置为选中状态
    var tempItem = event.target.dataset.key

    //遍历颜色尺码,根据库存切换显示状态
    tempItem && tempItem.size_list && tempItem.size_list.map((item, index) => {
      item.enable = item.storage_number > 0 ? true : false
    })

    tempItem.selected = true

    //设置标志位,表示已经选择颜色
    let colorSelected = true

    //重置库存、当前选中sku的值
    tempData.storageNumber = 0
    tempData.selectedSKU = 0

    tempData.view.goodsList[Number(event.target.id)] = tempItem
    tempData.view.sizeList = tempItem.size_list

    tempData.view.minusButtonEnable = false
    //将购买数量设为初始状态
    tempData.view.buyNumber = 1

    this.setData({
      colorSelected,
      pickerData: tempData,
    });
  },

  //点击选择尺码
  sizeTap: function (event) {
    var that = this
    var tempData = that.data.pickerData

    //现遍历将所有尺码置为未选中状态
    tempData.view.sizeList && tempData.view.sizeList.map((item, index) => {
      item.selected = false
    });

    //将当前尺码置为选中状态
    var tempItem = event.currentTarget.dataset.key
    tempItem.selected = true
    tempData.view.sizeList[parseInt(event.currentTarget.id)] = tempItem

    //设置数量加减按钮启用状态
    tempData.view.plusButtonEnable = tempItem.storage_number > 1
    tempData.view.minusButtonEnable = false
    tempData.view.buyButtonEnable = true
    //将购买数量设为初始状态
    tempData.view.buyNumber = 1
    // console.log(event)
    if (tempItem.storage_number <= 0) {
      this.wetoast.toast({
        title: '该尺码已经售罄',
        titleClassName: 'wetoast-title',
        duration: 1000
      });

      tempData.view.buyButtonEnable = false
    }
    this.setData({
      pickerData: tempData,
      selectedSKU: tempItem.storage_number > 0 ? tempItem.product_sku : 0,
      storageNumber: tempItem.storage_number,
    });
  },
  addShopCart: function (event) {
    let that = this;
    let select_sku = that.data.selectedSKU;
    let buy_number = that.data.pickerData.view.buyNumber;

    if (!select_sku) {
      that.wetoast.toast({
        title: '请选择颜色或尺码',
        titleClassName: 'wetoast-title',
        duration: 1000
      });
      return;
    }

    Picker.pickerHide(event, that);
    that.resetPickerData();

    logEvent(YB_GDS_ADD_TO_CART_C, { 'PRD_SKU': select_sku, 'POS_ID': (that.data.from_page_name == 'coupon' ? 102 : 101)});
    
    let goodsInfo = {
      method: "app.Shopping.add",
      product_sku: select_sku,
      buy_number: buy_number,
      edit_product_sku: 0,
      promotion_id: "",
      goods_type: 0,
      selected: "Y",
    };
    // console.log('添加凑单商品');
    // console.log(goodsInfo);
    GET(API_HOST, goodsInfo)
      .then(json => {
        if (json && json.code) {
          that.wetoast.toast({
            title: json.message,
            titleClassName: 'wetoast-title',
            duration: 1000
          });
        }
      })
      .catch(error => {
        
      });
  },
  resetPickerData: function (event) {
    let pickerData = this.data.pickerData;
    pickerData.view.buyNumber = 1;
    this.setData({
      pickerData,
      selectedSKU: 0,
      storageNumber: 0,
      colorSelected: false,
    })
  },  

  scroll: function (e) {
    var { scrollTop } = e.detail;
    var isShow = scrollTop > windowHeight * 2 ? true : false;
    if (isShow != this.data.isShowIndicator) {
      this.setData({
        isShowIndicator: isShow
      });
    }
  },

  backToTop: function () {
    this.setData({
      scrollTop: 0
    })
  }
})