1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- <template>
- <view class="countContainer">
- <view class="reduceBtn" @click="toReduce" />
- <input
- v-model="countNum"
- class="countNum"
- :class="Number(countNum) > 0 ? 'active' : ''"
- />
- <view class="plusBtn" @click="toPlus" />
- </view>
- </template>
- <script>
- export default {
- props: {
- countNum: {
- type: Number,
- default: 0
- }
- },
- methods: {
- toReduce() {
- let _v = this.countNum
- if(_v === 0) return false
- this.$emit('update:countNum', --_v)
- },
- toPlus() {
- let _v = this.countNum
- if(_v > 999) return false
- this.$emit('update:countNum', ++_v)
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .countContainer {
- flex: 1;
- overflow: hidden;
- height: 64rpx;
- border: 1px solid #F76454;
- box-sizing: border-box;
- border-radius: 16rpx;
- display: flex;
- align-items: center;
- justify-content: space-between;
- background-color: #FFF4F3;
- .reduceBtn, .plusBtn {
- width: 60rpx;
- height: 100%;
- display: flex;
- align-items: center;
- justify-content: center;
- position: relative;
- &::before {
- content: "";
- display: block;
- width: 18rpx;
- height: 2rpx;
- background-color: #F76454;
- }
- &.plusBtn {
- &::after {
- content: "";
- display: block;
- position: absolute;
- width: 2rpx;
- height: 18rpx;
- background-color: #F76454;
- top: 50%;
- left: 50%;
- transform: translate(-50%, -50%);
- }
- }
- }
- .countNum {
- flex: 1;
- overflow: hidden;
- border-left: 1px solid #F76454;
- border-right: 1px solid #F76454;
- text-align: center;
- line-height: 72rpx;
- height: 100%;
- &.active {
- color: #F76454;
- }
- }
- }
- </style>
|