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
812ab945
Commit
812ab945
authored
Nov 09, 2020
by
崔勇哲
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改以兼容队长端api接口
parent
a88b7965
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
42 deletions
+40
-42
app.js
app.js
+35
-37
bindTel.js
pages/sign/bindTel/bindTel.js
+1
-1
base.js
utils/base.js
+4
-4
No files found.
app.js
View file @
812ab945
import
{
Base
}
from
'
./utils/base.js
'
;
const
base
=
new
Base
()
App
({
App
({
onLaunch
:
function
()
{
onLaunch
:
function
()
{
this
.
isReload
()
// 小程序是否有新版本
this
.
isReload
()
// 小程序是否有新版本
this
.
get
Token
()
// 获取token
this
.
get
SessionKey
()
// 获取token
},
},
// 小程序是否有新版本
// 小程序是否有新版本
isReload
:
function
()
{
isReload
:
function
()
{
...
@@ -59,62 +61,58 @@ App({
...
@@ -59,62 +61,58 @@ App({
codeChangeToken
(
code
,
cb
)
{
codeChangeToken
(
code
,
cb
)
{
// 发起网络请求
// 发起网络请求
let
that
=
this
let
that
=
this
wx
.
request
({
let
params
=
{
url
:
'
https://openapi.xueyoubangedu.com/request/allrequest
'
,
data
:
{
data
:
{
url
:
'
https://wandoutiyu.test.xueyoubangedu.com/api/
getsessionkey
'
,
url
:
'
getsessionkey
'
,
code
:
code
code
:
code
},
},
method
:
'
GET
'
,
callback
:
(
data
)
=>
{
success
:
function
(
res
)
{
try
{
if
(
res
.
data
.
meta
.
code
===
200
)
{
wx
.
setStorageSync
(
'
token
'
,
data
.
token
)
try
{
}
catch
(
e
)
{
wx
.
setStorageSync
(
'
token
'
,
res
.
data
.
data
.
token
)
console
.
log
(
'
token缓存失败
'
)
}
catch
(
e
)
{
console
.
log
(
'
token缓存失败
'
)
}
that
.
globalData
.
token
=
res
.
data
.
data
.
token
typeof
cb
==
'
function
'
&&
cb
()
}
else
{
console
.
log
(
res
)
}
}
that
.
globalData
.
token
=
data
.
token
typeof
cb
==
'
function
'
&&
cb
()
}
}
})
}
base
.
newRequest
(
params
)
},
},
// 保存用户信息
// 保存用户信息
saveUserInfo
:
function
(
info
,
cb
)
{
saveUserInfo
:
function
(
info
,
cb
)
{
let
that
=
this
let
that
=
this
wx
.
checkSession
({
wx
.
checkSession
({
success
()
{
success
()
{
wx
.
request
({
let
params
=
{
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
'
)
},
},
method
:
'
POST
'
,
type
:
'
POST
'
,
success
:
function
(
res
)
{
callback
:
data
=>
{
if
(
res
.
data
.
meta
.
code
==
200
)
{
//
if (res.data.meta.code == 200) {
wx
.
showToast
({
wx
.
showToast
({
title
:
'
已授权
'
,
title
:
'
已授权
'
,
icon
:
'
none
'
,
icon
:
'
none
'
,
duration
:
1000
duration
:
1000
})
})
that
.
globalData
.
userInfo
=
res
.
data
.
data
;
that
.
globalData
.
userInfo
=
data
;
wx
.
setStorageSync
(
'
userInfo
'
,
res
.
data
.
data
)
wx
.
setStorageSync
(
'
userInfo
'
,
data
)
}
else
{
// }
wx
.
showToast
({
// else {
title
:
res
.
data
.
meta
.
message
,
// wx.showToast({
icon
:
'
none
'
,
// title: res.data.meta.message,
duration
:
1000
// icon: 'none',
})
// duration: 1000
}
// })
// }
typeof
cb
==
'
function
'
&&
cb
()
typeof
cb
==
'
function
'
&&
cb
()
}
,
}
fail
:
function
()
{
}
}
})
base
.
newRequest
(
params
)
},
},
fail
()
{
fail
()
{
// session_key 已经失效,需要重新执行登录流程
// session_key 已经失效,需要重新执行登录流程
...
...
pages/sign/bindTel/bindTel.js
View file @
812ab945
...
@@ -11,8 +11,8 @@ Page({
...
@@ -11,8 +11,8 @@ Page({
getPhoneNumber
:
function
(
e
)
{
getPhoneNumber
:
function
(
e
)
{
if
(
e
.
detail
.
errMsg
==
'
getPhoneNumber:ok
'
)
{
if
(
e
.
detail
.
errMsg
==
'
getPhoneNumber:ok
'
)
{
let
params
=
{
let
params
=
{
url
:
'
user/switchPhone
'
,
data
:
{
data
:
{
url
:
'
user/switchPhone
'
,
encryptedData
:
e
.
detail
.
encryptedData
,
encryptedData
:
e
.
detail
.
encryptedData
,
iv
:
e
.
detail
.
iv
iv
:
e
.
detail
.
iv
},
},
...
...
utils/base.js
View file @
812ab945
// 公共函数库
// 公共函数库
const
app
=
getApp
()
class
Base
{
class
Base
{
constructor
()
{
constructor
()
{
// this.baseUrl = 'https://wandoutiyu.xueyoubangedu.com/api/' //线上接口
// this.baseUrl = 'https://wandoutiyu.xueyoubangedu.com/api/' //线上接口
this
.
baseUrl
=
'
https://wandoutiyu.test.xueyoubangedu.com/api/
'
//测试接口
this
.
baseUrl
=
'
https://wandoutiyu.test.xueyoubangedu.com/api/
'
//测试接口
}
}
newRequest
(
params
,
flag
=
false
,
tips
=
true
)
{
newRequest
(
params
,
flag
=
false
,
tips
=
true
)
{
let
that
=
this
let
that
=
this
if
(
!
params
.
type
)
{
if
(
!
params
.
type
)
{
params
.
type
=
'
GET
'
params
.
type
=
'
GET
'
}
}
var
cur_url
=
that
.
baseUrl
+
params
.
url
var
cur_url
=
that
.
baseUrl
+
params
.
data
.
url
// if (flag) {
// if (flag) {
// params.url = params.url;
// params.url = params.url;
// } else {
// } else {
...
@@ -21,7 +20,8 @@ class Base {
...
@@ -21,7 +20,8 @@ class Base {
data
:
params
.
data
,
data
:
params
.
data
,
method
:
params
.
type
,
method
:
params
.
type
,
header
:
{
header
:
{
'
token
'
:
wx
.
getStorageSync
(
'
token
'
)
'
token
'
:
wx
.
getStorageSync
(
'
token
'
),
'
app
'
:
'
coach
'
},
},
success
:
function
(
res
)
{
success
:
function
(
res
)
{
console
.
log
(
res
)
console
.
log
(
res
)
...
...
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