修改会员价

version/0412
fanfan 9 months ago
parent abc729af13
commit 9bdd2eb5dd
  1. 41
      pages/news3/components/category.vue
  2. 48
      pages/news3/vipPrice.vue

@ -28,9 +28,9 @@
</view> </view>
</view> </view>
<view class="btnGroup"> <view class="btnGroup">
<!-- <view class="reset" @click="reset"> <view class="reset" @click="reset">
重置 重置
</view> --> </view>
<view class="submit" @click="submit" style="margin-left:24upx;"> <view class="submit" @click="submit" style="margin-left:24upx;">
确定 确定
</view> </view>
@ -56,12 +56,9 @@
}, },
methods: { methods: {
reset() { reset() {
this.activeIndex = [] this.activeIndex.splice(0)
}, },
getShop(item, category_id) { getShop(item, category_id) {
if (uni.getStorageSync('beyondList').indexOf(category_id) > -1) {
return this.$toast('此分类已被其他分类模板设置规则')
}
let arrIndex = this.activeIndex.indexOf(category_id) let arrIndex = this.activeIndex.indexOf(category_id)
if (arrIndex > -1) { if (arrIndex > -1) {
this.activeIndex.splice(arrIndex, 1) this.activeIndex.splice(arrIndex, 1)
@ -69,39 +66,11 @@
this.activeIndex.push(category_id) this.activeIndex.push(category_id)
} }
}, },
findElementsById(arr, ids) {
let result = []
arr.forEach(item => {
if (ids.indexOf(item.category_id) > -1) {
result.push(item.category_id);
item.children.forEach(item1 => {
if (ids.indexOf(item1.category_id) > -1) {
result.push(item1.category_id);
}
});
}
});
return result;
},
submit() { submit() {
let idList = []
idList = this.findElementsById(this.tabList, this.activeIndex);
let storage = uni.getStorageSync('beyondList') || []
console.log(idList, storage)
if (storage.length > 0 && idList.length > 0) {
idList = this.getArrDifference(idList, storage)
}
console.log(idList)
this.$emit('getChoseCategory', { this.$emit('getChoseCategory', {
category_id: idList || [], category_id: this.activeIndex || [],
}) })
}, },
getArrDifference(arr1, arr2) {
return arr1.concat(arr2).filter(function(v, i, arr) {
return arr.indexOf(v) === arr.lastIndexOf(v);
});
}
} }
} }
</script> </script>
@ -132,7 +101,7 @@
} }
.submit { .submit {
width: 416upx; width: 216upx;
height: 70upx; height: 70upx;
background: linear-gradient(180deg, #FD5D06 0%, #F3211A 100%); background: linear-gradient(180deg, #FD5D06 0%, #F3211A 100%);
border-radius: 50px 50px 50px 50px; border-radius: 50px 50px 50px 50px;

@ -109,11 +109,16 @@
if (status == 200) { if (status == 200) {
if (data.list.length > 0) { if (data.list.length > 0) {
data.list.forEach((item_1, index_1) => { data.list.forEach((item_1, index_1) => {
if (typeof item_1.category == 'string') {
item_1.category = item_1.category.split(",").map(item => Number(item))
item_1.category_name = this.findElementsById(this.categoryList, item_1
.category).join(',');
}
if (typeof item_1.category == 'number') { if (typeof item_1.category == 'number') {
item_1.category=item_1.category.toString() item_1.category = [item_1.category]
item_1.category_name = this.findElementsById(this.categoryList, item_1
.category).join(',');
} }
let name = this.findElementsById(this.categoryList,item_1.category.split(",").map(item => Number(item)))
item_1.category_name = name.join(',') + (name.length > 0 ? '等' : '');
item_1.price_list.forEach((item_2, index_2) => { item_1.price_list.forEach((item_2, index_2) => {
item_2.startProfit = Number((Number(item_2.min) * (Number(item_2 item_2.startProfit = Number((Number(item_2.min) * (Number(item_2
.add_price_rate) / 100)).toFixed(2)); .add_price_rate) / 100)).toFixed(2));
@ -132,7 +137,9 @@
let that = this let that = this
let step = 0; let step = 0;
let list = this.list let list = this.list
let ids = []
list.forEach((item, index) => { list.forEach((item, index) => {
ids = ids.concat(item.category)
if (!item.category_name) { if (!item.category_name) {
step++ step++
let name = "请选择第" + (index + 1) + '行分类' let name = "请选择第" + (index + 1) + '行分类'
@ -190,7 +197,14 @@
}); });
return return
} }
if (Array.isArray(item.category)) {
item.category = item.category.join(',')
}
}); });
if (this.hasDuplicate(ids)) {
this.$toast('分类模板有重复设置的分类')
return
}
if (step == 0) { if (step == 0) {
list.forEach((item, index) => { list.forEach((item, index) => {
delete item.category_name delete item.category_name
@ -215,6 +229,9 @@
} }
} }
}, },
hasDuplicate(arr) {
return new Set(arr).size !== arr.length;
},
// //
async getCategory() { async getCategory() {
let { let {
@ -310,25 +327,12 @@
}, },
// //
onCategory(categoryId, index) { onCategory(categoryId, index) {
let newId = [] if (typeof categoryId == 'string') {
this.categoryIndex = index; categoryId = categoryId.split(",").map(item => Number(item))
this.activeIndex = [];
this.list.forEach((item, index) => {
if (item.category) {
newId = newId.concat(item.category.split(",").map(item => Number(item)))
}
})
let list = Array.from(new Set(newId)); //
// id
let currentList = [];
if (this.list[index].category) {
currentList = this.list[index].category.split(",").map(item => Number(item))
} }
if (list.length > 0) { console.log(categoryId)
uni.removeStorageSync('beyondList'); this.categoryIndex = index;
uni.setStorageSync('beyondList', this.mergeArrays(list, currentList)) this.activeIndex = categoryId
}
this.activeIndex = list
this.$refs.category.afterSale = true; this.$refs.category.afterSale = true;
}, },
findElementsById(arr, ids) { findElementsById(arr, ids) {
@ -350,7 +354,7 @@
let nameList = []; let nameList = [];
nameList = this.findElementsById(this.categoryList, res.category_id); nameList = this.findElementsById(this.categoryList, res.category_id);
this.list[this.categoryIndex].category_name = nameList.join(',') + (nameList.length > 0 ? '等' : ''); this.list[this.categoryIndex].category_name = nameList.join(',') + (nameList.length > 0 ? '等' : '');
this.list[this.categoryIndex].category = res.category_id.join(',') this.list[this.categoryIndex].category = res.category_id;
this.$refs.category.afterSale = false; this.$refs.category.afterSale = false;
}, },
// //

Loading…
Cancel
Save