Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
U
user
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hooloo
mp
user
Commits
55934b43
Commit
55934b43
authored
Jun 30, 2022
by
宋冰琦
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复商品详情售罄刷新问题
parent
d677557b
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
70 additions
and
25 deletions
+70
-25
components/menuAssembly/index.vue
+47
-23
menuSubPackage/pages/goodsDetail/goodsDetail.vue
+16
-1
pages/menu/menu.vue
+2
-1
store/modules/menu.js
+5
-0
No files found.
components/menuAssembly/index.vue
View file @
55934b43
...
...
@@ -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
);
// 删除没有商品的分类
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
();
})
//
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();
//
})
},
getallNum
(
item
,
category
)
{
this
.
$emit
(
'getallNum'
,
item
,
category
)
...
...
@@ -385,7 +408,8 @@ export default {
}
.box
:last-child
{
padding-bottom
:
590
rpx
;
//
padding-bottom
:
590
rpx
;
height
:
100%
;
}
.nav-right-item
image
{
...
...
menuSubPackage/pages/goodsDetail/goodsDetail.vue
View file @
55934b43
...
...
@@ -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'
)
{
...
...
pages/menu/menu.vue
View file @
55934b43
...
...
@@ -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)
}
},
// 加入购物车数据
...
...
store/modules/menu.js
View file @
55934b43
...
...
@@ -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
:
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment