123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164 |
- <template>
- <view class="spec-select-conetnt">
- <view class="spec-select" v-for="(item,index) in newList" :key="item.key">
- <view class="spec-select-title">
- <text class="title-1">{{item.shopSpec}}</text>
- <text class="title-2">【{{item.featureType==1?'单选':'多选'}}】</text>
- </view>
- <view class="spec-select-list">
- <view v-for="(v,i) in item.params" :key="i"
- :class="item.featureType === 1 ? (item.inputValue == v.tagKey ? 'active' : 'list__item') : (item.inputValue.indexOf(v.tagKey) !==-1 ? 'active' : 'list__item')"
- @click="handleSelect(item,v)">
- {{v.name}}
- <image
- v-if="item.featureType === 1 ? (item.inputValue == v.tagKey ? 'active' : 'list__item') : (item.inputValue.indexOf(v.tagKey) !==-1 ? 'active' : 'list__item')"
- src="../static/xuanzhong.png" class="image_active">
- </image>
- </view>
- </view>
- </view>
- <view class="spec-btn">
- <u-button type="primary" text="确定" @click="submit"></u-button>
- </view>
- </view>
- </template>
- <script>
- export default {
- name: "specSelect",
- props: {
- list: {
- type: Array,
- default: {}
- },
- },
- data() {
- return {
- newList: []
- };
- },
- watch: {
- list: {
- handler(value) {
- if (!!value.length) {
- this.newList = value
- // console.log(value.length)
- }
- },
- immediate: true,
- deep: true
- }
- },
- methods: {
- handleSelect(item, value) {
- if (item.featureType == 1) {
- if (item.inputValue !== value.tagKey) {
- item.inputValue = value.tagKey
- } else {
- item.inputValue = ''
- }
- } else {
- const index = item.inputValue.indexOf(value.tagKey)
- if (index == -1) {
- item.inputValue.push(value.tagKey);
- } else {
- item.inputValue.splice(index, 1);
- }
- }
- },
- submit() {
- const values = this.newList.map(item => {
- return {
- ...item,
- selectData: item.params.filter(v => {
- if (item.featureType == 1) {
- return v.tagKey == item.inputValue;
- } else {
- // console.log(item, v);
- return item.inputValue.includes(v.tagKey);
- }
- })
- }
- })
- // console.log(values)
- this.$emit('changeSelect', values)
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .spec-select-conetnt {
- padding: 4px;
- .spec-select {
- .spec-select-title {
- .title-1 {
- color: #333;
- font-size: 17px;
- font-weight: 500;
- }
- .title-2 {
- color: #606266;
- font-size: 15px;
- font-weight: 400;
- }
- }
- .spec-select-list {
- display: flex;
- justify-content: space-between;
- align-items: center;
- width: 100%;
- flex-wrap: wrap;
- margin-top: 5.5px;
- .list__item {
- width: 158px;
- line-height: 43px;
- text-align: center;
- height: 43px;
- border-radius: 8px;
- background: #F3F4F6;
- margin-bottom: 12px;
- color: #333;
- font-size: 15px;
- font-weight: 400;
- overflow: hidden;
- }
- .active {
- width: 155px;
- height: 40px;
- line-height: 40px;
- text-align: center;
- border-radius: 8px;
- border: 1.5px solid #4C96FF;
- position: relative;
- background: #F3F4F6;
- margin-bottom: 12px;
- color: #333;
- font-size: 15px;
- font-weight: 400;
- overflow: hidden;
- .image_active {
- width: 20px;
- height: 16px;
- position: absolute;
- right: 0;
- bottom: 0;
- }
- }
- }
- }
- .spec-btn {
- padding: 0 10px;
- margin-top: 112px;
- margin-bottom: 32px;
- }
- }
- </style>
|