Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
project-online-fi
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
EzijingWeb
project-online-fi
Commits
3bdada40
提交
3bdada40
authored
11月 22, 2022
作者:
matian
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
updates
上级
a960cf42
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
90 行增加
和
112 行删除
+90
-112
index.html
index.html
+2
-0
RightAsideH5.vue
src/components/layout/RightAsideH5.vue
+1
-1
Confirm.vue
src/modules/pay/components/Confirm.vue
+87
-111
没有找到文件。
index.html
浏览文件 @
3bdada40
...
@@ -17,5 +17,7 @@
...
@@ -17,5 +17,7 @@
<body>
<body>
<div
id=
"app"
></div>
<div
id=
"app"
></div>
<script
type=
"module"
src=
"/src/main.ts"
></script>
<script
type=
"module"
src=
"/src/main.ts"
></script>
<script
src=
"https://res.wx.qq.com/open/js/jweixin-1.6.0.js"
></script>
</body>
</body>
</html>
</html>
src/components/layout/RightAsideH5.vue
浏览文件 @
3bdada40
...
@@ -43,7 +43,7 @@ export default {
...
@@ -43,7 +43,7 @@ export default {
}
}
.rigth-aside
{
.rigth-aside
{
position
:
fixed
;
position
:
fixed
;
top
:
5
0%
;
top
:
7
0%
;
right
:
16px
;
right
:
16px
;
z-index
:
99
;
z-index
:
99
;
transform
:
translateY
(
-50%
);
transform
:
translateY
(
-50%
);
...
...
src/modules/pay/components/Confirm.vue
浏览文件 @
3bdada40
...
@@ -3,11 +3,10 @@ import { ElMessage } from 'element-plus'
...
@@ -3,11 +3,10 @@ import { ElMessage } from 'element-plus'
import
{
Check
}
from
'@element-plus/icons-vue'
import
{
Check
}
from
'@element-plus/icons-vue'
import
{
useUserStore
}
from
'@/stores/user'
import
{
useUserStore
}
from
'@/stores/user'
import
{
useDevice
}
from
'@/composables/useDevice'
import
{
useDevice
}
from
'@/composables/useDevice'
import
{
wxJSPay
}
from
'@/utils/wxpay'
import
{
wxJSPay
,
getOpenId
}
from
'@/utils/wxpay'
import
{
createOrder
,
getOrderList
}
from
'../api'
import
{
createOrder
,
getOrderList
}
from
'../api'
import
{
getOpenId
}
from
'@/api/base
'
import
queryString
from
'query-string
'
const
router
=
useRouter
()
const
router
=
useRouter
()
const
route
=
useRoute
()
const
{
mobile
,
wechat
,
alipay
}
=
useDevice
()
const
{
mobile
,
wechat
,
alipay
}
=
useDevice
()
const
user
=
useUserStore
()
const
user
=
useUserStore
()
const
props
=
defineProps
({
const
props
=
defineProps
({
...
@@ -15,13 +14,12 @@ const props = defineProps({
...
@@ -15,13 +14,12 @@ const props = defineProps({
type
:
Object
type
:
Object
}
}
})
})
const
openId
:
any
=
ref
(
window
.
localStorage
.
getItem
(
'openId'
))
const
payment_method
=
ref
(
''
)
const
orderInfo
:
any
=
ref
({})
const
orderInfoDetail
:
any
=
ref
([])
const
payMode
=
ref
(
1
)
const
payMode
=
ref
(
1
)
const
isAgree
=
ref
(
false
)
const
isAgree
=
ref
(
false
)
const
currentCheck
=
ref
(
'
12
'
)
const
currentCheck
=
ref
(
'
4
'
)
const
timer
=
ref
(
)
const
orderInfoDetail
:
any
=
ref
([]
)
function
getDateTime
(
dayNum
:
any
)
{
function
getDateTime
(
dayNum
:
any
)
{
const
dateDay
=
new
Date
()
const
dateDay
=
new
Date
()
dateDay
.
setDate
(
dateDay
.
getDate
()
+
dayNum
)
//获取dayNum天后的日期
dateDay
.
setDate
(
dateDay
.
getDate
()
+
dayNum
)
//获取dayNum天后的日期
...
@@ -36,82 +34,23 @@ function getDateTime(dayNum: any) {
...
@@ -36,82 +34,23 @@ function getDateTime(dayNum: any) {
}
}
const
start_time
=
getDateTime
(
0
)
const
start_time
=
getDateTime
(
0
)
const
end_time
=
getDateTime
(
90
)
const
end_time
=
getDateTime
(
90
)
const
emit
=
defineEmits
<
{
const
emit
=
defineEmits
<
{
(
e
:
'success'
,
params
:
object
):
void
(
e
:
'success'
,
params
:
object
):
void
}
>
()
}
>
()
const
checkdChange
=
(
val
:
string
)
=>
{
const
checkdChange
=
(
val
:
string
)
=>
{
currentCheck
.
value
=
val
currentCheck
.
value
=
val
}
}
// const optionParams = reactive({
// shop_id: '6998523899570814976',
// spu_id: '6998525810348916736',
// sku_id: '6998525810365693952',
// redirect_url: '',
// buy_count: '1',
// payment_method: '',
// notify_url: `https://ep-lms-api.ezijing.com/v2/student/push?tenant=paa&sso_id=${user.user?.id}&class_id=${props.shopItem?.class_id}&course_flag=1&course_id=${props.shopItem?.course_id}`
// })
// 获取订单
const
getOrder
=
(
val
:
any
)
=>
{
getOrderList
({
order_detail_id
:
val
}).
then
((
resp
)
=>
{
orderInfoDetail
.
value
=
resp
.
data
[
0
]
const
params
=
{
status
:
'success'
,
orderId
:
orderInfoDetail
.
value
.
order_id
,
payPrice
:
orderInfoDetail
.
value
.
payment_money
,
payStatus
:
orderInfoDetail
.
value
.
order_status
}
clearInterval
(
timer
.
value
)
emit
(
'success'
,
params
)
})
}
// 创建订单
const
handleCreateOrder
=
()
=>
{
const
params
:
any
=
{
shop_id
:
'6998523899570814976'
,
spu_id
:
'6998525810348916736'
,
sku_id
:
'6998525810365693952'
,
redirect_url
:
''
,
buy_count
:
'1'
,
notify_url
:
`https://ep-lms-api.ezijing.com/v2/student/push?tenant=paa&sso_id=
${
user
.
user
?.
id
}
&
class_id
=
$
{
props
.
shopItem
?.
class_id
}
&
course_flag
=
1
&
course_id
=
$
{
props
.
shopItem
?.
course_id
}
`
}
if (wechat && currentCheck.value === '4') {
if (openId.value) {
params.open_id = openId.value
params.payment_method = '3'
fetchPlaceOrder(params)
}
} else if (alipay && currentCheck.value === '12') {
params.payment_method = '12'
fetchPlaceOrder(params)
}
}
const fetchPlaceOrder = (params: any) => {
createOrder(params).then((res) => {
placeOrderCallback(res)
})
}
const placeOrderCallback = (res: any) => {
const payType = payment_method.value
if (payType === '3') {
// 微信内支付
if (typeof res.payment_more_info === 'string') {
const payInfo = JSON.parse(res.payment_more_info)
if (payInfo.appId) {
wxJSPay(res, getOrder)
}
}
} else if (payType === '4') {
// 微信外微信h5支付
window.location.href =
res.payment_url +
'&redirect_url=' +
encodeURIComponent(res.order_details_url)
timer.value = setInterval(() => {
// 通过定时器每间隔一会去请求查询微信支付状态(具体参数根据项目需要而定)
getOrder(res.order_detail_id)
}, 2000)
} else if (payType === '12') {
// 支付宝网页支付
window.location.href = res.payment_url
timer.value = setInterval(() => {
// 通过定时器每间隔一会去请求查询微信支付状态(具体参数根据项目需要而定)
getOrder(res.order_detail_id)
}, 2000)
}
}
// 点击立即购买
// 点击立即购买
const
handlePay
=
()
=>
{
const
handlePay
=
()
=>
{
if
(
isAgree
.
value
===
false
)
{
if
(
isAgree
.
value
===
false
)
{
...
@@ -119,14 +58,17 @@ const handlePay = () => {
...
@@ -119,14 +58,17 @@ const handlePay = () => {
}
else
{
}
else
{
if
(
user
.
isLogin
)
{
if
(
user
.
isLogin
)
{
if
(
!
mobile
.
value
)
{
if
(
!
mobile
.
value
)
{
//pc
const
params
=
{
const
params
=
{
payMode
:
payMode
.
value
,
payMode
:
payMode
.
value
,
status
:
'order'
status
:
'order'
}
}
emit
(
'success'
,
params
)
emit
(
'success'
,
params
)
}
else
{
}
else
{
// H5创建订单
//H5
handleCreateOrder()
if
(
mobile
&&
(
wechat
||
alipay
))
{
pay
()
}
}
}
}
else
{
}
else
{
window
.
location
.
href
=
`
${
window
.
location
.
href
=
`
${
...
@@ -136,6 +78,71 @@ const handlePay = () => {
...
@@ -136,6 +78,71 @@ const handlePay = () => {
}
}
}
}
// 去支付
// const pay = () => {
// createOrderHandle().then((order: any) => {
// orderInfo.value = order
// if (wechat) {
// wxJSPay(order, payCallback(optionParams))
// } else {
// location.href = order.payment_url // '4' \ '12'
// getOrder()
// }
// })
// }
// // 支付回调
// const payCallback = async (options: any) => {
// const { callback } = options
// const order = await getOrder()
// callback && callback(order)
// const params = {
// status: 'success',
// orderId: order.order_id,
// payPrice: order.payment_money,
// payStatus: order.order_status
// }
// orderInfoDetail.value = order.order_status
// emit('success', params)
// }
// // 创建订单
// const createOrderHandle = () => {
// let defaultParams = {}
// // 微信内
// if (wechat) {
// const openId = localStorage.getItem('openId')
// if (!openId) {
// getOpenId(
// queryString.parse(location.search, { parseBooleans: true }).code,
// pay
// )
// return Promise.reject('openId不存在')
// }
// defaultParams = { open_id: openId, payment_method: '3' }
// }
// // 支付宝网页支付
// if (currentCheck.value === '12') {
// defaultParams = { payment_method: '12' }
// }
// //微信外微信h5支付
// if (currentCheck.value === '4') {
// defaultParams = { payment_method: '4' }
// }
// const params = Object.assign(optionParams, defaultParams)
// return createOrder(params).then((resp: any) => resp.data)
// }
// // 获取订单
// function getOrder() {
// return getOrderList({
// order_detail_id: orderInfo.value.order_detail_id
// }).then((resp) => {
// return resp.data[0]
// })
// }
const
handlePrev
=
()
=>
{
const
handlePrev
=
()
=>
{
router
.
push
({
router
.
push
({
path
:
`/shop/detail/
${
props
.
shopItem
?.
id
}
`,
path
:
`/shop/detail/
${
props
.
shopItem
?.
id
}
`,
...
@@ -144,38 +151,7 @@ const handlePrev = () => {
...
@@ -144,38 +151,7 @@ const handlePrev = () => {
}
}
})
})
}
}
const fetchOpenId = (code: any) => {
getOpenId({ code, identity: 'ezijing' }).then((res: any) => {
if (res.openid) {
openId.value = res.openid || ''
window.localStorage.setItem('openId', res.openid || '')
} else {
window.localStorage.removeItem('openId')
getCode()
}
})
}
const getCode = () => {
const redirectURI = `
https
:
//pages.ezijing.com/given/auth.html?redirect_uri=${encodeURIComponent(
window
.
location
.
href
)}
`
window.location.href = `
https
:
//open.weixin.qq.com/connect/oauth2/authorize?appid=wx451c01d40d090d7a&redirect_uri=${redirectURI}&response_type=code&scope=snsapi_base#wechat_redirect`
}
if
(
(
openId
.
value
===
''
||
openId
.
value
===
null
||
openId
.
value
===
undefined
)
&&
wechat
)
{
const
{
code
}
=
route
.
query
if
(
code
)
{
fetchOpenId
(
code
)
}
else
{
getCode
()
}
}
</
script
>
</
script
>
<
template
>
<
template
>
<div>
<div>
<div
class=
"main_con"
v-if=
"!mobile"
>
<div
class=
"main_con"
v-if=
"!mobile"
>
...
@@ -386,11 +362,11 @@ if (
...
@@ -386,11 +362,11 @@ if (
color
:
#333333
;
color
:
#333333
;
}
}
.info_date
{
.info_date
{
height
:
0
.22rem
;
font-size
:
0
.22rem
;
font-size
:
0
.22rem
;
font-weight
:
400
;
font-weight
:
400
;
line-height
:
0
.3rem
;
line-height
:
0
.3rem
;
color
:
#999999
;
color
:
#999999
;
white-space
:
nowrap
;
}
}
}
}
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论