细节修改

version/0412
fanfan 9 months ago
parent 06327d9a94
commit 9c1a8e87f7
  1. 25
      pages/news3/components/category.vue
  2. 52
      pages/news3/vipPrice.vue

@ -19,7 +19,7 @@
<view class="shopText" :class="{'active2':activeIndex.indexOf(item.category_id) > -1}"
@click="getShop(item,item.category_id)" v-for="(item, index) in item.children"
:key="index">
<text>{{ item.name }}2</text>
<text>{{ item.name }}</text>
<image v-if="activeIndex.indexOf(item.category_id) > -1"
:src="$picUrl + '/static/news1/selected.png'" mode="widthFix">
</image>
@ -28,9 +28,9 @@
</view>
</view>
<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>
@ -59,15 +59,8 @@
this.activeIndex = []
},
getShop(item, category_id) {
console.log(category_id,this.activeIndex)
if (uni.getStorageSync('list').indexOf(category_id) > -1) {
if(this.activeIndex.indexOf(category_id)!==-1){
console.log(this.activeIndex.indexOf(category_id)!==-1)
let index=this.activeIndex.indexOf(category_id);
this.activeIndex.splice(index, 1); //
}
// return this.$toast('')
if (uni.getStorageSync('beyondList').indexOf(category_id) > -1) {
return this.$toast('此分类已被其他分类模板设置规则')
}
let arrIndex = this.activeIndex.indexOf(category_id)
if (arrIndex > -1) {
@ -75,7 +68,6 @@
} else {
this.activeIndex.push(category_id)
}
console.log(this.activeIndex)
},
findElementsById(arr, ids) {
console.log(ids)
@ -95,13 +87,14 @@
submit() {
let idList = []
idList = this.findElementsById(this.tabList, this.activeIndex);
let storage = uni.getStorageSync('list') || []
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', {
category_id: idList||[],
category_id: idList || [],
})
},
getArrDifference(arr1, arr2) {
@ -140,7 +133,7 @@
}
.submit {
width: 216upx;
width: 416upx;
height: 70upx;
background: linear-gradient(180deg, #FD5D06 0%, #F3211A 100%);
border-radius: 50px 50px 50px 50px;

@ -109,8 +109,12 @@
if (status == 200) {
if (data.list.length > 0) {
data.list.forEach((item_1, index_1) => {
let name = this.findElementsById(this.categoryList, item_1.category.split(",").map(
item => Number(item)))
if (typeof item_1.category == 'string') {
item_1.category = item_1.category.split(",").map(item => Number(item))
} else {
item_1.category = [item_1.category]
}
let name = this.findElementsById(this.categoryList,item_1.category)
item_1.category_name = name.join(',') + (name.length > 0 ? '等' : '');
item_1.price_list.forEach((item_2, index_2) => {
item_2.startProfit = Number((Number(item_2.min) * (Number(item_2
@ -284,6 +288,28 @@
}
item.price_list.pop()
},
//
mergeArrays(arr1, arr2) {
//
let mergedArr = [];
//
for (let i = 0; i < arr1.length; i++) {
if (!arr2.includes(arr1[i])) {
//
mergedArr.push(arr1[i]);
}
}
//
for (let j = 0; j < arr2.length; j++) {
if (!arr1.includes(arr2[j]) && !mergedArr.includes(arr2[j])) {
//
mergedArr.push(arr2[j]);
}
}
return mergedArr;
},
//
onCategory(categoryId, index) {
let newId = []
@ -291,12 +317,19 @@
this.activeIndex = [];
this.list.forEach((item, index) => {
if (item.category) {
newId = newId.concat((item.category.split(",").map(item => Number(item))))
newId = newId.concat(item.category)
}
})
let list = Array.from(new Set(newId));
let list = Array.from(new Set(newId)); //
// id
let currentList = [];
if (this.list[index].category) {
currentList = this.list[index].category
}
if (currentList.length > 0 && list.length > 0) {
uni.setStorageSync('beyondList', this.mergeArrays(list, currentList))
}
this.activeIndex = list
uni.setStorageSync('list', list)
this.$refs.category.afterSale = true;
},
findElementsById(arr, ids) {
@ -316,14 +349,9 @@
//
getChoseCategory(res) {
let nameList = [];
let list = [];
if (this.list[this.categoryIndex].category) {
list = this.list[this.categoryIndex].category.split(",").map(item => Number(item))
}
let newList = list.concat(res.category_id);
nameList = this.findElementsById(this.categoryList, newList);
nameList = this.findElementsById(this.categoryList, res.category_id);
this.list[this.categoryIndex].category_name = nameList.join(',') + (nameList.length > 0 ? '等' : '');
this.list[this.categoryIndex].category = newList.join(',')
this.list[this.categoryIndex].category = res.category_id.join(',')
this.$refs.category.afterSale = false;
},
//

Loading…
Cancel
Save