Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
肖康
/
H5_2.0
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
6ab4cd79
authored
May 18, 2023
by
LJM
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
js
parent
34888d11
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
138 additions
and
55 deletions
pages/mine/login.vue
util/api.js
util/util.js
pages/mine/login.vue
View file @
6ab4cd79
...
...
@@ -49,16 +49,16 @@
<!-- 普通登录 -->
<
template
v-else
>
<view
class=
"input-box code row bothSide verCenter mb40"
>
<input
type=
"number"
placeholder=
"请输入手机号码/邮箱"
placeholder-style=
"color:#919399;"
class=
"uni-input"
/>
<input
type=
"number"
placeholder=
"请输入手机号码/邮箱"
placeholder-style=
"color:#919399;"
class=
"uni-input"
v-model=
"formParams.account"
/>
<text
class=
"code"
@
click=
"login_type = true"
>
国际手机
</text>
</view>
<view
class=
"input-box verification-code row bothSide verCenter"
style=
"margin-bottom: 24rpx;"
>
<input
type=
"text"
placeholder=
"请输入图中字符,不区分大小写"
placeholder-style=
"color:#919399;"
class=
"uni-input"
/>
<image
src=
"https://www.ichunt.com/v3/public/verify"
class=
"pic
"
></image>
<view
class=
"input-box verification-code row bothSide verCenter"
style=
"margin-bottom: 24rpx;"
v-if=
"verify_flag"
>
<input
type=
"text"
placeholder=
"请输入图中字符,不区分大小写"
placeholder-style=
"color:#919399;"
class=
"uni-input"
v-model=
"formParams.verify"
/>
<image
:src=
"url"
class=
"pic"
@
click=
"refresh()
"
></image>
</view>
</
template
>
<view
class=
"input-box pwd row bothSide verCenter mb40"
>
<input
type=
"number"
placeholder=
"请输入密码"
placeholder-style=
"color:#919399;"
class=
"uni-input"
/>
<input
type=
"number"
placeholder=
"请输入密码"
placeholder-style=
"color:#919399;"
class=
"uni-input"
v-model=
"formParams.pwd"
/>
<text
class=
"iconfont icon-a-juxingbeifen14"
></text>
</view>
</template>
...
...
@@ -73,6 +73,7 @@
<
script
>
import
{
Ichunt_Api
,
Api_Url
}
from
'@/util/api.js'
;
import
{
setCookie
}
from
'@/util/util.js'
;
export
default
{
data
()
{
return
{
...
...
@@ -80,10 +81,19 @@ export default {
index
:
0
,
curr
:
1
,
text_item
:
[
'免密登录/注册'
,
'账号登录'
],
array
:
[
'0086'
,
'00886'
,
'00853'
,
'00852'
]
array
:
[
'0086'
,
'00886'
,
'00853'
,
'00852'
],
verify_flag
:
false
,
//是否显示验证码
url
:
Ichunt_Api
+
'/public/verify'
,
formParams
:
{
account
:
'18682159081'
,
pwd
:
'123456'
,
verify
:
''
}
};
},
onLoad
()
{},
onLoad
()
{
console
.
log
(
Ichunt_Api
);
},
methods
:
{
bindPickerChange
:
function
(
e
,
type
)
{
console
.
log
(
'picker发送选择改变,携带值为'
,
e
.
detail
.
value
);
...
...
@@ -91,9 +101,46 @@ export default {
tab
(
index
)
{
this
.
curr
=
index
;
},
/**
* 刷新验证码
*/
refresh
()
{
this
.
url
=
Ichunt_Api
+
'/public/verify?time='
+
new
Date
().
getTime
();
},
submit
()
{
this
.
request
(
Api_Url
+
'/login/action'
,
'GET'
,
{}).
then
(
res
=>
{
console
.
log
(
res
);
this
.
request
(
Api_Url
+
'/login/action'
,
'POST'
,
this
.
formParams
,
true
,
true
).
then
(
res
=>
{
if
(
res
.
err_code
===
0
)
{
this
.
verify_flag
=
false
;
uni
.
showToast
({
title
:
'登录成功'
,
icon
:
'success'
});
setCookie
(
'Yo4teW_csrf'
,
res
.
data
.
cookie
.
Yo4teW_csrf
,
7
);
setCookie
(
'Yo4teW_gid'
,
res
.
data
.
cookie
.
Yo4teW_gid
,
7
);
setCookie
(
'Yo4teW_uid'
,
res
.
data
.
cookie
.
Yo4teW_uid
,
7
);
uni
.
navigateBack
({
delta
:
1
});
}
else
if
(
res
.
err_code
===
10001
||
res
.
err_code
===
10002
)
{
uni
.
showModal
({
itle
:
'提示'
,
content
:
res
.
err_msg
,
showCancel
:
false
,
success
:
res
=>
{
if
(
res
.
confirm
)
{
this
.
verify_flag
=
true
;
}
else
if
(
res
.
cancel
)
{
}
}
});
}
else
{
this
.
verify_flag
=
false
;
uni
.
showModal
({
itle
:
'提示'
,
content
:
res
.
err_msg
,
showCancel
:
false
});
}
});
}
}
...
...
util/api.js
View file @
6ab4cd79
let
Ichunt_Api
=
''
;
//3.0网站接口
let
Api_Url
=
''
;
//api项目url
let
Api_Es
=
''
;
//api项目url
let
Api_ES_Go
=
''
;
//型号联想
let
Api_Url
=
''
;
//api项目url
let
Api_Es
=
''
;
//api项目url
let
Api_ES_Go
=
''
;
//型号联想
switch
(
window
.
location
.
hostname
)
{
case
"m.ichunt.com"
:
Ichunt_Api
=
'https://www.ichunt.com/v3'
;
Api_Url
=
"https://api.ichunt.com"
Api_Es
=
"//so12.ichunt.com"
Api_ES_Go
=
"https://s.ichunt.com"
break
;
default
:
//本地proxy配置参考vue.config.js
Ichunt_Api
=
'/v3'
Api_Url
=
'/apis'
;
Api_Es
=
"/es"
Api_ES_Go
=
"http://192.168.1.237:9008"
case
"m.ichunt.com"
:
Ichunt_Api
=
'https://www.ichunt.com/v3'
;
Api_Url
=
"https://api.ichunt.com"
Api_Es
=
"//so12.ichunt.com"
Api_ES_Go
=
"https://s.ichunt.com"
break
;
default
:
//本地proxy配置参考vue.config.js
Ichunt_Api
=
'/v3'
Api_Url
=
'/apis'
;
Api_Es
=
"/es"
Api_ES_Go
=
"http://192.168.1.237:9008"
}
module
.
exports
=
{
Ichunt_Api
,
Api_Url
,
Api_Es
,
Api_ES_Go
}
Api_Url
,
Api_Es
,
Api_ES_Go
}
\ No newline at end of file
util/util.js
View file @
6ab4cd79
...
...
@@ -2,33 +2,43 @@ import API_BASE from '../util/api.js'
/**
* 请求封装
*/
const
request
=
(
url
=
''
,
type
=
'GET'
,
param
=
{},
Loading
,
headertype
)
=>
{
const
oa_user_id
=
uni
.
getStorageSync
(
'oa_user_id'
)
||
''
;
const
oa_skey
=
uni
.
getStorageSync
(
'oa_skey'
)
||
''
;
const
request
=
(
url
=
''
,
type
=
'GET'
,
param
=
{},
Loading
,
headertype
)
=>
{
const
Yo4teW_csrf
=
getCookie
(
'Yo4teW_csrf'
)
||
''
;
const
Yo4teW_gid
=
getCookie
(
'Yo4teW_gid'
)
||
''
;
const
Yo4teW_uid
=
getCookie
(
'Yo4teW_uid'
)
||
''
;
var
params
=
Object
.
assign
(
param
,
{
pf
:
2
});
//请求es相关
if
(
url
&&
(
url
.
indexOf
(
"so12.ichunt."
)
!=-
1
||
url
.
indexOf
(
"so.liexin.net"
)
!=-
1
)){
params
=
Object
.
assign
(
param
,
{
hkyefgyd
:
1
});
}
//是否启动加载
if
(
Loading
)
{
uni
.
showLoading
({
mask
:
true
});
}
let
header
=
{
"Content-Type"
:
"application/json; charset=utf-8"
}
if
(
headertype
)
{
header
=
{
'Content-Type'
:
'application/x-www-form-urlencoded'
}
//h5统一携带参数pf
var
params
=
Object
.
assign
(
param
,
{
pf
:
2
});
//请求es相关
if
(
url
&&
(
url
.
indexOf
(
"so12.ichunt."
)
!=
-
1
||
url
.
indexOf
(
"so.liexin.net"
)
!=
-
1
))
{
params
=
Object
.
assign
({
hkyefgyd
:
1
});
}
//如果uid没有,就添加参数ygagatetffafa,绕过验证登录
if
(
!
Yo4teW_csrf
&&
!
Yo4teW_gid
&&
!
Yo4teW_uid
)
{
params
=
Object
.
assign
({
ygagatetffafa
:
1
});
}
//请求类型判断
let
header
=
{
"Content-Type"
:
"application/json; charset=utf-8"
}
if
(
headertype
)
{
header
=
{
'Content-Type'
:
'application/x-www-form-urlencoded'
}
}
return
new
Promise
((
resolve
,
reject
)
=>
{
uni
.
request
({
...
...
@@ -44,10 +54,6 @@ const request = (url = '', type = 'GET', param = {}, Loading,headertype) => {
let
result
=
response
.
data
;
resolve
(
result
);
}
else
{
uni
.
showToast
({
title
:
'网络出现问题'
,
icon
:
'error'
});
reject
(
response
);
}
},
...
...
@@ -80,7 +86,37 @@ const getPlatform = () => {
}
/**
* 设置cookit
*/
const
setCookie
=
(
name
,
value
,
expireDays
)
=>
{
let
date
=
new
Date
();
date
.
setTime
(
date
.
getTime
()
+
(
expireDays
*
24
*
60
*
60
*
1000
));
let
expires
=
"expires="
+
date
.
toGMTString
();
document
.
cookie
=
name
+
"="
+
value
+
"; "
+
expires
;
}
/**
*获取cookie
*/
const
getCookie
=
(
name
)
=>
{
var
strCookie
=
document
.
cookie
;
var
arrCookie
=
strCookie
.
split
(
"; "
);
for
(
var
i
=
0
;
i
<
arrCookie
.
length
;
i
++
)
{
var
arr
=
arrCookie
[
i
].
split
(
"="
);
if
(
name
==
arr
[
0
])
{
return
arr
[
1
];
}
}
return
''
;
}
module
.
exports
=
{
request
,
getPlatform
getPlatform
,
setCookie
,
getCookie
}
\ 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