123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- <template>
- <view class="custom-counter">
- <text class="reduce cuIcon-move" @tap="reduce"></text>
- <text class="num">{{ inputValue }}</text>
- <text class="add cuIcon-add" @tap="add"></text>
- </view>
- </template>
- <script>
- export default {
- props: {
- value: String
- },
- data() {
- return {
- inputValue: this.value
- }
- },
- methods: {
- add () {
- if (this.inputValue < 99) {
- this.inputValue ++
- this.$emit('input', this.inputValue)
- }
- },
- reduce () {
- if (+this.inputValue) {
- this.inputValue --
- this.$emit('input', this.inputValue)
- }
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .custom-counter {
- display: flex;
- justify-content: space-between;
- align-items: center;
- width: 212rpx;
- height: 50rpx;
- border-radius:5rpx;
- font-size: 32rpx;
- color: rgba(42, 42, 42, 1);
- text {
- display: flex;
- justify-content: center;
- align-items: center;
- width: 90rpx;
- height: 100%;
- background: #EEEEEE;
- border-radius: 6rpx;
- &.num {
- background: #FFFFFF;
- border-radius: 0;
- }
- }
- .reduce, .add {
- width: 50rpx;
- height: 50rpx;
- border-radius: 50%;
- box-sizing: border-box;
- }
- .add {
- background-color: #FA6342;
- color: #FFFFFF;
- }
- .reduce {
- border: 2rpx solid #B5B5B5;
- color: #B5B5B5;
- background-color: #FFFFFF;
- }
- }
- </style>
|