Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
W
www.fudou6.com
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
liaili
www.fudou6.com
Commits
af987356
Commit
af987356
authored
Aug 01, 2016
by
superman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
8.1-2
parent
0eb4738c
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
321 additions
and
110 deletions
+321
-110
project.js
public/javascripts/project.js
+156
-106
project.js.map
public/javascripts/project.js.map
+1
-0
project.jsx
public/javascripts/project.jsx
+160
-0
project.min.js
public/javascripts/project.min.js
+1
-1
index.js
routes/index.js
+1
-1
project.hbs
views/project.hbs
+2
-2
No files found.
public/javascripts/project.js
View file @
af987356
/**
* Created by Administrator on 2016/7/27.
*/
(
function
()
{
var
$submit
=
$
(
'#submit'
);
var
$errorPhone
=
$
(
'.error-phone'
);
var
$errorDescription
=
$
(
'.error-description'
);
var
$introducerMobile
=
$
(
'#introducerMobile'
);
var
$projectDescription
=
$
(
'#projectDescription'
);
var
$modalBoxProject
=
$
(
'.modal-box-project'
);
var
$modalBoxSuccess
=
$
(
'.modal-box-success'
);
var
$introducer
=
$
(
'#introducer'
);
/**
* 验证手机号
* @param tel
* @returns {boolean}
*/
function
valiTel
(
tel
)
{
var
msg
=
/^
[\d]
/g
.
test
(
tel
)
?
''
:
'电话号码有误,请再次输入!'
;
//!msg && $introducerMobile.val('');
/^
[\d]
/g
.
test
(
tel
[
tel
.
length
-
1
])?
$introducerMobile
.
val
(
tel
)
:
$introducerMobile
.
val
(
tel
.
slice
(
0
,
tel
.
length
-
1
));
console
.
log
(
tel
[
tel
.
length
-
1
]);
console
.
log
(
/^
[\d]
/g
.
test
(
tel
[
tel
.
length
-
1
]));
!
msg
&&
$errorPhone
.
html
(
msg
);
$errorPhone
.
data
(
'vali'
,
!
msg
);
disableSubmit
();
return
!
msg
;
}
/**
* 验证项目描述不能为空
* @param text
* @returns {boolean}
*/
function
valiDescription
(
text
)
{
$errorDescription
.
html
(
text
?
''
:
'项目描述不能为空!'
);
$errorDescription
.
data
(
'vali'
,
text
);
disableSubmit
();
return
!
text
;
}
/**
* 提交按钮是否可用
*/
function
disableSubmit
()
{
$errorPhone
.
data
(
'vali'
)
&&
$errorDescription
.
data
(
'vali'
)
&&
$submit
.
attr
(
'disabled'
,
false
).
css
(
'background'
,
'#ff4a4b'
);
}
$introducerMobile
.
on
({
keyup
:
function
(
e
)
{
valiTel
((
$introducerMobile
.
val
()
+
''
).
trim
());
}
});
$projectDescription
.
on
({
keyup
:
function
(
e
)
{
valiDescription
((
$projectDescription
.
val
()
+
''
).
trim
());
}
});
/*
* 不需要在再次验证
$introducer.on('submit', function (e) {
if (!valiTel(($introducerMobile.val() + '').trim())) {
$introducerMobile.focus();
$errorPhone.html('电话号码有误!');
e.preventDefault();
return;
}
if (valiDescription(($projectDescription.val() + '').trim())) {
$projectDescription.focus();
$errorDescription.html('项目描述不能为空!');
e.preventDefault();
return;
}
});
*/
/**
* 地图项目地址弹框
*/
$
(
'.hot-project-address a'
).
click
(
function
(
e
)
{
e
.
preventDefault
();
$modalBox
.
fadeIn
(
300
);
});
$
(
'#modalBoxHidden'
).
click
(
function
(
e
)
{
e
.
preventDefault
();
$modalBox
.
fadeOut
(
300
);
});
/**
* 项目提交弹框
*/
$submit
.
on
(
'click'
,
function
(
e
){
e
.
preventDefault
();
$modalBoxSuccess
.
fadeIn
(
300
);
});
$
(
'.modal-box-success a'
).
on
(
'click'
,
function
(
e
){
e
.
preventDefault
();
$modalBoxSuccess
.
fadeOut
(
300
);
});
})();
\ No newline at end of file
'use strict'
;
/**
* Created by Administrator on 2016/7/27.
*/
(
function
()
{
var
$form
=
$
(
'#container .introducer'
);
var
$introducerMobile
=
$
(
'#introducerMobile'
,
$form
);
var
$projectDescription
=
$
(
'#projectDescription'
,
$form
);
var
$errorPhone
=
$
(
'.error-phone'
,
$form
);
var
$errorDescription
=
$
(
'.error-description'
,
$form
);
var
filterMobileInput
=
function
filterMobileInput
(
$mobile
)
{
$mobile
.
val
((
$mobile
.
val
()
+
''
).
replace
(
/
[^\d]
/g
,
''
));
};
var
validateMobile
=
function
validateMobile
(
mobile
)
{
return
(
/^
[\d]{11}
$/g
.
test
(
mobile
)
);
};
var
validateRequire
=
function
validateRequire
(
value
)
{
return
value
.
length
;
};
$introducerMobile
.
on
(
'keyup'
,
function
(
e
)
{
filterMobileInput
(
$introducerMobile
);
}).
on
(
'change blur'
,
function
(
e
)
{
validateMobile
(
$
.
trim
(
$introducerMobile
.
val
()
+
''
))
?
$errorPhone
.
empty
()
:
$errorPhone
.
html
(
'手机号输入错误!'
);
});
$projectDescription
.
on
(
'change blur'
,
function
(
e
)
{
validateRequire
(
$
.
trim
(
$projectDescription
.
val
()
+
''
))
?
$errorDescription
.
empty
()
:
$errorDescription
.
html
(
'请输入项目描述内容!'
);
});
$form
.
on
(
'submit'
,
function
(
e
)
{
var
mobile
=
$
.
trim
(
$introducerMobile
.
val
()
+
''
);
var
desc
=
$
.
trim
(
$projectDescription
.
val
()
+
''
);
if
(
validateMobile
(
mobile
))
{
$errorPhone
.
empty
();
}
else
{
$errorPhone
.
html
(
'手机号输入错误!'
);
return
;
}
if
(
validateRequire
(
desc
))
{
$errorDescription
.
empty
();
}
else
{
$errorDescription
.
html
(
'请输入项目描述内容!'
);
return
;
}
request
(
''
,
{},
'POST'
).
then
(
function
(
result
)
{
console
.
log
(
result
);
});
});
})();
(
function
()
{
var
$submit
=
$
(
'#submit'
);
var
$errorPhone
=
$
(
'.error-phone'
);
var
$errorDescription
=
$
(
'.error-description'
);
var
$introducerMobile
=
$
(
'#introducerMobile'
);
var
$projectDescription
=
$
(
'#projectDescription'
);
var
$modalBoxProject
=
$
(
'.modal-box-project'
);
var
$modalBoxSuccess
=
$
(
'.modal-box-success'
);
var
$introducer
=
$
(
'#introducer'
);
/**
* 验证手机号
* @param tel
* @returns {boolean}
*/
function
valiTel
(
tel
)
{
var
msg
=
/^
[\d]
/g
.
test
(
tel
)
?
''
:
'电话号码有误,请再次输入!'
;
//!msg && $introducerMobile.val('');
/^
[\d]
/g
.
test
(
tel
[
tel
.
length
-
1
])
?
$introducerMobile
.
val
(
tel
)
:
$introducerMobile
.
val
(
tel
.
slice
(
0
,
tel
.
length
-
1
));
console
.
log
(
tel
[
tel
.
length
-
1
]);
console
.
log
(
/^
[\d]
/g
.
test
(
tel
[
tel
.
length
-
1
]));
!
msg
&&
$errorPhone
.
html
(
msg
);
$errorPhone
.
data
(
'vali'
,
!
msg
);
disableSubmit
();
return
!
msg
;
}
/**
* 验证项目描述不能为空
* @param text
* @returns {boolean}
*/
function
valiDescription
(
text
)
{
$errorDescription
.
html
(
text
?
''
:
'项目描述不能为空!'
);
$errorDescription
.
data
(
'vali'
,
text
);
disableSubmit
();
return
!
text
;
}
/**
* 提交按钮是否可用
*/
function
disableSubmit
()
{
$errorPhone
.
data
(
'vali'
)
&&
$errorDescription
.
data
(
'vali'
)
&&
$submit
.
attr
(
'disabled'
,
false
).
css
(
'background'
,
'#ff4a4b'
);
}
$introducerMobile
.
on
({
keyup
:
function
keyup
(
e
)
{
valiTel
((
$introducerMobile
.
val
()
+
''
).
trim
());
}
});
$projectDescription
.
on
({
keyup
:
function
keyup
(
e
)
{
valiDescription
((
$projectDescription
.
val
()
+
''
).
trim
());
}
});
/*
* 不需要在再次验证
$introducer.on('submit', function (e) {
if (!valiTel(($introducerMobile.val() + '').trim())) {
$introducerMobile.focus();
$errorPhone.html('电话号码有误!');
e.preventDefault();
return;
}
if (valiDescription(($projectDescription.val() + '').trim())) {
$projectDescription.focus();
$errorDescription.html('项目描述不能为空!');
e.preventDefault();
return;
}
});
*/
/**
* 地图项目地址弹框
*/
$
(
'.hot-project-address a'
).
click
(
function
(
e
)
{
e
.
preventDefault
();
$modalBox
.
fadeIn
(
300
);
});
$
(
'#modalBoxHidden'
).
click
(
function
(
e
)
{
e
.
preventDefault
();
$modalBox
.
fadeOut
(
300
);
});
/**
* 项目提交弹框
*/
$submit
.
on
(
'click'
,
function
(
e
)
{
e
.
preventDefault
();
$modalBoxSuccess
.
fadeIn
(
300
);
});
$
(
'.modal-box-success a'
).
on
(
'click'
,
function
(
e
)
{
e
.
preventDefault
();
$modalBoxSuccess
.
fadeOut
(
300
);
});
})();
//# sourceMappingURL=project.js.map
\ No newline at end of file
public/javascripts/project.js.map
0 → 100644
View file @
af987356
{"version":3,"sources":["project.jsx"],"names":[],"mappings":";;AAAA;;;AAGA,CAAC,YAAI;AACD,QAAM,QAAQ,EAAE,wBAAF,CAAd;AACA,QAAM,oBAAoB,EAAE,mBAAF,EAAuB,KAAvB,CAA1B;AACA,QAAM,sBAAsB,EAAE,qBAAF,EAAyB,KAAzB,CAA5B;AACA,QAAM,cAAc,EAAE,cAAF,EAAkB,KAAlB,CAApB;AACA,QAAM,oBAAqB,EAAE,oBAAF,EAAwB,KAAxB,CAA3B;;AAEA,QAAM,oBAAoB,SAApB,iBAAoB,CAAC,OAAD,EAAW;AACjC,gBAAQ,GAAR,CAAY,CAAC,QAAQ,GAAR,KAAc,EAAf,EAAmB,OAAnB,CAA2B,QAA3B,EAAqC,EAArC,CAAZ;AACH,KAFD;;AAIA,QAAM,iBAAiB,SAAjB,cAAiB,CAAC,MAAD,EAAU;AAC7B,eAAO,eAAc,IAAd,CAAmB,MAAnB;AAAP;AACH,KAFD;;AAIA,QAAM,kBAAkB,SAAlB,eAAkB,CAAC,KAAD,EAAS;AAC7B,eAAO,MAAM,MAAb;AACH,KAFD;;AAIA,sBAAkB,EAAlB,CAAqB,OAArB,EAA8B,UAAC,CAAD,EAAK;AAC/B,0BAAkB,iBAAlB;A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,EAA3B,EAA+B,IAA/B,EAAR;AACH;AAHgB,KAArB;AAKA,wBAAoB,EAApB,CAAuB;AACnB,eAAO,eAAU,CAAV,EAAa;AAChB,4BAAgB,CAAC,oBAAoB,GAApB,KAA4B,EAA7B,EAAiC,IAAjC,EAAhB;AACH;AAHkB,KAAvB;AAKA;;;;;;;;;;;;;;;;;;AAkBA;;;AAGA,MAAE,wBAAF,EAA4B,KAA5B,CAAkC,UAAU,CAAV,EAAa;AAC3C,UAAE,cAAF;AACA,kBAAU,MAAV,CAAiB,GAAjB;AACH,KAHD;AAIA,MAAE,iBAAF,EAAqB,KAArB,CAA2B,UAAU,CAAV,EAAa;AACpC,UAAE,cAAF;AACA,kBAAU,OAAV,CAAkB,GAAlB;AACH,KAHD;;AAKA;;;AAGA,YAAQ,EAAR,CAAW,OAAX,EAAmB,UAAS,CAAT,EAAW;AAC1B,UAAE,cAAF;AACA,yBAAiB,MAAjB,CAAwB,GAAxB;AACH,KAHD;AAIA,MAAE,sBAAF,EAA0B,EAA1B,CAA6B,OAA7B,EAAqC,UAAS,CAAT,EAAW;AAC5C,UAAE,cAAF;AACA,yBAAiB,OAAjB,CAAyB,GAAzB;AACH,KAHD;AAMH,CAtGD","file":"project.js","sourcesContent":["/**\n * Created by Administrator on 2016/7/27.\n */\n(()=>{\n const $form = $('#container .introducer');\n const $introducerMobile = $('#introducerMobile', $form);\n const $projectDescription = $('#projectDescription', $form);\n const $errorPhone = $('.error-phone', $form);\n const $errorDescription = $('.error-description', $form);\n\n const filterMobileInput = ($mobile)=>{\n $mobile.val(($mobile.val()+'').replace(/[^\\d]/g, ''));\n };\n\n const validateMobile = (mobile)=>{\n return /^[\\d]{11}$/g.test(mobile);\n };\n\n const validateRequire = (value)=>{\n return value.length;\n };\n\n $introducerMobile.on('keyup', (e)=>{\n filterMobileInput($introducerMobile);\n }).on('change blur', (e)=>{\n validateMobile($.trim($introducerMobile.val()+'')) ?\n $errorPhone.empty() :\n $errorPhone.html('手机号输入错误!');\n });\n\n $projectDescription.on('change blur', (e)=>{\n validateRequire($.trim($projectDescription.val()+'')) ?\n $errorDescription.empty() :\n $errorDescription.html('请输入项目描述内容!');\n });\n\n $form.on('submit', (e)=>{\n let mobile = $.trim($introducerMobile.val()+'');\n let desc = $.trim($projectDescription.val()+'');\n if(validateMobile(mobile)){\n $errorPhone.empty()\n }else{\n $errorPhone.html('手机号输入错误!');\n return;\n }\n if(validateRequire(desc)){\n $errorDescription.empty()\n }else {\n $errorDescription.html('请输入项目描述内容!');\n return;\n }\n request('', {}, 'POST').then((result)=>{\n console.log(result);\n });\n });\n})();\n\n(function () {\n var $submit = $('#submit');\n var $errorPhone = $('.error-phone');\n var $errorDescription = $('.error-description');\n var $introducerMobile = $('#introducerMobile');\n var $projectDescription = $('#projectDescription');\n var $modalBoxProject = $('.modal-box-project');\n var $modalBoxSuccess = $('.modal-box-success');\n var $introducer = $('#introducer');\n\n\n\n /**\n * 验证手机号\n * @param tel\n * @returns {boolean}\n */\n function valiTel(tel) {\n var msg = /^[\\d]/g.test(tel) ? '' : '电话号码有误,请再次输入!';\n //!msg && $introducerMobile.val('');\n /^[\\d]/g.test(tel[tel.length-1])? $introducerMobile.val(tel) : $introducerMobile.val(tel.slice(0,tel.length-1));\n console.log(tel[tel.length-1]);\n console.log(/^[\\d]/g.test(tel[tel.length-1]));\n !msg && $errorPhone.html(msg);\n $errorPhone.data('vali', !msg);\n disableSubmit();\n return !msg;\n }\n\n /**\n * 验证项目描述不能为空\n * @param text\n * @returns {boolean}\n */\n function valiDescription(text) {\n $errorDescription.html(text ? '' : '项目描述不能为空!');\n $errorDescription.data('vali', text);\n disableSubmit();\n return !text;\n }\n\n /**\n * 提交按钮是否可用\n */\n function disableSubmit() {\n $errorPhone.data('vali') && $errorDescription.data('vali') &&\n $submit.attr('disabled', false).css('background', '#ff4a4b');\n }\n\n $introducerMobile.on({\n keyup: function (e) {\n valiTel(($introducerMobile.val() + '').trim());\n }\n });\n $projectDescription.on({\n keyup: function (e) {\n valiDescription(($projectDescription.val() + '').trim());\n }\n });\n /*\n * 不需要在再次验证\n $introducer.on('submit', function (e) {\n if (!valiTel(($introducerMobile.val() + '').trim())) {\n $introducerMobile.focus();\n $errorPhone.html('电话号码有误!');\n e.preventDefault();\n return;\n }\n if (valiDescription(($projectDescription.val() + '').trim())) {\n $projectDescription.focus();\n $errorDescription.html('项目描述不能为空!');\n e.preventDefault();\n return;\n }\n });\n */\n\n /**\n * 地图项目地址弹框\n */\n $('.hot-project-address a').click(function (e) {\n e.preventDefault();\n $modalBox.fadeIn(300);\n });\n $('#modalBoxHidden').click(function (e) {\n e.preventDefault();\n $modalBox.fadeOut(300);\n });\n\n /**\n * 项目提交弹框\n */\n $submit.on('click',function(e){\n e.preventDefault();\n $modalBoxSuccess.fadeIn(300);\n });\n $('.modal-box-success a').on('click',function(e){\n e.preventDefault();\n $modalBoxSuccess.fadeOut(300);\n });\n\n\n})();"]}
\ No newline at end of file
public/javascripts/project.jsx
0 → 100644
View file @
af987356
/**
* Created by Administrator on 2016/7/27.
*/
(()
=>
{
const
$form
=
$
(
'#container .introducer'
);
const
$introducerMobile
=
$
(
'#introducerMobile'
,
$form
);
const
$projectDescription
=
$
(
'#projectDescription'
,
$form
);
const
$errorPhone
=
$
(
'.error-phone'
,
$form
);
const
$errorDescription
=
$
(
'.error-description'
,
$form
);
const
filterMobileInput
=
(
$mobile
)
=>
{
$mobile
.
val
((
$mobile
.
val
()
+
''
).
replace
(
/
[^\d]
/g
,
''
));
};
const
validateMobile
=
(
mobile
)
=>
{
return
/^
[\d]{11}
$/g
.
test
(
mobile
);
};
const
validateRequire
=
(
value
)
=>
{
return
value
.
length
;
};
$introducerMobile
.
on
(
'keyup'
,
(
e
)
=>
{
filterMobileInput
(
$introducerMobile
);
}).
on
(
'change blur'
,
(
e
)
=>
{
validateMobile
(
$
.
trim
(
$introducerMobile
.
val
()
+
''
))
?
$errorPhone
.
empty
()
:
$errorPhone
.
html
(
'手机号输入错误!'
);
});
$projectDescription
.
on
(
'change blur'
,
(
e
)
=>
{
validateRequire
(
$
.
trim
(
$projectDescription
.
val
()
+
''
))
?
$errorDescription
.
empty
()
:
$errorDescription
.
html
(
'请输入项目描述内容!'
);
});
$form
.
on
(
'submit'
,
(
e
)
=>
{
let
mobile
=
$
.
trim
(
$introducerMobile
.
val
()
+
''
);
let
desc
=
$
.
trim
(
$projectDescription
.
val
()
+
''
);
if
(
validateMobile
(
mobile
)){
$errorPhone
.
empty
()
}
else
{
$errorPhone
.
html
(
'手机号输入错误!'
);
return
;
}
if
(
validateRequire
(
desc
)){
$errorDescription
.
empty
()
}
else
{
$errorDescription
.
html
(
'请输入项目描述内容!'
);
return
;
}
request
(
''
,
{},
'POST'
).
then
((
result
)
=>
{
console
.
log
(
result
);
});
});
})();
(
function
()
{
var
$submit
=
$
(
'#submit'
);
var
$errorPhone
=
$
(
'.error-phone'
);
var
$errorDescription
=
$
(
'.error-description'
);
var
$introducerMobile
=
$
(
'#introducerMobile'
);
var
$projectDescription
=
$
(
'#projectDescription'
);
var
$modalBoxProject
=
$
(
'.modal-box-project'
);
var
$modalBoxSuccess
=
$
(
'.modal-box-success'
);
var
$introducer
=
$
(
'#introducer'
);
/**
* 验证手机号
* @param tel
* @returns {boolean}
*/
function
valiTel
(
tel
)
{
var
msg
=
/^
[\d]
/g
.
test
(
tel
)
?
''
:
'电话号码有误,请再次输入!'
;
//!msg && $introducerMobile.val('');
/^
[\d]
/g
.
test
(
tel
[
tel
.
length
-
1
])?
$introducerMobile
.
val
(
tel
)
:
$introducerMobile
.
val
(
tel
.
slice
(
0
,
tel
.
length
-
1
));
console
.
log
(
tel
[
tel
.
length
-
1
]);
console
.
log
(
/^
[\d]
/g
.
test
(
tel
[
tel
.
length
-
1
]));
!
msg
&&
$errorPhone
.
html
(
msg
);
$errorPhone
.
data
(
'vali'
,
!
msg
);
disableSubmit
();
return
!
msg
;
}
/**
* 验证项目描述不能为空
* @param text
* @returns {boolean}
*/
function
valiDescription
(
text
)
{
$errorDescription
.
html
(
text
?
''
:
'项目描述不能为空!'
);
$errorDescription
.
data
(
'vali'
,
text
);
disableSubmit
();
return
!
text
;
}
/**
* 提交按钮是否可用
*/
function
disableSubmit
()
{
$errorPhone
.
data
(
'vali'
)
&&
$errorDescription
.
data
(
'vali'
)
&&
$submit
.
attr
(
'disabled'
,
false
).
css
(
'background'
,
'#ff4a4b'
);
}
$introducerMobile
.
on
({
keyup
:
function
(
e
)
{
valiTel
((
$introducerMobile
.
val
()
+
''
).
trim
());
}
});
$projectDescription
.
on
({
keyup
:
function
(
e
)
{
valiDescription
((
$projectDescription
.
val
()
+
''
).
trim
());
}
});
/*
* 不需要在再次验证
$introducer.on('submit', function (e) {
if (!valiTel(($introducerMobile.val() + '').trim())) {
$introducerMobile.focus();
$errorPhone.html('电话号码有误!');
e.preventDefault();
return;
}
if (valiDescription(($projectDescription.val() + '').trim())) {
$projectDescription.focus();
$errorDescription.html('项目描述不能为空!');
e.preventDefault();
return;
}
});
*/
/**
* 地图项目地址弹框
*/
$
(
'.hot-project-address a'
).
click
(
function
(
e
)
{
e
.
preventDefault
();
$modalBox
.
fadeIn
(
300
);
});
$
(
'#modalBoxHidden'
).
click
(
function
(
e
)
{
e
.
preventDefault
();
$modalBox
.
fadeOut
(
300
);
});
/**
* 项目提交弹框
*/
$submit
.
on
(
'click'
,
function
(
e
){
e
.
preventDefault
();
$modalBoxSuccess
.
fadeIn
(
300
);
});
$
(
'.modal-box-success a'
).
on
(
'click'
,
function
(
e
){
e
.
preventDefault
();
$modalBoxSuccess
.
fadeOut
(
300
);
});
})();
\ No newline at end of file
public/javascripts/project.min.js
View file @
af987356
(
function
(){
var
$submit
=
$
(
"#submit"
);
var
$errorPhone
=
$
(
".error-phone"
);
var
$errorDescription
=
$
(
".error-description"
);
var
$introducerMobile
=
$
(
"#introducerMobile"
);
var
$projectDescription
=
$
(
"#projectDescription"
);
var
$modalBoxProject
=
$
(
".modal-box-project"
);
var
$modalBoxSuccess
=
$
(
".modal-box-success"
);
var
$introducer
=
$
(
"#introducer"
);
function
valiTel
(
tel
){
var
msg
=
/^
[\d]
/g
.
test
(
tel
)?
""
:
"电话号码有误,请再次输入!"
;
/^
[\d]
/g
.
test
(
tel
[
tel
.
length
-
1
])?
$introducerMobile
.
val
(
tel
):
$introducerMobile
.
val
(
tel
.
slice
(
0
,
tel
.
length
-
1
));
console
.
log
(
tel
[
tel
.
length
-
1
]);
console
.
log
(
/^
[\d]
/g
.
test
(
tel
[
tel
.
length
-
1
]));
!
msg
&&
$errorPhone
.
html
(
msg
);
$errorPhone
.
data
(
"vali"
,
!
msg
);
disableSubmit
();
return
!
msg
}
function
valiDescription
(
text
){
$errorDescription
.
html
(
text
?
""
:
"项目描述不能为空!"
);
$errorDescription
.
data
(
"vali"
,
text
);
disableSubmit
();
return
!
text
}
function
disableSubmit
(){
$errorPhone
.
data
(
"vali"
)
&&
$errorDescription
.
data
(
"vali"
)
&&
$submit
.
attr
(
"disabled"
,
false
).
css
(
"background"
,
"#ff4a4b"
)}
$introducerMobile
.
on
({
keyup
:
function
(
e
){
valiTel
((
$introducerMobile
.
val
()
+
""
).
trim
())}});
$projectDescription
.
on
({
keyup
:
function
(
e
){
valiDescription
((
$projectDescription
.
val
()
+
""
).
trim
())}});
$
(
".hot-project-address a"
).
click
(
function
(
e
){
e
.
preventDefault
();
$modalBox
.
fadeIn
(
300
)});
$
(
"#modalBoxHidden"
).
click
(
function
(
e
){
e
.
preventDefault
();
$modalBox
.
fadeOut
(
300
)});
$submit
.
on
(
"click"
,
function
(
e
){
e
.
preventDefault
();
$modalBoxSuccess
.
fadeIn
(
300
)});
$
(
".modal-box-success a"
).
on
(
"click"
,
function
(
e
){
e
.
preventDefault
();
$modalBoxSuccess
.
fadeOut
(
300
)})})();
\ No newline at end of file
"use strict"
;(
function
(){
var
$form
=
$
(
"#container .introducer"
);
var
$introducerMobile
=
$
(
"#introducerMobile"
,
$form
);
var
$projectDescription
=
$
(
"#projectDescription"
,
$form
);
var
$errorPhone
=
$
(
".error-phone"
,
$form
);
var
$errorDescription
=
$
(
".error-description"
,
$form
);
var
filterMobileInput
=
function
filterMobileInput
(
$mobile
){
$mobile
.
val
((
$mobile
.
val
()
+
""
).
replace
(
/
[^\d]
/g
,
""
))};
var
validateMobile
=
function
validateMobile
(
mobile
){
return
/^
[\d]{11}
$/g
.
test
(
mobile
)};
var
validateRequire
=
function
validateRequire
(
value
){
return
value
.
length
};
$introducerMobile
.
on
(
"keyup"
,
function
(
e
){
filterMobileInput
(
$introducerMobile
)}).
on
(
"change blur"
,
function
(
e
){
validateMobile
(
$
.
trim
(
$introducerMobile
.
val
()
+
""
))?
$errorPhone
.
empty
():
$errorPhone
.
html
(
"手机号输入错误!"
)});
$projectDescription
.
on
(
"change blur"
,
function
(
e
){
validateRequire
(
$
.
trim
(
$projectDescription
.
val
()
+
""
))?
$errorDescription
.
empty
():
$errorDescription
.
html
(
"请输入项目描述内容!"
)});
$form
.
on
(
"submit"
,
function
(
e
){
var
mobile
=
$
.
trim
(
$introducerMobile
.
val
()
+
""
);
var
desc
=
$
.
trim
(
$projectDescription
.
val
()
+
""
);
if
(
validateMobile
(
mobile
)){
$errorPhone
.
empty
()}
else
{
$errorPhone
.
html
(
"手机号输入错误!"
);
return
}
if
(
validateRequire
(
desc
)){
$errorDescription
.
empty
()}
else
{
$errorDescription
.
html
(
"请输入项目描述内容!"
);
return
}
request
(
""
,{},
"POST"
).
then
(
function
(
result
){
console
.
log
(
result
)})})})();(
function
(){
var
$submit
=
$
(
"#submit"
);
var
$errorPhone
=
$
(
".error-phone"
);
var
$errorDescription
=
$
(
".error-description"
);
var
$introducerMobile
=
$
(
"#introducerMobile"
);
var
$projectDescription
=
$
(
"#projectDescription"
);
var
$modalBoxProject
=
$
(
".modal-box-project"
);
var
$modalBoxSuccess
=
$
(
".modal-box-success"
);
var
$introducer
=
$
(
"#introducer"
);
function
valiTel
(
tel
){
var
msg
=
/^
[\d]
/g
.
test
(
tel
)?
""
:
"电话号码有误,请再次输入!"
;
/^
[\d]
/g
.
test
(
tel
[
tel
.
length
-
1
])?
$introducerMobile
.
val
(
tel
):
$introducerMobile
.
val
(
tel
.
slice
(
0
,
tel
.
length
-
1
));
console
.
log
(
tel
[
tel
.
length
-
1
]);
console
.
log
(
/^
[\d]
/g
.
test
(
tel
[
tel
.
length
-
1
]));
!
msg
&&
$errorPhone
.
html
(
msg
);
$errorPhone
.
data
(
"vali"
,
!
msg
);
disableSubmit
();
return
!
msg
}
function
valiDescription
(
text
){
$errorDescription
.
html
(
text
?
""
:
"项目描述不能为空!"
);
$errorDescription
.
data
(
"vali"
,
text
);
disableSubmit
();
return
!
text
}
function
disableSubmit
(){
$errorPhone
.
data
(
"vali"
)
&&
$errorDescription
.
data
(
"vali"
)
&&
$submit
.
attr
(
"disabled"
,
false
).
css
(
"background"
,
"#ff4a4b"
)}
$introducerMobile
.
on
({
keyup
:
function
keyup
(
e
){
valiTel
((
$introducerMobile
.
val
()
+
""
).
trim
())}});
$projectDescription
.
on
({
keyup
:
function
keyup
(
e
){
valiDescription
((
$projectDescription
.
val
()
+
""
).
trim
())}});
$
(
".hot-project-address a"
).
click
(
function
(
e
){
e
.
preventDefault
();
$modalBox
.
fadeIn
(
300
)});
$
(
"#modalBoxHidden"
).
click
(
function
(
e
){
e
.
preventDefault
();
$modalBox
.
fadeOut
(
300
)});
$submit
.
on
(
"click"
,
function
(
e
){
e
.
preventDefault
();
$modalBoxSuccess
.
fadeIn
(
300
)});
$
(
".modal-box-success a"
).
on
(
"click"
,
function
(
e
){
e
.
preventDefault
();
$modalBoxSuccess
.
fadeOut
(
300
)})})();
\ No newline at end of file
routes/index.js
View file @
af987356
...
...
@@ -88,7 +88,7 @@ router.get('/about', function (req, res) {
router
.
get
(
'/project'
,
function
(
req
,
res
)
{
res
.
render
(
'project'
,
{
styles
:
[
'project'
],
scripts
:[
'project'
],
scripts
:[
'
utils'
,
'
project'
],
});
});
...
...
views/project.hbs
View file @
af987356
...
...
@@ -30,13 +30,13 @@
<h2>
寻找优质项目介绍人
</h2>
<div
class=
"clear"
>
<label
for=
"introducerMobile"
>
联系方式:
</label>
<input
type=
"text"
id=
"introducerMobile"
name=
"introducer-mobile"
placeholder=
"填写您的联系方式"
<input
type=
"text"
id=
"introducerMobile"
placeholder=
"填写您的联系方式"
maxlength=
"11"
/>
<p
class=
"error-phone"
></p>
</div>
<div
class=
"clear"
>
<label>
项目描述:
</label>
<textarea
name=
"project-description"
id=
"projectDescription"
<textarea
id=
"projectDescription"
placeholder=
"详细写明您的项目需求 例如:项目时间、内容、合作意向。"
></textarea>
<p
class=
"error-description"
></p>
</div>
...
...
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