Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
L
loomoJSTools
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
fdevcloud
loomoJSTools
Commits
5fe3a853
Commit
5fe3a853
authored
Aug 11, 2021
by
yanghailong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
用户信息管理
parents
Pipeline
#317
failed with stages
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
116 additions
and
0 deletions
+116
-0
UserInfo.js
wxminiapp/service/UserInfo.js
+116
-0
No files found.
wxminiapp/service/UserInfo.js
0 → 100644
View file @
5fe3a853
var
netTool
=
require
(
"../tools/APIurl"
)
var
rootUrl
=
"capi/V2/shUser/memberUser/"
var
storageName
=
"userInfo"
;
var
wx_synchronization_flag
=
0
;
var
checkdata
=
require
(
'../utils/dataCheek'
)
var
page
=
{
pageSize
:
10
,
total
:
0
,
currentPage
:
1
}
/**
* wx_synchronization_flag = 1表示已经拉取用户信息
*/
function
UserInfo
()
{
// 用户登录
this
.
login
=
function
(
data
)
{
console
.
log
(
data
)
var
that
=
this
;
if
(
checkdata
.
isEmpty
(
data
.
mobile
)
||
checkdata
.
isEmpty
(
data
.
password
))
{
wx
.
showToast
({
title
:
'请输入信息'
,
icon
:
"none"
})
return
}
// if (!apis.verify(data.password, '密码不能为空')) return
netTool
.
getAjaxUrlValue
(
'capi/V2/permissionV2/memberUser/login'
,
{
// mark: xxx
is_deleted
:
0
,
...
data
},
function
(
res
)
{
if
(
res
.
token
)
{
wx
.
setStorageSync
(
'isLogin'
,
1
)
wx
.
setStorageSync
(
'token'
,
res
.
token
),
wx
.
setStorageSync
(
'user_id'
,
res
.
rows
[
0
].
id
),
// wx.navigateTo({
// url: '/pages/usercenter/index/index',
// })
wx
.
showToast
({
title
:
'登陆成功'
,
})
wx
.
navigateBack
({
delta
:
0
,
})
}
else
{
wx
.
showToast
({
title
:
'用户名密码错误'
,
})
wx
.
setStorageSync
(
'isLogin'
,
0
)
}
})
}
this
.
getInfo
=
function
(
data
,
fn
)
{
netTool
.
getAjaxUrlValue
(
rootUrl
+
'findById'
,
{
id
:
wx
.
getStorageSync
(
'user_id'
),
...
data
},
function
(
res
)
{
typeof
fn
==
'function'
&&
fn
(
res
);
})
}
this
.
update
=
function
(
netTool
,
data
,
fn
)
{
if
(
data
.
real_name
==
'undefined'
)
{
data
.
real_name
=
''
}
var
that
=
this
;
netTool
.
getAjaxUrlValue
(
'capi/V2/recruitxcx/memberUser/update'
,
data
,
function
(
res
)
{
let
_chache
=
that
.
get
()
_chache
.
id
if
(
_chache
)
{
let
_cache1
=
{
id
:
_chache
.
id
,
...
_chache
,
...
data
}
debugger
wx
.
setStorageSync
(
'userInfo'
,
_cache1
)
_chache
=
that
.
get
()
typeof
fn
==
"function"
&&
fn
(
_chache
);
}
else
{
netTool
.
getAjaxUrlValueBackground
(
'capi/V2/recruitxcx/memberUser/list'
,
{
id
:
data
.
id
},
function
(
res
)
{
wx
.
setStorageSync
(
'userInfo'
,
res
.
rows
[
0
])
typeof
fn
==
"function"
&&
fn
(
res
.
rows
[
0
]);
})
}
})
}
this
.
getUserProfile
=
function
()
{
// 推荐使用wx.getUserProfile获取用户信息,开发者每次通过该接口获取用户个人信息均需用户确认
// 开发者妥善保管用户快速填写的头像昵称,避免重复弹窗
let
_cache
=
wx
.
getStorageSync
(
storageName
)
if
(
_cache
)
{
wx_synchronization_flag
=
_cache
.
wx_synchronization_flag
}
if
(
wx_synchronization_flag
)
{
return
true
}
let
that
=
this
;
wx
.
getUserProfile
({
desc
:
'用于完善会员资料'
,
// 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
success
:
(
res
)
=>
{
wx_synchronization_flag
=
1
let
rawData
=
JSON
.
parse
(
res
.
rawData
)
that
.
updateSycn
({
avatar
:
rawData
.
avatarUrl
,
wx_synchronization_flag
:
1
,
nick_name
:
rawData
.
nickName
})
}
})
}
this
.
get
=
function
()
{
return
wx
.
getStorageSync
(
'userInfo'
)
}
this
.
getMyId
=
function
()
{
return
wx
.
getStorageSync
(
'userInfo'
).
id
}
this
.
getOpenId
=
function
()
{
return
wx
.
getStorageSync
(
'userInfo'
).
open_id
}
}
module
.
exports
=
UserInfo
;
\ No newline at end of file
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