From d41f1f707dc643b726a42b9d2a63b186dd9e4f28 Mon Sep 17 00:00:00 2001
From: liukangdong <898885815@qq.com>
Date: 星期二, 06 八月 2024 16:12:38 +0800
Subject: [PATCH] ll
---
wechat_jiaxuan/components/disProduct/index.js | 73 +++++++++++++++++++++++++++++++-----
1 files changed, 63 insertions(+), 10 deletions(-)
diff --git a/wechat_jiaxuan/components/disProduct/index.js b/wechat_jiaxuan/components/disProduct/index.js
index 85c328b..e2cecb3 100644
--- a/wechat_jiaxuan/components/disProduct/index.js
+++ b/wechat_jiaxuan/components/disProduct/index.js
@@ -1,5 +1,6 @@
import { getCatalogList, getCataLogTagList, getZhongTaiProductPage } from '../../api/index'
import { eventBus } from '../../utils/eventBus'
+let touchDot = 0
Component({
/**
* 缁勪欢鐨勫睘鎬у垪琛�
@@ -12,6 +13,10 @@
* 缁勪欢鐨勫垵濮嬫暟鎹�
*/
data: {
+ // 鍔ㄧ敾
+ showTouch: true,
+ animationData: {},
+
activeIndex: -1,
activeParam: [],
tagCodes: [],
@@ -24,7 +29,8 @@
total: 0,
query: '',
sortType: '',
- catalogCode: ""
+ catalogCode: "",
+ scrollTop: 0
},
pageLifetimes: {
show: function() {
@@ -34,8 +40,17 @@
const datalist = this.data.datalist
datalist.forEach(item => {
if(item.id === info.id){
+ console.log(item)
+ console.log(info)
+ if(item.isCollection != info.isCollection){
+ if(!item.isCollection){
+ item.collectCount = (item.collectCount || 0)+1
+ }else if(item.collectCount >0){
+ item.collectCount = (item.collectCount || 0)-1
+ }
+ }
item.isCollection = info.isCollection
- item.viewCount ++
+ item.viewCount =(item.viewCount||0) +1
}
})
this.setData({ datalist })
@@ -52,8 +67,48 @@
getApp().globalData.catalogCode = ''
}, 2000)
}
+ this.animation = wx.createAnimation({
+ duration: 600,
+ timingFunction: 'ease',
+ });
},
methods: {
+ bindscrolltoupper() {
+ this.setData({ showTouch: true })
+ this.fadeIn();
+ },
+ touchstart(e){
+ touchDot = e.detail.scrollTop;
+ },
+ touchmove(e) {
+ var touchMove = e.detail.scrollTop;
+ if(touchDot - touchMove > 16){
+ touchDot = touchMove
+ this.fadeOut();
+ }
+ if(touchDot - touchMove > 16){
+ touchDot = touchMove
+ setTimeout(() => {
+ this.setData({ showTouch: true })
+ this.fadeIn();
+ }, 200)
+ }
+ },
+ 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({ showTouch: false });
+ }, 200); // 鍔ㄧ敾鎸佺画鏃堕棿
+ },
getCatelist() {
getCatalogList({
catalogCode: 'product_intro'
@@ -91,10 +146,12 @@
getZhongTaiProductPage({
catalogCode, pageNum, pageSize, sortType, query, tagCodes
}).then(res => {
- this.setData({
- datalist: [...this.data.datalist, ...res.data.records],
- total: res.data.total
- })
+ if (res.data && res.data.records) {
+ this.setData({
+ datalist: [...this.data.datalist, ...res.data.records],
+ total: res.data.total
+ })
+ }
}).finally(()=>{
that.setData({isLoading:false})
})
@@ -111,10 +168,6 @@
icon: 'none'
})
}
- },
- scrolltoupper() {
- this.setData({ pageNum: 1, datalist: [], total: 0 })
- this.getList()
},
cateClick(e) {
var {isLoading} = this.data
--
Gitblit v1.9.3