123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216 |
- var $body = $('.yjk-body');
- var d = dialog({contentType:'load', skin:'bk-popup'});
- var userAgent = JSON.parse(window.localStorage.getItem(agentName));
- var cache = window.localStorage.getItem("oneStep"+userAgent.uid);
- var Request = GetRequest();
- var going = Request["isContinue"];
- //定义弹窗
- function toast(msg){
- dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:msg}).show()
- }
- //请求失败
- function queryFailed(){
- d.close()
- toast('请求失败')
- }
- $(function(){
- //先判断是否有缓存
- if(cache && going){
- var cacheObj = JSON.parse(cache)
- var html = template('msg_tmp',{data:cacheObj,submitBtn:1})
- $body.html(html)
- baseInfoInit()
- }else if(cache){
- dialog({
- content: '<div><div class="c-f16 c-333 c-t-left mb10">检测到有未提交信息,是否继续填写?</div></div>',
- okValue: '继续',
- cancelValue: '清空',
- cancel: function () {
- window.localStorage.removeItem("oneStep"+userAgent.uid)
- queryBaseInfo()
- },
- ok: function() {
- var cacheObj = JSON.parse(cache)
- var html = template('msg_tmp',{data:cacheObj,submitBtn:0})
- $body.html(html)
- baseInfoInit()
- }
- }).showModal()
- }else{
- queryBaseInfo()
- }
- //请求用户数据
- function queryBaseInfo(){
- d.show()
- sendPost('patient/baseinfo',{},'json','post', queryFailed,function(res){
- d.close()
- if(res.status == 200){
- var html = template('msg_tmp',{data:res.data,submitBtn:0})
- $body.html(html)
- baseInfoInit()
- }else{
- toast('获取信息失败')
- }
- })
- }
- })
- //初始化
- function baseInfoInit() {
- var opt = {
- preset: 'date',
- theme: 'ios',
- lang: 'zh',
- minDate: new Date(1900, 01, 01)
- };
- var marital = {
- theme: 'ios',
- lang:'zh',
- customWheels:true,
- wheels: [
- [
- {
- keys: ['20','10'],
- values: ['已婚', '未婚']
- }
- ]
- ],
- onSelect: function(valueText, inst){
- var dd = eval("[" + valueText + "]");
- $('#marital').val(dd[0].values);
- $('#marital').attr('data-id',dd[0].keys);
- }
- }
- $('#birthday').mobiscroll(opt);
- $('#lastMenstruation').mobiscroll(opt);
- $('#marital').mobiscroll(marital);
- //选择居委会
- selectCommittee()
- //选择户籍
- initExpressAddr($('#idAddress'))
- //提交事件
- $('.j-btn').click(function(){
- var $this = $(this)
- commit($this)
- })
- }
- /*判断输入是否为合法的医社保卡号*/
- function isSsc(inputString){
- var partten = /^([a-zA-Z]{1}[a-zA-Z0-9]{8}|[0-9]{12})$/;
- if(partten.test(inputString)){
- return true;
- }else{
- return false;
- }
- }
- /*判断输入是否为合法的手机号码*/
- function isphone(inputString){
- var partten = /^[1][3578][0-9]{9}$/;
- if(partten.test(inputString)){
- return true;
- }else{
- return false;
- }
- }
- /*判断输入是否为合法的身份证*/
- function isID(inputString){
- var idCardReg = /^(^[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(inputString.length == 15) {
- idCardReg = /^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$/;
- }
- if(idCardReg.test(inputString)){
- return true;
- }else{
- return false;
- }
- }
- //验证信息
- function validate(data) {
- if (!data.name) {
- toast('请输入姓名')
- return false;
- }
- if (!isSsc(data.ssc)) {
- toast('医保卡号不正确')
- return false;
- }
- if (!isID(data.idcardAll)) {
- toast('身份证不正确')
- return false;
- }
- if (!data.birthday) {
- toast('请选择出生日期')
- return false;
- }
- if (!isphone(data.mobile)) {
- toast('手机号码不正确')
- return false;
- }
- if (!data.lastMenstruation) {
- toast('请选择末次月经')
- return false;
- }
- if (!data.marital) {
- toast('请选择婚姻状况')
- return false;
- }
- if (!data.allergy) {
- toast('请输入过敏史')
- return false;
- }
-
- if (!data.permanentProvinceCode) {
- toast('请选择户籍地址')
- return false;
- }
- if (!data.countryCode) {
- toast('请选择所属居委会')
- return false;
- }
- if (!data.address) {
- toast('请输入现居住地址')
- return false;
- }
- return true;
- }
- // 提交第一步
- function commit($this) {
- var params = {}
- params.name = $("#name").val().trim(); //姓名
- params.ssc = $("#medicalCard").val().trim(); //医保卡号
- params.idcardAll = $("#idCard").val().trim(); //身份证
- params.birthday = $("#birthday").val(); //出生日期
- params.mobile = $("#mobile").val().trim(); //手机号码
- params.lastMenstruation = $("#lastMenstruation").val();//末次月经
- params.marital = $("#marital").attr('data-id')//婚姻状况
- params.maritalName = $("#marital").val()
- params.allergy = $("#allergy").val().trim(); //过敏史
- params.address = $("#address").val().trim(); //现居住址
- params.countryCode = $("#committee").attr('data-code');//居委会
- params.countryName = $("#committee").val();
- params.permanentProvince = $("#idAddress").attr('data-provinceName') //户籍
- params.permanentCity = $("#idAddress").attr('data-cityName')
- params.permanentProvinceCode = $("#idAddress").attr('data-province')
- params.permanentCityCode = $("#idAddress").attr('data-city')
- params.allergy = $("#allergy").val().trim();
-
-
- if(validate(params)){
- window.localStorage.setItem("oneStep"+userAgent.uid,JSON.stringify(params))
- if($this.text()=='直接提交'){
- window.location.href = "yjk-preview.html"
- }else{
- if($("#marital").attr('data-id') == 20){
- window.location.href = 'yjk-step2.html';
- }else{
- window.location.href = 'yjk-step3.html';
- }
- }
- }
- }
|