Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
Sign in / Register
Toggle navigation
S
site-uniapp
概览
Overview
详情
活动
周期分析
版本库
存储库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
Issues
0
列表
Board
标记
里程碑
合并请求
0
Merge Requests
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
Snippets
Members
Collapse sidebar
Close sidebar
活动
图像
聊天
创建新问题
作业
提交
Issue Boards
Open sidebar
王柯
site-uniapp
Commits
df0e535f
提交
df0e535f
authored
12月 19, 2022
作者:
wk
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
登录模块页面
父级
c5ecec5a
隐藏空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
527 行增加
和
11 行删除
+527
-11
common/toast.js
+10
-0
main.js
+6
-2
pages.json
+14
-0
pages/index/index.vue
+34
-1
pages/login/joinOrg/joinOrg.vue
+146
-0
pages/login/login/login.vue
+4
-4
pages/login/register/register.vue
+313
-4
static/icon_wechat.jpg
+0
-0
没有找到文件。
common/toast.js
0 → 100644
View file @
df0e535f
const
$toast
=
{
showToast
:
function
(
msg
)
{
uni
.
showToast
({
title
:
msg
,
icon
:
'none'
})
}
}
export
default
$toast
main.js
View file @
df0e535f
...
...
@@ -4,8 +4,12 @@ import App from './App'
import
Vue
from
'vue'
import
tabBar
from
'components/uni-tabbar/uni-tabbar.vue'
import
api
from
'api/api.js'
Vue
.
prototype
.
$api
=
api
;
import
$api
from
'api/api.js'
Vue
.
prototype
.
$api
=
$api
;
import
$toast
from
'./common/toast.js'
import
$config
from
'./common/config.js'
Vue
.
prototype
.
$toast
=
$toast
Vue
.
prototype
.
$config
=
$config
Vue
.
component
(
'tabBar'
,
tabBar
)
Vue
.
config
.
productionTip
=
false
App
.
mpType
=
'app'
...
...
pages.json
View file @
df0e535f
...
...
@@ -14,6 +14,13 @@
}
},
{
"path"
:
"pages/login/register/register"
,
"style"
:
{
"navigationBarTitleText"
:
""
,
"enablePullDownRefresh"
:
false
}
},
{
"path"
:
"pages/login/login/login"
,
"style"
:
{
"navigationBarTitleText"
:
""
,
...
...
@@ -90,6 +97,13 @@
"enablePullDownRefresh"
:
false
}
},
{
"path"
:
"pages/login/joinOrg/joinOrg"
,
"style"
:
{
"navigationBarTitleText"
:
""
,
"enablePullDownRefresh"
:
false
}
}
],
"globalStyle"
:
{
...
...
pages/index/index.vue
View file @
df0e535f
...
...
@@ -2,7 +2,7 @@
<view
class=
"content"
>
<view
class=
"header-content"
>
<image
src=
"../../static/home-head.png"
class=
"header-image"
></image>
<navbar
:title=
"title"
:showBack=
"false"
></navbar>
<navbar
:title=
"title"
:showBack=
"false"
></navbar>
<!-- 天气 -->
<view
class=
"weather-content"
:style=
"
{top:statusBarHeight+36+'px'}">
<view
class=
"temp-content"
>
...
...
@@ -115,8 +115,41 @@
onLoad
()
{
const
info
=
uni
.
getSystemInfoSync
()
this
.
statusBarHeight
=
info
.
statusBarHeight
this
.
loginState
()
},
onShow
()
{
},
methods
:
{
loginState
()
{
let
that
=
this
uni
.
getStorage
({
key
:
that
.
$config
.
authCode
,
success
(
res
)
{
},
fail
()
{
uni
.
showModal
({
title
:
'登录提示'
,
content
:
'是否已有组织账号,还是以访客身份访问?'
,
showCancel
:
true
,
confirmText
:
"账号登录"
,
cancelText
:
"访客模式"
,
confirmColor
:
'#3B73FE'
,
success
:
res
=>
{
if
(
res
.
confirm
)
{
that
.
toLogin
()
}
}
})
}
})
},
toLogin
:
function
()
{
uni
.
reLaunch
({
url
:
"/pages/login/login/login"
})
},
isLineVisil
(
index
)
{
return
index
%
2
==
0
},
...
...
pages/login/joinOrg/joinOrg.vue
0 → 100644
View file @
df0e535f
<
template
>
<view
class=
"join-company-root"
>
<view
class=
"join-company-code"
>
<text
class=
"text-black-normal"
>
邀请码
</text>
<input
placeholder=
"请输入邀请码"
v-model=
"code"
style=
"border: 1rpx solid #E5E5E5;margin-left: 32rpx;padding: 20rpx;"
placeholder-class=
"placeholderStyle"
/>
</view>
<view
style=
"height: 144rpx;"
></view>
<view
class=
"uni-group-button"
>
<button
class=
"uni-grey-button"
@
click=
"toScan"
>
扫码加入
</button>
<button
class=
"uni-blue-button"
@
click=
"toNext"
>
下一步
</button>
</view>
</view>
</
template
>
<
script
>
export
default
{
data
()
{
return
{
code
:
""
}
},
methods
:
{
toScan
:
function
()
{
uni
.
scanCode
({
scanType
:
[
'qrcode'
],
success
:
(
res
)
=>
{
console
.
log
(
"扫码结果"
,
res
);
let
result
=
JSON
.
parse
(
res
.
result
)
let
type
=
result
.
type
if
(
type
==
"company"
)
{
this
.
code
=
result
.
text
uni
.
navigateTo
({
url
:
`../join-department/join-department?code=
${
this
.
code
}
&type=company`
})
}
else
if
(
type
==
"project"
)
{
this
.
code
=
result
.
text
uni
.
navigateTo
({
url
:
`../join-department/join-department?code=
${
this
.
code
}
&type=project&projectId=
${
result
.
ext
.
id
}
`
})
}
else
if
(
type
==
"department"
)
{
this
.
code
=
result
.
text
uni
.
navigateTo
({
url
:
`../join-department/join-department?code=
${
this
.
code
}
&type=department`
})
}
else
{
this
.
$toast
.
showToast
(
"二维码格式不正确"
)
}
},
fail
:
(
res
)
=>
{
console
.
log
(
"扫码结果"
,
res
);
this
.
$toast
.
showToast
(
"二维码识别失败"
)
}
})
},
toNext
()
{
if
(
this
.
code
==
""
)
{
return
}
uni
.
navigateTo
({
url
:
`../join-department/join-department?code=
${
this
.
code
}
`
})
},
toJoin
:
function
()
{
let
that
=
this
this
.
$http
.
consoleGet
({
url
:
"/api/v1/org/company/detail_by_invite_code"
,
data
:
{
invite_code
:
this
.
code
},
header
:
{
access_token
:
this
.
getToken
()
}
}).
then
((
res
)
=>
{
let
result
=
res
.
data
console
.
log
(
"单位信息"
,
result
);
if
(
result
.
code
==
0
)
{
uni
.
showModal
({
title
:
"提示"
,
content
:
`确定加入
${
result
.
data
.
company_name
}
?`
,
showCancel
:
true
,
confirmText
:
"加入"
,
confirmColor
:
"#1890FF"
,
success
:
function
(
res
)
{
if
(
res
.
confirm
)
{
that
.
joinCompany
()
}
}
})
}
else
{
this
.
$toast
.
showToast
(
result
.
msg
)
}
})
},
joinCompany
:
function
()
{
this
.
$http
.
consolePost
({
url
:
"/api/v1/org/o_comp_user/join_comp_by_invite_code"
,
data
:
{
invite_code
:
this
.
code
},
header
:
{
access_token
:
this
.
getToken
()
}
}).
then
((
res
)
=>
{
let
result
=
res
.
data
console
.
log
(
"加入单位"
,
result
);
if
(
result
.
code
==
0
)
{
uni
.
showModal
({
title
:
"提示"
,
content
:
"你的申请已提交"
,
showCancel
:
false
,
confirmText
:
"确定"
,
confirmColor
:
"#1890FF"
,
success
:
function
(
res
)
{
if
(
res
.
confirm
)
{
uni
.
navigateBack
({
delta
:
1
})
}
}
})
}
else
{
this
.
$toast
.
showToast
(
result
.
msg
)
}
})
}
}
}
</
script
>
<
style
>
.join-company-root
{
display
:
flex
;
flex-direction
:
column
;
}
.join-company-code
{
display
:
flex
;
flex-direction
:
row
;
align-items
:
center
;
justify-content
:
center
;
height
:
800
rpx
;
}
</
style
>
pages/login/login/login.vue
View file @
df0e535f
...
...
@@ -36,7 +36,7 @@
<button
@
click=
"login"
>
登录
</button>
<button
@
click=
"register"
>
注册
</button>
<image
src=
'../../static/icon_wechat.jpg'
<image
src=
'../../
../
static/icon_wechat.jpg'
style=
"margin-top: 20rpx;width: 60rpx;height: 60rpx;border-radius: 40rpx;"
@
click=
"toBind"
></image>
</view>
</view>
...
...
@@ -69,12 +69,12 @@
methods
:
{
register
:
function
()
{
uni
.
redirectTo
({
url
:
"
..
/register/register"
url
:
"
/pages/login
/register/register"
})
},
toBind
:
function
()
{
uni
.
reLaunch
({
url
:
"
../wxlogin/wxl
ogin"
url
:
"
/pages/login/wxLogin/wxL
ogin"
})
},
sendCode
()
{
...
...
@@ -360,7 +360,7 @@
justify-content
:
center
;
button
{
background-color
:
#
007AFF
;
background-color
:
#
3B73FE
;
width
:
70%
;
color
:
#FFFFFF
;
margin-top
:
30px
;
...
...
pages/login/register/register.vue
View file @
df0e535f
<
template
>
<view>
<view
class=
"register-root"
>
<form
@
submit=
"formSubmit"
>
<view
class=
"form-item"
>
<view
class=
"star"
>
*
</view>
<view
class=
"text-black-normal"
>
账号
</view>
<input
class=
"text-black-normal"
style=
"margin-left: 32rpx;flex: 1;"
name=
"account"
placeholder=
"请输入账号(数字字母组合)"
/>
</view>
<view
class=
"form-item"
>
<view
class=
"star"
>
*
</view>
<view
class=
"text-black-normal"
>
姓名
</view>
<input
class=
"text-black-normal"
style=
"margin-left: 32rpx;"
name=
"username"
placeholder=
"请输入姓名"
/>
</view>
<view
class=
"form-item"
>
<view
class=
"star"
>
*
</view>
<view
class=
"text-black-normal"
>
密码
</view>
<input
class=
"text-black-normal"
style=
"margin-left: 32rpx;"
name=
"password"
placeholder=
"请输入密码"
type=
"password"
/>
</view>
<view
class=
"form-item"
>
<view
class=
"star"
>
*
</view>
<view
class=
"text-black-normal"
>
确认密码
</view>
<input
class=
"text-black-normal"
style=
"margin-left: 32rpx;"
name=
"confirmpassword"
placeholder=
"请再次输入密码"
type=
"password"
/>
</view>
<view
class=
"form-item"
>
<view
class=
"star"
>
*
</view>
<view
class=
"text-black-normal"
>
手机号
</view>
<input
class=
"text-black-normal"
style=
"margin-left: 32rpx;"
name=
"phone"
placeholder=
"请输入手机号"
v-model=
"phone"
type=
"number"
/>
</view>
<view
class=
"form-item"
>
<view
class=
"star"
>
*
</view>
<view
class=
"text-black-normal"
>
验证码
</view>
<input
class=
"text-black-normal"
style=
"margin-left: 32rpx;flex: 1;"
name=
"code"
placeholder=
"请输入验证码"
type=
"number"
/>
<view
class=
"text-blue"
@
click=
"getCode"
>
{{
codeText
}}
</view>
</view>
<view
style=
"margin-top: 60rpx;"
>
<button
form-type=
"submit"
class=
"form-submit"
>
注册
</button>
</view>
<view
class=
"text-blue-normal"
style=
"display: flex;flex-direction: column;margin-top: 30rpx;align-items: center;"
@
click=
"toLogin"
>
已有账号
</view>
</form>
</view>
</
template
>
...
...
@@ -8,15 +51,281 @@
export
default
{
data
()
{
return
{
isCanSend
:
true
,
downTime
:
60
,
phone
:
""
,
codeText
:
"获取验证码"
,
unique_token
:
""
,
type
:
""
}
},
onLoad
:
function
(
params
)
{
this
.
unique_token
=
params
.
unique_token
this
.
type
=
params
.
type
},
methods
:
{
checkAccount
(
account
)
{
var
reg
=
/^
(?![
0-9
]
+$
)(?![
a-zA-Z
]
+$
)[
0-9A-Za-z
]{2,16}
$/
var
re
=
new
RegExp
(
reg
)
if
(
re
.
test
(
account
))
{
return
true
;
}
else
{
return
false
;
}
},
formSubmit
:
function
(
e
)
{
console
.
log
(
"表单内容:"
,
e
.
detail
.
value
);
let
data
=
e
.
detail
.
value
if
(
data
.
account
==
""
)
{
this
.
$toast
.
showToast
(
"请输入账号"
)
return
}
if
(
!
this
.
checkAccount
(
data
.
account
))
{
this
.
$toast
.
showToast
(
"账号必须为2-16位数字字母组合"
)
return
}
if
(
data
.
username
==
""
)
{
this
.
$toast
.
showToast
(
"请输入姓名"
)
return
}
if
(
data
.
password
==
""
)
{
this
.
$toast
.
showToast
(
"请输入密码"
)
return
}
if
(
data
.
password
!=
data
.
confirmpassword
)
{
this
.
$toast
.
showToast
(
"两次输入密码不一致"
)
return
}
if
(
data
.
phone
==
""
)
{
this
.
$toast
.
showToast
(
"请输入手机号"
)
return
}
if
(
data
.
code
==
""
)
{
this
.
$toast
.
showToast
(
"请输入验证码"
)
return
}
this
.
get_key
(
data
)
},
register
:
function
(
key
,
data
)
{
this
.
$http
.
consolePost
({
url
:
"/api/v1/access/login/user_register"
,
data
:
{
phone
:
data
.
phone
,
user_no
:
data
.
account
,
user_name
:
data
.
username
,
code
:
data
.
code
,
useage_code
:
2
,
system_no
:
this
.
systemCode
,
password
:
data
.
password
,
confirm_password
:
data
.
confirmpassword
,
audit_status
:
2
},
header
:
{
key
:
key
}
}).
then
((
res
)
=>
{
let
result
=
res
.
data
if
(
result
.
code
==
0
)
{
this
.
$toast
.
showToast
(
"注册成功!"
)
if
(
this
.
type
==
"bind"
)
{
this
.
bindLogin
(
data
.
account
,
data
.
password
)
}
else
{
this
.
login
(
data
.
account
,
data
.
password
)
}
}
else
{
this
.
$toast
.
showToast
(
result
.
msg
)
}
})
},
login
:
function
(
account
,
password
)
{
this
.
$http
.
consolePost
({
url
:
"/api/v1/access/login/do_login"
,
data
:
{
"user_no"
:
account
,
"password"
:
password
,
"login_type"
:
1
,
"system_no"
:
this
.
systemCode
},
header
:
{
"key"
:
key
,
"Content-Type"
:
"application/json"
}
}).
then
((
res
)
=>
{
let
result
=
res
.
data
console
.
log
(
"登录用户信息:"
,
result
);
if
(
result
.
code
===
0
)
{
uni
.
setStorageSync
(
'isCanUse'
,
false
);
//记录是否第一次授权 false:表示不是第一次授权
uni
.
setStorageSync
(
"short_token"
,
result
.
data
.
short_token
)
this
.
setToken
(
result
.
data
.
access_token
)
uni
.
setStorageSync
(
"user_info"
,
result
.
data
)
uni
.
setStorageSync
(
"company_id"
,
result
.
data
.
comp_id
)
uni
.
setStorageSync
(
"refresh_token"
,
result
.
data
.
refresh_token
)
uni
.
showToast
({
title
:
"登录成功"
,
icon
:
'none'
})
uni
.
switchTab
({
url
:
"../desk-page/desk-page"
})
}
else
{
uni
.
showToast
({
title
:
result
.
msg
,
icon
:
'none'
})
}
})
},
bindLogin
(
account
,
password
)
{
this
.
$http
.
consolePost
({
url
:
"/api/v1/system/p_user_third/user_third_bind"
,
data
:
{
"user_no"
:
account
,
"third_type"
:
1
,
"unique_token"
:
this
.
unique_token
,
"password"
:
password
}
}).
then
((
res
)
=>
{
let
result
=
res
.
data
console
.
log
(
"登录用户信息:"
,
result
);
if
(
result
.
code
===
0
)
{
uni
.
setStorageSync
(
'isCanUse'
,
false
);
//记录是否第一次授权 false:表示不是第一次授权
this
.
setToken
(
result
.
data
.
access_token
)
uni
.
setStorageSync
(
"short_token"
,
result
.
data
.
short_token
)
uni
.
setStorageSync
(
"user_info"
,
result
.
data
)
uni
.
setStorageSync
(
"company_id"
,
result
.
data
.
comp_id
)
uni
.
setStorageSync
(
"refresh_token"
,
result
.
data
.
refresh_token
)
uni
.
showToast
({
title
:
"登录成功"
,
icon
:
'none'
})
uni
.
switchTab
({
url
:
"../desk-page/desk-page"
})
}
else
{
uni
.
showToast
({
title
:
result
.
msg
,
icon
:
'none'
})
}
})
},
get_key
(
data
)
{
// 先获取key 再登录
this
.
$http
.
consolePost
({
url
:
"/api/v1/access/access_system/get_key"
,
data
:
{
"system_no"
:
this
.
systemCode
,
"auth_code"
:
this
.
authCode
},
header
:
{
"Content-Type"
:
"application/json"
}
}).
then
((
res
)
=>
{
console
.
log
(
res
);
let
result
=
res
.
data
if
(
result
.
code
===
0
)
{
this
.
register
(
result
.
data
.
key
,
data
)
}
else
{
uni
.
showToast
({
title
:
result
.
msg
,
icon
:
'none'
})
}
})
},
toLogin
:
function
()
{
if
(
this
.
type
==
"bind"
)
{
uni
.
redirectTo
({
url
:
`../bind-login/bind-login?unique_token=
${
this
.
unique_token
}
`
})
}
else
{
uni
.
redirectTo
({
url
:
"../login/login"
})
}
},
getCode
:
function
()
{
let
that
=
this
if
(
!
(
this
.
isCanSend
))
{
return
}
if
(
this
.
phone
==
""
||
this
.
phone
.
length
!=
11
)
{
uni
.
showToast
({
title
:
"请输入正确的手机号"
,
duration
:
1000
,
icon
:
'none'
,
})
return
}
this
.
$http
.
consolePost
({
url
:
"/api/v1/access/login/create_validate_code"
,
data
:
{
"phone"
:
this
.
phone
,
"usage_code"
:
"2"
,
"template_no"
:
"industry-0001"
,
"system_no"
:
this
.
systemCode
},
header
:
{
"Content-Type"
:
"application/json"
}
}).
then
(
function
(
res
)
{
console
.
log
(
res
);
let
code
=
res
.
data
.
code
if
(
code
==
0
)
{
that
.
timeDown
(
that
.
downTime
)
uni
.
showToast
({
title
:
"验证码已发送"
,
icon
:
'none'
})
}
else
{
uni
.
showToast
({
title
:
res
.
data
.
msg
,
icon
:
'none'
})
}
})
},
timeDown
(
num
)
{
let
that
=
this
;
if
(
num
==
0
)
{
this
.
downTime
=
60
this
.
isCanSend
=
true
;
this
.
codeText
=
"发送验证码"
return
clearTimeout
();
}
else
{
this
.
isCanSend
=
false
;
setTimeout
(
function
()
{
that
.
downTime
=
num
-
1
that
.
codeText
=
that
.
downTime
+
"秒"
that
.
timeDown
(
num
-
1
)
},
1000
);
}
},
}
}
</
script
>
<
style
>
.register-root
{
display
:
flex
;
flex-direction
:
column
;
padding
:
32
rpx
;
}
.form-item
{
display
:
flex
;
flex-direction
:
row
;
align-items
:
center
;
height
:
96
rpx
;
}
.form-submit
{
height
:
96
rpx
;
border
:
1
rpx
solid
#E5E5E5
;
border-radius
:
10
rpx
;
font-size
:
32
rpx
;
color
:
#FFFFFF
;
background-color
:
#1890FF
;
}
</
style
>
static/icon_wechat.jpg
0 → 100644
View file @
df0e535f
12.2 KB
Write
Preview
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
Please
register
or
sign in
to comment