Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
wandouchengzhang_coach
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
石盼盼
wandouchengzhang_coach
Commits
28b06958
Commit
28b06958
authored
Nov 10, 2020
by
吴颖
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
'修改页面登录'
parent
945588be
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
279 additions
and
289 deletions
+279
-289
app.js
app.js
+124
-129
project.config.json
project.config.json
+153
-159
base.js
utils/base.js
+2
-1
No files found.
app.js
View file @
28b06958
import
{
Base
}
from
'
./utils/base.js
'
;
import
{
Base
}
from
'
./utils/base.js
'
;
const
base
=
new
Base
()
const
base
=
new
Base
()
App
({
App
({
onLaunch
:
function
()
{
onLaunch
:
function
()
{
...
@@ -39,15 +41,6 @@ App({
...
@@ -39,15 +41,6 @@ App({
}
}
},
},
// 将token从缓存中 赋值到全局变量
getToken
:
function
()
{
try
{
var
token
=
wx
.
getStorageSync
(
'
token
'
)
if
(
token
)
{
this
.
globalData
.
token
=
token
}
}
catch
(
e
)
{
}
},
// 获取sessionkey 提交后台换取基本openid unionid
// 获取sessionkey 提交后台换取基本openid unionid
getSessionKey
:
function
(
cb
)
{
getSessionKey
:
function
(
cb
)
{
let
that
=
this
let
that
=
this
...
@@ -59,63 +52,65 @@ App({
...
@@ -59,63 +52,65 @@ App({
},
},
// sessionkey 换取token
// sessionkey 换取token
codeChangeToken
(
code
,
cb
)
{
codeChangeToken
(
code
,
cb
)
{
// 发起网络请求
let
that
=
this
let
that
=
this
let
params
=
{
wx
.
request
({
url
:
'
https://wandoutiyu.test.xueyoubangedu.com/api/getsessionkey
'
,
data
:
{
data
:
{
url
:
'
getsessionkey
'
,
code
:
code
code
:
code
},
},
callback
:
(
data
)
=>
{
header
:
{
'
app
'
:
'
coach
'
},
method
:
'
GET
'
,
success
:
function
(
res
)
{
if
(
res
.
data
.
meta
.
code
===
200
)
{
try
{
try
{
wx
.
setStorageSync
(
'
token
'
,
data
.
token
)
wx
.
setStorageSync
(
'
token
'
,
res
.
data
.
data
.
token
)
}
catch
(
e
)
{
}
catch
(
e
)
{
console
.
log
(
'
token缓存失败
'
)
console
.
log
(
'
token缓存失败
'
)
}
}
that
.
globalData
.
token
=
data
.
token
that
.
globalData
.
token
=
res
.
data
.
data
.
token
typeof
cb
==
'
function
'
&&
cb
()
typeof
cb
==
'
function
'
&&
cb
()
}
else
{
console
.
log
(
res
)
}
}
}
}
base
.
newRequest
(
params
)
}
)
},
},
// 保存用户信息
// 保存用户信息
saveUserInfo
:
function
(
info
,
cb
)
{
saveUserInfo
:
function
(
info
,
cb
)
{
let
that
=
this
let
that
=
this
wx
.
checkSession
({
wx
.
checkSession
({
success
()
{
success
()
{
let
params
=
{
wx
.
request
({
url
:
'
https://wandoutiyu.test.xueyoubangedu.com/api/saveinfo
'
,
data
:
{
data
:
{
url
:
'
saveinfo
'
,
encryptedData
:
encodeURIComponent
(
info
.
encryptedData
),
encryptedData
:
encodeURIComponent
(
info
.
encryptedData
),
iv
:
encodeURIComponent
(
info
.
iv
),
iv
:
encodeURIComponent
(
info
.
iv
),
token
:
wx
.
getStorageSync
(
'
token
'
)
token
:
wx
.
getStorageSync
(
'
token
'
)
},
},
type
:
'
POST
'
,
header
:
{
callback
:
data
=>
{
'
app
'
:
'
coach
'
// if (res.data.meta.code == 200) {
},
method
:
'
POST
'
,
success
:
function
(
res
)
{
if
(
res
.
data
.
meta
.
code
==
200
)
{
that
.
globalData
.
userInfo
=
res
.
data
.
data
;
wx
.
setStorageSync
(
'
userInfo
'
,
res
.
data
.
data
)
}
else
{
console
.
log
(
res
.
data
.
meta
.
message
)
wx
.
showToast
({
wx
.
showToast
({
title
:
'
已授权
'
,
title
:
res
.
data
.
meta
.
message
,
icon
:
'
none
'
,
icon
:
'
none
'
,
duration
:
1
000
duration
:
2
000
})
})
that
.
globalData
.
userInfo
=
data
;
wx
.
setStorageSync
(
'
userInfo
'
,
data
)
// }
// else {
// wx.showToast({
// title: res.data.meta.message,
// icon: 'none',
// duration: 1000
// })
// }
typeof
cb
==
'
function
'
&&
cb
()
}
}
}
typeof
cb
==
'
function
'
&&
cb
()
base
.
newRequest
(
params
)
},
fail
:
function
()
{}
})
},
},
fail
()
{
fail
()
{
// session_key 已经失效,需要重新执行登录流程
// session_key 已经失效,需要重新执行登录流程
that
.
getSessionKey
(()
=>
that
.
saveUserInfo
(
info
,
cb
))
that
.
getSessionKey
(()
=>
that
.
saveUserInfo
(
info
,
cb
))
}
}
})
})
...
...
project.config.json
View file @
28b06958
...
@@ -43,27 +43,21 @@
...
@@ -43,27 +43,21 @@
"simulatorPluginLibVersion"
:
{},
"simulatorPluginLibVersion"
:
{},
"condition"
:
{
"condition"
:
{
"search"
:
{
"search"
:
{
"current"
:
-1
,
"list"
:
[]
"list"
:
[]
},
},
"conversation"
:
{
"conversation"
:
{
"current"
:
-1
,
"list"
:
[]
"list"
:
[]
},
},
"plugin"
:
{
"plugin"
:
{
"current"
:
-1
,
"list"
:
[]
"list"
:
[]
},
},
"game"
:
{
"game"
:
{
"current"
:
-1
,
"list"
:
[]
"list"
:
[]
},
},
"gamePlugin"
:
{
"gamePlugin"
:
{
"current"
:
-1
,
"list"
:
[]
"list"
:
[]
},
},
"miniprogram"
:
{
"miniprogram"
:
{
"current"
:
-1
,
"list"
:
[
"list"
:
[
{
{
"id"
:
-1
,
"id"
:
-1
,
...
...
utils/base.js
View file @
28b06958
...
@@ -9,12 +9,13 @@ class Base {
...
@@ -9,12 +9,13 @@ class Base {
if
(
!
params
.
type
)
{
if
(
!
params
.
type
)
{
params
.
type
=
'
GET
'
params
.
type
=
'
GET
'
}
}
var
cur_url
=
that
.
baseUrl
+
params
.
data
.
url
var
cur_url
=
that
.
baseUrl
+
params
.
url
// if (flag) {
// if (flag) {
// params.url = params.url;
// params.url = params.url;
// } else {
// } else {
// params.url = that.baseUrl + params.url;
// params.url = that.baseUrl + params.url;
// }
// }
console
.
log
(
cur_url
)
wx
.
request
({
wx
.
request
({
url
:
cur_url
,
url
:
cur_url
,
data
:
params
.
data
,
data
:
params
.
data
,
...
...
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