Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mini_own
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
geruidan
mini_own
Commits
f9aa0f8c
Commit
f9aa0f8c
authored
Mar 20, 2023
by
珠峰架构
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
小程序支付调整
parent
7750ba44
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
266 additions
and
158 deletions
+266
-158
pages.json
pages.json
+10
-10
pages/h5/index.vue
pages/h5/index.vue
+11
-13
pages/h5/pay.vue
pages/h5/pay.vue
+98
-21
pages/index/index.vue
pages/index/index.vue
+36
-84
shopro/platform/index.js
shopro/platform/index.js
+0
-1
shopro/request/apis.js
shopro/request/apis.js
+11
-1
shopro/store/modules/user.js
shopro/store/modules/user.js
+100
-27
shopro/wechat/sdk.js
shopro/wechat/sdk.js
+0
-1
No files found.
pages.json
View file @
f9aa0f8c
...
...
@@ -30,6 +30,15 @@
"enablePullDownRefresh"
:
false
}
},{
"path"
:
"pages/h5/pay"
,
"name"
:
"pay"
,
"style"
:
{
"navigationBarTitleText"
:
"支付"
,
"enablePullDownRefresh"
:
false
}
},{
"path"
:
"pages/index/cart"
,
"name"
:
"cart"
,
"style"
:
...
...
@@ -47,16 +56,7 @@
}
}
,{
"path"
:
"pages/h5/pay"
,
"name"
:
"pay"
,
"style"
:
{
"navigationBarTitleText"
:
"支付"
,
"enablePullDownRefresh"
:
false
}
}
],
"subPackages"
:[],
"tabBar"
:
{
...
...
pages/h5/index.vue
View file @
f9aa0f8c
...
...
@@ -9,21 +9,18 @@
export
default
{
data
()
{
return
{
webUrl
:
''
webUrl
:
''
,
appointPage
:
''
}
}
,
onReady
(){
// this.webUrl = "http://172.18.0.147:8000/#/?time="+new Date().getTime()
// this.webUrl = "https://wxcs.zhonghuihaotai.com/webpage/wxdist/index.html#/?mallId=171795610000098&time="+new Date().getTime()
// this.webUrl = "https://wx.zhonghuihaotai.com/webpage/wxdist/index.html#/?mallId=134581110000230&companyId=00000310&time="+new Date().getTime()
},
methods
:{
handleMsg
(
e
){
console
.
log
(
e
)
console
.
log
(
'
接收到消息:
'
+
JSON
.
stringify
(
e
.
detail
.
data
));
uni
.
navigateToMiniProgram
({
orderId
:
data
.
orderId
,
});
// uni.navigateToMiniProgram({
// orderId: data.orderId,
// });
},
saveMiniCode
(){
let
fsCode
=
uni
.
getStorageSync
(
'
token
'
);
...
...
@@ -31,16 +28,17 @@
if
(
!
res
.
code
&&
res
.
data
)
{
let
code
=
res
.
data
.
sfCode
;
let
time
=
new
Date
().
getTime
();
this
.
webUrl
=
`https://wxcs.zhonghuihaotai.com/webpage/wxdist/index.html#/?mallId=106975910000477&companyId=999999998&time=
${
time
}
&sfCode=
${
code
}
`
this
.
webUrl
=
`https://wxcs.zhonghuihaotai.com/webpage/wxdist/index.html#/
${
this
.
appointPage
?
this
.
appointPage
:
""
}
?mallId=106975910000477&companyId=999999998&time=
${
time
}
&sfCode=
${
code
}
&authMode=force
`
// this.webUrl = `https://wxcs.zhonghuihaotai.com/webpage/wxdist/index.html#/?mallId=106975910000477&companyId=999999998&time=${time}&sfCode=${code}`
}
else
{
}
console
.
log
(
this
.
webUrl
)
}
})
}
},
onLoad
(){
uni
.
hideTabBar
();
onLoad
(
option
){
this
.
appointPage
=
option
.
appointPage
;
//指定页面
// uni.hideTabBar();
this
.
saveMiniCode
();
},
onLaunch
(){
...
...
pages/h5/pay.vue
View file @
f9aa0f8c
<
template
>
<view>
<button
@
click=
"pay"
>
测试小程序支付
</button>
<view
class=
"pay-container"
v-if=
"!isPay"
>
<view
class=
"money-box"
>
¥
<text
class=
"money"
>
{{
actuallyPay
}}
</text></view>
<u-button
@
click=
"pay"
shape=
"circle"
type=
"primary"
text=
"确认支付"
color=
"#61b077"
></u-button>
</view>
<view
class=
"payResult"
v-else
>
<u-icon
v-if=
"payStatus == 'pending'"
name=
"clock"
size=
"60px"
color=
"#61b077"
></u-icon>
<u-icon
v-else-if=
"payStatus == 'fulfilled'"
name=
"checkmark-circle"
size=
"60px"
color=
"#61b077"
></u-icon>
<u-icon
v-else
name=
"close-circle"
size=
"60px"
color=
"#ff0000"
></u-icon>
<view
class=
"tips"
>
{{
payTips
}}
</view>
<view
class=
"bot"
>
<view
class=
"lf"
>
<u-button
type=
"primary"
color=
"#61b077"
text=
"查看订单"
@
click=
"goPath('shopMallList')"
></u-button>
</view>
<view
class=
"rt"
>
<u-button
type=
"primary"
color=
"#61b077"
:plain=
"true"
text=
"继续购买"
@
click=
"goPath('')"
></u-button>
</view>
</view>
</view>
</view>
</
template
>
<
script
>
import
http
from
'
@/shopro/request/index
'
;
export
default
{
data
()
{
return
{
params
:{}
params
:{},
actuallyPay
:
""
,
//现金支付
payStatus
:
'
pending
'
,
payTips
:
"
等待中
"
,
orderId
:
""
,
isPay
:
false
}
},
methods
:
{
goPath
(
path
){
uni
.
navigateTo
({
url
:
`/pages/h5/index?appointPage=
${
path
}
`
})
},
// 支付结果查询
payResult
(){
http
(
'
user.status
'
,
{
orderId
:
this
.
orderId
}).
then
(
res
=>
{
if
(
res
.
code
==
0
){
if
(
res
.
data
)
{
this
.
payStatus
=
"
fulfilled
"
;
this
.
payTips
=
"
下单成功
"
;
}
else
{
this
.
payStatus
=
"
rejected
"
;
this
.
payTips
=
"
支付有延迟,请查看订单
"
;
}
}
})
},
pay
()
{
console
.
log
(
this
.
params
)
let
that
=
this
;
wx
.
requestPayment
({
appId
:
this
.
params
.
appId
,
timeStamp
:
this
.
params
.
timeStamp
,
nonceStr
:
this
.
params
.
nonceStr
,
package
:
this
.
params
.
nonceStr
,
package
:
this
.
params
.
package
,
signType
:
this
.
params
.
signType
,
paySign
:
this
.
params
.
paySign
,
success
(
res
)
{
console
.
log
(
"
小程序成功。。。。
"
)
console
.
log
(
res
)
that
.
isPay
=
true
;
that
.
payResult
();
},
fail
(
res
)
{
console
.
log
(
"
shibai 。。。。
"
)
console
.
log
(
res
)
fail
(
err
)
{
that
.
isPay
=
false
;
if
(
err
.
errMsg
==
'
requestPayment:fail cancel
'
){
that
.
$u
.
toast
(
"
取消支付
"
);
}
else
{
that
.
$u
.
toast
(
err
.
errMsg
);
}
}
})
}
},
onLoad
(
option
){
let
{
data
,
orderId
}
=
option
;
console
.
log
(
option
);
let
{
data
,
orderId
,
actuallyPay
}
=
option
;
this
.
actuallyPay
=
actuallyPay
;
this
.
orderId
=
orderId
;
this
.
params
=
JSON
.
parse
(
decodeURIComponent
(
data
));
console
.
log
(
this
.
params
);
}
}
</
script
>
<
style
>
<
style
lang=
"scss"
scoped
>
.pay-container
{
.money-box
{
font-size
:
28rpx
;
font-weight
:
bold
;
margin
:
100rpx
0
;
text-align
:
center
;
.money
{
font-size
:
48rpx
;
}
}
::v-deep
.u-button
{
width
:
80%
;
}
}
.payResult
{
text-align
:
center
;
margin
:
100rpx
0
;
::v-deep
.u-icon
{
justify-content
:
center
;
}
.tips
{
font-size
:
38rpx
;
color
:
#61b077
;
margin
:
20rpx
0
80rpx
0
;
}
.bot
{
margin
:
0
auto
;
display
:
flex
;
justify-content
:
space-between
;
align-items
:
center
;
padding
:
0
10%
;
.lf
,
.rt
{
width
:
45%
;
}
}
}
</
style
>
pages/index/index.vue
View file @
f9aa0f8c
...
...
@@ -6,17 +6,15 @@
<image
src=
"../../static/img/run/runBg.png"
class=
"run-logo"
mode=
"widthFix"
></image>
<view
class=
"run-step-number"
>
<text
class=
"title"
>
今日步数
</text>
<view
class=
"steps"
v-if=
"
todayNum
"
>
<view
class=
"steps"
v-if=
"
unregistered
"
>
<text
class=
"num"
>
{{
todayNum
}}
</text>
<text>
步
</text>
</view>
<view
v-else
class=
"steps-empower"
>
<u-button
type=
"primary"
size=
"mini"
color=
"#00c791"
:plain=
"true"
text=
"授权查看"
></u-button>
<u-button
open-type=
"getPhoneNumber"
@
getphonenumber=
"getInfoPhoneNumber"
type=
"primary"
size=
"mini"
color=
"#00c791"
:plain=
"true"
text=
"授权查看"
></u-button>
</view>
</view>
<image
src=
"../../static/img/run/ranking_btn.png"
class=
"ranking_btn"
mode=
"widthFix"
></image>
<!-- open-type="getPhoneNumber" @getphonenumber="getPhoneNumber" -->
<!--
<button
open-type=
"getPhoneNumber"
@
getphonenumber=
"getPhoneNumber"
>
1111
</button>
-->
</view>
</view>
<u-tabbar
:value=
"tabBarVal"
@
change=
"changeTabBar"
:fixed=
"true"
:placeholder=
"true"
activeColor=
"#00c791"
:safeAreaInsetBottom=
"true"
>
...
...
@@ -45,7 +43,7 @@
export
default
{
data
()
{
return
{
todayNum
:
0
,
unregistered
:
false
,
tabBarVal
:
'
步数
'
,
registerPopup
:
true
,
form
:{
name
:
'
xxx
'
},
...
...
@@ -54,55 +52,47 @@
}
},
computed
:
{
...
mapGetters
([
'
userInfo
'
])
...
mapGetters
([
'
userInfo
'
,
'
todayNum
'
])
},
methods
:
{
...
mapActions
([]),
// 获取步数
getWeRunData
()
{
let
wRunEncryptedData
=
{}
let
that
=
this
;
uni
.
getWeRunData
({
success
:
function
(
res
)
{
wRunEncryptedData
.
encryptedData
=
res
.
encryptedData
wRunEncryptedData
.
iv
=
res
.
iv
http
(
'
user.wxRun
'
,
wRunEncryptedData
).
then
(
res
=>
{
if
(
!
res
.
code
&&
res
.
data
)
{
// that.todayNum = res.data.todayNum;
that
.
todayNum
=
0
;
console
.
log
(
that
.
todayNum
)
}
else
{
that
.
todayNum
=
0
;
// that.$u.toast(res.msg);
}
})
}
})
},
...
mapActions
([
'
getPhoneNumber
'
,
'
registerInfoFn
'
,
'
getWeRunDataFn
'
,
'
authCheck
'
,
'
getUserInfo
'
]),
// 切换底部tab;
changeTabBar
(
name
){
this
.
tabBarVal
=
name
;
console
.
log
(
name
)
if
(
name
==
'
商城
'
)
{
// let fsCode = uni.getStorageSync('token');
// http('user.miniCode', {fsCode:fsCode}).then(res => {
// if (!res.code && res.data) {
uni
.
navigateTo
({
url
:
'
/pages/h5/index
'
,
})
// } else {
// that.todayNum = 0;
// }
// })
if
(
!
this
.
unregistered
)
{
this
.
$u
.
toast
(
"
点击授权进行注册
"
);
return
false
;
}
uni
.
navigateTo
({
url
:
'
/pages/h5/index
'
,
})
}
},
getPhoneNumber
(
e
)
{
if
(
!
e
.
detail
.
code
){
this
.
$u
.
toast
(
e
.
detail
.
code
);
// 获取手机号
async
getInfoPhoneNumber
(
e
)
{
let
number
=
await
this
.
getPhoneNumber
(
e
);
let
register
=
await
this
.
registerInfoFn
();
if
(
register
){
//注册成功,再掉获取步数接口
let
runData
=
await
this
.
getWeRunDataFn
();
runData
&&
(
this
.
unregistered
=
true
);
}
},
async
getAuth
(){
let
token
=
uni
.
getStorageSync
(
'
token
'
);
// 如果有缓存信息
if
(
token
)
{
let
auth
=
await
this
.
authCheck
();
if
(
auth
==
0
)
{
let
runData
=
await
this
.
getWeRunDataFn
();
runData
&&
(
this
.
unregistered
=
true
);
}
else
if
(
auth
==
2001
){
this
.
unregistered
=
false
;
}
}
else
{
let
getUserInfo
=
await
this
.
getUserInfo
();
}
}
},
onHide
(){
},
...
...
@@ -111,45 +101,7 @@
// uni.hideTabBar();
},
onReady
()
{
// this.geAauthorizeWeRun()
let
token
=
uni
.
getStorageSync
(
'
token
'
);
// 如果有缓存信息
if
(
token
)
{
let
authCheck
=
store
.
dispatch
(
'
authCheck
'
);
authCheck
.
then
(
resolve
=>
{
this
.
getWeRunData
()
}).
catch
(
errCode
=>
{
console
.
log
(
errCode
)
if
(
errCode
==
2001
)
{
// 手机号输入
console
.
log
(
this
.
userInfo
)
console
.
log
(
"
信息是--------------
"
)
this
.
registerInfo
=
{
companyId
:
'
999999998
'
,
//开放式传
mobile
:
'
15501156151
'
,
//封闭式传
empcardno
:
''
,
//封闭式传
registerType
:
'
register
'
//注册时的类型为普通注册
}
console
.
log
(
this
.
registerInfo
)
http
(
'
user.register
'
,
this
.
registerInfo
).
then
(
res
=>
{
if
(
!
res
.
code
)
{
// this.getWeRunData()
}
else
{
// that.$u.toast(res.msg);
}
})
}
})
}
else
{
let
getUserInfo
=
store
.
dispatch
(
'
getUserInfo
'
);
getUserInfo
.
then
(
resolve
=>
{
}).
catch
(
errCode
=>
{
})
}
this
.
getAuth
();
}
}
</
script
>
...
...
shopro/platform/index.js
View file @
f9aa0f8c
...
...
@@ -65,7 +65,6 @@ export default {
// 处理wechat jssdk 签名网址(针对IOS微信浏览器做优化)
entry
()
{
let
that
=
this
;
var
entryUrl
=
location
.
href
;
if
(
this
.
device
()
===
'
ios
'
)
{
if
(
typeof
(
location
.
entryUrl
)
!==
'
undefined
'
)
{
...
...
shopro/request/apis.js
View file @
f9aa0f8c
...
...
@@ -16,7 +16,7 @@ export default {
},
register
:{
url
:
'
mall/register
'
,
auth
:
tru
e
,
auth
:
fals
e
,
method
:
"
post
"
},
wxRun
:{
...
...
@@ -33,6 +33,16 @@ export default {
url
:
'
mall/miniCode
'
,
auth
:
true
,
method
:
"
get
"
},
miniPhone
:{
url
:
'
mall/miniPhone
'
,
auth
:
false
,
method
:
"
get
"
},
status
:{
url
:
'
order/status
'
,
auth
:
true
,
method
:
"
get
"
}
},
index
:{
...
...
shopro/store/modules/user.js
View file @
f9aa0f8c
...
...
@@ -2,22 +2,35 @@
import
http
from
'
@/shopro/request/index
'
import
api
from
"
@/shopro/request/index
"
;
const
state
=
{
mallId
:
'
106975910000477
'
,
sessionkey
:
uni
.
getStorageSync
(
"
sessionkey
"
)
||
""
,
userInfo
:
{}
// token:""
userInfo
:
{},
registerInfo
:
{
//注册信息
companyId
:
'
999999998
'
,
//开放式传
mobile
:
''
,
//封闭式传
empcardno
:
''
,
//封闭式传
registerType
:
'
register
'
//注册时的类型为普通注册
},
// weRunData:{//今日步数
// todayNum: 0,
// totalNum: 0,
// updateDate: "",
// yesterdayNum: 0
// },
todayNum
:
0
}
const
getters
=
{
token
:
state
=>
state
.
token
,
userInfo
:
state
=>
state
.
userInfo
userInfo
:
state
=>
state
.
userInfo
,
todayNum
:
state
=>
state
.
todayNum
}
const
actions
=
{
/***获取用户信息
无token 走获取用户信息接口。
有token 走校验authcheck信息
*/
*/
async
getUserInfo
({
dispatch
,
commit
,
...
...
@@ -37,8 +50,6 @@ const actions = {
}
else
{
uni
.
login
({
success
:
function
(
info
)
{
console
.
log
(
"
获取手机号======
"
)
console
.
log
(
info
)
let
code
=
info
.
code
;
http
(
'
user.getHomePage
'
,
{
code
:
code
,
...
...
@@ -81,38 +92,100 @@ const actions = {
if
(
res
.
code
===
0
)
{
resolve
(
res
.
code
)
}
else
if
(
res
.
code
==
1001
)
{
dispatch
(
'
getUserInfo
'
)
dispatch
(
'
getUserInfo
'
);
reject
(
res
.
code
)
}
else
{
reject
(
res
.
code
)
}
});
})
},
// // 获取用户信息
// geAauthorizeWeRun({
// commit,
// dispatch,
// getters,
// state
// }) {
// //解密微信运动
// uni.getWeRunData({
// success: function(res) {
// console.log(res)
// wRunEncryptedData.encryptedData = res.encryptedData
// wRunEncryptedData.iv = res.iv
// }
// })
// },
// 获取手机号
getPhoneNumber
({
commit
},
e
){
return
new
Promise
((
resolve
,
reject
)
=>
{
let
code
=
e
.
detail
.
code
;
if
(
!
code
){
uni
.
showToast
({
title
:
code
,
duration
:
2000
,
icon
:
'
none
'
});
}
else
{
http
(
'
user.miniPhone
'
,{
code
:
code
,
mallId
:
state
.
mallId
}).
then
(
res
=>
{
if
(
!
res
.
code
&&
res
.
data
)
{
state
.
registerInfo
.
mobile
=
res
.
data
;
resolve
(
res
.
data
);
}
else
{
uni
.
showToast
({
title
:
res
.
msg
,
duration
:
2000
,
icon
:
'
none
'
});
reject
(
0
);
}
})
}
})
},
// 注册用户
registerInfoFn
({
commit
,
state
},
e
){
return
new
Promise
((
resolve
,
reject
)
=>
{
if
(
!
state
.
registerInfo
.
mobile
){
uni
.
showToast
({
title
:
"
手机号为空
"
,
duration
:
2000
,
icon
:
'
none
'
});
}
http
(
'
user.register
'
,
state
.
registerInfo
).
then
(
res
=>
{
if
(
res
.
code
==
0
)
{
resolve
(
1
);
}
else
{
uni
.
showToast
({
title
:
res
.
msg
,
duration
:
2000
,
icon
:
'
none
'
});
reject
(
res
.
data
);
}
})
})
},
// 查询步数
getWeRunDataFn
({
state
}){
return
new
Promise
((
resolve
,
reject
)
=>
{
let
wRunEncryptedData
=
{}
uni
.
getWeRunData
({
success
:
function
(
res
)
{
wRunEncryptedData
.
encryptedData
=
res
.
encryptedData
;
wRunEncryptedData
.
iv
=
res
.
iv
;
http
(
'
user.wxRun
'
,
wRunEncryptedData
).
then
(
res
=>
{
if
(
!
res
.
code
&&
res
.
data
)
{
state
.
todayNum
=
res
.
data
.
todayNum
;
resolve
(
res
.
data
);
}
else
{
state
.
todayNum
=
0
;
uni
.
showToast
({
title
:
res
.
msg
,
duration
:
2000
,
icon
:
'
none
'
});
reject
(
res
.
data
);
}
})
}
})
})
}
}
const
mutations
=
{
token
(
state
,
payload
)
{
state
.
token
=
payload
;
uni
.
setStorageSync
(
"
token
"
,
payload
);
},
USER_INFO
(
state
,
info
)
{
commit
(
"
userInfo
"
,
info
);
}
}
export
default
{
state
,
...
...
shopro/wechat/sdk.js
View file @
f9aa0f8c
...
...
@@ -142,7 +142,6 @@ export default {
//微信支付
wxpay
(
data
,
callback
)
{
let
that
=
this
;
this
.
isWechat
()
&&
this
.
initJssdk
(
function
(
res
)
{
jweixin
.
ready
(
function
()
{
jweixin
.
chooseWXPay
({
...
...
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