productListCell.js
2.37 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
// component/productListCell.js
import { shouldDiscardTap} from '../utils/util';
//获取应用实例
let app = getApp();
const screenHeight = app.globalData.systemInfo.screenHeight;
const windowWidth = app.globalData.systemInfo.windowWidth;
const windowHeight = app.globalData.systemInfo.windowHeight;
const DEVICE_WIDTH_RATIO = windowWidth / 320;
let listWidth = Math.ceil(137.5 * DEVICE_WIDTH_RATIO);
let listHeight = Math.ceil(254 * DEVICE_WIDTH_RATIO);
const IMAGE_WIDTH = 145;
const IMAGE_HEIGHT = 193;
const IMAGE_RATIO = IMAGE_HEIGHT / IMAGE_WIDTH;
let listImageTop = 31;
let listImageWidth = listWidth;
let listImageHeight = Math.ceil(listWidth * IMAGE_RATIO);
let listMarginHorizontal = (windowWidth - listWidth * 2) / 3;
let PV_ID = new Date().getTime() + '';
Component({
/**
* 组件的属性列表
*/
properties: {
item:{
type: Object
},
pageName: {
type: String,
value: ""
},
animationType: {
type: String,
value: ""
},
logEvenName: {
type: String,
value: ""
},
index: {
type: Number,
value: 0
},
fIndex: {
type: Number,
value: 0
},
fName: {
type: String,
value: ""
},
pageParam: {
type: String,
value: ""
}
},
/**
* 组件的初始数据
*/
data: {
lastTapTimeStamp: 0,
screenHeight,
windowHeight,
listWidth,
listHeight,
listImageWidth,
listImageHeight,
listImageTop,
listMarginHorizontal,
},
/**
* 组件的方法列表
*/
methods: {
productCellTapped(event) {
if (shouldDiscardTap(event.timeStamp, this.data.lastTapTimeStamp)) {
return;
}
this.setData({ lastTapTimeStamp: event.timeStamp });
let data = event.currentTarget.dataset;
let productSkn = data.productSkn;
// 根据动画类型来选择动画效果
if (this.properties.animationType && this.properties.animationType == "redirectTo") {
wx.redirectTo({
url: '/pages/goodsDetail/goodsDetail?productSkn=' + productSkn + '&page_name=' + this.properties.pageName + '&page_param=' + this.properties.pageParam
})
} else {
wx.navigateTo({
url: '/pages/goodsDetail/goodsDetail?productSkn=' + productSkn + '&page_name=' + this.properties.pageName + '&page_param=' + this.properties.pageParam
});
}
}
}
})