| | |
| | | import { getZhongTaiProductNewsPage, getCatalogList,actionDo } from '../../api/index' |
| | | let touchDot = 0 |
| | | Page({ |
| | | |
| | | /** |
| | |
| | | data: { |
| | | category: [], |
| | | secondCategory: [], |
| | | showCate: true, |
| | | animationData: {}, |
| | | |
| | | catalogCode: '', |
| | | tagCode: '', |
| | |
| | | }, |
| | | onLoad(options) { |
| | | this.getCate() |
| | | this.animation = wx.createAnimation({ |
| | | duration: 500, |
| | | timingFunction: 'ease', |
| | | }); |
| | | }, |
| | | onReachBottom() { |
| | | console.log('触底事件'); |
| | |
| | | }, |
| | | itemClick(e) { |
| | | const item = e.currentTarget.dataset.item |
| | | const { dataList } = this.data |
| | | dataList.forEach(ite => { |
| | | if(item.id === ite.id){ |
| | | ite.viewCount += 1 |
| | | } |
| | | }) |
| | | this.setData({ dataList }) |
| | | actionDo({actionType: 'view',id: item.id}) |
| | | if(item.contentType == 'link'){ |
| | | wx.navigateTo({ |
| | | url: '/pages/webView/index?link=' + item.content, |
| | | url: '/pages/webView/index', |
| | | success: function(res) { |
| | | // 通过eventChannel向被打开页面传送数据 |
| | | res.eventChannel.emit('acceptDataFromOpenerPage', { link: item.openContent, title: item.title }) |
| | | res.eventChannel.emit('acceptDataFromOpenerPage', { link: item.content, title: item.title }) |
| | | } |
| | | }) |
| | | }else{ |
| | |
| | | onReady() { |
| | | |
| | | }, |
| | | |
| | | bindscrolltoupper() { |
| | | this.setData({ showCate: true }) |
| | | this.fadeIn(); |
| | | }, |
| | | touchstart(e){ |
| | | touchDot = e.detail.scrollTop; |
| | | }, |
| | | touchmove(e) { |
| | | var touchMove = e.detail.scrollTop; |
| | | if(touchMove - touchDot > 60){ |
| | | this.fadeOut(); |
| | | } |
| | | if(touchDot - touchMove > 60){ |
| | | this.fadeIn(); |
| | | this.setData({ showCate: true }) |
| | | } |
| | | }, |
| | | fadeIn: function () { |
| | | this.animation.opacity(1).step(); |
| | | this.setData({ |
| | | animationData: this.animation.export() |
| | | }); |
| | | }, |
| | | fadeOut: function () { |
| | | this.animation.opacity(0).step(); |
| | | this.setData({ |
| | | animationData: this.animation.export() |
| | | }); |
| | | setTimeout(() => { |
| | | this.setData({ showCate: false }); |
| | | }, 500); // 动画持续时间 |
| | | }, |
| | | /** |
| | | * 生命周期函数--监听页面显示 |
| | | */ |
| | |
| | | * 用户点击右上角分享 |
| | | */ |
| | | onShareAppMessage() { |
| | | |
| | | let { info } = this.data |
| | | console.log('点击了分享') |
| | | if(info.users && info.users.userId){ |
| | | return { |
| | | path: '/pages/detailDis/product?id=' + info.id + '&userId=' + info.users.id |
| | | } |
| | | } |
| | | } |
| | | }) |