Authored by lore-w

订单确认优化

@@ -14,16 +14,16 @@ @@ -14,16 +14,16 @@
14 <h2 class="title">请填写并核对以下信息</h2> 14 <h2 class="title">请填写并核对以下信息</h2>
15 <div class="order-content"> 15 <div class="order-content">
16 <div class="order-selection address-list"> 16 <div class="order-selection address-list">
17 - <h2>收货地址:<span>[不保存并关闭]</span></h2> 17 + <h2>收货地址:<span>[修改]</span></h2>
18 <div class="address-list-inner"> 18 <div class="address-list-inner">
19 <ul class="exist-address-list"> 19 <ul class="exist-address-list">
20 {{#each hasAddress}} 20 {{#each hasAddress}}
21 - <li class="active has-exist-address"> 21 + <li class="has-exist-address">
22 <input class="radio" type="radio" name="exist-address" id="{{id}}" {{#if checked}}checked{{/if}}/> 22 <input class="radio" type="radio" name="exist-address" id="{{id}}" {{#if checked}}checked{{/if}}/>
23 <label for="{{id}}"> 23 <label for="{{id}}">
24 <strong>{{user}}</strong> 24 <strong>{{user}}</strong>
25 <span>{{address}}</span> 25 <span>{{address}}</span>
26 - <a href="javascript:void(0);">设为默认地址</a> 26 + <b class="default-address">设为默认地址</b>
27 <div class="order-modify-btn"> 27 <div class="order-modify-btn">
28 <span class="address-modify">[修改]</span> 28 <span class="address-modify">[修改]</span>
29 <span class="address-del">[删除]</span> 29 <span class="address-del">[删除]</span>
@@ -12,7 +12,7 @@ var $addressManage = $('.address-manage'), @@ -12,7 +12,7 @@ var $addressManage = $('.address-manage'),
12 $city = $addressManage.find('.text-input[name="city"]'), 12 $city = $addressManage.find('.text-input[name="city"]'),
13 $county = $addressManage.find('.text-input[name="county"]'), 13 $county = $addressManage.find('.text-input[name="county"]'),
14 $selectList = $addressManage.find('.text-input[name="province"], .text-input[name="city"]'), 14 $selectList = $addressManage.find('.text-input[name="province"], .text-input[name="city"]'),
15 - $btn = $('.order-modify-btn'), 15 + $addressList = $('.address-list'),
16 $name = $addressManage.find('.text-input[name="name"]'), 16 $name = $addressManage.find('.text-input[name="name"]'),
17 $phone = $addressManage.find('.text-input[name="phone"]'), 17 $phone = $addressManage.find('.text-input[name="phone"]'),
18 $telCode = $addressManage.find('.text-input[name="code-tel"]'), 18 $telCode = $addressManage.find('.text-input[name="code-tel"]'),
@@ -108,9 +108,9 @@ function getUserInfo(id) { @@ -108,9 +108,9 @@ function getUserInfo(id) {
108 108
109 for (key in data) { 109 for (key in data) {
110 110
111 - if (data.hasOwnProperty[key]) { 111 + if (data.hasOwnProperty(key)) {
112 if (!!data[key]) { 112 if (!!data[key]) {
113 - window('$' + key).val(data[key]); 113 + eval('$' + key).val(data[key]);
114 } 114 }
115 } 115 }
116 } 116 }
@@ -182,15 +182,13 @@ exports.newAddress = function(id) { @@ -182,15 +182,13 @@ exports.newAddress = function(id) {
182 //修改地址 182 //修改地址
183 exports.modifyAddress = function() { 183 exports.modifyAddress = function() {
184 184
185 - $btn.click(function(event) {  
186 - 185 + $addressList.click(function(event) {
187 var $this = $(event.target), 186 var $this = $(event.target),
188 id = $this.closest('li').find('.radio').attr('id'); 187 id = $this.closest('li').find('.radio').attr('id');
189 188
190 if ($this.hasClass('address-modify')) { 189 if ($this.hasClass('address-modify')) {
191 - 190 + $addressManage.removeClass('hide');
192 exports.newAddress(id); 191 exports.newAddress(id);
193 -  
194 } else if ($this.hasClass('address-del')) { 192 } else if ($this.hasClass('address-del')) {
195 193
196 $.ajax({ 194 $.ajax({
@@ -208,6 +206,24 @@ exports.modifyAddress = function() { @@ -208,6 +206,24 @@ exports.modifyAddress = function() {
208 206
209 //todo 207 //todo
210 }); 208 });
  209 + } else if ($this.hasClass('default-address')) {
  210 +
  211 + // 设为默认地址
  212 + $.ajax({
  213 + type: 'post',
  214 + url: '/order/save/defaultAddress',
  215 + data: {
  216 + id: id
  217 + }
  218 + }).then(function(data) {
  219 +
  220 + if (!!data.status) {
  221 + $this.remove();
  222 + }
  223 + }).fail(function() {
  224 +
  225 + //todo
  226 + });
211 } 227 }
212 }); 228 });
213 }; 229 };
@@ -35,6 +35,7 @@ var Order = { @@ -35,6 +35,7 @@ var Order = {
35 $spanPayTypeLegend: $('span.pay-type-legend'), 35 $spanPayTypeLegend: $('span.pay-type-legend'),
36 $supportType: $('.support-type'), 36 $supportType: $('.support-type'),
37 $existAddressList: $('.exist-address-list').find('li'), 37 $existAddressList: $('.exist-address-list').find('li'),
  38 + $existAddress: $('.exist-address-list').find('input[name="exist-address"]'),
38 $payTimeModify: $('.pay-time-modify'), 39 $payTimeModify: $('.pay-time-modify'),
39 $switchPayModify: $('.switch-pay-modify') 40 $switchPayModify: $('.switch-pay-modify')
40 }, 41 },
@@ -118,26 +119,27 @@ var Order = { @@ -118,26 +119,27 @@ var Order = {
118 if (!$(this).data('expand')) { 119 if (!$(this).data('expand')) {
119 $('.address-list-inner').addClass('hide'); 120 $('.address-list-inner').addClass('hide');
120 121
121 - $(this).data('expand', 'expand').text('[修改]'); 122 + $(this).data('expand', 'expand').text('[不保存并关闭]');
122 123
123 } else { 124 } else {
124 $('.address-list-inner').removeClass('hide'); 125 $('.address-list-inner').removeClass('hide');
125 126
126 - $(this).removeData('expand').text('[不保存并关闭]'); 127 + $(this).removeData('expand').text('[修改]');
127 } 128 }
128 129
129 }); 130 });
130 131
131 - //展开新地址填写表单  
132 - e.$addAddress.click(function() {  
133 132
134 - if (e.$addressManage.hasClass('hide')) { 133 + //支付及送货时间
  134 + e.$switchPayModify.click(function() {
135 135
136 - e.$addressManage.removeClass('hide'); 136 + if (e.$payTimeModify.hasClass('hide')) {
  137 + e.$payTimeModify.removeClass('hide');
  138 + $(this).text('[不保存并关闭]');
137 } else { 139 } else {
138 - return; 140 + e.$payTimeModify.addClass('hide');
  141 + $(this).text('[修改]');
139 } 142 }
140 -  
141 }); 143 });
142 144
143 e.$spanPayTypeLegend.click(function() { 145 e.$spanPayTypeLegend.click(function() {
@@ -146,20 +148,17 @@ var Order = { @@ -146,20 +148,17 @@ var Order = {
146 e.$supportType.toggleClass('hide'); 148 e.$supportType.toggleClass('hide');
147 }); 149 });
148 150
149 - e.$existAddressList.click(function(event) { 151 + $(document).on('click', '.exist-address-list li', function() {
  152 +
150 e.$existAddressList.removeClass('active'); 153 e.$existAddressList.removeClass('active');
151 $(this).addClass('active'); 154 $(this).addClass('active');
152 155
  156 + e.$existAddress.removeAttr('checked');
  157 + $(this).find('input[name="exist-address"]').attr('checked', 'checked');
  158 +
153 if ($(this).hasClass('use-new-address')) { 159 if ($(this).hasClass('use-new-address')) {
154 - e.$addAddress.attr('checked', true);// 必须在trigger前  
155 - e.$addAddress.trigger('click'); 160 + e.$addressManage.removeClass('hide');
156 } 161 }
157 -  
158 - event.stopPropagation();  
159 - });  
160 -  
161 - e.$switchPayModify.click(function() {  
162 - e.$payTimeModify.toggleClass('hide');  
163 }); 162 });
164 }, 163 },
165 164
@@ -118,11 +118,20 @@ @@ -118,11 +118,20 @@
118 display: inline-block; 118 display: inline-block;
119 float: right; 119 float: right;
120 color: #e8044f; 120 color: #e8044f;
  121 + width: 80px;
  122 + padding-right: 20px;
  123 + height: auto;
  124 + overflow: hidden;
121 125
122 span { 126 span {
123 text-decoration: underline; 127 text-decoration: underline;
124 - margin: 0 10px;  
125 cursor: pointer; 128 cursor: pointer;
  129 +
  130 + float: right;
  131 +
  132 + &.address-modify {
  133 + float: left;
  134 + }
126 } 135 }
127 } 136 }
128 137
@@ -130,6 +139,7 @@ @@ -130,6 +139,7 @@
130 139
131 li { 140 li {
132 border: 1px solid #fff; 141 border: 1px solid #fff;
  142 + padding-left: 15px;
133 143
134 &.active { 144 &.active {
135 background: #dbedf7; 145 background: #dbedf7;
@@ -137,9 +147,10 @@ @@ -137,9 +147,10 @@
137 } 147 }
138 148
139 &.has-exist-address { 149 &.has-exist-address {
140 - a { 150 + .default-address {
141 color: #468fa2; 151 color: #468fa2;
142 text-decoration: underline; 152 text-decoration: underline;
  153 + cursor: pointer;
143 } 154 }
144 } 155 }
145 } 156 }
@@ -102,7 +102,7 @@ class SaveController extends AbstractAction @@ -102,7 +102,7 @@ class SaveController extends AbstractAction
102 array( 102 array(
103 'name' => '111省', 103 'name' => '111省',
104 'value' => 11, 104 'value' => 11,
105 - 'checked' => false 105 + 'checked' => true
106 ), 106 ),
107 array( 107 array(
108 'name' => '222省', 108 'name' => '222省',
@@ -128,7 +128,7 @@ class SaveController extends AbstractAction @@ -128,7 +128,7 @@ class SaveController extends AbstractAction
128 array( 128 array(
129 'name' => '222市', 129 'name' => '222市',
130 'value' => 22, 130 'value' => 22,
131 - 'checked' => false 131 + 'checked' => true
132 ), 132 ),
133 array( 133 array(
134 'name' => '333市', 134 'name' => '333市',
@@ -154,7 +154,7 @@ class SaveController extends AbstractAction @@ -154,7 +154,7 @@ class SaveController extends AbstractAction
154 array( 154 array(
155 'name' => '333县', 155 'name' => '333县',
156 'value' => 33, 156 'value' => 33,
157 - 'checked' => false 157 + 'checked' => true
158 ) 158 )
159 ); 159 );
160 160
@@ -196,4 +196,14 @@ class SaveController extends AbstractAction @@ -196,4 +196,14 @@ class SaveController extends AbstractAction
196 196
197 $this->echoJson($data); 197 $this->echoJson($data);
198 } 198 }
  199 +
  200 + //设为默认地址
  201 + public function defaultAddressAction()
  202 + {
  203 + $data = array(
  204 + 'status' => true
  205 + );
  206 +
  207 + $this->echoJson($data);
  208 + }
199 } 209 }