yjk-step3.js 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. var $body = $('.yjk-body');
  2. var d = dialog({contentType:'load', skin:'bk-popup'});
  3. var userAgent = JSON.parse(window.localStorage.getItem(agentName));
  4. var cache = window.localStorage.getItem("threeStep"+userAgent.uid);
  5. var Request = GetRequest();
  6. var going = Request["isContinue"];
  7. $(function(){
  8. //先判断是否有缓存
  9. if(cache && going){
  10. var cacheObj = JSON.parse(cache)
  11. showPage(cacheObj)
  12. }else if(cache){
  13. dialog({
  14. content: '<div><div class="c-f16 c-333 c-t-left mb10">检测到有未提交信息,是否继续填写?</div></div>',
  15. okValue: '继续',
  16. cancelValue: '清空',
  17. cancel: function () {
  18. window.localStorage.removeItem("threeStep"+userAgent.uid)
  19. showPage({})
  20. },
  21. ok: function() {
  22. var cacheObj = JSON.parse(cache)
  23. showPage(cacheObj)
  24. }
  25. }).showModal()
  26. }else{
  27. showPage({})
  28. }
  29. //显示页面
  30. function showPage(data){
  31. var html = template('msg_tmp',{data:data})
  32. $body.html(html)
  33. baseInfoInit()
  34. }
  35. })
  36. //初始化
  37. function baseInfoInit() {
  38. var opt = {
  39. theme: 'ios',
  40. lang:'zh',
  41. customWheels:true,
  42. wheels: [
  43. [
  44. {
  45. keys: ['1', '0'],
  46. values: ['是', '否']
  47. }
  48. ]
  49. ],
  50. onSelect: function(valueText, inst){
  51. var dd = eval("[" + valueText + "]");
  52. $(this).val(dd[0].values);
  53. $(this).attr('data-key',dd[0].keys);
  54. }
  55. }
  56. $('#folicacid').mobiscroll(opt);
  57. $('#contrapills').mobiscroll(opt);
  58. $('#smoke').mobiscroll(opt);
  59. $('#drink').mobiscroll(opt);
  60. //点击
  61. $('#page3_next').on('tap',function(){
  62. commit(function(){
  63. window.location.href = "yjk-step4.html"
  64. })
  65. })
  66. $('#page3_submit').on('tap',function(){
  67. commit(function(){
  68. window.location.href = "yjk-preview.html"
  69. })
  70. })
  71. }
  72. //保存数据到缓存
  73. function commit(fun){
  74. var params={}
  75. params.folicacid = $("#folicacid").val();
  76. params.folicacidCode = $("#folicacid").attr('data-key');
  77. params.contrapills = $("#contrapills").val();
  78. params.contrapillsCode = $("#contrapills").attr('data-key');
  79. params.smoke = $("#smoke").val();
  80. params.smokeCode = $("#smoke").attr('data-key');
  81. params.drink = $("#drink").val();
  82. params.drinkCode = $("#drink").attr('data-key');
  83. params.otherPills = $('#otherPills').val().trim()
  84. window.localStorage.setItem("threeStep"+userAgent.uid,JSON.stringify(params))
  85. fun&&fun.call(this)
  86. }