123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566 |
- <template>
- <div class="detail">
- <div class="item">
- <div class="img inline-block">
- <img :src="commodity.img || '/images/store/common/default.png'" alt=""/>
- </div>
- <div class="info inline-block">
- <p class="name">{{commodity.code}}</p>
- <p class="remind"><span>官方自营,品质保障</span>厂家直销,品质保证</p>
-
-
-
-
- <div class="price-level">
- <span class="left inline-block">
- <div>单价 ¥ (含税):</div>
- 起订量:
- </span>
- <ul class="inline-block">
- <li :class="{active: getPriceLevel(fragment.num) == index}" v-for="(price, index) in commodity.prices">
- <span class="price"><em>{{commodity.currencyName == 'RMB' ? '¥' : '$'}}</em>{{price.rMBPrice}}</span>
- <div class="level" :title="price.start + '-' + price.end">{{price.start}}-{{price.end}}</div>
- <i class="arrow"></i>
- </li>
- </ul>
- </div>
- <div class="input-area">
-
- <div class="operate-btn inline-block" @click="fragment.canSub ?subNum():''" :style="!fragment.canSub ?'cursor: not-allowed;':''">-</div>
- <input type="text" class="form-control" placeholder="数量" v-model.number="fragment.num" @change="inputNum()"style="padding: 0;min-width: 100px;text-align: center;"/>
- <div class="operate-btn inline-block" @click="fragment.canAdd ?addNum():''" :style="!fragment.canAdd ?'cursor: not-allowed;':''">+</div>
- <span class="reserve-info">
- 库存:{{commodity.reserve}} {{commodity.unit}} ({{commodity.minBuyQty + commodity.unit}} 起订)
- </span>
- </div>
- <div class="operate-area">
- <a class="inline-block operate-buy" @click="buy(true)">立即购买</a>
- <a class="inline-block" @click="buy(false)">加入购物车</a>
- </div>
- </div>
- <div class="shop inline-block fr">
- <p class="shop-info-title">
- 商家信息
- </p>
- <div class="shop-info">
- <p class="shop-name">{{storeInfo.storeName}}</p>
- <img class="identify" src="/images/pcb/identified.png">
- <div class="info-line">
- <span class="inline-block">电话:</span>
- <span class="inline-block">{{storeInfo.enterprise.enTel || '暂无信息'}}</span>
- </div>
- <div class="info-line">
- <span class="inline-block">传真:</span>
- <span class="inline-block">{{storeInfo.enterprise.enFax || '暂无信息'}}</span>
- </div>
- <div class="info-line">
- <span class="inline-block">地址:</span>
- <span class="inline-block">{{storeInfo.enterprise.enAddress || '暂无信息'}}</span>
- </div>
- <div class="link">
- <span class="link-btn" @click="goLink()"><img src="/images/pcb/link.png" alt="">联系卖家</span>
- </div>
- </div>
- </div>
- </div>
- <ul class="kind">
- <template v-if="properties && properties.length">
- <li class="inline-block text-ellipse" :title="prop[0].value" v-for="prop in properties">
- {{prop[1].labelCn}}:{{prop[0].value || '-'}}
- </li>
- </template>
- <li class="empty-param" v-else>
- <img src="/images/all/empty-cart.png" alt="">该产品暂无参数
- </li>
- </ul>
- <link-saler-box
- :tel="tel"
- v-if="showLinkBox"
- @cancelAction="showLinkBox = false">
- </link-saler-box>
- </div>
- </template>
- <script>
- function initFragment (commodity) {
- if (!commodity) {
- return {}
- }
- let fragment = {}
- let prices = commodity.prices[0]
- fragment.num = commodity.minBuyQty
- fragment.prices = prices
- if (commodity.currencyName !== 'USD') {
- fragment.currency = 'RMB'
- } else {
- fragment.currency = 'USD'
- }
- if (fragment.currency !== 'USD') {
- fragment.price = prices.rMBPrice
- } else {
- fragment.price = prices.uSDPrice
- }
- fragment.canAdd = true
- fragment.canSub = false
- return fragment
- }
- function getFragment (commodity, fragment) {
-
- if (commodity.prices[0].start > fragment.num) {
- fragment.num = commodity.prices[0].start
- }
-
- let prices = commodity.prices
- for (let i = 0; i < prices.length; i++) {
- if (fragment.num <= prices[i].end) {
- fragment.prices = prices[i]
- break
- }
- }
- }
- import LinkSalerBox from '~components/common/LinkSalerBox.vue'
- export default {
- data () {
- return {
- fragment: {
- currency: 'RMB',
- num: 0,
- price: 0,
- canAdd: true,
- canSub: true
- },
- showLinkBox: false,
- tel: ''
- }
- },
- components: {
- LinkSalerBox
- },
- computed: {
- properties () {
- return this.$store.state.pcb.product.detail.data
- },
- storeInfo () {
- return this.$store.state.shop.storeInfo.store.data
- },
- commodity () {
- let commodity = this.$store.state.shop.storeInfo.commodity.data
- this.fragment = initFragment(commodity)
- return commodity
- }
- },
- methods: {
- getPriceLevel: function (num) {
- let prices = this.commodity.prices
- if (this.commodity.prices) {
- for (let i = 0; i < prices.length; i++) {
- if (num >= prices[i].start && num <= prices[i].end) {
- return i
- }
- }
- }
- return -1
- },
- changeNum: function (newNum) {
- let pack = this.commodity.perQty || this.commodity.minPackQty
- let buy = this.commodity.minBuyQty
- let reserve = this.commodity.reserve
- if (newNum < buy) {
- this.$message.error('该商品最少购买' + buy + '件')
- this.fragment.num = buy
- this.fragment.canSub = false
- if (this.fragment.num > reserve) {
- this.$message.error('库存不足')
- this.fragment.num = reserve - (reserve % pack)
- this.fragment.canAdd = false
- } else {
- if (reserve - this.fragment.num - pack < 0) {
- this.fragment.canAdd = false
- } else {
- this.fragment.canAdd = true
- }
- }
- } else {
- if (newNum - buy - pack < 0) {
- this.fragment.canSub = false
- } else {
- this.fragment.canSub = true
- }
-
- if (newNum % pack === 0) {
- this.fragment.num = newNum
- } else {
- this.fragment.num = (Math.floor(newNum / pack) + 1) * pack
- }
- if (this.fragment.num > reserve) {
- this.$message.error('库存不足')
- this.fragment.num = reserve - (reserve % pack)
- this.fragment.canAdd = false
- } else {
- if (reserve - this.fragment.num - pack < 0) {
- this.fragment.canAdd = false
- } else {
- this.fragment.canAdd = true
- }
- }
- }
- },
- subNum () {
- let pack = this.commodity.perQty || this.commodity.minPackQty
- let newNum = this.fragment.num - pack
- this.changeNum(newNum)
- getFragment(this.commodity, this.fragment)
- },
- addNum () {
- let pack = this.commodity.perQty || this.commodity.minPackQty
- let newNum = this.fragment.num + pack
- this.changeNum(newNum)
- getFragment(this.commodity, this.fragment)
- },
- inputNum () {
- if ((/^[\d]*$/).test(this.fragment.num)) {
- this.changeNum(this.fragment.num)
- getFragment(this.commodity, this.fragment)
- } else {
- this.$message.error('请输入数字')
- this.fragment.num = this.commodity.minBuyQty
- }
- },
- buy (flag) {
- this.baseUtils.buyOrCar(flag, null, this, this.commodity, '/user#/order/pay/', this.fragment.num)
- },
- goLink: function () {
- this.baseUtils.goLinkUser(this, this.storeInfo.enUU)
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .detail {
- .inline-block {
- display: inline-block;
- vertical-align: middle;
- }
- .item {
- .img {
- width: 300px;
- height: 356px;
- line-height: 356px;
- text-align: center;
- box-shadow: 0 0 7px 0 rgba(199, 200, 200, .35);
- img {
- max-width: 300px;
- max-height: 356px;
- }
- }
- .info {
- margin-left: 17px;
- height: 356px;
- padding-top: 10px;
- .name {
- font-size: 24px;
- font-weight: bold;
- color: #666;
- margin-bottom: 17px;
- }
- .remind {
- margin: 17px 0;
- span {
- background: #e4393c;
- color: #fff;
- padding: 4px 8px;
- border-radius: 3px;
- margin-right: 10px;
- }
- }
- /*.price-area {
- width: 449px;
- height: 75px;
- background: url('/images/pcb/price-bg.png') no-repeat;
- .left {
- color: #666;
- margin-left: 13px;
- line-height: 40px;
- height: 40px;
- width: 339px;
- border-right: 1px solid #c8e5ff;
- margin-top: 18px;
- span {
- margin-left: 17px;
- font-size: 32px;
- color: #e4393c;
- i {
- font-size: 18px;
- font-style: normal;
- }
- }
- }
- .right {
- margin: 22px 0 0 30px;
- font-size: 12px;
- color: #666;
- span {
- font-size: 14px;
- color: #ffa133;
- margin-bottom: 8px;
- }
- }
- }*/
- .price-level {
- width: 570px;
- height: 87px;
- padding: 17px 0 0 7px;
- background: #fffaf1;
- .left {
- color: #999;
- div {
- margin-bottom: 19px;
- }
- }
- ul {
- margin-left: 15px;
- li {
- width: 145px;
- padding:0 5px;
- float: left;
- text-align: center;
- .price {
- color: #ffb385;
- font-size: 20px;
- margin-bottom: 19px;
- em {
- font-style: normal;
- font-size: 13px;
- margin-right: 4px;
- }
- }
- .level {
- height: 21px;
- line-height: 21px;
- font-size: 12px;
- color: #999;
- background: #e4e4e4;
- margin-top: 9px;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- }
- &.active {
- position: relative;
- .price {
- color: #ff7800;
- }
- .level {
- background: #ccc;
- color: #333;
- }
- .arrow {
- content: '';
- position: absolute;
- top: 28px;
- left: 37px;
- border: {
- left: 4px solid transparent;
- right: 4px solid transparent;
- bottom: 8px solid #ccc;
- }
- }
- }
- }
- }
- }
- .input-area {
- margin-top: 25px;
- .operate-btn {
- width: 33px;
- height: 45px;
- text-align: center;
- line-height: 45px;
- border: 1px solid #d9d9d9;
- background: #f4f4f4;
- cursor: pointer;
- font-size: 20px;
- user-select: none;
- }
- .form-control {
- border: 1px solid #d9d9d9;
- background: #fff;
- width: 77px;
- height: 45px;
- border-radius: 0;
- vertical-align: middle;
- text-align: center;
- }
- .reserve-info {
- color: #999;
- margin-left: 10px;
- vertical-align: bottom;
- }
- }
- .operate-area {
- margin-top: 12px;
- .inline-block {
- width: 126px;
- height: 45px;
- line-height: 45px;
- text-align: center;
- font-size: 18px;
- color: #fff;
- background: #418cf6;
- border: 1px solid #418cf6;
- &.operate-buy {
- color: #418cf6;
- background: #fff;
- margin-right: 8px;
- }
- }
- }
- }
- $base-color: #ffa133;
- .shop {
- height: 356px;
- width: 259px;
- text-align: center;
- .search-area {
- .form-control {
- width: 198px;
- height: 28px;
- font-size: 12px;
- padding: 0 14px;
- border: 1px solid $base-color;
- vertical-align: middle;
- border: {
- bottom-left-radius: 13px;
- top-left-radius: 13px;
- top-right-radius: 0;
- bottom-right-radius: 0;
- };
- }
- .search-btn {
- width: 60px;
- height: 28px;
- line-height: 28px;
- color: #fff;
- background: $base-color;
- border: 1px solid $base-color;
- border: {
- bottom-left-radius: 0;
- top-left-radius: 0;
- top-right-radius: 13px;
- bottom-right-radius: 13px;
- };
- cursor: pointer;
- }
- }
- .shop-info-title {
- position: relative;
- font-size: 16px;
- color: #ffa133;
- border: 1px solid #fee9d0;
- line-height: 35px;
- margin: 30px 0 0 0;
- &::before {
- content: '';
- background: #fff;
- width: 24px;
- height: 24px;
- position: absolute;
- left: -12px;
- top: -12px;
- border-right: 1px solid #fee9d0;
- -webkit-transform: rotate(45deg);
- -moz-transform: rotate(45deg);
- -ms-transform: rotate(45deg);
- -o-transform: rotate(45deg);
- transform: rotate(45deg);
- }
- &::after {
- content: '';
- position: absolute;
- left: 1px;
- top: 1px;
- border: {
- top: 15px solid $base-color;
- right: 15px solid transparent;
- }
- }
- }
- .shop-info {
- border: 1px solid #fee9d0;
- .shop-name {
- margin: 19px 0 9px;
- color: #666;
- }
- .identify {
- margin-bottom: 20px;
- }
- .info-line {
- margin-bottom: 21px;
- padding: 0 16px;
- text-align: left;
- .inline-block {
- vertical-align: top;
- &:first-child {
- color: #666;
- }
- &:last-child {
- max-width: 182px;
- }
- }
- }
- .link {
- height: 70px;
- width: 232px;
- margin: 0 auto;
- border-top: 1px dashed $base-color;
- .link-btn {
- display: block;
- margin: 23px auto 0;
- width: 124px;
- height: 26px;
- background: $base-color;
- color: #fff;
- line-height: 26px;
- border-radius: 13px;
- cursor: pointer;
- img {
- margin-right: 7px;
- }
- }
- }
- }
- }
- }
- .kind {
- background: #f8fbfd;
- margin: 38px 0 80px;
- border: 1px solid #d6ebfd;
- li {
- width: 25%;
- color: #666;
- height: 40px;
- line-height: 40px;
- padding-left: 47px;
- padding-right: 10px;
- border-bottom: 1px solid #d6ebfd;
- &:nth-last-child(-n + 4) {
- border-bottom: none;
- }
- a {
- color: #418cf6;
- }
- &.empty-param {
- width: 100%;
- height: auto;
- text-align: center;
- padding: 20px 0;
- color: #999;
- font-size: 12px;
- }
- }
- }
- }
- </style>
|