Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
train_vue
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
train
train_vue
Commits
8ee29e44
Commit
8ee29e44
authored
Feb 21, 2022
by
不吃草的咩
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
微信支付
parent
e44af9bb
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
75 additions
and
1 deletion
+75
-1
pages/my/home.js
pages/my/home.js
+6
-0
pages/uploadcard/uploadcard.js
pages/uploadcard/uploadcard.js
+68
-0
pages/uploadcard/uploadcard.wxml
pages/uploadcard/uploadcard.wxml
+1
-1
No files found.
pages/my/home.js
View file @
8ee29e44
...
@@ -36,6 +36,12 @@ Page({
...
@@ -36,6 +36,12 @@ Page({
//如果返回成功手机号,就随机生成一串字符串存进去
//如果返回成功手机号,就随机生成一串字符串存进去
if
(
e
.
detail
.
code
!==
undefined
){
if
(
e
.
detail
.
code
!==
undefined
){
console
.
log
(
e
.
detail
);
console
.
log
(
e
.
detail
);
wx
.
login
({
timeout
:
30000
,
success
:
function
(
res
){
console
.
log
(
res
);
}
})
app
.
colorUISdk
.
request
({
app
.
colorUISdk
.
request
({
url
:
`wx/gt?code=
${
e
.
detail
.
code
}
`
,
url
:
`wx/gt?code=
${
e
.
detail
.
code
}
`
,
method
:
'
POST
'
method
:
'
POST
'
...
...
pages/uploadcard/uploadcard.js
View file @
8ee29e44
...
@@ -123,6 +123,74 @@ Page({
...
@@ -123,6 +123,74 @@ Page({
});
});
}
}
});
});
},
sendMeans
(){
const
toast
=
Toast
.
loading
({
message
:
'
订单生成中,请稍候。。。
'
,
forbidClick
:
true
,
loadingType
:
'
spinner
'
,
});
app
.
colorUISdk
.
request
({
url
:
`wx/gt?code=
${
e
.
detail
.
code
}
`
,
//上传课程价格接口
method
:
'
POST
'
,
data
:{
price
:
price
,
courseName
:
''
}
}).
then
(({
data
})
=>
{
//创建订单成功,返回给我一些必要参数,然后调起微信支付
Toast
.
clear
();
//唤起微信支付
let
time
=
(
new
Date
().
getTime
().
toString
()).
substring
(
0
,
10
)
wx
.
requestPayment
({
appId
:
'
wx95ac219beca2f34f
'
,
timeStamp
:
time
,
nonceStr
:
this
.
randomWord
(
true
,
parseInt
((
Math
.
random
()
*
20
)),
parseInt
((
Math
.
random
()
*
30
))),
//生成长度为20~30的随机字符串
package
:
'
prepay_id=wx201410272009395522657a690389285100
'
,
//等待回传结果
signType
:
"
RSA
"
,
paySign
:
''
,
//后台加密计算好给我
fail
:
function
(){
Toast
.
fail
(
'
您已取消支付
'
)
},
})
if
(
data
.
errcode
==
0
){
let
random
=
this
.
randomWord
(
false
,
43
);
// let random = Math.random().toString(36).substr(2);
try
{
wx
.
setStorageSync
(
'
token
'
,
random
+
data
.
phone_info
.
phoneNumber
);
app
.
phone
=
data
.
phone_info
.
phoneNumber
;
Toast
.
success
(
'
登录成功
'
);
this
.
setData
({
show
:
false
,
title
:
data
.
phone_info
.
phoneNumber
,
})
}
catch
(
e
)
{
wx
.
showToast
({
title
:
'
数据存储失败!
'
,
icon
:
'
none
'
})
}
}
this
.
setData
({
courseData
:
res
.
data
.
records
})
}).
catch
(
err
=>
{
console
.
log
(
err
)
})
},
randomWord
(
randomFlag
,
min
,
max
){
let
str
=
""
,
range
=
min
,
arr
=
[
'
0
'
,
'
1
'
,
'
2
'
,
'
3
'
,
'
4
'
,
'
5
'
,
'
6
'
,
'
7
'
,
'
8
'
,
'
9
'
,
'
a
'
,
'
b
'
,
'
c
'
,
'
d
'
,
'
e
'
,
'
f
'
,
'
g
'
,
'
h
'
,
'
i
'
,
'
j
'
,
'
k
'
,
'
l
'
,
'
m
'
,
'
n
'
,
'
o
'
,
'
p
'
,
'
q
'
,
'
r
'
,
'
s
'
,
'
t
'
,
'
u
'
,
'
v
'
,
'
w
'
,
'
x
'
,
'
y
'
,
'
z
'
,
'
A
'
,
'
B
'
,
'
C
'
,
'
D
'
,
'
E
'
,
'
F
'
,
'
G
'
,
'
H
'
,
'
I
'
,
'
J
'
,
'
K
'
,
'
L
'
,
'
M
'
,
'
N
'
,
'
O
'
,
'
P
'
,
'
Q
'
,
'
R
'
,
'
S
'
,
'
T
'
,
'
U
'
,
'
V
'
,
'
W
'
,
'
X
'
,
'
Y
'
,
'
Z
'
];
// 随机产生
if
(
randomFlag
){
range
=
Math
.
round
(
Math
.
random
()
*
(
max
-
min
))
+
min
;
}
for
(
var
i
=
0
;
i
<
range
;
i
++
){
let
pos
=
Math
.
round
(
Math
.
random
()
*
(
arr
.
length
-
1
));
str
+=
arr
[
pos
];
}
return
str
;
},
},
/**
/**
* 生命周期函数--监听页面加载
* 生命周期函数--监听页面加载
...
...
pages/uploadcard/uploadcard.wxml
View file @
8ee29e44
...
@@ -46,7 +46,7 @@
...
@@ -46,7 +46,7 @@
</view>
</view>
</view>
</view>
<view class="subbtn">
<view class="subbtn">
<van-button type="primary" block color="#1989fa">提交资料</van-button>
<van-button type="primary" block color="#1989fa"
bindtap="sendMeans"
>提交资料</van-button>
</view>
</view>
</view>
</view>
<van-toast id="van-toast" />
<van-toast id="van-toast" />
...
...
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