goodsItem_7.vue
3.85 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<template>
<div class="goods-item-7-box" v-if="item" @click="jump(item)">
<div class="item" :class="'g-' + goodType">
<div class="img-box">
<!-- 产品图片 -->
<img v-lazy="item.simg + SIGN.MIDDLE" class="img" />
<!-- 补货中提示 -->
<div v-if="item && item.stock && item.stock == 0" class="goods_active">
补货中
</div>
<!-- goodType=1为积分商城定义实物商品展示tip积分+现金形式 -->
<div v-if="goodType == 1 && item && item.price && item.price > 0" class="goods_tip">
积分+现金
</div>
<!-- 角标 -->
<slot name="flag"></slot>
</div>
<div class="content-box" :class="{'integral-content-box':company == 1 || company == 2}">
<div class="title" :class="{'grey-title':company == 2}">
{{item.title}}
</div>
<!-- 运营标签 -->
<div class="tags-box" v-if="item.istop && item.istop == '2'">
<div class="tag week">本周推荐</div>
</div>
<!-- <div class="coupon-box">
满180减10
</div> -->
<!-- 积分加现金 -->
<div v-if="goodType == 1" class="price-title-box">
{{parseInt(item.num) > 9999 ? this.formatDecimal((parseInt(item.num) / 10000), 2) + "万" : item.num}}<span>积分 <span v-show="item.price > 0">+ {{item.price}}元</span></span>
</div>
<!-- 积分 -->
<div v-else-if="company == 1 || company == 2" class="grade-box" >
<span class="num" :class="{'grey-box':company == 2}">
{{parseInt(item.num)>9999 ? this.formatDecimal((parseInt(item.num) / 10000), 2) + "万" : item.num}}
</span>
<span v-if="company==1">积分</span>
<span v-else>健康值</span>
</div>
<!-- 价格 -->
<div v-else class="price-box">
<div class="left">
<div class="y">¥ </div>
<div class="integer">{{getInteger(item.price)}}.</div>
<div class="decimal">{{getDecimal(item.price)}}</div>
</div>
<div class="right">
<img src="static/img/icon_add.png" class="icon-add" mode="widthFix" @click.stop.prevent="primary(item)" />
</div>
</div>
</div>
</div>
</div>
</template>
<script>
export default {
data: function () {
return {
}
},
props: ["item", "goodType", "company"],
computed: {
/**
* 获取输入数字的整数部分
*/
getInteger () {
return (number) => {
return parseInt(number);
}
},
/**
* 获取输入数字的小数部分
*/
getDecimal () {
return (number) => {
// 拆分数字
let numberArr = number.toString().split(".");
// 判断是否有效数部分
if (numberArr.length === 2) {
return numberArr[1];
} else {
return "00";
}
}
}
},
methods: {
/**
* 点击跳转
* @param {object} item [数据对象]
*/
jump (item) {
this.$emit("jump", item);
},
/**
* 主按钮点击事件
* @param {object} item [数据对象]
*/
primary (item) {
this.$emit("primary", item);
}
}
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style rel="stylesheet/less" lang="less" scoped>
@import './goodsItem_7';
</style>