Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
U
uni-pdtravel
Project
Project
Details
Activity
Releases
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
panyongping
uni-pdtravel
Commits
8f224082
Commit
8f224082
authored
Aug 05, 2021
by
潘永坪
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
扫码支付页面登录修改
parent
50584994
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
68 additions
and
13 deletions
+68
-13
App.vue
App.vue
+2
-1
request.js
common/request.js
+0
-3
ourPayment.vue
pages/ourPayment/ourPayment.vue
+66
-9
No files found.
App.vue
View file @
8f224082
...
@@ -6,8 +6,9 @@
...
@@ -6,8 +6,9 @@
//4.setStorageSync与setStorage的区别:如果后续的操作需要使用更新storage后保存的data,则使用setStorageSync使用异步性能更好,使用同步数据更安全
//4.setStorageSync与setStorage的区别:如果后续的操作需要使用更新storage后保存的data,则使用setStorageSync使用异步性能更好,使用同步数据更安全
export
default
{
export
default
{
onLaunch
:
function
(
options
)
{
//初始化完成时触发(全局只触发一次
onLaunch
:
function
(
options
)
{
//初始化完成时触发(全局只触发一次
let
path
=
options
.
path
let
openid
=
uni
.
getStorageSync
(
"openid"
)
let
openid
=
uni
.
getStorageSync
(
"openid"
)
if
(
!
openid
){
if
(
!
openid
&&
path
.
indexOf
(
"pages/ourPayment/ourPayment"
)
==-
1
){
//扫码支付页面不需要在此登录
setTimeout
(()
=>
{
//解决关联普通二维码扫码首次进入时一直显示登录中
setTimeout
(()
=>
{
//解决关联普通二维码扫码首次进入时一直显示登录中
uni
.
navigateTo
({
uni
.
navigateTo
({
url
:
"/pages/login/login"
url
:
"/pages/login/login"
...
...
common/request.js
View file @
8f224082
...
@@ -6,7 +6,6 @@ if(process.env.NODE_ENV === 'development'){//开发环境
...
@@ -6,7 +6,6 @@ if(process.env.NODE_ENV === 'development'){//开发环境
}
}
const
request
=
(
url
=
''
,
data
=
{},
type
=
'POST'
)
=>
{
const
request
=
(
url
=
''
,
data
=
{},
type
=
'POST'
)
=>
{
uni
.
showLoading
({
title
:
'加载中'
,
mask
:
true
})
data
.
reqId
=
new
Date
().
getTime
()
//获取时间戳
data
.
reqId
=
new
Date
().
getTime
()
//获取时间戳
return
new
Promise
((
resolve
,
reject
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
uni
.
request
({
uni
.
request
({
...
@@ -15,11 +14,9 @@ const request = (url = '', data = {}, type = 'POST') => {
...
@@ -15,11 +14,9 @@ const request = (url = '', data = {}, type = 'POST') => {
data
:
data
,
data
:
data
,
dataType
:
'json'
,
dataType
:
'json'
,
}).
then
((
response
)
=>
{
}).
then
((
response
)
=>
{
uni
.
hideLoading
()
let
[
error
,
res
]
=
response
;
let
[
error
,
res
]
=
response
;
resolve
(
res
.
data
);
resolve
(
res
.
data
);
}).
catch
(
error
=>
{
}).
catch
(
error
=>
{
uni
.
hideLoading
()
let
[
err
,
res
]
=
error
;
let
[
err
,
res
]
=
error
;
reject
(
err
)
reject
(
err
)
})
})
...
...
pages/ourPayment/ourPayment.vue
View file @
8f224082
...
@@ -172,17 +172,66 @@
...
@@ -172,17 +172,66 @@
this
.
merchantId
=
option
.
merchantId
this
.
merchantId
=
option
.
merchantId
this
.
companyId
=
option
.
companyId
this
.
companyId
=
option
.
companyId
}
}
if
(
this
.
merchantId
)
{
//大商家的有merchantId
if
(
uni
.
getStorageSync
(
"openid"
)){
this
.
init
()
this
.
openid
=
uni
.
getStorageSync
(
"openid"
)
}
else
{
//小商家没有merchantId
if
(
this
.
merchantId
)
{
//大商家的有merchantId
this
.
initTwo
()
this
.
init
()
}
else
{
//小商家没有merchantId
this
.
initTwo
()
}
//#ifdef MP-WEIXIN
this
.
initCoupon
()
//#endif
}
else
{
this
.
login
()
}
}
//#ifdef MP-WEIXIN
this
.
initCoupon
()
//#endif
},
},
methods
:
{
methods
:
{
login
(){
//---------------------------------------------------------------------登录
let
_this
=
this
uni
.
getProvider
({
service
:
'oauth'
,
success
(
proRes
){
uni
.
login
({
provider
:
proRes
.
provider
[
0
],
success
:
function
(
res
)
{
if
(
res
.
code
){
let
source
=
""
if
(
proRes
.
provider
[
0
]
==
"weixin"
){
source
=
3
}
else
if
(
proRes
.
provider
[
0
]
==
"alipay"
){
source
=
4
}
let
data
=
{
code
:
res
.
code
,
source
,
//微信小程序3,支付宝小程序4
}
_this
.
$request
(
'wechat/wx/getUserInfoByCode'
,
data
).
then
(
res
=>
{
if
(
res
.
code
==
'00'
){
_this
.
openid
=
res
.
data
.
openid
uni
.
setStorageSync
(
'openid'
,
_this
.
openid
)
if
(
_this
.
merchantId
)
{
//大商家的有merchantId
_this
.
init
()
}
else
{
//小商家没有merchantId
_this
.
initTwo
()
}
//#ifdef MP-WEIXIN
_this
.
initCoupon
()
//#endif
}
else
{
uni
.
removeStorageSync
(
'openid'
)
}
}).
catch
((
err
)
=>
{
uni
.
removeStorageSync
(
'openid'
)
})
}
}
})
}
})
},
getUrlKey
(
name
){
//---------------------------------------------------------------获取url
getUrlKey
(
name
){
//---------------------------------------------------------------获取url
return
(
new
RegExp
(
'[?|&]'
+
name
+
'='
+
'([^&;]+?)(&|#|;|$)'
).
exec
(
decodeURIComponent
(
this
.
enterUrl
))
||
[,
""
])[
1
].
replace
(
/
\+
/g
,
'%20'
)
||
""
;
return
(
new
RegExp
(
'[?|&]'
+
name
+
'='
+
'([^&;]+?)(&|#|;|$)'
).
exec
(
decodeURIComponent
(
this
.
enterUrl
))
||
[,
""
])[
1
].
replace
(
/
\+
/g
,
'%20'
)
||
""
;
},
},
...
@@ -223,7 +272,9 @@
...
@@ -223,7 +272,9 @@
"merchantId"
:
this
.
merchantId
,
"merchantId"
:
this
.
merchantId
,
"companyId"
:
this
.
companyId
,
"companyId"
:
this
.
companyId
,
}
}
uni
.
showLoading
({
title
:
'加载中'
,
mask
:
true
})
this
.
$request
(
"scenic/order/findCodePayInfo"
,
data
).
then
((
res
)
=>
{
this
.
$request
(
"scenic/order/findCodePayInfo"
,
data
).
then
((
res
)
=>
{
uni
.
hideLoading
()
if
(
res
.
code
==
"00"
)
{
if
(
res
.
code
==
"00"
)
{
this
.
name
=
res
.
data
.
name
this
.
name
=
res
.
data
.
name
}
else
{
}
else
{
...
@@ -232,13 +283,17 @@
...
@@ -232,13 +283,17 @@
icon
:
"none"
icon
:
"none"
})
})
}
}
}).
catch
((
err
)
=>
{
uni
.
hideLoading
()
})
})
},
},
initTwo
()
{
//--------------------------------------------------------------------------初始化获取商家名称,没有merchantId的小商家
initTwo
()
{
//--------------------------------------------------------------------------初始化获取商家名称,没有merchantId的小商家
let
data
=
{
let
data
=
{
"id"
:
this
.
companyId
,
"id"
:
this
.
companyId
,
}
}
uni
.
showLoading
({
title
:
'加载中'
,
mask
:
true
})
this
.
$request
(
"user/company/detail"
,
data
).
then
((
res
)
=>
{
this
.
$request
(
"user/company/detail"
,
data
).
then
((
res
)
=>
{
uni
.
hideLoading
()
if
(
res
.
code
==
"00"
){
if
(
res
.
code
==
"00"
){
this
.
name
=
res
.
data
.
companyVo
.
companyName
this
.
name
=
res
.
data
.
companyVo
.
companyName
}
else
{
}
else
{
...
@@ -247,6 +302,8 @@
...
@@ -247,6 +302,8 @@
icon
:
"none"
icon
:
"none"
})
})
}
}
}).
catch
((
err
)
=>
{
uni
.
hideLoading
()
})
})
},
},
initCoupon
()
{
//-------------------------------------------------------------------------加载优惠券
initCoupon
()
{
//-------------------------------------------------------------------------加载优惠券
...
@@ -258,7 +315,7 @@
...
@@ -258,7 +315,7 @@
merchantId
:
this
.
merchantId
,
//商户Id
merchantId
:
this
.
merchantId
,
//商户Id
companyId
:
this
.
companyId
,
//公司Id
companyId
:
this
.
companyId
,
//公司Id
orderSource
:
this
.
orderSource
,
//订单来源 8扫码支付
orderSource
:
this
.
orderSource
,
//订单来源 8扫码支付
openid
:
uni
.
getStorageSync
(
"openid"
)
openid
:
this
.
openid
}
}
this
.
$request
(
"wechatUser/myPage/usableCouponList"
,
data
).
then
((
res
)
=>
{
this
.
$request
(
"wechatUser/myPage/usableCouponList"
,
data
).
then
((
res
)
=>
{
if
(
res
.
code
==
"00"
)
{
if
(
res
.
code
==
"00"
)
{
...
@@ -315,7 +372,7 @@
...
@@ -315,7 +372,7 @@
let
data
=
{
let
data
=
{
companyId
:
this
.
companyId
,
companyId
:
this
.
companyId
,
merchantId
:
this
.
merchantId
,
merchantId
:
this
.
merchantId
,
userId
:
uni
.
getStorageSync
(
"openid"
)
,
userId
:
this
.
openid
,
orderMoney
:
parseFloat
(
this
.
buyMoney
),
orderMoney
:
parseFloat
(
this
.
buyMoney
),
payType
:
this
.
payType
,
//支付类型,
payType
:
this
.
payType
,
//支付类型,
orderSource
:
this
.
orderSource
,
//订单来源 8扫码支付
orderSource
:
this
.
orderSource
,
//订单来源 8扫码支付
...
...
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