Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
saas_plus
/
dj-car-life-h5-ailipay
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 3efca0fc
authored
Sep 05, 2022
by
张立顺
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
修复支付宝支付问题
1 parent
15c493c1
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
22 additions
and
15 deletions
public/index.html
src/api/alipayApi.js
src/api/axios.js
src/views/alipay/index.vue
vue.config.js
public/index.html
View file @
3efca0f
...
@@ -4,10 +4,10 @@
...
@@ -4,10 +4,10 @@
<meta
name=
"viewport"
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no,viewport-fit=cover"
>
content=
"width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no,viewport-fit=cover"
>
<link
rel=
"icon"
href=
"<%= BASE_URL %>favicon.ico"
>
<link
rel=
"icon"
href=
"<%= BASE_URL %>favicon.ico"
>
<
% for (var i in htmlWebpackPlugin.options.cdn
&&
htmlWebpackPlugin.options.cdn.css) { %>
<
!-- <
% for (var i in htmlWebpackPlugin.options.cdn&&htmlWebpackPlugin.options.cdn.css) { %>
<link href="<%= htmlWebpackPlugin.options.cdn.css[i] %>" rel="preload" as="style" />
<link href="<%= htmlWebpackPlugin.options.cdn.css[i] %>" rel="preload" as="style" />
<link href="<%= htmlWebpackPlugin.options.cdn.css[i] %>" rel="stylesheet" />
<link href="<%= htmlWebpackPlugin.options.cdn.css[i] %>" rel="stylesheet" />
<
% } %>
<% } %>
-->
<title>
<title>
<
%= webpackConfig.name %>
<
%= webpackConfig.name %>
</title>
</title>
...
@@ -24,9 +24,9 @@
...
@@ -24,9 +24,9 @@
<!-- <script src="//res.wx.qq.com/open/js/jweixin-1.2.0.js"></script> -->
<!-- <script src="//res.wx.qq.com/open/js/jweixin-1.2.0.js"></script> -->
<!-- <script src="https://open.work.weixin.qq.com/wwopen/js/jwxwork-1.0.0.js"></script> -->
<!-- <script src="https://open.work.weixin.qq.com/wwopen/js/jwxwork-1.0.0.js"></script> -->
<!-- 使用CDN加速的JS文件,配置在vue.config.js下 -->
<!-- 使用CDN加速的JS文件,配置在vue.config.js下 -->
<
% for (var i in htmlWebpackPlugin.options.cdn
&&
htmlWebpackPlugin.options.cdn.js) { %>
<
!-- <
% for (var i in htmlWebpackPlugin.options.cdn&&htmlWebpackPlugin.options.cdn.js) { %>
<script src="<%= htmlWebpackPlugin.options.cdn.js[i] %>"></script>
<script src="<%= htmlWebpackPlugin.options.cdn.js[i] %>"></script>
<
% } %>
<% } %>
-->
<!-- built files will be auto injected -->
<!-- built files will be auto injected -->
</body>
</body>
...
...
src/api/alipayApi.js
View file @
3efca0f
...
@@ -5,7 +5,9 @@ const path = 'dj.api.smartcarlife.'
...
@@ -5,7 +5,9 @@ const path = 'dj.api.smartcarlife.'
// /router/dj.api.smartcarlife.alipay.oauth.token
// /router/dj.api.smartcarlife.alipay.oauth.token
// 支付宝授权码换取用户ID
// 支付宝授权码换取用户ID
export
function
alipayOauthToken
(
data
)
{
export
function
alipayOauthToken
(
data
)
{
console
.
log
(
'data'
,
data
)
data
.
method
=
`
${
path
}
alipay.oauth.token`
data
.
method
=
`
${
path
}
alipay.oauth.token`
console
.
log
(
'data'
,
data
)
return
request
(
data
,
RequestMethods
.
POST
)
return
request
(
data
,
RequestMethods
.
POST
)
}
}
// 发起支付
// 发起支付
...
...
src/api/axios.js
View file @
3efca0f
...
@@ -116,6 +116,7 @@ service.interceptors.response.use(
...
@@ -116,6 +116,7 @@ service.interceptors.response.use(
// subErrors: null
// subErrors: null
// }
// }
const
dataAxios
=
response
.
data
const
dataAxios
=
response
.
data
console
.
log
(
'dataAxios'
,
dataAxios
)
const
ruleResult
=
baseConfig
.
axios
.
result
const
ruleResult
=
baseConfig
.
axios
.
result
// 这个状态码是和后端约定的
// 这个状态码是和后端约定的
// 有 code 代表这是一个后端接口 可以进行进一步的判断
// 有 code 代表这是一个后端接口 可以进行进一步的判断
...
@@ -141,6 +142,7 @@ service.interceptors.response.use(
...
@@ -141,6 +142,7 @@ service.interceptors.response.use(
},
},
error
=>
{
error
=>
{
console
.
log
(
error
,
'error'
)
if
(
error
&&
error
.
response
)
{
if
(
error
&&
error
.
response
)
{
switch
(
error
.
response
.
status
)
{
switch
(
error
.
response
.
status
)
{
case
400
:
case
400
:
...
...
src/views/alipay/index.vue
View file @
3efca0f
...
@@ -116,7 +116,7 @@ export default {
...
@@ -116,7 +116,7 @@ export default {
// openId: 'oQ6Sh5cGirPd55Oc1J1oJSRpboFM',
// openId: 'oQ6Sh5cGirPd55Oc1J1oJSRpboFM',
// openId: '',
// openId: '',
userId
:
''
,
// 测试用数据
userId
:
''
,
// 测试用数据
// userId: '2088012113317722'
,
// 测试用数据
// userId: '2088012113317722' // 测试用数据
tradeNO
:
''
// 测试用数据
tradeNO
:
''
// 测试用数据
// tradeNO: '2022083122001417721446143547'// 测试用数据
// tradeNO: '2022083122001417721446143547'// 测试用数据
}
}
...
@@ -140,13 +140,13 @@ export default {
...
@@ -140,13 +140,13 @@ export default {
scopes
:
[
'auth_base'
]
scopes
:
[
'auth_base'
]
},
function
(
res
)
{
},
function
(
res
)
{
console
.
log
(
'res.authCode'
,
res
.
authCode
)
console
.
log
(
'res.authCode'
,
res
.
authCode
)
res
.
authCode
&&
that
.
g
te
OpenId
(
res
.
authCode
)
res
.
authCode
&&
that
.
g
et
OpenId
(
res
.
authCode
)
},
function
(
res
)
{
},
function
(
res
)
{
console
.
log
(
'res.fail'
,
res
)
console
.
log
(
'res.fail'
,
res
)
// res.authCode && that.g
te
OpenId(res.authCode)
// res.authCode && that.g
et
OpenId(res.authCode)
})
})
// this.g
te
OpenId('ab3aa51e466140b5b96475706653UX72')
// this.g
et
OpenId('ab3aa51e466140b5b96475706653UX72')
// this.aliPayment()
// this.aliPayment()
...
@@ -158,9 +158,11 @@ export default {
...
@@ -158,9 +158,11 @@ export default {
// })
// })
},
},
methods
:
{
methods
:
{
g
te
OpenId
(
code
)
{
g
et
OpenId
(
code
)
{
// ap.alert(JSON.stringify(code))
// ap.alert(JSON.stringify(code))
console
.
log
(
'gteOpenId'
,
code
)
console
.
log
(
'getOpenId'
,
code
)
console
.
log
(
alipayOauthToken
)
// !code&&console.log('alipayOauthToken')
code
&&
alipayOauthToken
({
code
}).
then
((
result
)
=>
{
code
&&
alipayOauthToken
({
code
}).
then
((
result
)
=>
{
console
.
log
(
'alipayOauthToken'
,
result
)
console
.
log
(
'alipayOauthToken'
,
result
)
const
{
userId
}
=
result
const
{
userId
}
=
result
...
@@ -296,8 +298,9 @@ export default {
...
@@ -296,8 +298,9 @@ export default {
// return
// return
createWxPayH5
(
params
).
then
((
result
)
=>
{
createWxPayH5
(
params
).
then
((
result
)
=>
{
const
{
tradeNO
}
=
JSON
.
parse
(
result
.
jsapiPayInfo
)
const
{
tradeNO
}
=
JSON
.
parse
(
result
.
jsapiPayInfo
)
this
.
outTradeNo
=
tradeNO
this
.
tradeNO
=
tradeNO
this
.
outTradeNo
&&
this
.
aliPayment
()
console
.
log
(
'tradeNO'
,
tradeNO
)
this
.
tradeNO
&&
this
.
aliPayment
()
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
console
.
log
(
err
)
console
.
log
(
err
)
}).
finally
(()
=>
{
}).
finally
(()
=>
{
...
@@ -307,7 +310,7 @@ export default {
...
@@ -307,7 +310,7 @@ export default {
aliPayment
()
{
aliPayment
()
{
const
that
=
this
const
that
=
this
// 调用支付宝api唤起支付功能
// 调用支付宝api唤起支付功能
console
.
log
(
'this.
outTradeNo
'
,
this
.
tradeNO
)
console
.
log
(
'this.
tradeNO
'
,
this
.
tradeNO
)
const
{
tradeNO
}
=
this
const
{
tradeNO
}
=
this
AlipayJSBridge
.
call
(
AlipayJSBridge
.
call
(
'tradePay'
,
'tradePay'
,
...
...
vue.config.js
View file @
3efca0f
...
@@ -53,9 +53,9 @@ const spritesmithFunction = data => {
...
@@ -53,9 +53,9 @@ const spritesmithFunction = data => {
return
`
${
shared
}
\n
${
perSprite
}
`
return
`
${
shared
}
\n
${
perSprite
}
`
}
}
module
.
exports
=
{
module
.
exports
=
{
// publicPath: IS_PROD ? './' : '/dj-scrm-wx-work-lwk
/', // 本地调试时需登录时使用
publicPath
:
IS_PROD
?
'/dj-carlife-web-alipay'
:
'.
/'
,
// 本地调试时需登录时使用
// publicPath: './',
// publicPath: './',
publicPath
:
'/dj-carlife-web-alipay'
,
// 署应用包时的基本 URL。 vue-router history模式使用
//
publicPath: '/dj-carlife-web-alipay', // 署应用包时的基本 URL。 vue-router history模式使用
// publicPath: '/dj-carlife-web-alipay/', // 署应用包时的基本 URL。 vue-router history模式使用
// publicPath: '/dj-carlife-web-alipay/', // 署应用包时的基本 URL。 vue-router history模式使用
outputDir
:
'dist'
,
// 生产环境构建文件的目录
outputDir
:
'dist'
,
// 生产环境构建文件的目录
// assetsDir: 'static', // outputDir的静态资源(js、css、img、fonts)目录
// assetsDir: 'static', // outputDir的静态资源(js、css、img、fonts)目录
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment