多规格下架处理
This commit is contained in:
parent
83aeb25652
commit
3b3a08d460
|
|
@ -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)
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in New Issue