UNPKG

captain-ui

Version:

有赞vue wap业务组件库

254 lines (234 loc) 9 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); exports.__esModule = true; exports.default = void 0; var _fullfillImage = _interopRequireDefault(require("@youzan/utils/fullfillImage")); var _index = _interopRequireDefault(require("../../countdown/index")); var _goodsImg = _interopRequireDefault(require("./goodsImg")); var _constant = require("../constant"); var _components; var IMAGE_MAP = { 0: '!730x0.jpg', 1: '!520x0.jpg', 2: '!290x0.jpg' }; var _default = { render: function render() { var _vm = this; var _h = _vm.$createElement; var _c = _vm._self._c || _h; return _c('a', { class: ['cap-ump-seckill-goods', { 'cap-ump-seckill-goods--preview': _vm.isPreview, 'cap-ump-seckill-goods--soldout': !_vm.hasStock, 'cap-ump-seckill-goods--end': _vm.isEnd, 'cap-ump-seckill-goods--not-start': _vm.isNotStart }], attrs: { "href": _vm.goodsUrl } }, [_c('div', { staticClass: "cap-ump-seckill-goods__header" }, [_c('cap-ump-seckill-goods-img', { attrs: { "ratio": _vm.ratio, "img-url": _vm.imageUrl, "size": _vm.size, "fill-style": _vm.imageFillStyle, "goods-id": _vm.goods.id, "show-mask": (!_vm.hasStock || _vm.isEnd) && !_vm.isPreview } }), _c('div', { staticClass: "cap-ump-seckill-goods__tag-info" }, [_vm.isShowActivityTag ? _c('span', { staticClass: "cap-ump-seckill-goods__tag" }, [_vm._v("\n " + _vm._s(_vm.goods.tag) + "\n ")]) : _vm._e(), _vm.isShowCountdown ? _c('div', { staticClass: "cap-ump-seckill-goods__tag-countdown" }, [_vm.countdownText.length > 0 ? _c('span', { staticClass: "cap-ump-seckill-goods__countdown-text" }, [_vm._v("\n " + _vm._s(_vm.countdownText) + "\n ")]) : _vm._e(), _c('cap-countdown', { staticClass: "cap-ump-seckill-goods__countdown", attrs: { "time-style": "white", "prevent-init": _vm.preventInit, "start": _vm.goods.startAt, "end": _vm.goods.endAt, "time-separator": ['天', ':', ':', ':'], "hide-zero-day": "" }, on: { "timechange": _vm.handleTimeChange, "countdown-started": _vm.handleCountdownStart, "countdown-ended": _vm.handleCountdownEnd } })], 1) : _vm._e()])], 1), _c('div', { staticClass: "cap-ump-seckill-goods__content" }, [_vm.showTitle ? _c('h3', { staticClass: "cap-ump-seckill-goods__title" }, [_c('span', { staticClass: "cap-ump-seckill-goods__discount" }, [_vm._v("立减" + _vm._s(_vm.discount) + "元")]), _vm._v("\n " + _vm._s(_vm.goods.title) + "\n ")]) : _vm._e(), _c('div', { class: ['cap-ump-seckill-goods__info', { 'cap-ump-seckill-goods__stock--hide': !_vm.showStockNum }] }, [_c('span', { staticClass: "cap-ump-seckill-goods__discount" }, [_vm._v("立减" + _vm._s(_vm.discount) + "元")]), _vm.showStockNum ? _c('span', { staticClass: "cap-ump-seckill-goods__stock" }, [_vm._v("\n " + _vm._s(_vm.limitText) + _vm._s(_vm.goods.currentStock || 0) + "件\n ")]) : _vm._e()]), _c('div', { staticClass: "cap-ump-seckill-goods__detail" }, [_c('div', { staticClass: "cap-ump-seckill-goods__price" }, [_vm._v("\n " + _vm._s(_vm.priceText) + "\n "), _c('span', { staticClass: "cap-ump-seckill-goods__price-symbol" }, [_vm._v("¥")]), _c('span', { staticClass: "cap-ump-seckill-goods__price-yuan" }, [_vm._v(_vm._s(_vm.price.yuan))]), _c('span', { staticClass: "cap-ump-seckill-goods__price-cent" }, [_vm._v(_vm._s(_vm.price.cent) + " ")])]), _c('div', { staticClass: "cap-ump-seckill-goods__origin-price" }, [_vm._v(_vm._s(_vm.originPriceText) + " ¥" + _vm._s(_vm.originPrice))])]), _c('div', { class: ['cap-ump-seckill-goods__bottom', { 'cap-ump-seckill-goods__bottom--hide-stock': !_vm.isShowMicroStockNum }] }, [_vm.isShowMicroStockNum ? _c('span', { staticClass: "cap-ump-seckill-goods__stock" }, [_vm._v("\n " + _vm._s(_vm.limitText) + _vm._s(_vm.goods.currentStock || 0) + "件\n ")]) : _vm._e(), _vm.showBuyBtn ? _c('div', { staticClass: "cap-ump-seckill-goods__action" }, [_vm._v("\n " + _vm._s(_vm.btnText) + "\n ")]) : _vm._e()]), _vm.isShowMicroCountdown ? _c('cap-countdown', { staticClass: "cap-ump-seckill-goods__countdown--mirco", attrs: { "time-style": "white", "prevent-init": _vm.preventInit, "time-separator": _vm.timeSeparator, "start": _vm.goods.startAt, "end": _vm.goods.endAt }, on: { "timechange": _vm.handleTimeChange, "countdown-started": _vm.handleCountdownStart, "countdown-ended": _vm.handleCountdownEnd } }) : _vm._e()], 1)]); }, name: 'cap-ump-seckill-goods', components: (_components = {}, _components[_index.default.name] = _index.default, _components[_goodsImg.default.name] = _goodsImg.default, _components), props: { ratio: String, size: Number, goods: Object, showCountDown: Number, showStockNum: Number, showBuyBtn: Number, buyBtnType: Number, showTitle: Number, imageFillStyle: Number, isPreview: Boolean }, data: function data() { return { leftDay: null, status: this.goods.activityStatus, timeSeparator: ['天', '时', '分', '秒'] }; }, computed: { imageUrl: function imageUrl() { return (0, _fullfillImage.default)(this.goods.thumbUrl, IMAGE_MAP[this.size]); }, preventInit: function preventInit() { return this.isPreview || this.isEnd || !this.hasStock; }, limitText: function limitText() { return this.isNotStart ? '限量' : '仅剩'; }, goodsUrl: function goodsUrl() { return this.isPreview ? '' : this.goods.detailUrl; }, hasStock: function hasStock() { return this.goods.currentStock > 0; }, countdownText: function countdownText() { if (this.isNotStart) { return '距开秒还有'; } if (this.size === _constant.SIZE.list) { return this.leftDay ? '' : '仅剩'; } if (this.size === _constant.SIZE.small) { return this.leftDay ? '仅剩' : '距结束仅剩'; } return '距结束仅剩'; }, isNotStart: function isNotStart() { return this.status === _constant.ACTIVITY_STATUS.notStart; }, isEnd: function isEnd() { return this.status === _constant.ACTIVITY_STATUS.end; }, isShowActivityTag: function isShowActivityTag() { return this.size === _constant.SIZE.big; }, isShowCountdown: function isShowCountdown() { return this.showCountDown && !this.isShowMicroCountdown && (this.size === _constant.SIZE.big || this.hasStock && !this.isEnd && this.size !== _constant.SIZE.big); }, isShowMicroCountdown: function isShowMicroCountdown() { return this.showCountDown && this.size === _constant.SIZE.list && this.isNotStart && !this.isEnd && this.hasStock; }, isShowMicroStockNum: function isShowMicroStockNum() { return this.size === _constant.SIZE.small && !!this.showStockNum; }, discount: function discount() { var _this$goods = this.goods, goodsPrice = _this$goods.goodsPrice, activityPrice = _this$goods.activityPrice; return ((goodsPrice - activityPrice) / 100).toFixed(2); }, originPrice: function originPrice() { return (this.goods.goodsPrice / 100).toFixed(2); }, originPriceText: function originPriceText() { return this.size === _constant.SIZE.big ? '' : '活动结束价'; }, priceText: function priceText() { return this.size === _constant.SIZE.big ? '秒杀价:' : '秒杀价'; }, price: function price() { var activityPrice = (this.goods.activityPrice / 100).toFixed(2); var _activityPrice$match = activityPrice.match(/(\d+)(\.\d+)/), yuan = _activityPrice$match[1], cent = _activityPrice$match[2]; return { yuan: yuan, cent: cent }; }, btnText: function btnText() { if (this.isPreview) { return '马上秒'; } if (this.isEnd || !this.hasStock) { return '去看看'; } if (this.isNotStart) { if (this.goods.isCheckRight) { return '马上预约'; } return '即将开秒'; } return '马上秒'; } }, methods: { handleTimeChange: function handleTimeChange(val) { this.leftDay = val.day; }, handleCountdownStart: function handleCountdownStart() { this.status = _constant.ACTIVITY_STATUS.start; }, handleCountdownEnd: function handleCountdownEnd() { this.status = _constant.ACTIVITY_STATUS.end; } } }; exports.default = _default;