goodsItem_7.vue 3.85 KB
<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">¥&nbsp;</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>