1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- 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("twoStep"+userAgent.uid);
- var Request = GetRequest();
- var going = Request["isContinue"];
- //定义弹窗
- function toast(msg){
- dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:msg}).show()
- }
- $(function(){
- //先判断是否有缓存
- if(cache && going){
- var cacheObj = JSON.parse(cache)
- showPage(cacheObj)
- }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("twoStep"+userAgent.uid)
- showPage({})
- },
- ok: function() {
- var cacheObj = JSON.parse(cache)
- showPage(cacheObj)
- }
- }).showModal()
- }else{
- showPage({})
- }
- //显示页面
- function showPage(data){
- var html = template('msg_tmp',{data:data})
- $body.html(html)
- baseInfoInit()
- }
- })
- //初始化
- function baseInfoInit() {
- var opt = {
- preset: 'date',
- theme: 'ios',
- lang: 'zh',
- minDate: new Date(1900, 01, 01)
- }
- $('#weddingDate').mobiscroll(opt);
- $('#spouseBirthday').mobiscroll(opt);
- //点击
- $('#page2_next').bind('tap',function(){
- commit(function(){
- window.location.href = "yjk-step3.html"
- })
- })
- $('#page2_submit').bind('tap',function(){
- commit(function(){
- window.location.href = "yjk-preview.html"
- })
- })
- }
- //保存数据到缓存
- function commit(fun){
- var params={}
- params.weddingDate = $("#weddingDate").val();
- params.spouseName = $("#spouseName").val();
- params.spouseBirthday = $("#spouseBirthday").val();
- params.spouseMobile = $("#spouseMobile").val();
- if(validate(params)){
- window.localStorage.setItem("twoStep"+userAgent.uid,JSON.stringify(params))
- fun&&fun.call(this)
- }
- }
- /*判断输入是否为合法的手机号码*/
- function isphone(inputString){
- var partten = /^[1][3578][0-9]{9}$/;
- if(partten.test(inputString)){
- return true;
- }else{
- return false;
- }
- }
- //验证信息
- function validate(data) {
- if(data.spouseMobile){
- if (!isphone(data.spouseMobile)) {
- toast('手机号码格式不对')
- return false;
- }
- }
- return true;
- }
|