多规格下架处理
This commit is contained in:
@@ -277,11 +277,11 @@
|
|||||||
<view class="shop_sku_box_name">
|
<view class="shop_sku_box_name">
|
||||||
{{item.name}}
|
{{item.name}}
|
||||||
</view>
|
</view>
|
||||||
<view class="flex-start">
|
<view class="flex-start" >
|
||||||
<view class="shop_sku_box_item" v-for="(item1,index1) in item.children" :key="index1"
|
<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':''}"
|
@click="morloe(item1,index,index1,item)" :style="{color:!item1.isGrounding?'#999':''}"
|
||||||
:class=" item.start == index1 ?'shop_sku_box_item_selected':''">
|
:class=" item.start == index1 ?'shop_sku_box_item_selected':''">
|
||||||
{{item1.info}}
|
{{item1.name}}
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@@ -347,6 +347,7 @@
|
|||||||
shopInfo: {}, //店铺信息
|
shopInfo: {}, //店铺信息
|
||||||
shopProductList: {}, //商品信息
|
shopProductList: {}, //商品信息
|
||||||
specifications: {}, // 规格信息
|
specifications: {}, // 规格信息
|
||||||
|
querySpecList: [],
|
||||||
socketTicket: null,
|
socketTicket: null,
|
||||||
amountcartNumber: 0,
|
amountcartNumber: 0,
|
||||||
isSpec: false,
|
isSpec: false,
|
||||||
@@ -417,6 +418,7 @@
|
|||||||
this.fixedtrue = true
|
this.fixedtrue = true
|
||||||
},
|
},
|
||||||
onShow() {
|
onShow() {
|
||||||
|
let _this = this;
|
||||||
this.orderdetailFlag = true;
|
this.orderdetailFlag = true;
|
||||||
uni.pageScrollTo({
|
uni.pageScrollTo({
|
||||||
scrollTop: 0,
|
scrollTop: 0,
|
||||||
@@ -442,48 +444,7 @@
|
|||||||
uni.cache.set('userInfo', res.data.userInfo);
|
uni.cache.set('userInfo', res.data.userInfo);
|
||||||
uni.$on('message', this.getMessage)
|
uni.$on('message', this.getMessage)
|
||||||
|
|
||||||
uni.getLocation({
|
_this.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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
fail: (err) => {}
|
fail: (err) => {}
|
||||||
@@ -493,7 +454,7 @@
|
|||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
uni.$on('message', this.getMessage)
|
uni.$on('message', this.getMessage)
|
||||||
this.productqueryShop();
|
_this.getLocation()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@@ -520,6 +481,54 @@
|
|||||||
"type": "connect",
|
"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 {
|
} else {
|
||||||
// 多规格数据处理
|
// 多规格数据处理
|
||||||
this.isSpec = false;
|
this.isSpec = false;
|
||||||
let res = await this.api.productquerySpec({
|
let obj = await this.api.productquerySpec({
|
||||||
productId: item1.id, //商品id
|
productId: item1.id, //商品id
|
||||||
querySpecList: [],
|
|
||||||
})
|
})
|
||||||
if (res.code == 0) {
|
this.querySpecList = obj.data;
|
||||||
this.specifications.tagSnap = res.data.map((item) => {
|
this.specifications.tagSnap = JSON.parse(item1.productSkuResult.tagSnap).map((item) => {
|
||||||
console.log(item)
|
let res = {
|
||||||
let data = {
|
id: item1.id, //商品id
|
||||||
id: item1.id, //商品id
|
name: item.name,
|
||||||
name: item.name,
|
start: -1,
|
||||||
start: -1,
|
children: []
|
||||||
children: item.value
|
}
|
||||||
}
|
item.value.split(",").forEach((v,e)=>{
|
||||||
// for (let i = 0; i < item.value.length; i++) {
|
res.children.push({
|
||||||
// if ( item.value[i].isGrounding ) {
|
name: v,
|
||||||
// data.start = i;
|
isGrounding: false
|
||||||
// break; // 终止循环
|
})
|
||||||
// }
|
|
||||||
// }
|
|
||||||
return data
|
|
||||||
})
|
})
|
||||||
|
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.skuBtnText = `您还没选择${this.specifications.tagSnap[0].name}哦`
|
||||||
|
|
||||||
// this.specifications.tagSnap.forEach((val, index, arr) => { //初始化skuidname的数据 选择第一个
|
// this.specifications.tagSnap.forEach((val, index, arr) => { //初始化skuidname的数据 选择第一个
|
||||||
@@ -793,16 +820,20 @@
|
|||||||
} else {
|
} else {
|
||||||
this.$set(this.specifications.tagSnap[index], 'start', -1)
|
this.$set(this.specifications.tagSnap[index], 'start', -1)
|
||||||
}
|
}
|
||||||
// this.skuidname.splice(index, 1, e.info); //替换skuidname的数据
|
this.skuidname = [];
|
||||||
this.specifications.tagSnap.forEach((v,i)=>{
|
this.specifications.tagSnap.forEach((val, i, arr) => { //初始化skuidname的数据 选择第一个
|
||||||
if ( v.start >= 0 && v.start <= v.children.length) {
|
if ( i > index ) {
|
||||||
querySpecList.push({
|
val.children.forEach(( v1,e1)=>{
|
||||||
name: v.name,
|
v1.isGrounding = false;
|
||||||
value: v.children[v.start].info
|
|
||||||
})
|
})
|
||||||
|
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++) {
|
for (let i = 0; i < this.specifications.tagSnap.length; i++) {
|
||||||
if (this.specifications.tagSnap[i].start < 0) {
|
if (this.specifications.tagSnap[i].start < 0) {
|
||||||
this.isSpec = false;
|
this.isSpec = false;
|
||||||
@@ -811,23 +842,35 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let res = await this.api.productquerySpec({
|
|
||||||
productId: item.id, //商品id
|
let filteredJson;
|
||||||
querySpecList: querySpecList,
|
let isSkuidname = [];
|
||||||
})
|
//提前下一列规格循环,查看是否有下架规格
|
||||||
if( res.code == 0 ){
|
if ( this.specifications.tagSnap[index+1] ) {
|
||||||
res.data.forEach((v,e)=>{
|
for (let o = 0; o < this.specifications.tagSnap[index+1].children.length; o++) {
|
||||||
this.$set(this.specifications.tagSnap[e], 'children', v.value)
|
isSkuidname = JSON.parse(JSON.stringify(this.skuidname));
|
||||||
})
|
isSkuidname.push(this.specifications.tagSnap[index+1].children[o].name)
|
||||||
}
|
//筛选符合条件的规格列表
|
||||||
console.log(this.specifications.tagSnap)
|
console.log(isSkuidname);
|
||||||
this.skuidname = [];
|
filteredJson = this.querySpecList.filter(obj => obj.specSnap.indexOf(isSkuidname) == 0);
|
||||||
this.specifications.tagSnap.forEach((val, index, arr) => { //初始化skuidname的数据 选择第一个
|
console.log(filteredJson);
|
||||||
console.log(val)
|
for (let i = 0; i < filteredJson.length; i++) {
|
||||||
if ( val.start >= 0 ) {
|
console.log(filteredJson[i].isGrounding)
|
||||||
this.skuidname.push(val.children[val.start].info)
|
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.$forceUpdate();
|
||||||
this.hodgepodge(item, 2)
|
this.hodgepodge(item, 2)
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user