Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
X
XAMJW-Hospita
Overview
Overview
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wechatminiprogram
XAMJW-Hospita
Commits
e5985b49
Commit
e5985b49
authored
Jul 29, 2021
by
chenzhenan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复生活事件量表bug,新增量表信息录入增加手机号必填,验证身份证号
parent
fb9ccfdf
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
94 additions
and
9 deletions
+94
-9
pages/dati08/dati08.js
+9
-2
pages/dati08/dati08.wxml
+3
-2
pages/info/info.js
+17
-1
utils/util.js
+65
-4
No files found.
pages/dati08/dati08.js
View file @
e5985b49
...
...
@@ -118,9 +118,16 @@ Page({
let
answerIndex
=
parameter
.
answerIndex
let
contentIndex
=
parameter
.
contentIndex
let
currentIndex
=
this
.
data
.
currentIndex
let
scaleTitleIndex
=
parameter
.
scaleTitleIndex
if
(
this
.
data
.
isCanClick
===
false
)
{
return
}
if
(
scaleTitleIndex
!=
currentIndex
){
return
}
if
(
this
.
data
.
questionData
[
answerIndex
].
isShow
===
false
){
return
}
this
.
setData
({
isCanClick
:
false
})
...
...
@@ -144,7 +151,6 @@ Page({
//判断是否可以提交了
this
.
canSubmit
()
}
else
{
this
.
setData
({
currentIndex
:
currentIndex
+
1
})
...
...
@@ -161,7 +167,7 @@ Page({
})
}
clearTimeout
(
timer
)
},
200
)
},
200
)
}
else
{
//将选项存入答题记录,同时更新视图内容,记录答题
let
record
=
this
.
data
.
answerRecord
[
this
.
data
.
currentIndex
]
...
...
@@ -213,6 +219,7 @@ Page({
//提交
submit
:
debouce
(
function
()
{
//验证数据的完整性
console
.
log
(
this
.
data
.
answerRecord
)
if
(
!
checkAnswerRecord
(
this
.
data
.
answerRecord
))
{
wx
.
showModal
({
showCancel
:
false
,
...
...
pages/dati08/dati08.wxml
View file @
e5985b49
...
...
@@ -3,7 +3,7 @@
<block wx:for="{{scaleTitleData}}" wx:for-item="scaleTitle" wx:for-index="scaleTitleIndex" wx:key="scaleTitleIndex">
<block wx:if="{{currentIndex === scaleTitleIndex}}">
<block wx:for="{{questionData}}" wx:for-index="answerIndex" wx:for-item="answerItem" wx:key="answerIndex">
<
block wx:if="{{
answerItem.isShow}}">
<
view hidden="{{!
answerItem.isShow}}">
<view class="con">
<text style="margin-top: 10rpx;">{{scaleTitle}}--{{answerItem.subtitle}}</text>
</view>
...
...
@@ -11,11 +11,12 @@
wx:key="contentIndex">
<view bindtap="selectOption" data-content-item="{{contentItem}}" data-answer-index="{{answerIndex}}"
data-content-index="{{contentIndex}}"
data-scale-title-index="{{scaleTitleIndex}}"
class="answer + {{answerRecord[currentIndex][answerIndex].index === contentIndex?'s-active':''}}">
<text>{{contentItem.title}}</text>
</view>
</view>
</
block
>
</
view
>
</block>
</block>
</block>
...
...
pages/info/info.js
View file @
e5985b49
var
Api
=
require
(
'../../utils/api.js'
);
import
{
validateIdCard
}
from
'../../utils/util'
var
app
=
getApp
();
Page
({
...
...
@@ -412,6 +413,7 @@ Page({
data
.
name
=
that
.
data
.
username
;
//姓名
data
.
sex
=
that
.
data
.
sex
;
//性别
data
.
birthday
=
that
.
data
.
date
;
// 年龄
data
.
usernumber
=
that
.
data
.
usernumber
//手机号
data
.
jobnumber
=
that
.
data
.
jobnumber
;
//工号
data
.
sheqvNumber
=
that
.
data
.
sheqvNumber
;
data
.
workNumber
=
that
.
data
.
workNumber
;
...
...
@@ -424,13 +426,27 @@ Page({
// 新添加学历功能
data
.
edu
=
that
.
data
.
index
||
0
;
console
.
log
(
'data'
,
data
)
if
(
data
.
name
==
''
||
data
.
name
==
'null'
||
data
.
sex
==
"null"
||
data
.
sex
==
""
||
data
.
birthday
==
''
||
data
.
birthday
==
'null'
||
data
.
edu
==
0
||
data
.
idCard
==
""
||
data
.
username1
==
""
||
data
.
select
==
0
)
{
if
(
data
.
name
==
''
||
data
.
name
==
'null'
||
data
.
sex
==
"null"
||
data
.
sex
==
""
||
data
.
birthday
==
''
||
data
.
birthday
==
'null'
||
data
.
edu
==
0
||
data
.
idCard
==
""
||
data
.
username1
==
""
||
data
.
select
==
0
){
that
.
setData
({
payInfo
:
true
})
Api
.
alert
(
'请完善信息'
);
return
;
}
if
(
data
.
usernumber
==
''
||
data
.
usernumber
==
'null'
||
data
.
usernumber
.
length
!=
11
){
that
.
setData
({
payInfo
:
true
})
Api
.
alert
(
'请填写正确的手机号'
);
return
;
}
if
(
!
validateIdCard
(
data
.
idCard
)){
that
.
setData
({
payInfo
:
true
})
Api
.
alert
(
'请填写正确的身份证号'
);
return
;
}
var
timer1
=
setTimeout
(
function
()
{
// Api.alert("加载失败,请重试")
wx
.
hideLoading
()
...
...
utils/util.js
View file @
e5985b49
...
...
@@ -242,6 +242,24 @@ function debouce(func, delay, immediate) {
}
}
/**
* 节流函数
* @param {function} fn 实际要执行的函数
* @param {interval} interval 间隔时间,如果interval不传,则默认300ms
*/
function
throttle
(
fn
,
interval
)
{
var
enterTime
=
0
;
//触发的时间
var
gapTime
=
interval
||
300
;
//间隔时间,如果interval不传,则默认300ms
return
function
()
{
var
context
=
this
;
//闭包取当前函数this
var
backTime
=
new
Date
();
//第一次函数return即触发的时间
if
(
backTime
-
enterTime
>=
gapTime
)
{
//封装实参的对象arguments
fn
.
apply
(
context
,
arguments
);
enterTime
=
backTime
;
//赋值给第一次触发的时间,这样就保存了第二次触发的时间
}
};
}
/**
* 秒数转换时间
* @param {Int} value
*/
...
...
@@ -294,9 +312,49 @@ function base64src(base64data) {
fail
()
{
reject
(
new
Error
(
'ERROR_BASE64SRC_WRITE'
));
},
});
});
};
})
})
}
/**
*身份验证
* @param {string} idCard 身份证号码
*/
function
validateIdCard
(
idCard
)
{
//15位和18位身份证号码的正则表达式
var
regIdCard
=
/^
(
^
[
1-9
]\d{7}((
0
\d)
|
(
1
[
0-2
]))(([
0|1|2
]\d)
|3
[
0-1
])\d{3}
$
)
|
(
^
[
1-9
]\d{5}[
1-9
]\d{3}((
0
\d)
|
(
1
[
0-2
]))(([
0|1|2
]\d)
|3
[
0-1
])((\d{4})
|
\d{3}[
Xx
])
$
)
$/
;
//如果通过该验证,说明身份证格式正确,但准确性还需计算
if
(
regIdCard
.
test
(
idCard
))
{
if
(
idCard
.
length
==
18
)
{
var
idCardWi
=
new
Array
(
7
,
9
,
10
,
5
,
8
,
4
,
2
,
1
,
6
,
3
,
7
,
9
,
10
,
5
,
8
,
4
,
2
);
//将前17位加权因子保存在数组里
var
idCardY
=
new
Array
(
1
,
0
,
10
,
9
,
8
,
7
,
6
,
5
,
4
,
3
,
2
);
//这是除以11后,可能产生的11位余数、验证码,也保存成数组
var
idCardWiSum
=
0
;
//用来保存前17位各自乖以加权因子后的总和
for
(
var
i
=
0
;
i
<
17
;
i
++
)
{
idCardWiSum
+=
idCard
.
substring
(
i
,
i
+
1
)
*
idCardWi
[
i
];
}
var
idCardMod
=
idCardWiSum
%
11
;
//计算出校验码所在数组的位置
var
idCardLast
=
idCard
.
substring
(
17
);
//得到最后一位身份证号码
//如果等于2,则说明校验码是10,身份证号码最后一位应该是X
if
(
idCardMod
==
2
)
{
if
(
idCardLast
==
"X"
||
idCardLast
==
"x"
)
{
return
true
;
}
else
{
return
false
;
}
}
else
{
//用计算出的验证码与最后一位身份证号码匹配,如果一致,说明通过,否则是无效的身份证号码
if
(
idCardLast
==
idCardY
[
idCardMod
])
{
return
true
;
}
else
{
return
false
;
}
}
}
}
else
{
return
false
;
}
}
module
.
exports
=
{
base64src
:
base64src
,
formatTime
:
formatTime
,
...
...
@@ -307,6 +365,8 @@ module.exports = {
formatLocation
:
formatLocation
,
timestampToTime
:
timestampToTime
,
debouce
:
debouce
,
throttle
:
throttle
,
isEmpty
:
isEmpty
,
formatSeconds
:
formatSeconds
formatSeconds
:
formatSeconds
,
validateIdCard
:
validateIdCard
}
\ 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