UNPKG

captain-ui

Version:

有赞vue wap业务组件库

104 lines (96 loc) 3 kB
"use strict"; exports.__esModule = true; exports.default = void 0; var _default2 = { render: function render() { var _vm = this; var _h = _vm.$createElement; var _c = _vm._self._c || _h; return _c('div', { staticClass: "cap-coupon", class: { 'cap-coupon--preview': _vm.isPreview } }, [_c('div', { staticClass: "cap-coupon__track", style: _vm.trackStyle }, _vm._l(_vm.coupon, function (item) { return _c('div', { class: ['cap-coupon__item', { 'cap-coupon__item--disabled': item.disabled, 'cap-coupon__item--two': _vm.count === 2, 'cap-coupon__item--one': _vm.count === 1 }], on: { "click": function click($event) { _vm.$emit('click', item); } } }, [_c('div', { staticClass: "cap-coupon__price", domProps: { "innerHTML": _vm._s(_vm.getItemPrice(item)) } }), _c('div', { staticClass: "cap-coupon__desc" }, [_vm.count === 1 ? _c('div', [_vm._v("优惠券")]) : _vm._e(), _c('div', [_vm._v(_vm._s(_vm.getAtLeastText(item)))])]), _vm.count === 1 ? _c('div', { staticClass: "cap-coupon__receive van-hairline--left" }, [_vm._v("\n 立即领取\n ")]) : _vm._e(), item.disabled && item.disabledText ? _c('div', { staticClass: "cap-coupon__disabled-text-wrap" }, [_c('div', { staticClass: "cap-coupon__disabled-text" }, [_vm._v(_vm._s(item.disabledText))])]) : _vm._e()]); }), 0)]); }, name: 'cap-coupon', props: { isPreview: Boolean, coupon: { type: Array, default: function _default() { return []; } } }, computed: { count: function count() { return this.coupon.length; }, couponStyle: function couponStyle() { return this.count <= 3 ? {} : { width: this.couponWidth + 'px' }; }, trackStyle: function trackStyle() { return this.count <= 3 ? {} : { width: this.count * 40 + '%' }; } }, methods: { getItemPrice: function getItemPrice(item) { var texts = ['', '', '']; if (item.value) { texts[0] = '¥'; texts[1] = Math.floor(item.value / 100); if (item.value % 100 !== 0) { texts[2] = '.' + this.padZero(item.value % 100); } } else if (item.discount) { texts[1] = item.discount / 10; texts[2] = ' 折'; if (item.discount % 10 !== 0) { texts[1] = texts[1].toFixed(1); } } return "<span>" + texts[0] + "</span><span>" + texts[1] + "</span><span>" + texts[2] + "</span>"; }, padZero: function padZero(num) { return (num < 10 ? '0' : '') + num; }, getAtLeastText: function getAtLeastText(item) { return item.at_least && +item.at_least !== 0 ? "\u6EE1" + item.at_least + "\u5143\u53EF\u7528" : '无门槛使用'; } } }; exports.default = _default2;