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
2837aad0
Commit
2837aad0
authored
Jun 22, 2022
by
songbingqi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复部分bug
parent
34c2268d
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
106 additions
and
29 deletions
+106
-29
components/menuAssembly/index.vue
+18
-3
menuSubPackage/pages/goodsDetail/goodsDetail.vue
+21
-8
orderSubPackage/pages/orderInfo/index.vue
+14
-2
pages/menu/menu.vue
+40
-14
pages/order/order.vue
+1
-0
request/order/index.js
+11
-1
utils/utils.js
+1
-1
No files found.
components/menuAssembly/index.vue
View file @
2837aad0
...
...
@@ -40,6 +40,7 @@
</view>
</view>
</scroll-view>
<show-toast
ref=
"toast"
/>
</view>
</
template
>
...
...
@@ -133,9 +134,19 @@ export default {
});
},
cart
:
(
item
,
category
)
=>
{
uni
.
setStorageSync
(
'goodsInfo'
,
JSON
.
stringify
({
...
item
,
category
}));
uni
.
navigateTo
({
url
:
'/menuSubPackage/pages/goodsDetail/goodsDetail'
})
cart
(
item
,
category
){
console
.
log
(
item
)
const
skuStatus
=
item
.
skus
.
filter
(
item
=>
{
return
Number
(
item
.
state
)
===
1
})
if
(
skuStatus
.
length
===
0
){
this
.
showToast
({
title
:
'该商品已售罄'
,
icon
:
'none'
,
})
}
else
{
uni
.
setStorageSync
(
'goodsInfo'
,
JSON
.
stringify
({
...
item
,
category
}));
uni
.
navigateTo
({
url
:
'/menuSubPackage/pages/goodsDetail/goodsDetail'
})
}
}
}
}
...
...
@@ -553,6 +564,10 @@ export default {
}
.box
:last-child
{
padding-bottom
:
590
rpx
;
}
.nav-right-item
image
{
width
:
150
rpx
;
height
:
150
rpx
;
...
...
menuSubPackage/pages/goodsDetail/goodsDetail.vue
View file @
2837aad0
...
...
@@ -86,6 +86,7 @@
<
script
>
import
Utils
from
'@/utils/utils'
import
User
from
'@/request/user'
;
import
Order
from
'@/request/order'
export
default
{
data
()
{
return
{
...
...
@@ -251,24 +252,36 @@ export default {
this
.
size
=
size
-
1
;
}
},
shoppingCart
()
{
async
shoppingCart
()
{
if
(
this
.
checkNum
(
'addShop'
)){
const
{
goods
}
=
this
;
goods
.
num
=
this
.
size
;
Utils
.
getallNum
(
goods
)
uni
.
switchTab
({
url
:
'/pages/menu/menu'
})
const
{
data
}
=
await
Order
.
checkSku
({
skuId
:
goods
.
skuId
})
if
(
data
.
data
&&
data
.
data
.
state
===
2
){
this
.
showToast
({
title
:
'本商品已经售罄'
,
icon
:
'none'
});
return
;
}
else
{
goods
.
num
=
this
.
size
;
Utils
.
getallNum
(
goods
)
uni
.
switchTab
({
url
:
'/pages/menu/menu'
})
}
}
},
getallNum
(
e
)
{
async
getallNum
(
e
)
{
let
Authorization
=
uni
.
getStorageSync
(
'Authorization'
);
if
(
!
Authorization
)
{
this
.
loginByPhoneNumber
(
e
);
return
}
const
{
goods
}
=
this
;
goods
.
num
=
this
.
size
Utils
.
addGoods
(
goods
)
uni
.
navigateTo
({
url
:
`/orderSubPackage/pages/settlement/index?buyType=1&goodsList=1`
})
const
{
data
}
=
await
Order
.
checkSku
({
skuId
:
goods
.
skuId
})
if
(
data
.
data
&&
data
.
data
.
state
===
2
){
this
.
showToast
({
title
:
'本商品已经售罄'
,
icon
:
'none'
});
return
;
}
else
{
goods
.
num
=
this
.
size
Utils
.
addGoods
(
goods
)
uni
.
navigateTo
({
url
:
`/orderSubPackage/pages/settlement/index?buyType=1&goodsList=1`
})
}
},
// 付款前未登录发起授权
loginByPhoneNumber
(
e
)
{
...
...
orderSubPackage/pages/orderInfo/index.vue
View file @
2837aad0
...
...
@@ -106,7 +106,7 @@
</view>
</button>
</div>
<show-toast
ref=
"toast"
/>
</div>
</
template
>
...
...
@@ -154,13 +154,25 @@ export default {
orderDetails
[
item
.
skuId
]
=
item
.
num
})
const
{
data
}
=
await
Order
.
moreOrder
({
orderId
:
id
,
shopId
});
if
(
!
data
||
!
data
.
data
){
this
.
showToast
({
title
:
"该订单中的商品已经售罄了"
});
return
;
}
let
list
=
new
Array
();
data
.
data
.
forEach
(
item
=>
{
const
skuId
=
item
.
skus
[
0
].
skuId
const
nextData
=
{
...
item
,
skuId
,
num
:
orderDetails
[
skuId
],
flag
:
true
,
sku
:
item
.
skus
[
0
]
}
if
(
nextData
.
sku
.
state
==
1
)
{
Utils
.
getallNum
(
nextData
)
list
.
push
(
nextData
);
}
});
if
(
!
list
||
list
.
length
<=
0
)
{
this
.
showToast
({
title
:
"该订单中的商品已经售罄了"
,
icon
:
'error'
});
return
;
}
list
.
forEach
(
nextData
=>
{
Utils
.
getallNum
(
nextData
);
})
uni
.
switchTab
({
url
:
'/pages/menu/menu'
})
},
async
PayNow
()
{
...
...
pages/menu/menu.vue
View file @
2837aad0
...
...
@@ -116,17 +116,7 @@ export default {
this
.
$refs
.
shopbar
.
showShopCar
=
false
;
},
async
onShow
()
{
if
(
!
this
.
userms
)
return
;
const
res
=
await
Order
.
getHomeOrder
()
const
data
=
res
?.
data
if
(
data
?.
data
)
{
// this.$set(data.data, 'state', '2');
// console.log("getHomeOrder:"+JSON.stringify(data.data));
this
.
buied
=
true
;
this
.
orderInfo
=
data
.
data
}
else
{
this
.
buied
=
false
}
},
methods
:
{
getShopMenus
(
params
)
{
...
...
@@ -139,10 +129,25 @@ export default {
$EventBus
.
$emit
(
'updateCar'
);
}
this
.
shopInfo
=
data
;
uni
.
setStorageSync
(
"shopInfo"
,
JSON
.
stringify
(
this
.
shopInfo
))
this
.
getMenuList
(
data
.
id
);
this
.
getHomeOrder
(
data
.
id
)
});
User
.
getShopInfo
(
params
);
},
async
getHomeOrder
(
id
){
if
(
!
this
.
userms
)
return
;
const
res
=
await
Order
.
getHomeOrder
({
shopId
:
id
})
const
data
=
res
?.
data
if
(
data
?.
data
)
{
// this.$set(data.data, 'state', '2');
// console.log("getHomeOrder:"+JSON.stringify(data.data));
this
.
buied
=
true
;
this
.
orderInfo
=
data
.
data
}
else
{
this
.
buied
=
false
}
},
openQrcode
()
{
// 不生成二维码
if
([
'2'
,
'3'
].
indexOf
(
this
.
orderInfo
.
state
)
!=
-
1
){
...
...
@@ -256,13 +261,17 @@ export default {
}
},
// 加入购物车数据
getallNum
(
item
,
category
)
{
async
getallNum
(
item
,
category
)
{
let
itemCopy
=
JSON
.
parse
(
JSON
.
stringify
(
item
));
const
sku
=
itemCopy
.
skus
.
find
(
v
=>
v
.
isDefault
==
1
&&
v
.
state
!=
2
)
||
itemCopy
.
skus
.
find
(
v
=>
v
.
isDefault
==
0
&&
v
.
state
!=
2
);
if
(
!
sku
)
{
const
{
data
}
=
await
Order
.
checkSku
({
skuId
:
sku
.
skuId
})
if
(
data
.
data
&&
data
.
data
.
state
===
2
){
this
.
showToast
({
title
:
'本商品已经售罄'
,
icon
:
'none'
});
return
;
}
else
{
}
else
{
if
(
sku
.
isDefault
!=
1
){
this
.
showToast
({
title
:
'默认规格已售罄,已添加其他规格'
,
icon
:
'none'
});
}
itemCopy
.
skus
=
[
sku
];
itemCopy
.
sku
=
sku
itemCopy
.
skuId
=
sku
?.
skuId
...
...
@@ -272,6 +281,23 @@ export default {
itemCopy
.
goodsName
=
category
.
name
;
Utils
.
getallNum
(
itemCopy
);
}
return
// if (!sku) {
// this.showToast({ title: '本商品已经售罄', icon: 'none' });
// return;
// } else {
// if(sku.isDefault != 1){
// this.showToast({ title: '默认规格已售罄,已添加其他规格', icon: 'none' });
// }
// itemCopy.skus = [sku];
// itemCopy.sku = sku
// itemCopy.skuId = sku?.skuId
// itemCopy.num = 1;
// itemCopy.flag = true;
// itemCopy.categoryId = category.id;
// itemCopy.goodsName = category.name;
// Utils.getallNum(itemCopy);
// }
},
goToMyPage
(
logined
)
{
logined
&&
uni
.
switchTab
({
url
:
'/pages/mine/mine'
})
...
...
pages/order/order.vue
View file @
2837aad0
...
...
@@ -258,6 +258,7 @@ export default {
}
.empty_button
::after
{
border-radius
:
0
rpx
;
border
:
0
rpx
;
}
}
...
...
request/order/index.js
View file @
2837aad0
...
...
@@ -67,7 +67,7 @@ export default {
},
getHomeOrder
(
params
)
{
return
uni
.
$u
.
http
.
get
(
'/app/getHomeOrder'
,
{
.
get
(
`/app/getHomeOrder?shopId=
${
params
.
shopId
}
`
,
{
params
:
{},
})
.
then
((
res
)
=>
res
)
...
...
@@ -96,4 +96,14 @@ export default {
console
.
log
(
'服务器错误'
);
});
},
checkSku
(
params
)
{
const
shopInfo
=
JSON
.
parse
(
uni
.
getStorageSync
(
'shopInfo'
))
return
uni
.
$u
.
http
.
get
(
`/application/checkSku?shopId=
${
shopInfo
.
id
}
&skuId=
${
params
.
skuId
}
`
)
.
then
((
res
)
=>
res
)
.
catch
((
err
)
=>
{
// uni.showToast({ title: '服务器错误', icon: 'none' })
console
.
log
(
'服务器错误'
);
});
}
};
utils/utils.js
View file @
2837aad0
...
...
@@ -167,5 +167,5 @@ export default {
}
else
{
return
val
.
toFixed
(
1
)
}
}
}
,
};
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