Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
groupPurchase-miniapp
Project
Project
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
彭佳妮(贵阳日报)
groupPurchase-miniapp
Commits
e9163ecd
Commit
e9163ecd
authored
Aug 12, 2024
by
石建新(贵阳日报)
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
支付
parent
5603a2bb
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
80 additions
and
38 deletions
+80
-38
ConfirmOrder.vue
src/pages/assistingAgriculture/cart/ConfirmOrder.vue
+80
-38
No files found.
src/pages/assistingAgriculture/cart/ConfirmOrder.vue
View file @
e9163ecd
...
...
@@ -151,7 +151,7 @@ import {
previewOrderBasketUpdate
,
sgyOrderOrderInfo
,
}
from
'@/api/assistingAgriculture/shop'
;
import
{
groupBuyConfirm
}
from
'@/api/confirmOrder'
;
import
{
groupBuyConfirm
,
groupBuyUpdate
,
groupBuyCreate
}
from
'@/api/confirmOrder'
;
const
imgUrl
=
import
.
meta
.
env
.
VITE_APP_IMG_URL
;
const
textInputs
=
ref
(
''
);
const
basketIds
=
ref
([]);
...
...
@@ -171,10 +171,14 @@ onLoad((options) => {
prodIds
.
value
=
prodId
;
skuIds
.
value
=
skuId
;
types
.
value
=
type
;
basketIds
.
value
=
ids
.
split
(
','
);
if
(
type
===
'qg'
)
{
groupBuyConfirmFn
(
prodId
,
skuId
);
groupBuyConfirmFn
(
prodId
,
skuId
).
then
((
res
)
=>
{
useraddrDefaultUserAddrFn
().
then
(()
=>
{
groupBuyUpdateFnQg
();
});
});
}
else
{
basketIds
.
value
=
ids
.
split
(
','
);
sgyrddBasketConfirmFn
(
basketIds
.
value
).
then
(()
=>
{
useraddrDefaultUserAddrFn
().
then
(()
=>
{
groupBuyUpdateFn
();
...
...
@@ -182,13 +186,35 @@ onLoad((options) => {
});
}
});
function
groupBuyUpdateFnQg
(
couponUserId
=
''
)
{
const
{
receiverName
,
receiverMobile
,
receiverAddress
}
=
addressParams
.
value
;
groupBuyUpdate
({
key
:
orderInfo
.
value
.
key
,
couponUserId
,
receiverName
,
receiverMobile
,
receiverAddress
,
}).
then
((
res
)
=>
{
if
(
res
.
code
===
0
)
{
orderInfo
.
value
=
res
.
data
;
}
});
}
onShow
(()
=>
{
if
(
changeAddress
.
value
)
{
sgyrddBasketConfirmFn
(
basketIds
.
value
).
then
(()
=>
{
useraddrDefaultUserAddrFn
().
then
(()
=>
{
groupBuyUpdateFn
();
if
(
types
.
value
===
'qg'
)
{
groupBuyConfirmFn
(
prodIds
.
value
,
skuIds
.
value
).
then
((
res
)
=>
{
useraddrDefaultUserAddrFn
().
then
(()
=>
{
groupBuyUpdateFnQg
();
});
});
});
}
else
{
sgyrddBasketConfirmFn
(
basketIds
.
value
).
then
(()
=>
{
useraddrDefaultUserAddrFn
().
then
(()
=>
{
groupBuyUpdateFn
();
});
});
}
}
if
(
outTradeNos
.
value
)
{
...
...
@@ -226,7 +252,6 @@ function groupBuyConfirmFn(prodId, skuId) {
return
new
Promise
((
resolve
,
reject
)
=>
{
groupBuyConfirm
({
prodId
,
skuId
}).
then
((
res
)
=>
{
if
(
res
.
code
===
0
)
{
res
.
data
.
orderItems
[
0
].
pic
=
imgUrl
+
res
.
data
.
orderItems
[
0
].
pic
;
orderInfo
.
value
=
res
.
data
;
resolve
(
res
.
data
.
shopId
);
}
else
{
...
...
@@ -257,7 +282,11 @@ function selectShopCoupon(item) {
activeCouponId
.
value
=
item
.
couponId
;
activeCouponInfo
.
value
=
item
;
showpopup
.
value
=
false
;
groupBuyUpdateFn
(
item
.
couponUserId
);
if
(
types
.
value
===
'qg'
)
{
groupBuyUpdateFnQg
(
item
.
couponUserId
);
}
else
{
groupBuyUpdateFn
(
item
.
couponUserId
);
}
}
else
{
xma
.
showToast
({
title
:
'不满足优惠券使用条件'
,
...
...
@@ -268,18 +297,11 @@ function selectShopCoupon(item) {
const
jumpToAddressList
=
()
=>
{
changeAddress
.
value
=
true
;
wx
.
navigateTo
({
url
:
'/pages/address/
l
ist'
,
url
:
'/pages/address/
addressL
ist'
,
});
};
function
groupBuyUpdateFn
(
couponUserId
)
{
const
{
receiverName
,
receiverMobile
,
receiverAddress
}
=
addressParams
.
value
;
console
.
log
(
'receiverName, receiverMobile, receiverAddress'
,
receiverName
,
receiverMobile
,
receiverAddress
,
);
previewOrderBasketUpdate
({
receiverName
,
receiverMobile
,
...
...
@@ -328,6 +350,7 @@ const params = ref({
basketIds
:
[],
remark
:
''
,
});
const
PaymentRef
=
ref
(
null
);
const
openZfType
=
()
=>
{
PaymentRef
.
value
.
open
();
...
...
@@ -336,28 +359,47 @@ const payNow = async (data) => {
params
.
value
.
id
=
orderInfo
.
value
.
key
;
params
.
value
.
tradeType
=
data
.
selectType
;
params
.
value
.
basketIds
=
basketIds
.
value
;
znsgyOrderCreate
(
params
.
value
).
then
((
res
)
=>
{
if
(
res
.
code
===
0
)
{
const
{
paymentUrl
,
outTradeNo
}
=
res
.
data
.
result
;
outTradeNos
.
value
=
outTradeNo
;
window
.
location
.
href
=
paymentUrl
;
// 设置一个延时器
const
start
=
Date
.
now
();
setTimeout
(()
=>
{
const
end
=
Date
.
now
();
if
(
end
-
start
<
1200
)
{
// 如果 iframe 加载时间小于 1.2 秒,说明应用没有安装
xma
.
showToast
({
title
:
'未安装App'
,
icon
:
'error'
,
});
// 这里可以跳转到应用下载页面
}
},
1600
);
}
else
{
groupBuyConfirmFn
(
prodIds
.
value
,
skuIds
.
value
);
if
(
types
.
value
===
'qg'
)
{
const
qgParams
=
{
id
:
orderInfo
.
value
.
key
,
placeOrderWay
:
'sgy'
,
payWayCode
:
5
,
tradeType
:
data
.
selectType
,
};
groupBuyCreate
(
qgParams
).
then
((
res
)
=>
{
if
(
res
.
code
===
0
)
{
openUrl
(
res
.
data
.
result
);
}
else
{
groupBuyConfirmFn
(
prodIds
.
value
,
skuIds
.
value
);
}
});
}
else
{
znsgyOrderCreate
(
params
.
value
).
then
((
res
)
=>
{
if
(
res
.
code
===
0
)
{
openUrl
(
res
.
data
.
result
);
}
else
{
groupBuyConfirmFn
(
prodIds
.
value
,
skuIds
.
value
);
}
});
}
};
const
openUrl
=
(
result
)
=>
{
const
{
paymentUrl
,
outTradeNo
}
=
result
;
outTradeNos
.
value
=
outTradeNo
;
window
.
location
.
href
=
paymentUrl
;
// 设置一个延时器
const
start
=
Date
.
now
();
setTimeout
(()
=>
{
const
end
=
Date
.
now
();
if
(
end
-
start
<
1200
)
{
// 如果 iframe 加载时间小于 1.2 秒,说明应用没有安装
xma
.
showToast
({
title
:
'未安装App'
,
icon
:
'error'
,
});
// 这里可以跳转到应用下载页面
}
});
}
,
1600
);
};
</
script
>
...
...
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