index.js 8.45 KB
import resource from '../../common/resource';

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

Page({
    data: {
        resource

    },

    onLoad: function (e) {
        // new app.WeToast;
        //
        // let jumpType = e.jumpType;
        // if (jumpType == config.constants.JUMP_BRAND) {
        //
        //   let brandId = e.brandId;
        //   let brandName = e.brandName;
        //   if (brandId != '' && brandName != '')
        //     wx.navigateTo({
        //       url: '../goodsList/brand?brandId=' + brandId + '&brandName=' + brandName + '&page_name=' + 'home' + '&page_param=' + ''
        //     });
        // } else if (jumpType == config.constants.JUMP_DETAIL) {
        //   let productSkn = e.productSkn;
        //   if (productSkn != '') {
        //     wx.navigateTo({
        //       url: '../goodsDetail/goodsDetail?productSkn=' + productSkn + '&page_name=' + 'home' + '&page_param=' + ''
        //     });
        //   }
        // } else if (jumpType == config.constants.JUMP_PRODUCTPOOL) {
        //   let productPool = e.productPool;
        //   if (productPool != '') {
        //     wx.navigateTo({
        //       url: '../goodsList/productPool?productPool=' + productPool + '&page_name=' + 'home' + '&page_param=' + ''
        //     });
        //   }
        // }
    },

    onShow: function () {
        // var pages = getCurrentPages()
        // var currentPage = pages[pages.length - 1]
        // var url = currentPage.route
        // let params = {
        //     PAGE_NAME: 'home',
        //     PAGE_PARAM: '',
        //     FROM_PAGE_NAME: '',
        //     FROM_PAGE_PARAM: '',
        //     PV_ID: PV_ID,
        //     PAGE_PATH: url
        // };
        // logEvent(YB_PAGE_OPEN_L, params);
        //
        // logEvent(YB_MAIN_TAB_C, {TAB_ID: 1});

    },

    onShareAppMessage: function (res) {
        // let param = {
        //     FROM: res.from,
        //     SHARE_RESUIL: 0,
        //     TITLE: 'Yoho!Buy有货-潮流购物逛不停',
        //     PATH: '/pages/index/index'
        // }
        //
        // // 用户点击右上角分享
        // return {
        //     title: param.TITLE, // 分享标题
        //     desc: '精选1400+全球潮流品牌,明星潮牌和新锐原创品牌每日上新,100%正品行货。', // 分享描述
        //     path: param.PATH, // 分享路径
        //     success: function (res) {
        //         param.SHARE_RESUIL = 1
        //         logEvent(YB_SHARE_RESULT_L, param);
        //     },
        //     fail: function (res) {
        //         param.SHARE_RESUIL = 2
        //         logEvent(YB_SHARE_RESULT_L, param);
        //     }
        // }
    },

    onPullDownRefresh: function () {
        // wx.stopPullDownRefresh();
        // this.getLastChannel();
        // this.fetchNewHomeData(true);
    },

    onPageScroll: function (event) {
        // var {scrollTop} = event;
        // var isShow = scrollTop > windowHeight * 2 ? true : false;
        // if (isShow != this.data.isShowIndicator) {
        //     this.setData({
        //         isShowIndicator: isShow
        //     });
        // }
    },
    //回到顶部
    backToTop: function () {
        wx.pageScrollTo({
            scrollTop: 0
        })
    },

    jumpByRule: function (e) {
        // let jumpUrl = e.currentTarget.dataset.jump_rule;
        // if (!jumpUrl) {
        //     return;
        // }
        // let F_ID = e.currentTarget.dataset.f_id;//楼层id
        // let I_INDEX = e.currentTarget.dataset.f_inindex + 1//楼层内index
        // let F_INDEX = e.currentTarget.dataset.f_index + 1//楼层序号
        // let F_NAME = e.currentTarget.dataset.f_name;//楼层名称
        // let param = {
        //     F_ID, I_INDEX, F_INDEX, F_NAME,
        //     F_URL: jumpUrl
        // }
        //
        // logEvent('YB_MAIN_EVENT', param);
        // jumpByUrl(jumpUrl, 'home');
    },
    //获取新首页数据
    fetchNewHomeData: function (force) {
        // var channel = this.data.selectedChannel;
        // let newChannels = this.data.newChannels;
        // let currentData = newChannels[channel];
        // if (currentData && currentData.data && currentData.data.length > 0 && !force) {
        //     this.setHomeList();
        //     return;
        // }
        // let cotentCode = getHomeContentCode(channel);
        // let gender = getGenderCode(channel);
        // let yh_channel = getChannelCode(channel);
        // if (!force) {
        //     this.setLoadingHomeData(true);
        // }
        // let param = {
        //     content_code: cotentCode,
        //     gender,
        //     yh_channel,
        //     page: 1,
        //     limit: 10,
        //     fromPage: 'aFP_Home'
        // }
        // GET(config.constants.API_HOST + '/operations/api/v5/resource/home', param)
        //     .then(json => {
        //         this.setLoadingHomeData(false);
        //         if (json && json.code && json.code == 200) {
        //             let homeList = json.data.list;
        //             homeList = parseHomeList(homeList, windowWidth, windowHeight, activityItemWidth, activityItemHeight);
        //
        //             if (!homeList || homeList.length <= 0) {
        //                 this.wetoast.toast({
        //                     title: json.message,
        //                     titleClassName: 'wetoast-title',
        //                     duration: 1500
        //                 });
        //             }
        //             let newChannels = this.data.newChannels;
        //             let currentData = newChannels[channel];
        //             currentData.data = homeList;
        //             newChannels[channel] = currentData;
        //             this.setData({
        //                 newChannels: newChannels
        //             })
        //             this.setHomeList(force);
        //         } else {
        //             this.setHomeList(force);
        //             this.wetoast.toast({
        //                 title: json.message,
        //                 titleClassName: 'wetoast-title',
        //                 duration: 1500
        //             });
        //         }
        //     })
        //     .catch(error => {
        //         this.setLoadingHomeData(false);
        //         this.setHomeList(force);
        //         this.wetoast.toast({
        //             title: error.message,
        //             titleClassName: 'wetoast-title',
        //             duration: 1500
        //         });
        //     })
    },
    setLoadingHomeData: function (isLoading) {
        let channel = this.data.selectedChannel;
        let _newChannels = this.data.newChannels;
        let currentData = _newChannels[channel];
        if (currentData) {
            currentData.isLoading = isLoading;
        }
        this.setData({
            newChannels: _newChannels
        })
    },
    setHomeList: function (force) {
        // let channel = this.data.selectedChannel;
        // let newChannels = this.data.newChannels;
        // let currentData = newChannels[channel];
        // if (currentData && currentData.data) {
        //     this.setData({
        //         homelist: currentData.data
        //     })
        // }
        // this.fetchRecommend(force);
    },
    toSearch: function () {
        wx.navigateTo({
            url: '../search/search'
        });
    },

    //商品点击进入商品详情
    productCellTapped: function (event) {
        // if (shouldDiscardTap(event.timeStamp, this.data.lastTapTimeStamp)) {
        //     return;
        // }
        // this.setData({lastTapTimeStamp: event.timeStamp});
        //
        // let data = event.currentTarget.dataset;
        // let productSkn = data.productSkn;
        // let productIndex = data.productIndex;
        // let productF_index = data.productF_index;
        // let f_name = productF_index == 2 ? '新品到着' : '猜你喜欢';
        //
        // let params = {
        //     F_ID: productF_index,
        //     F_NAME: f_name,
        //     F_URL: '../goodsDetail/goodsDetail?productSkn=' + productSkn,
        //     F_INDEX: productF_index,
        //     I_INDEX: productIndex + 1,
        //     PV_ID: PV_ID
        // };
        // logEvent(YB_MAIN_EVENT, params);
        //
        // wx.navigateTo({
        //     url: '../goodsDetail/goodsDetail?productSkn=' + productSkn + '&page_name=' + 'home' + '&page_param=' + ''
        // });
    },
    sortChange: function (e) {
        console.log(e.detail);
    }
});