<template> <section> <div class="block oneDataGoods" v-for="(itemchild,indexdata) in dataList"> <div class="history-line" v-if="isHistory">{{itemchild.create_time}}</div> <dl class="mui-row img-box"> <a :href="isZy?(hostName+'/item/'+itemchild.goods_id+'.html'):(hostName+'/goods_'+itemchild.goods_id+'.html')" > <dt v-lazy-container="{selector:'img'}"> <img class="lazy img-lazy" :alt="itemchild.goods_name_temp" :data-src="isZy?itemchild.goods_images:itemchild.goods_img" data-error="https://www.ichunt.com/v3/dist/res/m/images/materiel_img_3.png" > </dt> <dd> <template v-if="isZy"> <h4>{{itemchild.sku_name}}</h4> <p v-if="itemchild.class_id2_name">分类:{{itemchild.class_id2_name}}</p> <p>制造商:{{itemchild.brand_name}}</p> <p v-if="itemchild.encap">封装:{{itemchild.encap}}</p> <p v-if="itemchild.isLcKc0"> 库存: <span>可订货</span> ( {{"一"+itemchild.mpq_unit_name +"有"}} <span class="f-orange" v-html="itemchild.mpq"></span> {{itemchild.goods_unit_name}} ) </p> <p v-else> 库存: <span v-html="itemchild.stock"></span> ( {{"一"+itemchild.mpq_unit_name +"有"}} <span class="f-orange" v-html="itemchild.mpq"></span> {{itemchild.goods_unit_name}} ) </p> </template> <template v-else> <h4>{{itemchild.goods_name_temp||itemchild.goods_name}}</h4> <p>制造商:{{itemchild.brand_name||'- -'}}</p> <p> 库存: <span v-html="itemchild.stock||0"></span> </p> <p> 起订: <span v-html="itemchild.moq||1"></span> </p> <p> MPQ: <span v-html="itemchild.mpq||1"></span> </p> </template> </dd> </a> </dl> <div class="mui-row block-but"> <div class="morePrice"> <template v-if="isZy"> <div :id="'priceContent'+itemchild.goods_id" :class="{'zyClass':itemchild.ladder_price&&itemchild.ladder_price.length<4,'zyMoreData':itemchild.ladder_price&&itemchild.ladder_price.length>3}" > <div class="mui-row list_data" v-for="(itemPrice,index) in itemchild.ladder_price"> <p class="mui-col-sm-6 mui-col-xs-6" v-html="itemPrice.purchases+'+'"></p> <p class="mui-col-sm-6 mui-col-xs-6">¥{{itemPrice.price_cn}}</p> </div> </div> <div class="mui-row list_data f-fff" v-if="!itemchild.ladder_price||itemchild.ladder_price.length==0" > <p class="mui-col-sm-6 mui-col-xs-6">- -</p> <p class="mui-col-sm-6 mui-col-xs-6">- -</p> </div> </template> <template v-else> <div :id="'priceContent'+itemchild.goods_id" :class="{'lyClass':itemchild.ladder_price&&itemchild.ladder_price.length<4,'lyMoreData':itemchild.ladder_price&&itemchild.ladder_price.length>3}" > <div class="mui-row list_data" v-for="(itemPrice,index) in itemchild.ladder_price"> <p class="mui-col-sm-4 mui-col-xs-4" v-html="itemPrice.purchases+'+'"></p> <p class="mui-col-sm-4 mui-col-xs-4">¥{{itemPrice.price_cn}}</p> <p class="mui-col-sm-4 mui-col-xs-4">{{!itemPrice.price_us?'- -':'$'+itemPrice.price_us}}</p> </div> </div> <div class="mui-row list_data f-fff" v-if="!itemchild.ladder_price||itemchild.ladder_price.length==0" > <p class="mui-col-sm-4 mui-col-xs-4">- -</p> <p class="mui-col-sm-4 mui-col-xs-4">- -</p> <p class="mui-col-sm-4 mui-col-xs-4">- -</p> </div> </template> <div class="more-height" v-if="itemchild.ladder_price&&itemchild.ladder_price.length>limitLength" @click="priceRow(indexdata,itemchild.goods_id)" v-html="itemchild.checkBtn||defaultBtn" > 更多梯度价格 <i class="icon-bot"></i> </div> </div> <div class="but-shop"> <template v-if="isZy"> <a class="but" v-if="itemchild.is_buy==1" @click="placeOrder(itemchild.goods_id)">我要下单</a> <a class="but but-orange" v-else @click="xunjia">立即询价</a> </template> <template v-else="isZy"> <a class="but" v-if="itemchild.is_buy==1" @click="placeOrder(itemchild.goods_id)">我要下单</a> <a class="but but-orange" v-else-if="itemchild.is_buy==0" @click="xunjia">立即询价</a> <a class="but but-orange" v-else-if="itemchild.is_buy==3" @click="xunjia">确认库存信息</a> </template> </div> </div> </div> </section> </template> <script> import Vue from "vue"; import { Lazyload } from "vant"; import util from "../../util/index"; import bus from "../../util/bus.js"; Vue.use(Lazyload); export default { name: "GoodsOne", props: { dataList: { //数组数据 type: Array, default: [] }, //是否历史记录 isHistory:{ type: Boolean, default: false }, isZy: { //是否自营 type: Boolean, default: false } }, data() { return { hostName:window.location.origin, limitLength: 3, defaultBtn: '更多梯度价格<i class="icon-bot"></i>' }; }, created(){ }, watch: { dataList(res){ for(var i=0;i<res.length;i++){ //处理力创数据库存为0 if(util.aggxde(res[i].stock)==0&&res[i].self_supplier_type==2){ res[i].isLcKc0=true; }else{ res[i].isLcKc0=false; } } } }, mounted() { }, methods: { priceRow: function(index, id) { let dom = document.getElementById("priceContent" + id); let arrLength = this.dataList[index].ladder_price.length; if (this.dataList[index]["check"]) { dom.style.height = "57px"; this.$set(this.dataList[index], "check", false); this.$set( this.dataList[index], "checkBtn", '更多梯度价格<i class="icon-bot"></i>' ); } else { dom.style.height = 19 * arrLength + "px"; dom.style.transition = `height ${(arrLength - 3) * 0.125}s linear`; dom.style.webkitTransition = `height ${(arrLength - 3) * 0.125}s linear`; this.$set(this.dataList[index], "check", true); this.$set( this.dataList[index], "checkBtn", '收起梯度价格<i class="icon-top"></i>' ); } }, placeOrder(id) { this.$emit("placeOrder", id); }, xunjia() { bus.$emit("xunjia"); } }, components: {} }; </script> <style lang="scss" > .oneDataGoods { .hidex{display:none;} background: #fff; &.block { padding: 5px 10px 0 10px; border-top: 1px solid #d6d7dc; .img-box { padding: 10px 10px 0 0; dt { position: relative; float: left; height: 80px; width: 80px; span { position: absolute; top: 0; right: 0; background: #e10601; display: block; padding: 0px 3px; height: 12px; line-height: 12px; border-radius: 2px; font-size: 10px; color: #fff; } img { border: 1px solid #e5e5e5; height: 80px; width: 80px; display: block; } } dd { padding-left: 90px; h4 { font-size: 16px; color: #333; height: 20px; font-weight: 400; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; .f-red { font-weight: 400; color: #1080d0; } } h5 { height: 21px; padding-bottom: 9px; overflow: hidden; span { padding: 0 5px; display: inline-block; background: #ffa200; height: 12px; line-height: 12px; border-radius: 2px; font-size: 12px; color: #fff; } } p { font-size: 12px; color: #666; height: 16px; line-height: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } } } .icon-hint span { display: inline-block; height: 18px; line-height: 19px; color: #fff; background: #ffa200; margin-right: 5px; border-radius: 3px; padding: 0 9px; font-size: 12px; } .block .icon-hint i { font-size: 13px; margin-right: 4px; } .block-but { padding: 5px 0 10px 0; padding-left: 0; vertical-align: middle; display: table; width: 100%; .morePrice { color: #666; font-size: 12px; width: 100%; .zyClass, .lyClass { height: auto !important; } .zyMoreData, .lyMoreData { height: 57px; border: 1px solid transparent; overflow: hidden; } .list_data { height: 19px; &.dataNo { display: none; } &.f-fff { p { color: rgba(255, 255, 255, 0) !important; } } } p { font-size: 12px; color: #666; line-height: 19px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } } .but-shop { width: 25%; vertical-align: middle; display: table-cell; } .but { height: 30px; float: right; line-height: 30px; width: 100px; font-size: 14px; display: block; color: #fff; background: #1080d0; text-align: center; cursor: pointer; box-sizing: border-box; border-radius: 4px; &.but-orange { background: #ffa200; } } } .more-height, .zkxk { font-size: 12px; margin-right: 10%; height: 24px; line-height: 24px; border: 1px solid #e5e5e5; text-align: center; color: #666; } .icon-bot { top: 9px; position: relative; content: ""; height: 0; width: 0; pointer-events: none; border: solid transparent; border-top-color: #4d4d4d; border-width: 4px; margin-left: 5px; } .icon-top { bottom: 9px; position: relative; content: ""; height: 0; width: 0; pointer-events: none; border: solid transparent; border-bottom-color: #4d4d4d; border-width: 4px; margin-left: 5px; } } } </style>