| import { | 
|   getDictData, | 
|   getDailyUpdates, | 
|   getZSZXCatalogs, | 
|   getZhongTaiVideoPage, | 
|   getCustomizedNewsList, | 
|   newsPage | 
| } from '../../api/index' | 
| const { HYEventBus } = require('hy-event-store') | 
| const eventBus = new HYEventBus() | 
| Page({ | 
|   data: { | 
|     searchValue: '', | 
|     clientHeight: 0, | 
|     clientTop: 0, | 
|   | 
|     DailyUpdates: {}, //每日上新 | 
|     everydayTop: ['../../static/ic_top1@2x.png', '../../static/ic_top2@2x.png', '../../static/ic_top3@2x.png'], | 
|     serviceHeight: 0, | 
|     serviceList: [], | 
|   | 
|     videoTop: 0, | 
|     windowHeight: 0, | 
|     videoPlay: true, | 
|   | 
|     bannerSwiperOption: { | 
|       indicatorDots: true, | 
|       vertical: false, | 
|       autoplay: true, | 
|       interval: 3000, | 
|       duration: 500 | 
|     }, | 
|   }, | 
|   onLoad() { | 
|     const res = wx.getMenuButtonBoundingClientRect() | 
|     this.setData({ | 
|       clientHeight: res.height, | 
|       clientTop: res.top | 
|     }) | 
|   }, | 
|   onShow() { | 
|     this.initData() | 
|   }, | 
|   onReady() { | 
|     const windowInfo = wx.getWindowInfo() | 
|     setTimeout(() => { | 
|       const query = wx.createSelectorQuery() | 
|       query.select('.product_video').boundingClientRect(function (rect) { | 
|         rect.top // 节点的上边界坐标 | 
|         rect.bottom // 节点的下边界坐标 | 
|       }).exec(res => { | 
|         this.setData({ videoTop: res[0].top,windowHeight: windowInfo.windowHeight}) | 
|       }) | 
|     }, 2000) | 
|   }, | 
|   initData() { | 
|     // 每日上新 | 
|     getDailyUpdates({ | 
|       fileType: '0' | 
|     }).then(res => { | 
|       this.setData({ | 
|         DailyUpdates: res.data || {} | 
|       }) | 
|     }) | 
|     // 产品视频 | 
|     getZhongTaiVideoPage({ | 
|       pageSize: 1, | 
|       pageNum: 1 | 
|     }).then(res => { | 
|       if (res.data && res.data.records && res.data.records.length > 0) { | 
|         this.setData({ | 
|           productVideo: res.data.records | 
|         }) | 
|       } | 
|     }) | 
|     //志说装修 | 
|     getZSZXCatalogs().then(res => { | 
|       this.setData({ | 
|         ZSZXCata: res.data || {} | 
|       }) | 
|     }) | 
|     // 定制服务 | 
|     getCustomizedNewsList().then(res => { | 
|       this.setData({ | 
|         serviceList: res.data || [] | 
|       }) | 
|     }) | 
|     getDictData({ | 
|       code: 'WEIXIN_DEFAULT_IMGS', | 
|       label: 'HOME_CLASS_A' | 
|     }).then(res => { | 
|       this.setData({ | 
|         HOME_CLASS_A: res.data.code | 
|       }) | 
|     }) | 
|     getDictData({ | 
|       code: 'WEIXIN_DEFAULT_IMGS', | 
|       label: 'HOME_CLASS_B' | 
|     }).then(res => { | 
|       this.setData({ | 
|         HOME_CLASS_B: res.data.code | 
|       }) | 
|     }) | 
|     getDictData({ | 
|       code: 'WEIXIN_DEFAULT_IMGS', | 
|       label: 'HOME_CLASS_B2' | 
|     }).then(res => { | 
|       this.setData({ | 
|         HOME_CLASS_B2: res.data.code | 
|       }) | 
|     }) | 
|     getDictData({ | 
|       code: 'WEIXIN_DEFAULT_IMGS', | 
|       label: 'HOME_CLASS_C' | 
|     }).then(res => { | 
|       this.setData({ | 
|         HOME_CLASS_C: res.data.code | 
|       }) | 
|     }) | 
|   }, | 
|   bindVideoPlay() { | 
|     const { id } = this.data.productVideo[0] | 
|     actionDo({ | 
|       actionType: 'view', | 
|       id | 
|     }) | 
|   }, | 
|   onPageScroll(e) { | 
|     const { videoTop, windowHeight, videoPlay } = this.data | 
|     if(e.scrollTop + 60 > videoTop - (windowHeight / 2) && videoPlay ){ | 
|       this.setData({ videoPlay: false }) | 
|       let videoplay = wx.createVideoContext('myvideo', this) | 
|       videoplay.play(); | 
|     } | 
|   }, | 
|   promotionClick() { | 
|     wx.navigateTo({ | 
|       url: '/pages/promotion/index', | 
|     }) | 
|   }, | 
|   funClick(e){ | 
|     const i = e.currentTarget.dataset.i | 
|     let map = ['product_intro', 'whole_case', 'real_case']  | 
|     if(i == 3){ | 
|       wx.navigateTo({ | 
|         url: '/pages/consult/consult', | 
|       }) | 
|     }else{ | 
|       wx.setStorageSync('discoverKey', map[i]) | 
|       wx.switchTab({ | 
|         url: '/pages/discover/discover', | 
|       }) | 
|     } | 
|   }, | 
|   jumpProVideo() { | 
|     wx.navigateTo({ | 
|       url: '/pages/productVideo/index', | 
|     }) | 
|   }, | 
|   videoClick(e) { | 
|     const { | 
|       videourl | 
|     } = e.currentTarget.dataset | 
|     let videoPlay = this.selectComponent('.videoPlay');  | 
|     if(videoPlay){  | 
|       videoPlay.startPlayVideo(videourl,this ); | 
|     } | 
|     // wx.previewMedia({ | 
|     //   sources: [{ | 
|     //     url: videourl, | 
|     //     type: 'video' | 
|     //   }] | 
|     // }) | 
|   }, | 
|   seriveClick(e) { | 
|     const { | 
|       id, | 
|       title | 
|     } = e.currentTarget.dataset | 
|     if (title === '专属客服') { | 
|       wx.navigateTo({ | 
|         url: `/pages/kefu/index?title=${title}&id=${id}`, | 
|       }) | 
|     } else { | 
|       wx.navigateTo({ | 
|         url: `/pages/kefu/service?title=${title}&id=${id}`, | 
|       }) | 
|     } | 
|   }, | 
|   goserHeight: function (e) { | 
|     const serviceHeight = e.detail.height | 
|     this.setData({ | 
|       serviceHeight: serviceHeight | 
|     }) | 
|   }, | 
|   changeStrategy(e) { | 
|     let item = e.currentTarget.dataset.item | 
|     wx.navigateTo({ | 
|       url: `/pages/homeId/index?code=${item.code}&name=${item.name}`, | 
|     }) | 
|   }, | 
| }) |