Commit 55934b43 by 宋冰琦

修复商品详情售罄刷新问题

parent d677557b
......@@ -56,7 +56,6 @@ export default {
'--scroll-height': 0
},
Utils,
classifyData: [],
categoryId: '',
categoryPostion: [],
scrollLeftTop: 0,
......@@ -79,6 +78,30 @@ export default {
}
}
},
computed:{
classifyData(){
const categorys = JSON.parse(JSON.stringify(this.$store.state.menu.setMenuCategorys))
// 删除没有商品的分类
if(categorys) {
for(var i=categorys.length-1; i>=0; i--) {
var category = categorys[i];
if(!category.goods || category.goods.length<=0) {
categorys.splice(i, 1);
}
}
if(categorys.length>0){
this.categoryId = categorys[0].id;
}
}
this.$nextTick(() => {
const query = uni.createSelectorQuery().in(this);
query.selectAll('.box').boundingClientRect(data => {
this.categoryPostion = data
}).exec();
})
return categorys
}
},
created() {
$EventBus.$off('updateCar');
},
......@@ -105,27 +128,27 @@ export default {
return sku;
},
createList(data) {
this.classifyData = data;
console.log(this.classifyData);
// this.classifyData = data;
// console.log(this.classifyData);
// 删除没有商品的分类
if(this.classifyData) {
for(var i=this.classifyData.length-1; i>=0; i--) {
var category = this.classifyData[i];
if(!category.goods || category.goods.length<=0) {
this.classifyData.splice(i, 1);
}
}
if(this.classifyData.length>0){
this.categoryId = this.classifyData[0].id;
}
}
this.$nextTick(() => {
const query = uni.createSelectorQuery().in(this);
query.selectAll('.box').boundingClientRect(data => {
this.categoryPostion = data
}).exec();
})
// // 删除没有商品的分类
// if(this.classifyData) {
// for(var i=this.classifyData.length-1; i>=0; i--) {
// var category = this.classifyData[i];
// if(!category.goods || category.goods.length<=0) {
// this.classifyData.splice(i, 1);
// }
// }
// if(this.classifyData.length>0){
// this.categoryId = this.classifyData[0].id;
// }
// }
// this.$nextTick(() => {
// const query = uni.createSelectorQuery().in(this);
// query.selectAll('.box').boundingClientRect(data => {
// this.categoryPostion = data
// }).exec();
// })
},
getallNum(item, category) {
this.$emit('getallNum', item, category)
......@@ -385,7 +408,8 @@ export default {
}
.box:last-child{
padding-bottom: 590rpx;
// padding-bottom: 590rpx;
height: 100%;
}
.nav-right-item image {
......
......@@ -84,6 +84,7 @@
import Utils from '@/utils/utils'
import User from '@/request/user';
import Order from '@/request/order'
import Menu from '@/request/menu'
export default {
data() {
return {
......@@ -298,13 +299,14 @@ export default {
if(state == 2){
this.showToast({ title: '本商品已经售罄', icon: 'none' });
this.getMenuList()
return;
}else{
goods.num = this.size;
Utils.getallNum(goods)
uni.switchTab({ url: '/pages/menu/menu' })
}
return
// return
// const { data } = await Order.checkSku({skuId:goods.skuId})
// else{
// goods.num = this.size;
......@@ -332,6 +334,7 @@ export default {
if(state == 2){
this.showToast({ title: '本商品已经售罄', icon: 'none' });
this.getMenuList()
return;
}else{
goods.num = this.size
......@@ -339,6 +342,18 @@ export default {
uni.navigateTo({ url: `/orderSubPackage/pages/settlement/index?buyType=1&goodsList=1` })
}
},
async getMenuList() {
const shopId = uni.getStorageSync('shopData').id
let { data } = await Menu.getMenuList(shopId);
// console.log("menus:"+JSON.stringify(data));
if (data.code == 200) {
data.data = data.data;
this.$store.commit('setMenuAllInfo', data.data);
this.$store.commit('setMenuCategorys', data.data.categorys);
uni.setStorageSync('countOfOrder', parseInt(data.data.countOfOrder));
// this.$refs.MenuAssembly.createList(data.data.categorys)
}
},
// 付款前未登录发起授权
loginByPhoneNumber(e) {
if (e.detail.errMsg == 'getPhoneNumber:ok') {
......
......@@ -259,8 +259,9 @@ export default {
if (data.code == 200) {
data.data = data.data;
this.$store.commit('setMenuAllInfo', data.data);
this.$store.commit('setMenuCategorys', data.data.categorys);
uni.setStorageSync('countOfOrder', parseInt(data.data.countOfOrder));
this.$refs.MenuAssembly.createList(data.data.categorys)
// this.$refs.MenuAssembly.createList(data.data.categorys)
}
},
// 加入购物车数据
......
......@@ -3,6 +3,7 @@ const menu = {
state: {
menuAllInfo: null, //菜单信息
orderPrePayInfo: null, //(需要和购物车数据格式一致)
setMenuCategorys:[]
},
mutations: {
// 设置用户菜单信息
......@@ -13,6 +14,10 @@ const menu = {
saveOrderPrePayInfo(state, orderPrePayInfo) {
state.orderPrePayInfo = orderPrePayInfo;
},
// 设置首页商品信息
setMenuCategorys(state, setMenuCategorys){
state.setMenuCategorys = setMenuCategorys
}
},
actions: {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment