|
|
@@ -33,9 +33,9 @@
|
|
|
<div
|
|
|
class="product"
|
|
|
:class="{ active: chooseIds.includes(item.id) }"
|
|
|
- v-for="item in list"
|
|
|
+ v-for="item in collections"
|
|
|
:key="item.id"
|
|
|
- @click="choose(item.id)"
|
|
|
+ @click="choose(item.id, item)"
|
|
|
>
|
|
|
<img
|
|
|
class="icon"
|
|
|
@@ -61,6 +61,17 @@
|
|
|
<div class="text2" v-if="item.number">编号:{{ item.number }}</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
+ <div class="num-right" @click.stop="" v-if="item.collections">
|
|
|
+ <van-stepper
|
|
|
+ v-model="item.num"
|
|
|
+ :name="item.id"
|
|
|
+ :min="0"
|
|
|
+ :max="item.collections.length"
|
|
|
+ @change="changeStepper"
|
|
|
+ size="mini"
|
|
|
+ />
|
|
|
+ <div class="num-text">共{{ item.collections.length }}个</div>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</van-pull-refresh>
|
|
|
@@ -88,15 +99,80 @@ export default {
|
|
|
search: '',
|
|
|
activityId: 0,
|
|
|
info: {},
|
|
|
- refreshing: false
|
|
|
+ refreshing: false,
|
|
|
+ nots: [],
|
|
|
+ collections: []
|
|
|
};
|
|
|
},
|
|
|
+ watch: {
|
|
|
+ showList() {
|
|
|
+ let list = [...this.showList];
|
|
|
+ this.collections = list.map(item => {
|
|
|
+ return {
|
|
|
+ ...item,
|
|
|
+ num: 0
|
|
|
+ };
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
computed: {
|
|
|
canNext() {
|
|
|
return this.needChoose === 0 || this.chooseIds.length === this.needChoose;
|
|
|
},
|
|
|
+ needNum() {
|
|
|
+ if (this.needChoose > 0) {
|
|
|
+ return this.needChoose - this.chooseIds.length;
|
|
|
+ } else {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ },
|
|
|
showTips() {
|
|
|
return this.list.length < this.needChoose && !this.empty;
|
|
|
+ },
|
|
|
+ showList() {
|
|
|
+ let list = [...this.list];
|
|
|
+ let nots = [...this.nots];
|
|
|
+ let _map = new Map();
|
|
|
+ console.log(list);
|
|
|
+ list.forEach(item => {
|
|
|
+ let flag = true;
|
|
|
+ nots.forEach(_not => {
|
|
|
+ if (item.name.indexOf(_not) !== -1) {
|
|
|
+ flag = false;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ if (flag) {
|
|
|
+ _map.set(item.id, item);
|
|
|
+ } else {
|
|
|
+ if (_map.has(item.prefixName)) {
|
|
|
+ let info = _map.get(item.prefixName);
|
|
|
+ info.collections.push(item.id);
|
|
|
+ _map.set(item.prefixName, info);
|
|
|
+ } else {
|
|
|
+ _map.set(item.prefixName, {
|
|
|
+ ...item,
|
|
|
+ collections: [item.id]
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ console.log(_map);
|
|
|
+
|
|
|
+ return [..._map.values()];
|
|
|
+ },
|
|
|
+ numList() {
|
|
|
+ let chooseIds = [...this.chooseIds];
|
|
|
+ let collections = [...this.collections];
|
|
|
+ let nums = [];
|
|
|
+ chooseIds.forEach(item => {
|
|
|
+ let info = collections.find(coll => {
|
|
|
+ return coll.id === item;
|
|
|
+ });
|
|
|
+ if (info) {
|
|
|
+ nums.push(`${info.id}_${info.num || 1}`);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return nums;
|
|
|
}
|
|
|
},
|
|
|
mounted() {
|
|
|
@@ -110,6 +186,9 @@ export default {
|
|
|
|
|
|
if (this.$route.query.activityId) {
|
|
|
this.activityId = this.$route.query.activityId;
|
|
|
+ this.$http.get('/sysConfig/get/xingtu_not').then(res => {
|
|
|
+ this.nots = res.value.split(',');
|
|
|
+ });
|
|
|
this.$http.get('/mintActivity/get/' + this.$route.query.activityId).then(res => {
|
|
|
this.needChoose = res.num;
|
|
|
this.search = res.collectionName;
|
|
|
@@ -121,6 +200,46 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
+ changeStepper(value, detail) {
|
|
|
+ console.log(value);
|
|
|
+ let collectIndex = [...this.collections].findIndex(item => {
|
|
|
+ return detail.name === item.id;
|
|
|
+ });
|
|
|
+ let collection = [...this.collections][collectIndex];
|
|
|
+ let collections = collection.collections;
|
|
|
+ let _collections = collections.filter(item => {
|
|
|
+ return [...this.chooseIds].includes(item);
|
|
|
+ });
|
|
|
+ let chooseIds = [...this.chooseIds];
|
|
|
+ let choose = chooseIds.filter(item => {
|
|
|
+ return collections.includes(item);
|
|
|
+ });
|
|
|
+ let index = chooseIds.indexOf(detail.name);
|
|
|
+ if (value > choose.length && this.chooseIds.length === this.needChoose && this.needChoose !== 0) {
|
|
|
+ this.$toast(`只能选择${this.needChoose}个藏品`);
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.collections[collectIndex] = {
|
|
|
+ ...collection,
|
|
|
+ num: _collections.length
|
|
|
+ };
|
|
|
+ });
|
|
|
+ } else if (value + (this.chooseIds.length - choose.length) > this.needChoose) {
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.collections[collectIndex] = {
|
|
|
+ ...collection,
|
|
|
+ num: this.needChoose - this.chooseIds.length + choose.length
|
|
|
+ };
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ // value = this.needChoose - this.chooseIds.length;
|
|
|
+ chooseIds.splice(index, _collections.length);
|
|
|
+ chooseIds = [...chooseIds, ...collections.slice(0, value)];
|
|
|
+ }
|
|
|
+ this.chooseIds = chooseIds;
|
|
|
+ },
|
|
|
+ getMax(max) {
|
|
|
+ return max;
|
|
|
+ },
|
|
|
getList(refresh, done) {
|
|
|
this.$http
|
|
|
.get('/asset/assetsForMint', {
|
|
|
@@ -139,13 +258,23 @@ export default {
|
|
|
done && done();
|
|
|
});
|
|
|
},
|
|
|
- choose(id) {
|
|
|
+ choose(id, info) {
|
|
|
let chooseIds = [...this.chooseIds];
|
|
|
if (chooseIds.includes(id)) {
|
|
|
let index = chooseIds.indexOf(id);
|
|
|
- chooseIds.splice(index, 1);
|
|
|
- } else if (this.chooseIds.length < this.needChoose || this.needChoose === 0) {
|
|
|
- chooseIds.push(id);
|
|
|
+ if (info.collections) {
|
|
|
+ chooseIds.splice(index, info.num);
|
|
|
+ info.num = 0;
|
|
|
+ } else {
|
|
|
+ chooseIds.splice(index, 1);
|
|
|
+ }
|
|
|
+ } else if (this.needNum > 0 || this.needChoose === 0) {
|
|
|
+ if (info.collections) {
|
|
|
+ info.num = this.needNum;
|
|
|
+ chooseIds = [...chooseIds, ...info.collections.slice(0, info.num)];
|
|
|
+ } else {
|
|
|
+ chooseIds.push(id);
|
|
|
+ }
|
|
|
} else if (this.chooseIds.length == this.needChoose) {
|
|
|
this.$toast(`只能选择${this.needChoose}个藏品`);
|
|
|
}
|
|
|
@@ -182,7 +311,8 @@ export default {
|
|
|
path: '/activitySubmit',
|
|
|
query: {
|
|
|
assets: this.chooseIds.join(','),
|
|
|
- activityId: this.activityId
|
|
|
+ activityId: this.activityId,
|
|
|
+ numList: this.numList.join(',')
|
|
|
}
|
|
|
});
|
|
|
});
|
|
|
@@ -313,4 +443,13 @@ export default {
|
|
|
font-size: 12px;
|
|
|
padding: 10px;
|
|
|
}
|
|
|
+.num-right {
|
|
|
+ .flex-col();
|
|
|
+ align-items: center;
|
|
|
+ .num-text {
|
|
|
+ font-size: 10px;
|
|
|
+ color: @text3;
|
|
|
+ margin-top: 6px;
|
|
|
+ }
|
|
|
+}
|
|
|
</style>
|