123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225 |
- <template>
- <view class="upload_num_container">
- <!-- <picker :value="sexIndex" :range="sexList" range-key="name" @change="pickerSexChange">
- <view class="sex_select">
- <view class="select_main">{{ sexList[sexIndex].name || '选款式' }}</view>
- <view class="select_arrow"></view>
- </view>
- </picker>
- <picker :value="sizeIndex" :range="sizeList" range-key="name" @change="pickerSizeChange">
- <view class="sex_select">
- <view class="select_main">{{ sizeList[sizeIndex].name || '选尺码' }}</view>
- <view class="select_arrow"></view>
- </view>
- </picker> -->
- <view class="upload_input_counter">
- <view class="counter_delete" @click="changeCounter(0)"></view>
- <input v-model="sarr[2]" type="number" class="counter_input" :class="sarr[2] === 0 ? 'counter_input_had' : ''" @input="inputCounter">
- <view class="counter_add" @click="changeCounter(1)"></view>
- </view>
- </view>
- </template>
- <script>
- export default {
- props: {
- sarr: {
- type: Array,
- default: () => ['', '', 0]
- },
- skey: {
- type: String,
- default: ''
- },
- sindex: {
- type: Number,
- default: 0
- }
- },
- data() {
- return {
- sexList: [
- {
- id: 0,
- name: '女'
- },
- {
- id: 1,
- name: '男'
- }
- ],
- sizeList: [
- {
- id: 0,
- name: 'M'
- },
- {
- id: 1,
- name: 'L'
- },
- {
- id: 2,
- name: 'XL'
- },
- {
- id: 3,
- name: '2XL'
- },
- {
- id: 4,
- name: '3XL'
- },
- {
- id: 5,
- name: '5XL'
- }
- ],
- sexIndex: -1,
- sizeIndex: -1
- }
- },
- watch: {
- sarr: {
- handler(a) {
- this.sexIndex = this.sexList.findIndex(({ id }) => +id === a[0])
- this.sizeIndex = this.sizeList.findIndex(({ id }) => +id === a[1])
- },
- deep: true,
- immediate: true
- }
- },
- methods: {
- pickerSexChange(e) {
- this.sexIndex = Number(e.detail.value)
- if(this.sexIndex === -1) return false
- let id = this.sexList[this.sexIndex].id
- this.$emit('inputCounter', this.skey, this.sindex, 0, id)
- },
- pickerSizeChange(e) {
- this.sizeIndex = Number(e.detail.value)
- if(this.sizeIndex === -1) return false
- let id = this.sizeList[this.sizeIndex].id
- this.$emit('inputCounter', this.skey, this.sindex, 1, id)
- },
- changeCounter(type) {
- let n = this.sarr[2]
- type ? ++ n : (n > 0 ? --n : n)
- this.$emit('inputCounter', this.skey, this.sindex, 2, n)
- },
- inputCounter(e) {
- let n = e.detail.value
- this.$emit('inputCounter', this.skey, this.sindex, 2, n)
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .upload_num_container {
- width: 100%;
- display: flex;
- align-items: center;
- justify-content: space-between;
- .select_arrow {
- &::after {
- content: "";
- display: block;
- width: 28rpx;
- height: 28rpx;
- background-image: url(../static/icon/arrow.png);
- background-size: 100% 100%;
- background-repeat: no-repeat;
- transform: rotate(90deg);
- }
- }
- .select_main {
- flex: 1;
- text-align: center;
- overflow: hidden;
- }
- .sex_select {
- width: 160rpx;
- height: 64rpx;
- line-height: 64rpx;
- display: flex;
- justify-content: center;
- align-items: center;
- color: #FB6342;
- font-size: 32rpx;
- background-color: #F5F5F5;
- border-radius: 8rpx;
- padding: 0 16rpx;
- box-sizing: border-box;
- }
- .upload_input_counter {
- width: 300rpx;
- color: #FB6342;
- font-size: 32rpx;
- height: 64rpx;
- border-radius: 64rpx;
- border: 1px solid #FB6342;
- display: flex;
- align-items: center;
- justify-content: space-between;
- .counter_input_had {
- color: #000 !important;
- }
- .counter_input {
- flex: 1;
- overflow: hidden;
- height: 64rpx;
- line-height: 64rpx;
- text-align: center;
- border-left: 1px solid #FB6342;
- border-right: 1px solid #FB6342;
- }
- .counter_add {
- width: 54rpx;
- position: relative;
- height: 100%;
- &::before {
- content: "";
- display: block;
- width: 4rpx;
- height: 16rpx;
- background-color: #FB6342;
- position: absolute;
- top: 50%;
- left: 50%;
- margin-top: -8rpx;
- margin-left: -2rpx;
- }
- &::after {
- content: "";
- display: block;
- width: 16rpx;
- height: 2rpx;
- background-color: #FB6342;
- position: absolute;
- top: 50%;
- left: 50%;
- margin-top: -2rpx;
- margin-left: -8rpx;
- }
- }
- .counter_delete {
- width: 54rpx;
- height: 100%;
- position: relative;
- &::before {
- content: "";
- display: block;
- width: 16rpx;
- height: 2rpx;
- background-color: #FB6342;
- position: absolute;
- top: 50%;
- left: 50%;
- margin-top: -2rpx;
- margin-left: -8rpx;
- }
- }
- }
- }
- </style>
|