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
4c9ddc05
Commit
4c9ddc05
authored
May 16, 2022
by
zhangcheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
调整页面bug
parent
c0519cc6
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
446 additions
and
72 deletions
+446
-72
components/shopCar/shopCar.vue
+39
-32
menuSubPackage/pages/goodsDetail/goodsDetail.vue
+347
-6
menuSubPackage/pages/settlement/settlement.vue
+7
-7
pages.json
+1
-0
pages/index/index.vue
+1
-1
pages/menu/menu.vue
+5
-10
request/menu/index.js
+35
-16
utils/utils.js
+11
-0
No files found.
components/shopCar/shopCar.vue
View file @
4c9ddc05
...
@@ -57,10 +57,14 @@
...
@@ -57,10 +57,14 @@
<text
style=
"color:#000000;font-weight: bold;font-size: 28rpx;display: flex; margin-left: 30rpx; align-items: center;"
>
¥
{{
totalPrice
.
toFixed
(
2
)
}}
</text>
<text
style=
"color:#000000;font-weight: bold;font-size: 28rpx;display: flex; margin-left: 30rpx; align-items: center;"
>
¥
{{
totalPrice
.
toFixed
(
2
)
}}
</text>
</view>
</view>
</view>
</view>
<view
class=
"end-right"
@
click=
"saveReserve"
>
<view
class=
"end-right"
@
click=
"saveReserve"
v-if=
"userms"
>
付款
付款
<!-- (
{{
totalNum
}}
) -->
<!-- (
{{
totalNum
}}
) -->
</view>
</view>
<button
v-if=
"!userms"
class=
"end-right"
style=
"border-radius: 0;"
open-type=
"getPhoneNumber"
@
getphonenumber=
"saveReserve"
>
付款
<!-- (
{{
totalNum
}}
) -->
</button>
</view>
</view>
...
@@ -70,6 +74,7 @@
...
@@ -70,6 +74,7 @@
<
script
>
<
script
>
import
{
$EventBus
}
from
"../../utils/EventBus"
;
import
{
$EventBus
}
from
"../../utils/EventBus"
;
import
Menu
from
'@/request/menu'
;
import
Menu
from
'@/request/menu'
;
import
User
from
'@/request/user'
;
export
default
{
export
default
{
data
(){
data
(){
return
{
return
{
...
@@ -111,46 +116,31 @@
...
@@ -111,46 +116,31 @@
this
.
showShopCar
=
false
;
this
.
showShopCar
=
false
;
},
},
//跳转到结算
//跳转到结算
saveReserve
()
{
saveReserve
(
e
)
{
let
Authorization
=
uni
.
getStorageSync
(
'Authorization'
);
let
Authorization
=
uni
.
getStorageSync
(
'Authorization'
);
let
shopCarInfo
=
uni
.
getStorageSync
(
'shopCarInfo'
).
filter
(
v
=>
v
.
flag
==
true
);
let
shopCarInfo
=
uni
.
getStorageSync
(
'shopCarInfo'
).
filter
(
v
=>
v
.
flag
==
true
);
if
(
shopCarInfo
&&
this
.
totalPrice
>
0
&&
this
.
totalNum
>
0
){
if
(
shopCarInfo
&&
this
.
totalPrice
>
0
&&
this
.
totalNum
>
0
){
// let orderDetails=[];
// shopCarInfo.forEach((item)=>{
// let res = {
// goodsId:item.goodsId,//商品id
// goodsName:item.name,//商品名称
// machineId:undefined,//点单屏机器ID
// num:item.num,//当前sku数量
// realAmount:item.skus[0].price*item.num,//实付金额
// specRuleDetail:JSON.stringify(item.skus[0].rules),//规格选项详情
// skuId:item.skus[0].skuId,//"sku ID"
// goodsCategory:item.categoryId//商品分类
// };
// orderDetails.push(res);
// });
// let DAta={
// amount:this.totalPrice,//商品总金额
// goodsNum:this.totalNum,//商品总数量
// shopId:this.$store.getters.shopInfo[0].id,//店铺
// machineId:undefined,//机器ID
// source:3,//小程序固定传3
// orderDetails:orderDetails
// }
// let res = Menu.saveReserve(DAta);
if
(
Authorization
){
if
(
Authorization
){
// 从购物车发起:
pa
yType=1;
// 从购物车发起:
bu
yType=1;
// 立即购买:
pa
yType=2;
// 立即购买:
bu
yType=2;
// 扫码进入:
pa
yType=3;
// 扫码进入:
bu
yType=3;
uni
.
navigateTo
({
uni
.
navigateTo
({
url
:
`/menuSubPackage/pages/settlement/settlement?totalPrice=
${
this
.
totalPrice
}
&totalNum=
${
this
.
totalNum
}
&
pa
yType=1`
url
:
`/menuSubPackage/pages/settlement/settlement?totalPrice=
${
this
.
totalPrice
}
&totalNum=
${
this
.
totalNum
}
&
bu
yType=1`
})
})
}
else
{
}
else
{
this
.
loginByPhoneNumber
(
e
)
}
}
}
}
return
;
return
;
},
},
// 付款前未登录发起授权
loginByPhoneNumber
(
e
)
{
if
(
e
.
detail
.
errMsg
==
'getPhoneNumber:ok'
){
User
.
getPhoneNumber
(
e
);
}
else
if
(
e
.
detail
.
errMsg
==
"getPhoneNumber:fail user deny"
){
uni
.
showToast
({
title
:
'已拒绝手机号授权'
,
icon
:
'error'
})
}
},
change
(
e
){
change
(
e
){
console
.
log
(
e
)
console
.
log
(
e
)
},
},
...
@@ -191,12 +181,26 @@
...
@@ -191,12 +181,26 @@
uni
.
setStorageSync
(
'shopCarInfo'
,
this
.
goods
);
uni
.
setStorageSync
(
'shopCarInfo'
,
this
.
goods
);
},
},
add
(
item
){
add
(
item
){
let
s
=
0
;
this
.
goods
.
forEach
(
function
(
val
)
{
s
+=
val
.
num
;
},
0
);
if
(
s
>=
9
){
uni
.
showToast
({
title
:
'最多可一次购买9杯'
,
icon
:
'none'
});
return
;
}
let
num
=
item
.
num
let
num
=
item
.
num
item
.
num
=
num
+
1
item
.
num
=
num
+
1
uni
.
setStorageSync
(
'shopCarInfo'
,
this
.
goods
);
uni
.
setStorageSync
(
'shopCarInfo'
,
this
.
goods
);
}
}
},
},
computed
:{
computed
:{
userms
()
{
return
this
.
$store
.
getters
.
Authorization
;
},
totalNum
(){
totalNum
(){
let
totalNum
=
0
;
let
totalNum
=
0
;
this
.
goods
.
map
(
item
=>
{
this
.
goods
.
map
(
item
=>
{
...
@@ -392,11 +396,14 @@
...
@@ -392,11 +396,14 @@
}
}
}
}
&
-right
{
&
-right
{
width
:
30%
;
width
:
169
rpx
;
line-height
:
90
rpx
;
font-size
:
32
rpx
;
line-height
:
92
rpx
;
background-color
:
#006ECF
;
background-color
:
#006ECF
;
text-align
:
center
;
text-align
:
center
;
color
:
#fff
;
color
:
#fff
;
font-family
:
PingFangSC-Medium
,
PingFang
SC
;
font-weight
:
500
;
}
}
}
}
</
style
>
</
style
>
menuSubPackage/pages/goodsDetail/goodsDetail.vue
View file @
4c9ddc05
<
template
>
<
template
>
<view>
详情页
<view
class=
"spec-content"
>
<view
class=
"uni-margin-wrap"
>
<swiper
class=
"swiper"
circular
autoplay
>
<swiper-item
v-for=
"item in goodInfo.pics.introImages"
>
<view
class=
"swiper-item"
>
<image
class=
"swiper-spec-content-item-img"
:src=
"item"
mode=
"widthFix"
></image>
</view>
</swiper-item>
</swiper>
</view>
<!--
<scroll-view
scroll-x=
"true"
>
<view
class=
"spec-banner-wrap"
scroll-x=
"true"
>
<view
class=
"spec-banner-wrap-item"
v-for=
"item in goodInfo.pics.introImages"
>
<image
class=
"spec-banner-wrap-item-img"
:src=
"item"
mode=
"widthFix"
></image>
</view>
</view>
</scroll-view>
-->
<view
class=
"good spec-info-left"
>
<text
class=
"good-name"
>
{{
goodInfo
.
name
}}
</text>
<view
v-for=
"specItem in goodInfo.specs"
>
<text
class=
"good-spec-name"
>
{{
specItem
.
specName
}}
</text>
<view
class=
"good-spec-rule"
>
<view
v-for=
"specItemRule in specItem.rules"
>
<text
class=
"good-spec-rule-item"
>
{{
specItemRule
.
ruleName
}}
</text>
</view>
</view>
</view>
</view>
<view
class=
"spec-detail"
>
<text
class=
"spec-detail-title spec-info-left"
>
商品详情
</text>
<view
class=
"spec-detail-img"
v-for=
"item in goodInfo.pics.detailImages"
>
<image
class=
".spec-detail-img-item "
:src=
"item"
mode=
"widthFix"
></image>
</view>
<view
class=
"good-select-height"
>
</view>
</view>
<view
class=
"good-select good-select-height"
>
<view
class=
"good-select-price"
>
<text
class=
"good-select-price-normal"
>
¥100
</text>
<text
class=
"good-select-price-small"
>
¥10
</text>
</view>
<view
class=
"good-select-cont"
>
<button
class=
"good-select-btn"
type=
"default"
>
立即购买
</button>
<button
class=
"good-select-btn"
type=
"default"
>
加入购物袋
</button>
</view>
</view>
</view>
</view>
</
template
>
</
template
>
...
@@ -8,15 +59,305 @@
...
@@ -8,15 +59,305 @@
export
default
{
export
default
{
data
()
{
data
()
{
return
{
return
{
title
:
'Hello1'
,
imglist
:[{
img
:
"/static/logo.png"
},{
img
:
"/static/ggxz01.png"
}],
goodInfo
:{
"goodId"
:
100
,
"name"
:
"冰茶咖啡"
,
"price"
:
29.9
,
"discount"
:
19.9
,
"pics"
:
{
"thumbnail"
:
"http://baidu.com"
,
"introImages"
:
[
"https://cdn.uviewui.com/uview/album/1.jpg"
,
"https://cdn.uviewui.com/uview/album/2.jpg"
,
"https://cdn.uviewui.com/uview/album/3.jpg"
],
"detailImages"
:
[
"https://cdn.uviewui.com/uview/album/4.jpg"
,
"https://cdn.uviewui.com/uview/album/5.jpg"
,
"https://cdn.uviewui.com/uview/album/6.jpg"
]
},
"desc"
:
""
,
"remark"
:
""
,
"tags"
:
[
"YYDS"
,
"杨幂同款"
],
"specs"
:
[
{
"rules"
:
[
{
"isDefault"
:
"1"
,
"isRecommend"
:
"0"
,
"price"
:
"2"
,
"ruleId"
:
"51"
,
"ruleName"
:
"冰"
},
{
"isDefault"
:
"0"
,
"isRecommend"
:
"0"
,
"price"
:
"1"
,
"ruleId"
:
"52"
,
"ruleName"
:
"热"
}
],
"specId"
:
"44"
,
"specName"
:
"温度"
},
{
"rules"
:
[
{
"isDefault"
:
"1"
,
"isRecommend"
:
"0"
,
"price"
:
"0"
,
"ruleId"
:
"53"
,
"ruleName"
:
"不加奶"
},
{
"isDefault"
:
"0"
,
"isRecommend"
:
"0"
,
"price"
:
"1"
,
"ruleId"
:
"54"
,
"ruleName"
:
"正常奶"
}
],
"specId"
:
"45"
,
"specName"
:
"加奶"
},
{
"rules"
:
[
{
"isDefault"
:
"1"
,
"isRecommend"
:
"0"
,
"price"
:
"0"
,
"ruleId"
:
"55"
,
"ruleName"
:
"不加糖"
},
{
"isDefault"
:
"0"
,
"isRecommend"
:
"0"
,
"price"
:
"1"
,
"ruleId"
:
"56"
,
"ruleName"
:
"半塘"
},
{
"isDefault"
:
"0"
,
"isRecommend"
:
"0"
,
"price"
:
"2"
,
"ruleId"
:
"57"
,
"ruleName"
:
"标准糖"
}
],
"specId"
:
"46"
,
"specName"
:
"糖度"
}
],
"skus"
:
[
{
"skuId"
:
1
,
"state"
:
1
,
"rules"
:
[
{
"specId"
:
1
,
"specName"
:
"温度"
,
"ruleId"
:
1
,
"ruleName"
:
"常温"
,
"price"
:
0.00
},
{
"specId"
:
2
,
"specName"
:
"糖度"
,
"ruleId"
:
3
,
"ruleName"
:
"无糖"
,
"price"
:
0.00
}
]
},
{
"skuId"
:
1
,
"state"
:
1
,
"rules"
:
[
{
"specId"
:
1
,
"specName"
:
"温度"
,
"ruleId"
:
2
,
"ruleName"
:
"冰"
,
"price"
:
2.00
},
{
"specId"
:
2
,
"specName"
:
"糖度"
,
"ruleId"
:
3
,
"ruleName"
:
"无糖"
,
"price"
:
0.00
}
]
},
{
"skuId"
:
1
,
"state"
:
1
,
"rules"
:
[
{
"specId"
:
1
,
"specName"
:
"温度"
,
"ruleId"
:
1
,
"ruleName"
:
"常温"
,
"price"
:
0.00
},
{
"specId"
:
2
,
"specName"
:
"糖度"
,
"ruleId"
:
3
,
"ruleName"
:
"加糖"
,
"price"
:
2.00
}
]
},
{
"skuId"
:
1
,
"state"
:
1
,
"rules"
:
[
{
"specId"
:
1
,
"specName"
:
"温度"
,
"ruleId"
:
1
,
"ruleName"
:
"冰"
,
"price"
:
2.00
},
{
"specId"
:
2
,
"specName"
:
"糖度"
,
"ruleId"
:
3
,
"ruleName"
:
"加糖"
,
"price"
:
4.00
}
]
}
]
}
}
}
},
},
onLoad
()
{
},
methods
:
{
methods
:
{
}
}
}
}
</
script
>
</
script
>
<
style
>
<
style
lang=
"scss"
>
.uni-margin-wrap
{
height
:
444
rpx
;
width
:
100%
;
background
:
#ff00f0
;
}
.swiper-spec-content
{
height
:
300
rpx
;
width
:
100%
;
}
.swiper-spec-content-item
{
display
:
block
;
height
:
300
rpx
;
line-height
:
300
rpx
;
text-align
:
center
;
}
.swiper-spec-content-item-img
{
height
:
100%
;
width
:
100%
;
}
.spec-content
{
}
.spec-info-left
{
padding
:
22
rpx
34
rpx
;
}
.good
{
display
:
block
;
width
:
100%
;
text-align
:
left
;
.good-name
{
font-size
:
32
rpx
;
font-family
:
PingFangSC-Semibold
,
PingFang
SC
;
font-weight
:
600
;
color
:
#000000
;
line-height
:
44
rpx
;
}
.good-spec-name
{
margin-top
:
22
rpx
;
color
:
rgba
(
0
,
0
,
0
,
1
);
font-size
:
28
rpx
;
text-align
:
left
;
line-height
:
40
rpx
;
font-weight
:
bold
;
}
.good-spec-rule
{
display
:
flex
;
flex-direction
:
row
;
justify-content
:
flex-start
;
margin-left
:
8
rpx
;
}
}
.good-spec-rule-item
{
font-size
:
24
rpx
;
margin-right
:
10
rpx
;
}
.spec-detail
{
width
:
100%
;
height
:
100%
;
}
.spec-detail-title
{
font-weight
:
bold
;
}
.spec-detail-img
{
display
:
flex
;
flex-direction
:
column
;
margin-top
:
0
rpx
;
margin-left
:
auto
;
margin-right
:
auto
;
margin-bottom
:
0
rpx
;
padding
:
0
rpx
;
justify-content
:
center
;
align-items
:
center
;
}
.spec-detail-img-item
{
width
:
100%
;
height
:
100%
;
}
.good-select-height
{
height
:
200
rpx
;
}
.good-select
{
width
:
90%
;
position
:
fixed
;
bottom
:
0
rpx
;
text-align
:
center
;
}
.good-select-price
{
display
:
flex
;
margin-top
:
20
rpx
;
justify-content
:
flex-start
;
align-items
:
flex-end
;
}
.good-select-price-normal
{
font-size
:
36
rpx
;
color
:
rgba
(
235
,
95
,
23
,
1
);
}
.good-select-price-small
{
font-size
:
20
rpx
;
text-decoration
:
line-through
;
}
.good-select-cont
{
margin-top
:
20
rpx
;
display
:
flex
;
flex-direction
:
row
;
align-items
:
center
;
justify-content
:
center
;
}
.good-select-btn
{
}
</
style
>
</
style
>
menuSubPackage/pages/settlement/settlement.vue
View file @
4c9ddc05
...
@@ -11,7 +11,7 @@ import Menu from '@/request/menu'
...
@@ -11,7 +11,7 @@ import Menu from '@/request/menu'
export
default
{
export
default
{
data
()
{
data
()
{
return
{
return
{
payType
:
0
,
//发起支付的页面标识//// 从购物车发起:payType=1;// 立即购买:payType=2;// 扫码进入:pa
yType=3;
buyType
:
0
,
//发起支付的页面标识//// 从购物车发起:buyType=1;// 立即购买:buyType=2;// 扫码进入:bu
yType=3;
orderId
:
null
,
//扫码进来的orderId
orderId
:
null
,
//扫码进来的orderId
viewData
:{},
//预支付数据订单数据
viewData
:{},
//预支付数据订单数据
totalPrice
:
0
,
//总金额
totalPrice
:
0
,
//总金额
...
@@ -19,8 +19,8 @@ import Menu from '@/request/menu'
...
@@ -19,8 +19,8 @@ import Menu from '@/request/menu'
}
}
},
},
onLoad
(
options
)
{
onLoad
(
options
)
{
if
(
options
.
pa
yType
){
if
(
options
.
bu
yType
){
this
.
payType
=
options
.
pa
yType
;
this
.
buyType
=
options
.
bu
yType
;
}
}
if
(
options
.
orderId
){
if
(
options
.
orderId
){
this
.
orderId
=
options
.
orderId
;
this
.
orderId
=
options
.
orderId
;
...
@@ -33,12 +33,12 @@ import Menu from '@/request/menu'
...
@@ -33,12 +33,12 @@ import Menu from '@/request/menu'
}
}
},
},
onShow
()
{
onShow
()
{
if
(
this
.
orderId
!=
null
&&
this
.
pa
yType
==
3
){
if
(
this
.
orderId
!=
null
&&
this
.
bu
yType
==
3
){
this
.
getOrderInfo
()
this
.
getOrderInfo
()
}
}
},
},
onUnload
(
event
){
onUnload
(
event
){
if
(
this
.
orderId
&&
this
.
pa
yType
==
3
){
if
(
this
.
orderId
&&
this
.
bu
yType
==
3
){
uni
.
switchTab
({
uni
.
switchTab
({
url
:
'/pages/menu/menu'
url
:
'/pages/menu/menu'
});
});
...
@@ -60,12 +60,12 @@ import Menu from '@/request/menu'
...
@@ -60,12 +60,12 @@ import Menu from '@/request/menu'
//结算组装数据发起订单
//结算组装数据发起订单
async
saveReserve
()
{
async
saveReserve
()
{
// 组装购物车数据或者立即支付数据
// 组装购物车数据或者立即支付数据
let
res
=
await
Utils
.
AssemblyOrder
(
this
.
totalPrice
,
this
.
totalNum
,
this
.
pa
yType
);
let
res
=
await
Utils
.
AssemblyOrder
(
this
.
totalPrice
,
this
.
totalNum
,
this
.
bu
yType
);
if
(
res
){
if
(
res
){
// 发起订单
// 发起订单
let
orderInfo
=
await
Menu
.
saveReserve
(
res
);
let
orderInfo
=
await
Menu
.
saveReserve
(
res
);
if
(
orderInfo
&&
orderInfo
.
data
.
code
==
200
){
if
(
orderInfo
&&
orderInfo
.
data
.
code
==
200
){
let
payMent
=
await
Menu
.
requestPayment
(
orderInfo
.
data
.
data
);
let
payMent
=
await
Menu
.
requestPayment
(
orderInfo
.
data
.
data
,
res
,
this
.
buyType
);
}
}
}
}
...
...
pages.json
View file @
4c9ddc05
...
@@ -46,6 +46,7 @@
...
@@ -46,6 +46,7 @@
"style"
:
"style"
:
{
{
"navigationBarTitleText"
:
""
,
"navigationBarTitleText"
:
""
,
"navigationStyle"
:
"custom"
,
"enablePullDownRefresh"
:
false
"enablePullDownRefresh"
:
false
}
}
...
...
pages/index/index.vue
View file @
4c9ddc05
...
@@ -36,7 +36,7 @@
...
@@ -36,7 +36,7 @@
this
.
$store
.
commit
(
'setAuthorization'
,
Authorization
);
this
.
$store
.
commit
(
'setAuthorization'
,
Authorization
);
if
(
this
.
id
!=
''
){
if
(
this
.
id
!=
''
){
uni
.
navigateTo
({
uni
.
navigateTo
({
url
:
`/menuSubPackage/pages/settlement/settlement?orderId=
${
this
.
id
}
&
pa
yType=3`
url
:
`/menuSubPackage/pages/settlement/settlement?orderId=
${
this
.
id
}
&
bu
yType=3`
})
})
}
else
{
}
else
{
uni
.
reLaunch
({
uni
.
reLaunch
({
...
...
pages/menu/menu.vue
View file @
4c9ddc05
...
@@ -177,16 +177,11 @@ import { $EventBus } from '@/utils/EventBus';
...
@@ -177,16 +177,11 @@ import { $EventBus } from '@/utils/EventBus';
},
},
// 手机号授权登录
// 手机号授权登录
getPhoneNumber
(
e
)
{
getPhoneNumber
(
e
)
{
// uni.exitMiniProgram({success: (res) => {}})
if
(
e
.
detail
.
errMsg
==
'getPhoneNumber:ok'
){
User
.
getPhoneNumber
(
e
,
this
.
orderId
);
if
(
e
.
detail
.
errMsg
==
'getPhoneNumber:ok'
){
}
else
if
(
e
.
detail
.
errMsg
==
"getPhoneNumber:fail user deny"
){
User
.
getPhoneNumber
(
e
,
this
.
orderId
);
uni
.
showToast
({
title
:
'已拒绝手机号授权'
,
icon
:
'error'
})
}
else
if
(
e
.
detail
.
errMsg
==
"getPhoneNumber:fail user deny"
){
}
uni
.
showToast
({
title
:
'已拒绝手机号授权'
,
icon
:
'error'
})
}
// console.log(e,333)
},
},
changeLocaltion
()
{
changeLocaltion
()
{
console
.
log
(
22345
)
console
.
log
(
22345
)
...
...
request/menu/index.js
View file @
4c9ddc05
...
@@ -38,30 +38,50 @@ export default {
...
@@ -38,30 +38,50 @@ export default {
})
})
},
},
// saveReserve 为业务接口
// saveReserve 为业务接口
requestPayment
(
data
)
{
requestPayment
(
data
,
oldData
,
buyType
)
{
const
{
errno
,
errmsg
,
res
}
=
data
;
// res为调起微信支付所需参数
// res为调起微信支付所需参数
if
(
errno
===
'0'
)
{
// 调起微信支付
// 调起微信支付
uni
.
requestPayment
({
uni
.
requestPayment
({
provider
:
'wxpay'
,
// 服务提提供商微信支付
provider
:
'wxpay'
,
// 服务提提供商微信支付
timeStamp
:
res
.
weChatPayData
.
times
tamp
,
// 时间戳
timeStamp
:
data
.
timeS
tamp
,
// 时间戳
nonceStr
:
res
.
weChatPayData
.
nonces
tr
,
// 随机字符串
nonceStr
:
data
.
nonceS
tr
,
// 随机字符串
package
:
res
.
weChatPayD
ata
.
package
,
package
:
d
ata
.
package
,
signType
:
res
.
weChatPayData
.
signt
ype
||
'MD5'
,
// 签名算法
signType
:
data
.
signT
ype
||
'MD5'
,
// 签名算法
paySign
:
res
.
weChatPayData
.
s
ign
,
// 签名
paySign
:
data
.
payS
ign
,
// 签名
success
:
function
(
res
)
{
success
:
function
(
res
)
{
console
.
log
(
'支付成功'
,
res
);
if
(
res
.
errMsg
==
'requestPayment:ok'
){
uni
.
showToast
({
title
:
'支付成功'
});
if
(
buyType
==
1
){
let
shopCarInfo
=
uni
.
getStorageSync
(
'shopCarInfo'
);
for
(
let
i
=
0
;
i
<
oldData
.
length
;
i
++
){
let
element
=
oldData
[
i
];
for
(
let
y
=
0
;
y
<
shopCarInfo
.
length
;
y
++
)
{
let
item
=
shopCarInfo
[
y
];
if
(
item
.
skus
[
0
].
skuId
===
element
.
skus
[
0
].
skuId
)
{
shopCarInfo
.
splice
(
index
,
1
);
}
}
}
// 删除购物车数据后重新放回购物车
uni
.
setStorageSync
(
'shopCarInfo'
,
shopCarInfo
);
$EventBus
.
$emit
(
'updateCar'
);
uni
.
navigateTo
({
url
:
'/page/menu/menu'
})
}
}
// 业务逻辑。。。
// 业务逻辑。。。
},
},
fail
:
function
(
err
)
{
fail
:
function
(
err
)
{
console
.
log
(
'支付失败'
,
err
);
uni
.
showToast
({
title
:
'支付失败'
,
icon
:
'error'
})
}
}
});
});
}
}
}
}
}
\ No newline at end of file
utils/utils.js
View file @
4c9ddc05
...
@@ -40,6 +40,17 @@ export default{
...
@@ -40,6 +40,17 @@ export default{
// 加入购物车数据
// 加入购物车数据
getallNum
(
Obj
){
getallNum
(
Obj
){
let
shopCarInfo
=
uni
.
getStorageSync
(
'shopCarInfo'
);
let
shopCarInfo
=
uni
.
getStorageSync
(
'shopCarInfo'
);
let
s
=
0
;
shopCarInfo
.
forEach
(
function
(
val
)
{
s
+=
val
.
num
;
},
0
);
if
(
s
>=
9
)
{
uni
.
showToast
({
title
:
'最多可一次购买9杯'
,
icon
:
'none'
});
return
;
}
console
.
log
(
shopCarInfo
,
'oooooo'
)
console
.
log
(
shopCarInfo
,
'oooooo'
)
if
(
shopCarInfo
){
if
(
shopCarInfo
){
let
currentGoods
=
shopCarInfo
.
find
(
v
=>
v
.
goodsId
==
Obj
.
goodsId
&&
v
.
skuId
==
Obj
.
skuId
);
let
currentGoods
=
shopCarInfo
.
find
(
v
=>
v
.
goodsId
==
Obj
.
goodsId
&&
v
.
skuId
==
Obj
.
skuId
);
...
...
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