goods.js
2.38 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
// components/Goods/Goods.js
import {
centsToyuan
} from '~/utils/format'
Component({
/**
* 组件的属性列表
*/
properties: {
list: {
type: Array,
value: [],
observer(val, o) {
if (val) {
val.forEach(v => {
v.IMGURL = this.data.IMGURL
let n = v.goods
if (n) {
if (n.activityInfo) {
n.originalPrice = ''
n.retailPrice = n.activityInfo.activityPrice
n.goodsStatistics.saleAmount = n.activityInfo.saleAmount
if (n.activityInfo.specificationExtraList && n.activityInfo.specificationExtraList.length) {
n.retailPrice = n.activityInfo.specificationExtraList[0].retailPrice
v.up = true
}
} else {
if (n.originalPrice) n.originalPrice = centsToyuan(n.originalPrice)
if (n.specificationDetailList && n.specificationDetailList.length) {
n.retailPrice = n.specificationDetailList[0].retailPrice
v.up = true
}
}
n.retailPrice = Number(centsToyuan(n.retailPrice)).toFixed(2)
if (n.retailPrice > 9999) {
n.retailPrice = Number(n.retailPrice / 10000).toFixed(2)
v.unit = '万'
}
}
})
this.setData({
list: val
})
}
}
}
},
/**
* 组件的初始数据
*/
data: {
IMGURL: wx.$imgUrl
},
/**
* 组件的方法列表
*/
methods: {
setWidth() {
wx.p.wxApi.getViewInfo(
'.Goods',
res => {
this.setData({
previewHeight: res.width * 2
})
},
this
)
},
jump(e) {
let {
item
} = e.currentTarget.dataset
let {
id,
activityInfo
} = item.classifyName && item.classifyName == '秒杀' ? item : item.goods
let isActivity = false
if (activityInfo) {
id = activityInfo.id
isActivity = true
}
if (item.classifyName && item.classifyName == '秒杀') {
isActivity = true
}
wx.p.router.go('/packageMall/pages/detail/detail', {
id,
isActivity,
notIntercept: true
})
}
},
lifetimes: {
attached() {
this.setWidth()
}
}
})