Toggle navigation
Toggle navigation
This project
Loading...
Sign in
mobile
/
yoho-miniapp-ufo
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
黄敬囿
6 years ago
Commit
00dc2eff2b21c2615c4474fc1026194e36a1c820
1 parent
4d4fed8c
微信支付流程 review by 李其昌
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
122 additions
and
100 deletions
src/components/order/orderaction.js
src/pages/order/orderConfirm/orderConfirm.js
src/pages/order/orderService.js
src/pages/order/orderSuccess/orderSuccess.js
src/pages/order/orderSuccess/orderSuccess.wxml
src/pages/order/wxpay.js
src/pages/orderDetail/index.js
src/router/rules.js
src/components/order/orderaction.js
View file @
00dc2ef
...
...
@@ -2,6 +2,7 @@
// import event from '../../utils/event.js';
import
{
formatTimeByMin
}
from
'../../utils/index.js'
;
import
{
showDialog
}
from
'./orderActionUtil.js'
;
import
{
prePay
}
from
'../../pages/order/wxpay.js'
// import OrderActionService from './orderActionService.js';
// const DEL_ORDER = 'del_order';
const
BUY_AGAIN
=
'buy_again'
;
...
...
@@ -94,16 +95,13 @@ detached: function () {
let
productId
=
e
.
currentTarget
.
dataset
.
productId
;
if
(
actionCode
==
BUY_AGAIN
)
{
wx
.
navigateTo
({
url
:
'/pages/productDetail/index?id='
+
productId
,
})
let
params
=
{
id
:
productId
}
router
.
go
(
'productDetail'
,
params
);
}
else
if
(
actionCode
==
NOW_BUY
){
console
.
log
(
"== 去支付页面==="
)
wx
.
navigateTo
({
//todo:
//url: '/pages/productDetail/index?id=' + productId,
})
prePay
(
productId
,
orderCode
,
1
);
}
else
if
(
actionCode
==
SHOW_DETAIL
)
{
wx
.
navigateTo
({
url
:
'../orderDetail/index?orderCode='
+
orderCode
...
...
src/pages/order/orderConfirm/orderConfirm.js
View file @
00dc2ef
...
...
@@ -8,6 +8,7 @@
import
orderService
from
'../orderService'
import
{
getImgUrl
}
from
'../../../utils'
;
import
router
from
'../../../router/index.js'
import
{
prePay
}
from
'../../order/wxpay.js'
Page
({
...
...
@@ -115,7 +116,9 @@ Page({
if
(
data
&&
data
.
orderCode
)
{
//todo:待处理微信数据分析上报,订单生成
// wx.reportAnalytics(eventName, data)
this
.
prePay
(
data
.
orderCode
)
let
orderCode
=
data
.
orderCode
;
let
productId
=
data
.
productId
?
data
.
productId
:
''
;
prePay
(
productId
,
orderCode
,
0
);
}
})
.
catch
(
error
=>
{
...
...
@@ -124,77 +127,10 @@ Page({
},
prePay
(
orderCode
)
{
this
.
setData
({
orderCode
:
orderCode
})
// return wx.navigateTo({
// url: `./orderSuccess?product_id=${this.data.product_id}&orderCode=${this.data.orderCode}`
// })
let
api
=
new
orderService
()
wx
.
showLoading
({
title
:
''
,
})
api
.
prePay
(
orderCode
,
()
=>
wx
.
hideLoading
())
.
then
(
data
=>
{
if
(
data
&&
data
.
prePayData
)
{
this
.
callWxPay
(
data
.
prePayData
)
}
})
.
catch
(
error
=>
{
console
.
log
(
error
)
})
},
callWxPay
(
data
)
{
data
.
paySign
=
data
.
sign
;
data
.
timeStamp
=
data
.
timestamp
data
.
nonceStr
=
data
.
noncestr
data
.
signType
=
'MD5'
data
.
package
=
'prepay_id='
+
data
.
prepayid
wx
.
requestPayment
({
...
data
,
success
:
function
(
res
)
{
wx
.
navigateTo
({
url
:
`
.
/
orderSuccess
?
product_id
=
$
{
this
.
data
.
product_id
}
&
orderCode
=
$
{
this
.
data
.
orderCode
}
`
})
},
fail
:
function
(
res
)
{
console
.
log
(
res
)
if
(
res
.
errMsg
==
'requestPayment:fail cancel'
){
// wx.redirectTo({
// url: '../orders/orders'
// })
}
else
{
wx
.
showModal
({
content
:
res
.
errMsg
,
showCancel
:
false
,
confirmText
:
"确定"
,
complete
:
function
(
res
)
{
// wx.redirectTo({
// url: '../orders/orders'
// })
}
})
}
}
})
},
chooseAddress
:
function
(){
// var pages = getCurrentPages();
// var prevPage = pages[pages.length - 2]; //上一个页面
// prevPage.setData({
// address: {
//
// }
// })
//
// wx.navigateBack();
wx
.
navigateTo
({
url
:
'../../userCenter/addressManager/addressManager?currentMode=modeSelect&address_id='
+
(
this
.
data
.
address
?
this
.
data
.
address
.
address_id
:
''
)
})
...
...
src/pages/order/orderService.js
View file @
00dc2ef
...
...
@@ -55,11 +55,12 @@ export default class orderService extends BaseService {
})
}
async
prePay
(
orderCode
,
complete
)
{
async
prePay
(
orderCode
,
openId
,
complete
)
{
return
await
this
.
GET
({
orderCode
,
payment
:
1
,
openid
:
openId
,
payment
:
3
,
method
:
BUYER_PREPAY
,
debug
:
'XYZ'
},{
...
...
src/pages/order/orderSuccess/orderSuccess.js
View file @
00dc2ef
...
...
@@ -6,6 +6,7 @@
*/
import
orderService
from
'../orderService'
import
router
from
'../../../router/index.js'
Page
({
...
...
@@ -19,22 +20,26 @@ Page({
},
onLoad
:
function
(
option
)
{
option
&&
this
.
setData
({
product_id
:
option
.
product_id
,
orderCode
:
option
.
orderCode
})
this
.
fetchComputeCompensate
()
this
.
fetchRecommend
()
},
if
(
option
){
let
productId
=
option
.
product_id
let
orderCode
=
option
.
orderCode
if
(
productId
){
this
.
fetchRecommend
(
productId
)
}
if
(
orderCode
){
this
.
fetchComputeCompensate
(
orderCode
)
}
}
},
fetchRecommend
()
{
fetchRecommend
(
product_id
)
{
let
api
=
new
orderService
()
wx
.
showLoading
({
title
:
''
,
})
let
product_id
=
this
.
data
.
product_id
//
let product_id = this.data.product_id
api
.
getRecommendList
(
product_id
,
()
=>
wx
.
hideLoading
())
.
then
(
data
=>
{
data
&&
data
.
product_list
&&
this
.
setData
({
...
...
@@ -51,14 +56,14 @@ Page({
})
},
fetchComputeCompensate
()
{
fetchComputeCompensate
(
orderCode
)
{
let
api
=
new
orderService
()
wx
.
showLoading
({
title
:
''
,
})
let
orderCode
=
this
.
data
.
orderCode
;
//
let orderCode = this.data.orderCode;
api
.
getComputeCompensate
(
orderCode
,
()
=>
wx
.
hideLoading
())
.
then
(
data
=>
{
this
.
setData
({
...
...
@@ -76,5 +81,12 @@ Page({
})
},
checkOrderClick
:
function
()
{
let
params
=
{
orderCode
:
this
.
data
.
orderCode
}
router
.
go
(
'orderDetail'
,
params
);
},
})
...
...
src/pages/order/orderSuccess/orderSuccess.wxml
View file @
00dc2ef
...
...
@@ -9,7 +9,7 @@
<text class="compensateText"> 如卖家原因导致交易失败,您可获赔付{{compensale}}元保证金,建议您设置支付宝账号作为赔偿收款账户,如未绑定支付宝账号则视为放弃赔偿。</text>
</view>
<view class="checkOrderContainer">
<view class="checkOrderContainer"
bindtap='checkOrderClick'
>
<text class="checkOrderText">{{checkOrderButtonText}}</text>
</view>
...
...
src/pages/order/wxpay.js
0 → 100644
View file @
00dc2ef
import
orderService
from
'./orderService.js'
import
router
from
'../../router/index.js'
// const api = new orderService();
/**
* orderCode 订单号
* fromWhere 支付来源页面 0:确认订单页面,1:订单列表,2:订单详情
*/
export
const
prePay
=
function
(
productId
,
orderCode
,
fromWhere
)
{
let
api
=
new
orderService
()
wx
.
showLoading
({
title
:
''
,
})
let
openID
=
''
;
try
{
openID
=
wx
.
getStorageSync
(
'openid'
)
}
catch
(
e
)
{
}
if
(
openID
)
{
api
.
prePay
(
orderCode
,
openID
,
()
=>
wx
.
hideLoading
())
.
then
(
data
=>
{
if
(
data
)
{
callWxPay
(
data
,
productId
,
orderCode
,
fromWhere
)
}
})
.
catch
(
error
=>
{
console
.
log
(
error
)
})
}
else
{
//提示重新登录
}
}
function
callWxPay
(
data
,
productId
,
orderCode
,
fromWhere
)
{
let
that
=
this
;
// let orderCode = ;
wx
.
requestPayment
({
...
data
,
success
:
function
(
res
)
{
console
.
log
(
'orderCode:'
+
orderCode
+
'==productID:'
+
productId
);
let
params
=
{
orderCode
:
orderCode
,
product_id
:
productId
}
router
.
go
(
'orderSuccess'
,
params
);
},
fail
:
function
(
res
)
{
console
.
log
(
res
)
let
params
=
{
orderCode
:
orderCode
}
if
(
res
.
errMsg
==
'requestPayment:fail cancel'
)
{
if
(
fromWhere
==
0
){
router
.
go
(
'orderDetail'
,
params
);
}
}
else
{
wx
.
showModal
({
content
:
res
.
errMsg
,
showCancel
:
false
,
confirmText
:
"确定"
,
complete
:
function
(
res
)
{
if
(
fromWhere
==
0
)
{
router
.
go
(
'orderDetail'
,
params
);
}
}
})
}
}
})
}
\ No newline at end of file
...
...
src/pages/orderDetail/index.js
View file @
00dc2ef
...
...
@@ -3,6 +3,8 @@ import OrderDetailService from './orderDetailService.js'
import
OrderActionService
from
'../../components/order/orderActionService.js'
;
import
{
getImgUrl
,
formatTimeByMin
}
from
'../../utils/index.js'
;
import
{
showDialog
}
from
'../../components/order/orderActionUtil.js'
;
import
{
prePay
}
from
'../order/wxpay.js'
import
router
from
'../../router/index.js'
const
BUY_AGAIN
=
'buy_again'
;
const
NOW_BUY
=
'now_buy'
;
var
interval
;
...
...
@@ -129,16 +131,13 @@ Page({
let
productId
=
e
.
currentTarget
.
dataset
.
productId
;
if
(
actionCode
==
BUY_AGAIN
)
{
wx
.
navigateTo
({
url
:
'/pages/productDetail/index?id='
+
productId
,
})
let
params
=
{
id
:
productId
}
router
.
go
(
'productDetail'
,
params
);
}
else
if
(
actionCode
==
NOW_BUY
)
{
console
.
log
(
"== 去支付页面==="
)
wx
.
navigateTo
({
//todo:
//url: '/pages/productDetail/index?id=' + productId,
})
prePay
(
productId
,
orderCode
,
2
);
}
else
{
showDialog
(
orderCode
,
actionCode
,
1
);
}
...
...
src/router/rules.js
View file @
00dc2ef
...
...
@@ -39,5 +39,8 @@ export default {
},
nativeLogin
:
{
path
:
'/pages/nativeLogin/nativeLogin'
},
orderSuccess
:
{
path
:
'/pages/order/orderSuccess/orderSuccess'
}
}
\ No newline at end of file
...
...
Please
register
or
login
to post a comment