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
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
79 additions
and
65 deletions
+79
-65
build/webpack.base.conf.js
+43
-36
src/pages/wxPay/index.vue
+36
-29
No files found.
build/webpack.base.conf.js
View file @
6d523aff
...
...
@@ -33,66 +33,67 @@ let baseWebpackConfig = {
// 可以将 entry 写成 {'toPath': 'fromPath'} 的形式,
// toPath 为相对于 dist 的路径, 例:index/demo,则生成的文件地址为 dist/index/demo.js
entry
,
target
:
require
(
'mpvue-webpack-target'
),
target
:
require
(
"mpvue-webpack-target"
),
output
:
{
path
:
config
.
build
.
assetsRoot
,
jsonpFunction
:
'webpackJsonpMpvue'
,
filename
:
'[name].js'
,
publicPath
:
process
.
env
.
NODE_ENV
===
'production'
?
config
.
build
.
assetsPublicPath
:
config
.
dev
.
assetsPublicPath
jsonpFunction
:
"webpackJsonpMpvue"
,
filename
:
"[name].js"
,
publicPath
:
process
.
env
.
NODE_ENV
===
"production"
?
config
.
build
.
assetsPublicPath
:
config
.
dev
.
assetsPublicPath
},
resolve
:
{
extensions
:
[
'.js'
,
'.vue'
,
'.json'
],
extensions
:
[
".js"
,
".vue"
,
".json"
],
alias
:
{
'vue'
:
'mpvue'
,
'@'
:
resolve
(
'src'
),
'@config'
:
resolve
(
'config'
)
vue
:
"mpvue"
,
"@"
:
resolve
(
"src"
),
"@config"
:
resolve
(
"config"
)
},
symlinks
:
false
,
aliasFields
:
[
'mpvue'
,
'weapp'
,
'browser'
],
mainFields
:
[
'browser'
,
'module'
,
'main'
]
aliasFields
:
[
"mpvue"
,
"weapp"
,
"browser"
],
mainFields
:
[
"browser"
,
"module"
,
"main"
]
},
module
:
{
rules
:
[
{
test
:
/
\.
vue$/
,
loader
:
'mpvue-loader'
,
loader
:
"mpvue-loader"
,
options
:
vueLoaderConfig
},
{
test
:
/
\.
js$/
,
include
:
[
resolve
(
'src'
),
resolve
(
'test'
)],
include
:
[
resolve
(
"src"
),
resolve
(
"test"
)],
use
:
[
'babel-loader'
,
"babel-loader"
,
{
loader
:
'mpvue-loader'
,
options
:
Object
.
assign
({
checkMPEntry
:
true
},
vueLoaderConfig
)
}
,
loader
:
"mpvue-loader"
,
options
:
Object
.
assign
({
checkMPEntry
:
true
},
vueLoaderConfig
)
}
]
},
{
test
:
/
\.(
png|jpe
?
g|gif|svg
)(\?
.*
)?
$/
,
loader
:
'url-loader'
,
loader
:
"url-loader"
,
options
:
{
limit
:
10000
,
name
:
utils
.
assetsPath
(
'img/[name].[ext]'
)
name
:
utils
.
assetsPath
(
"img/[name].[ext]"
)
}
},
{
test
:
/
\.(
mp4|webm|ogg|mp3|wav|flac|aac
)(\?
.*
)?
$/
,
loader
:
'url-loader'
,
loader
:
"url-loader"
,
options
:
{
limit
:
10000
,
name
:
utils
.
assetsPath
(
'media/[name].[ext]'
)
name
:
utils
.
assetsPath
(
"media/[name].[ext]"
)
}
},
{
test
:
/
\.(
woff2
?
|eot|ttf|otf
)(\?
.*
)?
$/
,
loader
:
'url-loader'
,
loader
:
"url-loader"
,
options
:
{
limit
:
10000
,
name
:
utils
.
assetsPath
(
'fonts/[name].[ext]'
)
name
:
utils
.
assetsPath
(
"fonts/[name].[ext]"
)
}
}
]
...
...
@@ -100,25 +101,31 @@ let baseWebpackConfig = {
plugins
:
[
// api 统一桥协议方案
new
webpack
.
DefinePlugin
({
'mpvue'
:
'global.mpvue'
,
'mpvuePlatform'
:
'global.mpvuePlatform'
mpvue
:
"global.mpvue"
,
mpvuePlatform
:
"global.mpvuePlatform"
,
MINI_ENV
:
JSON
.
stringify
(
process
.
env
.
PLATFORM
)
}),
new
MpvuePlugin
(),
new
CopyWebpackPlugin
([{
from
:
'**/*.json'
,
to
:
''
}],
{
context
:
'src/'
}),
new
CopyWebpackPlugin
(
[
{
from
:
"**/*.json"
,
to
:
""
}
],
{
context
:
"src/"
}
),
new
CopyWebpackPlugin
([
{
from
:
path
.
resolve
(
__dirname
,
'../static'
),
to
:
path
.
resolve
(
config
.
build
.
assetsRoot
,
'./static'
),
ignore
:
[
'.*'
]
from
:
path
.
resolve
(
__dirname
,
"../static"
),
to
:
path
.
resolve
(
config
.
build
.
assetsRoot
,
"./static"
),
ignore
:
[
".*"
]
}
])
]
}
}
;
// 针对百度小程序,由于不支持通过 miniprogramRoot 进行自定义构建完的文件的根路径
// 所以需要将项目根路径下面的 project.swan.json 拷贝到构建目录
...
...
src/pages/wxPay/index.vue
View file @
6d523aff
...
...
@@ -5,6 +5,7 @@
<
script
>
import
{
formatTime
}
from
"@/utils/index"
;
import
wxPay
from
"@/api/wxPay"
;
import
order
from
"@/api/order"
;
export
default
{
components
:
{
// card
...
...
@@ -41,7 +42,7 @@ export default {
that
.
options
.
tradeType
=
"Mini"
;
console
.
log
(
"支付开始"
,
that
.
options
);
if
(
MINI_ENV
==
'tt'
){
that
.
toTtPay
();
that
.
getTtPayInfo
();
}
else
{
that
.
toPay
();
}
...
...
@@ -140,35 +141,23 @@ export default {
wx
.
showToast
({
title
:
res
.
data
.
msg
,
icon
:
"none"
});
});
},
// 头条支付
toTtPay
(){
getTtPayInfo
(){
console
.
log
(
"-----------------145头条支付"
)
let
query
=
{
orderSn
:
this
.
options
.
orderSn
}
wxPay
.
to_tt_pay
(
query
).
then
(
res
=>
{
if
(
res
.
data
.
code
==
200
){
res
.
data
.
data
.
total_amount
=
Number
(
res
.
data
.
data
.
total_amount
);
this
.
toTtPay
(
res
.
data
.
data
);
}
})
},
// 头条支付
toTtPay
(
orderInfo
){
console
.
log
(
orderInfo
,
'---orderInfo'
)
tt
.
pay
({
orderInfo
:
{
app_id
:
"800000040005"
,
sign_type
:
"MD5"
,
out_order_no
:
"MicroApp7075638135"
,
merchant_id
:
"1300000004"
,
timestamp
:
"1566720681"
,
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"}'
,
},
orderInfo
,
service
:
3
,
payChannel
:
{
default_pay_channel
:
"wx"
,
// wx || alipay
...
...
@@ -177,7 +166,25 @@ export default {
let
{
out_order_no
}
=
res
;
return
new
Promise
(
function
(
resolve
,
reject
)
{
// 商户前端根据 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
)
{
...
...
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