作者 刘朕

登录选择年龄修改

@@ -121,8 +121,16 @@ class LoginController extends HomeBaseController @@ -121,8 +121,16 @@ class LoginController extends HomeBaseController
121 $where = [ 121 $where = [
122 'delete_time' => 0 122 'delete_time' => 0
123 ]; 123 ];
  124 + $list = [];
124 $babyList = $baby_model->where($where)->select(); 125 $babyList = $baby_model->where($where)->select();
125 - $this->assign('babyList',$babyList); 126 + foreach ($babyList as $kg=>$vg) {
  127 + $info = [
  128 + 'label' => $vg['age'],
  129 + 'value' => $vg['id']
  130 + ];
  131 + $list[] = $info;
  132 + }
  133 + $this->assign('babyList',json_encode($list));
126 return $this->fetch(':choose'); 134 return $this->fetch(':choose');
127 } else { 135 } else {
128 return redirect($this->request->root() . '/'); 136 return redirect($this->request->root() . '/');
@@ -10,6 +10,12 @@ @@ -10,6 +10,12 @@
10 <link rel="stylesheet" type="text/css" href="__TMPL__/public/mobile/css/augly.css" /> 10 <link rel="stylesheet" type="text/css" href="__TMPL__/public/mobile/css/augly.css" />
11 <title>选择年龄</title> 11 <title>选择年龄</title>
12 <style type="text/css"> 12 <style type="text/css">
  13 + .container {
  14 + height: 100%;
  15 + }
  16 + .input_num {
  17 + position: relative;
  18 + }
13 .input_num p { 19 .input_num p {
14 font-size: 0.3rem; 20 font-size: 0.3rem;
15 margin-left: 0.4rem; 21 margin-left: 0.4rem;
@@ -49,11 +55,13 @@ @@ -49,11 +55,13 @@
49 </div> 55 </div>
50 <div class="input_num"> 56 <div class="input_num">
51 <p>宝宝年龄</p> 57 <p>宝宝年龄</p>
52 - <select name="baby_age" class="input_text">  
53 - <volist name="babyList" id="vo">  
54 - <option value="{$vo.id}">{$vo.age}</option>  
55 - </volist>  
56 - </select> 58 + <input type="text" name="baby_age" id="age" value="" class="input_text" placeholder="请选择宝宝年龄" />
  59 + <img src="__TMPL__/public/mobile/images/youjiantou.png" class="jiantou" />
  60 + <!--<select name="baby_age" class="input_text">-->
  61 + <!--<volist name="babyList" id="vo">-->
  62 + <!--<option value="{$vo.id}">{$vo.age}</option>-->
  63 + <!--</volist>-->
  64 + <!--</select>-->
57 <!--<input type="text" name="" id="age" value="" class="input_text" placeholder="7~35月龄" />--> 65 <!--<input type="text" name="" id="age" value="" class="input_text" placeholder="7~35月龄" />-->
58 <!--<img src="__TMPL__/public/mobile/images/youjiantou.png" class="jiantou" />--> 66 <!--<img src="__TMPL__/public/mobile/images/youjiantou.png" class="jiantou" />-->
59 </div> 67 </div>
@@ -87,9 +95,29 @@ @@ -87,9 +95,29 @@
87 // id: 'datePicker' 95 // id: 'datePicker'
88 // }); 96 // });
89 // }) 97 // })
  98 +
  99 + var age_id = '';
  100 + $('#age').click(function() {
  101 + var babyList = JSON.parse(`{$babyList}`);
  102 + weui.picker(babyList, {
  103 + onChange: function(result) {
  104 + console.log(result);
  105 + },
  106 + onConfirm: function(result) {
  107 + $('#age').val(result[0].label);
  108 + age_id = result[0].value;
  109 + console.log(result);
  110 + },
  111 + id: 'multiPickerBtn'
  112 + });
  113 + });
90 $('.btn').click(function(){ 114 $('.btn').click(function(){
  115 + if($('#age').val() == '') {
  116 + _error('请选择宝宝年龄');
  117 + return false;
  118 + }
91 var data = { 119 var data = {
92 - id: $('select[name=baby_age]').val() 120 + id: age_id
93 }; 121 };
94 $.ajax({ 122 $.ajax({
95 url: "{:url('user/Login/chooseSubmit')}", 123 url: "{:url('user/Login/chooseSubmit')}",
@@ -107,6 +135,7 @@ @@ -107,6 +135,7 @@
107 }); 135 });
108 136
109 // 弹窗提示 137 // 弹窗提示
  138 + var popup_switch = true;
110 function _error(test) { 139 function _error(test) {
111 if(popup_switch) { 140 if(popup_switch) {
112 popup_switch = false; 141 popup_switch = false;