多规格下架处理

This commit is contained in:
GaoHao 2024-08-07 13:28:02 +08:00
parent 83aeb25652
commit 3b3a08d460
1 changed files with 129 additions and 86 deletions

View File

@ -277,11 +277,11 @@
<view class="shop_sku_box_name">
{{item.name}}
</view>
<view class="flex-start">
<view class="flex-start" >
<view class="shop_sku_box_item" v-for="(item1,index1) in item.children" :key="index1"
@click="morloe(item1,index,index1,item)" :style="{color:!item1.isGrounding?'#999':''}"
:class=" item.start == index1 ?'shop_sku_box_item_selected':''">
{{item1.info}}
{{item1.name}}
</view>
</view>
</view>
@ -347,6 +347,7 @@
shopInfo: {}, //
shopProductList: {}, //
specifications: {}, //
querySpecList: [],
socketTicket: null,
amountcartNumber: 0,
isSpec: false,
@ -417,6 +418,7 @@
this.fixedtrue = true
},
onShow() {
let _this = this;
this.orderdetailFlag = true;
uni.pageScrollTo({
scrollTop: 0,
@ -442,48 +444,7 @@
uni.cache.set('userInfo', res.data.userInfo);
uni.$on('message', this.getMessage)
uni.getLocation({
type: 'wgs84',
success: async (res) => {
let successres = await this.api.geocodelocation({
lng: res.longitude,
lat: res.latitude,
})
if (successres.code == 0) {
let datastorage = {
country: successres.data.addressComponent.country, // ""
province: successres.data.addressComponent.province, //province: "西"
address: successres.data.addressComponent.city, //district: "西"
district: successres.data.addressComponent.district, //district: ""
lng: res.longitude,
lat: res.latitude,
}
uni.cache.set('getLocationstorage', datastorage);
this.productqueryShop();
}
},
fail: async (err) => {
console.log(err, '获取错误') //app
let successres = await this.api.geocodelocation({
lng: '',
lat: '',
})
if (successres.code == 0) {
console.log(successres.data.addressComponent.streetNumber.location.split(','))
let res = successres.data.addressComponent.streetNumber.location.split(',')
let datastorage = {
country: successres.data.addressComponent.country, // ""
province: successres.data.addressComponent.province, //province: "西"
address: successres.data.addressComponent.city, //district: "西"
district: successres.data.addressComponent.district, //district: ""
lng: res[0],
lat: res[1],
}
uni.cache.set('getLocationstorage', datastorage);
this.productqueryShop();
}
}
});
_this.getLocation()
}
},
fail: (err) => {}
@ -493,7 +454,7 @@
});
} else {
uni.$on('message', this.getMessage)
this.productqueryShop();
_this.getLocation()
}
},
methods: {
@ -520,6 +481,54 @@
"type": "connect",
})
},
/**
* 获取定位
*/
getLocation () {
uni.getLocation({
type: 'wgs84',
success: async (res) => {
let successres = await this.api.geocodelocation({
lng: res.longitude,
lat: res.latitude,
})
if (successres.code == 0) {
let datastorage = {
country: successres.data.addressComponent.country, // ""
province: successres.data.addressComponent.province, //province: "西"
address: successres.data.addressComponent.city, //district: "西"
district: successres.data.addressComponent.district, //district: ""
lng: res.longitude,
lat: res.latitude,
}
uni.cache.set('getLocationstorage', datastorage);
this.productqueryShop();
}
},
fail: async (err) => {
console.log(err, '获取错误') //app
let successres = await this.api.geocodelocation({
lng: '',
lat: '',
})
if (successres.code == 0) {
console.log(successres.data.addressComponent.streetNumber.location.split(','))
let res = successres.data.addressComponent.streetNumber.location.split(',')
let datastorage = {
country: successres.data.addressComponent.country, // ""
province: successres.data.addressComponent.province, //province: "西"
address: successres.data.addressComponent.city, //district: "西"
district: successres.data.addressComponent.district, //district: ""
lng: res[0],
lat: res[1],
}
uni.cache.set('getLocationstorage', datastorage);
this.productqueryShop();
}
}
});
},
/**
* 通过桌码获取店铺信息
@ -736,28 +745,46 @@
} else {
//
this.isSpec = false;
let res = await this.api.productquerySpec({
let obj = await this.api.productquerySpec({
productId: item1.id, //id
querySpecList: [],
})
if (res.code == 0) {
this.specifications.tagSnap = res.data.map((item) => {
console.log(item)
let data = {
id: item1.id, //id
name: item.name,
start: -1,
children: item.value
}
// for (let i = 0; i < item.value.length; i++) {
// if ( item.value[i].isGrounding ) {
// data.start = i;
// break; //
// }
// }
return data
this.querySpecList = obj.data;
this.specifications.tagSnap = JSON.parse(item1.productSkuResult.tagSnap).map((item) => {
let res = {
id: item1.id, //id
name: item.name,
start: -1,
children: []
}
item.value.split(",").forEach((v,e)=>{
res.children.push({
name: v,
isGrounding: false
})
})
return res
})
//
let filteredJson;
let isSkuidname = [];
for (let o = 0; o < this.specifications.tagSnap[0].children.length; o++) {
isSkuidname = JSON.parse(JSON.stringify(this.skuidname));
isSkuidname.push(this.specifications.tagSnap[0].children[o].name)
//
console.log(isSkuidname);
filteredJson = this.querySpecList.filter(obj => obj.specSnap.indexOf(isSkuidname) == 0);
console.log(filteredJson);
for (let i = 0; i < filteredJson.length; i++) {
console.log(filteredJson[i].isGrounding)
if ( filteredJson[i].isGrounding ) {
this.specifications.tagSnap[0].children[o].isGrounding = true
break; //
}
}
}
this.skuBtnText = `您还没选择${this.specifications.tagSnap[0].name}`
// this.specifications.tagSnap.forEach((val, index, arr) => { //skuidname
@ -793,16 +820,20 @@
} else {
this.$set(this.specifications.tagSnap[index], 'start', -1)
}
// this.skuidname.splice(index, 1, e.info); //skuidname
this.specifications.tagSnap.forEach((v,i)=>{
if ( v.start >= 0 && v.start <= v.children.length) {
querySpecList.push({
name: v.name,
value: v.children[v.start].info
this.skuidname = [];
this.specifications.tagSnap.forEach((val, i, arr) => { //skuidname
if ( i > index ) {
val.children.forEach(( v1,e1)=>{
v1.isGrounding = false;
})
val.start = -1;
}
if ( val.start >= 0 ) {
this.skuidname.push(val.children[val.start].name)
}
})
// this.skuidname.splice(index, 1, e.info); //skuidname
for (let i = 0; i < this.specifications.tagSnap.length; i++) {
if (this.specifications.tagSnap[i].start < 0) {
this.isSpec = false;
@ -811,23 +842,35 @@
}
}
let res = await this.api.productquerySpec({
productId: item.id, //id
querySpecList: querySpecList,
})
if( res.code == 0 ){
res.data.forEach((v,e)=>{
this.$set(this.specifications.tagSnap[e], 'children', v.value)
})
}
console.log(this.specifications.tagSnap)
this.skuidname = [];
this.specifications.tagSnap.forEach((val, index, arr) => { //skuidname
console.log(val)
if ( val.start >= 0 ) {
this.skuidname.push(val.children[val.start].info)
let filteredJson;
let isSkuidname = [];
//
if ( this.specifications.tagSnap[index+1] ) {
for (let o = 0; o < this.specifications.tagSnap[index+1].children.length; o++) {
isSkuidname = JSON.parse(JSON.stringify(this.skuidname));
isSkuidname.push(this.specifications.tagSnap[index+1].children[o].name)
//
console.log(isSkuidname);
filteredJson = this.querySpecList.filter(obj => obj.specSnap.indexOf(isSkuidname) == 0);
console.log(filteredJson);
for (let i = 0; i < filteredJson.length; i++) {
console.log(filteredJson[i].isGrounding)
if ( filteredJson[i].isGrounding ) {
this.specifications.tagSnap[index+1].children[o].isGrounding = true
break; //
}
}
}
})
}
// res.data.forEach((v,e)=>{
// // this.$set(this.specifications.tagSnap[e], 'children', v.value)
// })
console.log(this.specifications.tagSnap)
this.$forceUpdate();
this.hodgepodge(item, 2)
},