Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mayi-mp-shop
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
程默
mayi-mp-shop
Commits
6d523aff
Commit
6d523aff
authored
Jul 09, 2020
by
李嘉林
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
支付兼容
parent
aa1f8ba7
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
77 additions
and
63 deletions
+77
-63
build/webpack.base.conf.js
+41
-34
src/pages/wxPay/index.vue
+36
-29
No files found.
build/webpack.base.conf.js
View file @
6d523aff
...
@@ -33,66 +33,67 @@ let baseWebpackConfig = {
...
@@ -33,66 +33,67 @@ let baseWebpackConfig = {
// 可以将 entry 写成 {'toPath': 'fromPath'} 的形式,
// 可以将 entry 写成 {'toPath': 'fromPath'} 的形式,
// toPath 为相对于 dist 的路径, 例:index/demo,则生成的文件地址为 dist/index/demo.js
// toPath 为相对于 dist 的路径, 例:index/demo,则生成的文件地址为 dist/index/demo.js
entry
,
entry
,
target
:
require
(
'mpvue-webpack-target'
),
target
:
require
(
"mpvue-webpack-target"
),
output
:
{
output
:
{
path
:
config
.
build
.
assetsRoot
,
path
:
config
.
build
.
assetsRoot
,
jsonpFunction
:
'webpackJsonpMpvue'
,
jsonpFunction
:
"webpackJsonpMpvue"
,
filename
:
'[name].js'
,
filename
:
"[name].js"
,
publicPath
:
process
.
env
.
NODE_ENV
===
'production'
publicPath
:
process
.
env
.
NODE_ENV
===
"production"
?
config
.
build
.
assetsPublicPath
?
config
.
build
.
assetsPublicPath
:
config
.
dev
.
assetsPublicPath
:
config
.
dev
.
assetsPublicPath
},
},
resolve
:
{
resolve
:
{
extensions
:
[
'.js'
,
'.vue'
,
'.json'
],
extensions
:
[
".js"
,
".vue"
,
".json"
],
alias
:
{
alias
:
{
'vue'
:
'mpvue'
,
vue
:
"mpvue"
,
'@'
:
resolve
(
'src'
),
"@"
:
resolve
(
"src"
),
'@config'
:
resolve
(
'config'
)
"@config"
:
resolve
(
"config"
)
},
},
symlinks
:
false
,
symlinks
:
false
,
aliasFields
:
[
'mpvue'
,
'weapp'
,
'browser'
],
aliasFields
:
[
"mpvue"
,
"weapp"
,
"browser"
],
mainFields
:
[
'browser'
,
'module'
,
'main'
]
mainFields
:
[
"browser"
,
"module"
,
"main"
]
},
},
module
:
{
module
:
{
rules
:
[
rules
:
[
{
{
test
:
/
\.
vue$/
,
test
:
/
\.
vue$/
,
loader
:
'mpvue-loader'
,
loader
:
"mpvue-loader"
,
options
:
vueLoaderConfig
options
:
vueLoaderConfig
},
},
{
{
test
:
/
\.
js$/
,
test
:
/
\.
js$/
,
include
:
[
resolve
(
'src'
),
resolve
(
'test'
)],
include
:
[
resolve
(
"src"
),
resolve
(
"test"
)],
use
:
[
use
:
[
'babel-loader'
,
"babel-loader"
,
{
{
loader
:
'mpvue-loader'
,
loader
:
"mpvue-loader"
,
options
:
Object
.
assign
({
checkMPEntry
:
true
},
vueLoaderConfig
)
options
:
Object
.
assign
({
checkMPEntry
:
true
},
vueLoaderConfig
)
}
,
}
]
]
},
},
{
{
test
:
/
\.(
png|jpe
?
g|gif|svg
)(\?
.*
)?
$/
,
test
:
/
\.(
png|jpe
?
g|gif|svg
)(\?
.*
)?
$/
,
loader
:
'url-loader'
,
loader
:
"url-loader"
,
options
:
{
options
:
{
limit
:
10000
,
limit
:
10000
,
name
:
utils
.
assetsPath
(
'img/[name].[ext]'
)
name
:
utils
.
assetsPath
(
"img/[name].[ext]"
)
}
}
},
},
{
{
test
:
/
\.(
mp4|webm|ogg|mp3|wav|flac|aac
)(\?
.*
)?
$/
,
test
:
/
\.(
mp4|webm|ogg|mp3|wav|flac|aac
)(\?
.*
)?
$/
,
loader
:
'url-loader'
,
loader
:
"url-loader"
,
options
:
{
options
:
{
limit
:
10000
,
limit
:
10000
,
name
:
utils
.
assetsPath
(
'media/[name].[ext]'
)
name
:
utils
.
assetsPath
(
"media/[name].[ext]"
)
}
}
},
},
{
{
test
:
/
\.(
woff2
?
|eot|ttf|otf
)(\?
.*
)?
$/
,
test
:
/
\.(
woff2
?
|eot|ttf|otf
)(\?
.*
)?
$/
,
loader
:
'url-loader'
,
loader
:
"url-loader"
,
options
:
{
options
:
{
limit
:
10000
,
limit
:
10000
,
name
:
utils
.
assetsPath
(
'fonts/[name].[ext]'
)
name
:
utils
.
assetsPath
(
"fonts/[name].[ext]"
)
}
}
}
}
]
]
...
@@ -100,25 +101,31 @@ let baseWebpackConfig = {
...
@@ -100,25 +101,31 @@ let baseWebpackConfig = {
plugins
:
[
plugins
:
[
// api 统一桥协议方案
// api 统一桥协议方案
new
webpack
.
DefinePlugin
({
new
webpack
.
DefinePlugin
({
'mpvue'
:
'global.mpvue'
,
mpvue
:
"global.mpvue"
,
'mpvuePlatform'
:
'global.mpvuePlatform'
mpvuePlatform
:
"global.mpvuePlatform"
,
MINI_ENV
:
JSON
.
stringify
(
process
.
env
.
PLATFORM
)
}),
}),
new
MpvuePlugin
(),
new
MpvuePlugin
(),
new
CopyWebpackPlugin
([{
new
CopyWebpackPlugin
(
from
:
'**/*.json'
,
[
to
:
''
{
}],
{
from
:
"**/*.json"
,
context
:
'src/'
to
:
""
}),
}
],
{
context
:
"src/"
}
),
new
CopyWebpackPlugin
([
new
CopyWebpackPlugin
([
{
{
from
:
path
.
resolve
(
__dirname
,
'../static'
),
from
:
path
.
resolve
(
__dirname
,
"../static"
),
to
:
path
.
resolve
(
config
.
build
.
assetsRoot
,
'./static'
),
to
:
path
.
resolve
(
config
.
build
.
assetsRoot
,
"./static"
),
ignore
:
[
'.*'
]
ignore
:
[
".*"
]
}
}
])
])
]
]
}
}
;
// 针对百度小程序,由于不支持通过 miniprogramRoot 进行自定义构建完的文件的根路径
// 针对百度小程序,由于不支持通过 miniprogramRoot 进行自定义构建完的文件的根路径
// 所以需要将项目根路径下面的 project.swan.json 拷贝到构建目录
// 所以需要将项目根路径下面的 project.swan.json 拷贝到构建目录
...
...
src/pages/wxPay/index.vue
View file @
6d523aff
...
@@ -5,6 +5,7 @@
...
@@ -5,6 +5,7 @@
<
script
>
<
script
>
import
{
formatTime
}
from
"@/utils/index"
;
import
{
formatTime
}
from
"@/utils/index"
;
import
wxPay
from
"@/api/wxPay"
;
import
wxPay
from
"@/api/wxPay"
;
import
order
from
"@/api/order"
;
export
default
{
export
default
{
components
:
{
components
:
{
// card
// card
...
@@ -41,7 +42,7 @@ export default {
...
@@ -41,7 +42,7 @@ export default {
that
.
options
.
tradeType
=
"Mini"
;
that
.
options
.
tradeType
=
"Mini"
;
console
.
log
(
"支付开始"
,
that
.
options
);
console
.
log
(
"支付开始"
,
that
.
options
);
if
(
MINI_ENV
==
'tt'
){
if
(
MINI_ENV
==
'tt'
){
that
.
toTtPay
();
that
.
getTtPayInfo
();
}
else
{
}
else
{
that
.
toPay
();
that
.
toPay
();
}
}
...
@@ -140,35 +141,23 @@ export default {
...
@@ -140,35 +141,23 @@ export default {
wx
.
showToast
({
title
:
res
.
data
.
msg
,
icon
:
"none"
});
wx
.
showToast
({
title
:
res
.
data
.
msg
,
icon
:
"none"
});
});
});
},
},
// 头条支付
getTtPayInfo
(){
toTtPay
(){
console
.
log
(
"-----------------145头条支付"
)
console
.
log
(
"-----------------145头条支付"
)
tt
.
pay
({
let
query
=
{
orderInfo
:
{
orderSn
:
this
.
options
.
orderSn
app_id
:
"800000040005"
,
}
sign_type
:
"MD5"
,
wxPay
.
to_tt_pay
(
query
).
then
(
res
=>
{
out_order_no
:
"MicroApp7075638135"
,
if
(
res
.
data
.
code
==
200
){
merchant_id
:
"1300000004"
,
res
.
data
.
data
.
total_amount
=
Number
(
res
.
data
.
data
.
total_amount
);
timestamp
:
"1566720681"
,
this
.
toTtPay
(
res
.
data
.
data
);
product_code
:
"pay"
,
}
payment_type
:
"direct"
,
})
total_amount
:
1
,
trade_type
:
"H5"
,
uid
:
"800000040005"
,
version
:
"2.0"
,
currency
:
"CNY"
,
subject
:
"microapp test"
,
body
:
"microapp test"
,
trade_time
:
"1566720681"
,
valid_time
:
"300"
,
notify_url
:
"https://wx.tenpay.com/paycallback"
,
wx_url
:
"https://wx.tenpay.com/cgi-bin/mmpayweb-bin/checkmweb?prepay_id=xxx&package=yyy"
,
wx_type
:
"MWEB"
,
alipay_url
:
"alipay_sdk=alipay-sdk-java-3.4.27.ALL&app_id=2018061460417275&biz_content=%7B%22body%22%3A%22%E6%B5%8B%E8%AF%95%E8%AE%A2%E5%8D%95%22%2C%22extend_params%22%3A%7B%7D%2C%22out_trade_no%22%3A%2211908250000028453790%22%2C%22product_code%22%3A%22QUICK_MSECURITY_PAY%22%2C%22seller_id%22%3A%222088721387102560%22%2C%22subject%22%3A%22%E6%B5%8B%E8%AF%95%E8%AE%A2%E5%8D%95%22%2C%22timeout_express%22%3A%22599m%22%2C%22total_amount%22%3A%220.01%22%7D&charset=utf-8&format=json&method=alipay.trade.app.pay¬ify_url=http%3A%2F%2Fapi-test-pcs.snssdk.com%2Fgateway%2Fpayment%2Fcallback%2Falipay%2Fnotify%2Fpay&sign=D2A6ua51os2aIzIH907ppK7Bd9Q2Kk5h7AtKPdudP%2Be%2BNTtAkp0Lfojtgl4BMOIQ3Z7cWyYMx6nk4qbntSx7aZnBhWAcImLbVVr1cmaYAedmrmJG%2B3f8G5TfAZu53ESzUgk02%2FhU1XV0iXRyE8TdEJ97ufmxwsUEc7K0EvwEFDIBCJg73meQtyCRFgCqYRWvmxetQgL7pwfKXpFXjAYsvFrRBas2YGYt689XpBS321g%2BZ8SZ0JOtLPWqhROzEs3dnAtWBW15y3NzRiSNi5rPzah4cWd4SgT0LZHmNf3eDQEHEcPmofoWfnA4ao75JmP95aLUxerMumzo9OwqhiYOUw%3D%3D&sign_type=RSA2×tamp=2019-08-25+16%3A11%3A22&version=1.0"
,
sign
:
"15aa99cd80878661a4d442b7540bdf96"
,
risk_info
:
'{"ip":"127.0.0.1"}'
,
},
},
// 头条支付
toTtPay
(
orderInfo
){
console
.
log
(
orderInfo
,
'---orderInfo'
)
tt
.
pay
({
orderInfo
,
service
:
3
,
service
:
3
,
payChannel
:
{
payChannel
:
{
default_pay_channel
:
"wx"
,
// wx || alipay
default_pay_channel
:
"wx"
,
// wx || alipay
...
@@ -177,7 +166,25 @@ export default {
...
@@ -177,7 +166,25 @@ export default {
let
{
out_order_no
}
=
res
;
let
{
out_order_no
}
=
res
;
return
new
Promise
(
function
(
resolve
,
reject
)
{
return
new
Promise
(
function
(
resolve
,
reject
)
{
// 商户前端根据 out_order_no 请求商户后端查询微信支付订单状态
// 商户前端根据 out_order_no 请求商户后端查询微信支付订单状态
let
query
=
{
orderSn
:
out_order_no
,
}
order
.
orderDetail
(
query
).
then
(
res
=>
{
if
(
res
.
data
.
code
==
200
){
console
.
log
(
res
.
data
.
data
,
'------------------订单信息'
)
// 商户后端查询的微信支付状态,通知收银台支付结果
// 0:支付成功
// 1:支付超时
// 2:支付失败
// 3:支付关闭
// 4:支付取消
// 9:订单状态未知/未支付
// resolve({ code: 0 | 1 | 2 | 3 | 9 });
}
else
{
console
.
log
(
res
.
data
.
msg
,
'------查询订单详情失败'
);
reject
(
res
.
data
.
msg
);
}
})
});
});
},
},
success
(
res
)
{
success
(
res
)
{
...
...
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