Posts.js
1.21 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
// components/Posts/Posts.js
import { componentsMixin } from '../../mixins/index'
import { timeago, centsToyuan } from '~/utils/format'
Component({
behaviors: [componentsMixin],
/**
* 组件的属性列表
*/
properties: {
item: {
type: Object,
observer(n) {
if (n) {
if (n.dataType == 3) {
} else {
n.share.time = timeago(n.share.createdDate)
if (n.share.goods) {
if (n.share.goods.originalPrice) n.share.goods.originalPrice = centsToyuan(n.share.goods.originalPrice)
if (n.share.goods.retailPrice) n.share.goods.retailPrice = centsToyuan(n.share.goods.retailPrice)
if (n.share.goods.specificationDetailList && n.share.goods.specificationDetailList.length) {
n.share.goods.specificationDetailList[0].retailPrice = centsToyuan(n.share.goods.specificationDetailList[0].retailPrice)
}
}
}
this.setData({ item: n })
}
}
}
},
/**
* 组件的初始数据
*/
data: {},
/**
* 组件的方法列表
*/
methods: {
click(e) {
let { item } = e.currentTarget.dataset
this.triggerEvent('click', item)
}
}
})