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
39dab9f5
Commit
39dab9f5
authored
Nov 10, 2020
by
吴颖
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'wuying' into 'master'
'修改页面登录' See merge request
!3
parents
945588be
28b06958
Changes
3
Hide 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 @
39dab9f5
import
{
Base
}
from
'
./utils/base.js
'
;
import
{
Base
}
from
'
./utils/base.js
'
;
const
base
=
new
Base
()
App
({
onLaunch
:
function
()
{
this
.
isReload
()
// 小程序是否有新版本
this
.
getSessionKey
()
// 获取token
},
// 小程序是否有新版本
isReload
:
function
()
{
let
that
=
this
if
(
wx
.
canIUse
(
'
getUpdateManager
'
))
{
const
updateManager
=
wx
.
getUpdateManager
()
updateManager
.
onCheckForUpdate
(
function
(
res
)
{
if
(
res
.
hasUpdate
)
{
updateManager
.
onUpdateReady
(
function
()
{
wx
.
showModal
({
title
:
'
更新提示
'
,
content
:
'
新版本已经准备好,是否重启应用?
'
,
success
:
function
(
res
)
{
if
(
res
.
confirm
)
{
updateManager
.
applyUpdate
()
}
}
})
})
updateManager
.
onUpdateFailed
(
function
()
{
wx
.
showModal
({
title
:
'
已经有新版本了哟~
'
,
content
:
'
新版本已经上线啦,请您删除当前小程序,重新搜索打开!
'
})
})
}
})
}
else
{
wx
.
showModal
({
title
:
'
提示
'
,
content
:
'
当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试!
'
})
}
},
onLaunch
:
function
()
{
this
.
isReload
()
// 小程序是否有新版本
this
.
getSessionKey
()
// 获取token
},
// 小程序是否有新版本
isReload
:
function
()
{
let
that
=
this
if
(
wx
.
canIUse
(
'
getUpdateManager
'
))
{
const
updateManager
=
wx
.
getUpdateManager
()
updateManager
.
onCheckForUpdate
(
function
(
res
)
{
if
(
res
.
hasUpdate
)
{
updateManager
.
onUpdateReady
(
function
()
{
wx
.
showModal
({
title
:
'
更新提示
'
,
content
:
'
新版本已经准备好,是否重启应用?
'
,
success
:
function
(
res
)
{
if
(
res
.
confirm
)
{
updateManager
.
applyUpdate
()
}
}
})
})
updateManager
.
onUpdateFailed
(
function
()
{
wx
.
showModal
({
title
:
'
已经有新版本了哟~
'
,
content
:
'
新版本已经上线啦,请您删除当前小程序,重新搜索打开!
'
})
})
}
})
}
else
{
wx
.
showModal
({
title
:
'
提示
'
,
content
:
'
当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试!
'
})
}
},
// 将token从缓存中 赋值到全局变量
getToken
:
function
()
{
try
{
var
token
=
wx
.
getStorageSync
(
'
token
'
)
if
(
token
)
{
this
.
globalData
.
token
=
token
}
}
catch
(
e
)
{
}
},
// 获取sessionkey 提交后台换取基本openid unionid
getSessionKey
:
function
(
cb
)
{
let
that
=
this
wx
.
login
({
success
:
function
(
res
)
{
that
.
codeChangeToken
(
res
.
code
,
cb
)
}
})
},
// sessionkey 换取token
codeChangeToken
(
code
,
cb
)
{
// 发起网络请求
let
that
=
this
let
params
=
{
data
:
{
url
:
'
getsessionkey
'
,
code
:
code
},
callback
:
(
data
)
=>
{
try
{
wx
.
setStorageSync
(
'
token
'
,
data
.
token
)
}
catch
(
e
)
{
console
.
log
(
'
token缓存失败
'
)
}
that
.
globalData
.
token
=
data
.
token
typeof
cb
==
'
function
'
&&
cb
()
}
}
base
.
newRequest
(
params
)
},
// 保存用户信息
saveUserInfo
:
function
(
info
,
cb
)
{
let
that
=
this
wx
.
checkSession
({
success
()
{
let
params
=
{
data
:
{
url
:
'
saveinfo
'
,
encryptedData
:
encodeURIComponent
(
info
.
encryptedData
),
iv
:
encodeURIComponent
(
info
.
iv
),
token
:
wx
.
getStorageSync
(
'
token
'
)
},
type
:
'
POST
'
,
callback
:
data
=>
{
// if (res.data.meta.code == 200) {
wx
.
showToast
({
title
:
'
已授权
'
,
icon
:
'
none
'
,
duration
:
1000
})
that
.
globalData
.
userInfo
=
data
;
wx
.
setStorageSync
(
'
userInfo
'
,
data
)
// }
// else {
// wx.showToast({
// title: res.data.meta.message,
// icon: 'none',
// duration: 1000
// })
// }
typeof
cb
==
'
function
'
&&
cb
()
}
}
base
.
newRequest
(
params
)
},
fail
()
{
// session_key 已经失效,需要重新执行登录流程
that
.
getSessionKey
(()
=>
that
.
saveUserInfo
(
info
,
cb
))
}
})
},
globalData
:
{
extAppid
:
'
wx6e6eaca9cc1c406d
'
,
// 当前appid
userInfo
:
''
,
//微信user信息
userTel
:
''
,
// 手机号
token
:
''
,
backurl
:
''
// 全局跳转页面路径
}
// 获取sessionkey 提交后台换取基本openid unionid
getSessionKey
:
function
(
cb
)
{
let
that
=
this
wx
.
login
({
success
:
function
(
res
)
{
that
.
codeChangeToken
(
res
.
code
,
cb
)
}
})
},
// sessionkey 换取token
codeChangeToken
(
code
,
cb
)
{
let
that
=
this
wx
.
request
({
url
:
'
https://wandoutiyu.test.xueyoubangedu.com/api/getsessionkey
'
,
data
:
{
code
:
code
},
header
:
{
'
app
'
:
'
coach
'
},
method
:
'
GET
'
,
success
:
function
(
res
)
{
if
(
res
.
data
.
meta
.
code
===
200
)
{
try
{
wx
.
setStorageSync
(
'
token
'
,
res
.
data
.
data
.
token
)
}
catch
(
e
)
{
console
.
log
(
'
token缓存失败
'
)
}
that
.
globalData
.
token
=
res
.
data
.
data
.
token
typeof
cb
==
'
function
'
&&
cb
()
}
else
{
console
.
log
(
res
)
}
}
})
},
// 保存用户信息
saveUserInfo
:
function
(
info
,
cb
)
{
let
that
=
this
wx
.
checkSession
({
success
()
{
wx
.
request
({
url
:
'
https://wandoutiyu.test.xueyoubangedu.com/api/saveinfo
'
,
data
:
{
encryptedData
:
encodeURIComponent
(
info
.
encryptedData
),
iv
:
encodeURIComponent
(
info
.
iv
),
token
:
wx
.
getStorageSync
(
'
token
'
)
},
header
:
{
'
app
'
:
'
coach
'
},
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
({
title
:
res
.
data
.
meta
.
message
,
icon
:
'
none
'
,
duration
:
2000
})
}
typeof
cb
==
'
function
'
&&
cb
()
},
fail
:
function
()
{}
})
},
fail
()
{
// session_key 已经失效,需要重新执行登录流程
that
.
getSessionKey
(()
=>
that
.
saveUserInfo
(
info
,
cb
))
}
})
},
globalData
:
{
extAppid
:
'
wx6e6eaca9cc1c406d
'
,
// 当前appid
userInfo
:
''
,
//微信user信息
userTel
:
''
,
// 手机号
token
:
''
,
backurl
:
''
// 全局跳转页面路径
}
})
\ No newline at end of file
project.config.json
View file @
39dab9f5
{
"description"
:
"项目配置文件"
,
"packOptions"
:
{
"ignore"
:
[]
},
"setting"
:
{
"urlCheck"
:
false
,
"es6"
:
true
,
"enhance"
:
false
,
"postcss"
:
true
,
"preloadBackgroundData"
:
false
,
"minified"
:
true
,
"newFeature"
:
false
,
"coverView"
:
true
,
"nodeModules"
:
false
,
"autoAudits"
:
false
,
"showShadowRootInWxmlPanel"
:
true
,
"scopeDataCheck"
:
false
,
"uglifyFileName"
:
false
,
"checkInvalidKey"
:
true
,
"checkSiteMap"
:
true
,
"uploadWithSourceMap"
:
true
,
"compileHotReLoad"
:
false
,
"babelSetting"
:
{
"ignore"
:
[],
"disablePlugins"
:
[],
"outputPath"
:
""
},
"useIsolateContext"
:
true
,
"useCompilerModule"
:
false
,
"userConfirmedUseCompilerModuleSwitch"
:
false
},
"compileType"
:
"miniprogram"
,
"libVersion"
:
"2.14.0"
,
"appid"
:
"wx6e6eaca9cc1c406d"
,
"projectname"
:
"wandouchengzhang_coach"
,
"debugOptions"
:
{
"hidedInDevtools"
:
[]
},
"scripts"
:
{},
"isGameTourist"
:
false
,
"simulatorType"
:
"wechat"
,
"simulatorPluginLibVersion"
:
{},
"condition"
:
{
"search"
:
{
"current"
:
-1
,
"list"
:
[]
},
"conversation"
:
{
"current"
:
-1
,
"list"
:
[]
},
"plugin"
:
{
"current"
:
-1
,
"list"
:
[]
},
"game"
:
{
"current"
:
-1
,
"list"
:
[]
},
"gamePlugin"
:
{
"current"
:
-1
,
"list"
:
[]
},
"miniprogram"
:
{
"current"
:
-1
,
"list"
:
[
{
"id"
:
-1
,
"name"
:
"pages/tabbar/personal/personal"
,
"pathName"
:
"pages/tabbar/personal/personal"
,
"query"
:
""
,
"scene"
:
null
},
{
"id"
:
-1
,
"name"
:
"pages/tabbar/personal/personal"
,
"pathName"
:
"pages/tabbar/personal/personal"
,
"query"
:
""
,
"scene"
:
null
},
{
"id"
:
-1
,
"name"
:
"pages/my/parents/parents"
,
"pathName"
:
"pages/my/parents/parents"
,
"query"
:
""
,
"scene"
:
null
},
{
"id"
:
-1
,
"name"
:
"pages/tabbar/personal/personal"
,
"pathName"
:
"pages/tabbar/personal/personal"
,
"query"
:
""
,
"scene"
:
null
},
{
"id"
:
-1
,
"name"
:
"pages/my/teachingArea/teachingArea"
,
"pathName"
:
"pages/my/teachingArea/teachingArea"
,
"query"
:
""
,
"scene"
:
null
},
{
"id"
:
-1
,
"name"
:
"pages/index/classManagement/classManagement"
,
"pathName"
:
"pages/index/classManagement/classManagement"
,
"query"
:
""
,
"scene"
:
null
},
{
"id"
:
-1
,
"name"
:
"pages/index/courseInstant/courseInstant"
,
"pathName"
:
"pages/index/courseInstant/courseInstant"
,
"query"
:
""
,
"scene"
:
null
},
{
"id"
:
7
,
"name"
:
"pages/index/classDetail/classDetail"
,
"pathName"
:
"pages/index/classDetail/classDetail"
,
"query"
:
""
,
"scene"
:
null
},
{
"id"
:
-1
,
"name"
:
"pages/team/teamDetail/teamDetail"
,
"pathName"
:
"pages/team/teamDetail/teamDetail"
,
"query"
:
""
,
"scene"
:
null
},
{
"id"
:
-1
,
"name"
:
"pages/index/performance/performance"
,
"pathName"
:
"pages/index/performance/performance"
,
"query"
:
""
,
"scene"
:
null
},
{
"id"
:
-1
,
"name"
:
"pages/index/evaluation/evaluation"
,
"pathName"
:
"pages/index/evaluation/evaluation"
,
"query"
:
""
,
"scene"
:
null
},
{
"id"
:
-1
,
"name"
:
"个人中心"
,
"pathName"
:
"pages/tabbar/personal/personal"
,
"query"
:
""
,
"scene"
:
null
},
{
"id"
:
-1
,
"name"
:
"pages/tabbar/class/class"
,
"pathName"
:
"pages/tabbar/class/class"
,
"scene"
:
null
}
]
}
}
"description"
:
"项目配置文件"
,
"packOptions"
:
{
"ignore"
:
[]
},
"setting"
:
{
"urlCheck"
:
false
,
"es6"
:
true
,
"enhance"
:
false
,
"postcss"
:
true
,
"preloadBackgroundData"
:
false
,
"minified"
:
true
,
"newFeature"
:
false
,
"coverView"
:
true
,
"nodeModules"
:
false
,
"autoAudits"
:
false
,
"showShadowRootInWxmlPanel"
:
true
,
"scopeDataCheck"
:
false
,
"uglifyFileName"
:
false
,
"checkInvalidKey"
:
true
,
"checkSiteMap"
:
true
,
"uploadWithSourceMap"
:
true
,
"compileHotReLoad"
:
false
,
"babelSetting"
:
{
"ignore"
:
[],
"disablePlugins"
:
[],
"outputPath"
:
""
},
"useIsolateContext"
:
true
,
"useCompilerModule"
:
false
,
"userConfirmedUseCompilerModuleSwitch"
:
false
},
"compileType"
:
"miniprogram"
,
"libVersion"
:
"2.14.0"
,
"appid"
:
"wx6e6eaca9cc1c406d"
,
"projectname"
:
"wandouchengzhang_coach"
,
"debugOptions"
:
{
"hidedInDevtools"
:
[]
},
"scripts"
:
{},
"isGameTourist"
:
false
,
"simulatorType"
:
"wechat"
,
"simulatorPluginLibVersion"
:
{},
"condition"
:
{
"search"
:
{
"list"
:
[]
},
"conversation"
:
{
"list"
:
[]
},
"plugin"
:
{
"list"
:
[]
},
"game"
:
{
"list"
:
[]
},
"gamePlugin"
:
{
"list"
:
[]
},
"miniprogram"
:
{
"list"
:
[
{
"id"
:
-1
,
"name"
:
"pages/tabbar/personal/personal"
,
"pathName"
:
"pages/tabbar/personal/personal"
,
"query"
:
""
,
"scene"
:
null
},
{
"id"
:
-1
,
"name"
:
"pages/tabbar/personal/personal"
,
"pathName"
:
"pages/tabbar/personal/personal"
,
"query"
:
""
,
"scene"
:
null
},
{
"id"
:
-1
,
"name"
:
"pages/my/parents/parents"
,
"pathName"
:
"pages/my/parents/parents"
,
"query"
:
""
,
"scene"
:
null
},
{
"id"
:
-1
,
"name"
:
"pages/tabbar/personal/personal"
,
"pathName"
:
"pages/tabbar/personal/personal"
,
"query"
:
""
,
"scene"
:
null
},
{
"id"
:
-1
,
"name"
:
"pages/my/teachingArea/teachingArea"
,
"pathName"
:
"pages/my/teachingArea/teachingArea"
,
"query"
:
""
,
"scene"
:
null
},
{
"id"
:
-1
,
"name"
:
"pages/index/classManagement/classManagement"
,
"pathName"
:
"pages/index/classManagement/classManagement"
,
"query"
:
""
,
"scene"
:
null
},
{
"id"
:
-1
,
"name"
:
"pages/index/courseInstant/courseInstant"
,
"pathName"
:
"pages/index/courseInstant/courseInstant"
,
"query"
:
""
,
"scene"
:
null
},
{
"id"
:
7
,
"name"
:
"pages/index/classDetail/classDetail"
,
"pathName"
:
"pages/index/classDetail/classDetail"
,
"query"
:
""
,
"scene"
:
null
},
{
"id"
:
-1
,
"name"
:
"pages/team/teamDetail/teamDetail"
,
"pathName"
:
"pages/team/teamDetail/teamDetail"
,
"query"
:
""
,
"scene"
:
null
},
{
"id"
:
-1
,
"name"
:
"pages/index/performance/performance"
,
"pathName"
:
"pages/index/performance/performance"
,
"query"
:
""
,
"scene"
:
null
},
{
"id"
:
-1
,
"name"
:
"pages/index/evaluation/evaluation"
,
"pathName"
:
"pages/index/evaluation/evaluation"
,
"query"
:
""
,
"scene"
:
null
},
{
"id"
:
-1
,
"name"
:
"个人中心"
,
"pathName"
:
"pages/tabbar/personal/personal"
,
"query"
:
""
,
"scene"
:
null
},
{
"id"
:
-1
,
"name"
:
"pages/tabbar/class/class"
,
"pathName"
:
"pages/tabbar/class/class"
,
"scene"
:
null
}
]
}
}
}
\ No newline at end of file
utils/base.js
View file @
39dab9f5
...
...
@@ -9,12 +9,13 @@ class Base {
if
(
!
params
.
type
)
{
params
.
type
=
'
GET
'
}
var
cur_url
=
that
.
baseUrl
+
params
.
data
.
url
var
cur_url
=
that
.
baseUrl
+
params
.
url
// if (flag) {
// params.url = params.url;
// } else {
// params.url = that.baseUrl + params.url;
// }
console
.
log
(
cur_url
)
wx
.
request
({
url
:
cur_url
,
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