Showing
6 changed files
with
51 additions
and
42 deletions
@@ -7,11 +7,11 @@ | @@ -7,11 +7,11 @@ | ||
7 | <li> | 7 | <li> |
8 | <a data-key="{{key}}" href="{{brandDomain}}" target="_blank"> | 8 | <a data-key="{{key}}" href="{{brandDomain}}" target="_blank"> |
9 | <img class="lazy" data-original="{{image brandIco 270 190}}"> | 9 | <img class="lazy" data-original="{{image brandIco 270 190}}"> |
10 | - <span>{{#if brandNameEn}}{{brandNameEn}}{{else}}{{brandName}}{{/if}}</span> | 10 | + <span>{{#if brandName}}{{brandName}}{{else}}{{brandNameEn}}{{/if}}</span> |
11 | </a> | 11 | </a> |
12 | </li> | 12 | </li> |
13 | {{/each}} | 13 | {{/each}} |
14 | </ul> | 14 | </ul> |
15 | </dd> | 15 | </dd> |
16 | </dl> | 16 | </dl> |
17 | -{{/each}} | ||
17 | +{{/each}} |
@@ -6,6 +6,8 @@ | @@ -6,6 +6,8 @@ | ||
6 | 'use strict'; | 6 | 'use strict'; |
7 | const mcHandler = require('../models/menu-crumb-handler'); | 7 | const mcHandler = require('../models/menu-crumb-handler'); |
8 | const addressModel = require('../models/address'); | 8 | const addressModel = require('../models/address'); |
9 | +const crypto = global.yoho.crypto; | ||
10 | +const config = global.yoho.config; | ||
9 | 11 | ||
10 | const _ = require('lodash'); | 12 | const _ = require('lodash'); |
11 | 13 | ||
@@ -31,6 +33,7 @@ const index = (req, res, next) => { | @@ -31,6 +33,7 @@ const index = (req, res, next) => { | ||
31 | for (let i = 0; i < length; i++) { | 33 | for (let i = 0; i < length; i++) { |
32 | resultData[i].default = resultData[i].is_default === 'Y'; | 34 | resultData[i].default = resultData[i].is_default === 'Y'; |
33 | resultData[i].mobile = resultData[i].mobile.replace(reg, '$1****$2'); | 35 | resultData[i].mobile = resultData[i].mobile.replace(reg, '$1****$2'); |
36 | + resultData[i].id = crypto.encryption(config.crypto.common, resultData[i].address_id + ''); | ||
34 | } | 37 | } |
35 | resultData.leftLength = 7 - length; | 38 | resultData.leftLength = 7 - length; |
36 | resultData.length = length; | 39 | resultData.length = length; |
@@ -56,6 +59,10 @@ const getAddressList = (req, res, next) => { | @@ -56,6 +59,10 @@ const getAddressList = (req, res, next) => { | ||
56 | if (result.data) { | 59 | if (result.data) { |
57 | let defaultAd = _.find(result.data, o => o.is_default === 'Y'); | 60 | let defaultAd = _.find(result.data, o => o.is_default === 'Y'); |
58 | 61 | ||
62 | + _.each(result.data, (d) => { | ||
63 | + d.address_id = crypto.encryption(config.crypto.common, d.address_id + ''); | ||
64 | + }); | ||
65 | + | ||
59 | defaultAd && (defaultAd.focus = true); | 66 | defaultAd && (defaultAd.focus = true); |
60 | } | 67 | } |
61 | res.send(result); | 68 | res.send(result); |
@@ -76,6 +83,10 @@ const addAddressData = (req, res, next) => { | @@ -76,6 +83,10 @@ const addAddressData = (req, res, next) => { | ||
76 | let isInit = req.body.init && req.body.init === 'true'; // 是否是初始地址 | 83 | let isInit = req.body.init && req.body.init === 'true'; // 是否是初始地址 |
77 | 84 | ||
78 | addressModel.addAddressData(uid, address, areaCode, consignee, mobile, phone, isInit).then(result => { | 85 | addressModel.addAddressData(uid, address, areaCode, consignee, mobile, phone, isInit).then(result => { |
86 | + if (result.data && result.data.address_id) { | ||
87 | + result.data.aid = crypto.encryption(config.crypto.common, result.data.address_id + ''); | ||
88 | + } | ||
89 | + | ||
79 | res.send(result); | 90 | res.send(result); |
80 | }).catch(next); | 91 | }).catch(next); |
81 | }; | 92 | }; |
@@ -84,7 +95,7 @@ const addAddressData = (req, res, next) => { | @@ -84,7 +95,7 @@ const addAddressData = (req, res, next) => { | ||
84 | * 修改地址 | 95 | * 修改地址 |
85 | */ | 96 | */ |
86 | const updateAddressData = (req, res, next) => { | 97 | const updateAddressData = (req, res, next) => { |
87 | - let id = req.body.id; | 98 | + let id = crypto.decrypt(config.crypto.common, req.body.id); |
88 | let uid = req.user.uid; | 99 | let uid = req.user.uid; |
89 | let address = req.body.address; | 100 | let address = req.body.address; |
90 | let areaCode = req.body.area_code; | 101 | let areaCode = req.body.area_code; |
@@ -101,7 +112,7 @@ const updateAddressData = (req, res, next) => { | @@ -101,7 +112,7 @@ const updateAddressData = (req, res, next) => { | ||
101 | * 删除地址 | 112 | * 删除地址 |
102 | */ | 113 | */ |
103 | const delAddressData = (req, res, next) => { | 114 | const delAddressData = (req, res, next) => { |
104 | - let id = req.body.id; | 115 | + let id = crypto.decrypt(config.crypto.common, req.body.id); |
105 | let uid = req.user.uid; | 116 | let uid = req.user.uid; |
106 | 117 | ||
107 | addressModel.delAddressData(id, uid).then(result => { | 118 | addressModel.delAddressData(id, uid).then(result => { |
@@ -113,7 +124,7 @@ const delAddressData = (req, res, next) => { | @@ -113,7 +124,7 @@ const delAddressData = (req, res, next) => { | ||
113 | * 设置默认地址 | 124 | * 设置默认地址 |
114 | */ | 125 | */ |
115 | const setDefaultAddress = (req, res) => { | 126 | const setDefaultAddress = (req, res) => { |
116 | - let id = req.body.id; | 127 | + let id = crypto.decrypt(config.crypto.common, req.body.id); |
117 | let uid = req.user.uid; | 128 | let uid = req.user.uid; |
118 | 129 | ||
119 | _setDefault(id, uid).then(result => { | 130 | _setDefault(id, uid).then(result => { |
@@ -11,7 +11,7 @@ | @@ -11,7 +11,7 @@ | ||
11 | </tr> | 11 | </tr> |
12 | {{#each data}} | 12 | {{#each data}} |
13 | <tr class="table-body "> | 13 | <tr class="table-body "> |
14 | - <input type="hidden" id="tr_{{address_id}}" value="{{address_id}}"> | 14 | + <input type="hidden" id="tr_{{address_id}}" value="{{address_id}}" data-addressid="{{id}}" data-default="{{default}}"> |
15 | <input type="hidden" id="tr_{{area_code}}" value="{{area_code}}"> | 15 | <input type="hidden" id="tr_{{area_code}}" value="{{area_code}}"> |
16 | <td class="width-name">{{consignee}}</td> | 16 | <td class="width-name">{{consignee}}</td> |
17 | <td class="width-address">{{area}}</td> | 17 | <td class="width-address">{{area}}</td> |
@@ -21,15 +21,15 @@ | @@ -21,15 +21,15 @@ | ||
21 | <td class="width-opearte"> | 21 | <td class="width-opearte"> |
22 | <div> | 22 | <div> |
23 | <span class="blue opreation update-address" data-id="{{address_id}}">修改</span> | 23 | <span class="blue opreation update-address" data-id="{{address_id}}">修改</span> |
24 | - | 24 | + |
25 | <em class="op-sep {{#if default}}hide{{/if}}">|</em> | 25 | <em class="op-sep {{#if default}}hide{{/if}}">|</em> |
26 | - <span class="blue opreation del-address {{#if default}}hide{{/if}}" data-id="{{address_id}}">删除</span> | 26 | + <span class="blue opreation del-address {{#if default}}hide{{/if}}" data-id="{{id}}">删除</span> |
27 | {{#if default}} | 27 | {{#if default}} |
28 | - <span class="btn set-default opreation current-default" data-id={{address_id}}>默认地址</span> | 28 | + <span class="btn set-default opreation current-default" data-id={{id}}>默认地址</span> |
29 | {{else}} | 29 | {{else}} |
30 | - <span class="btn set-default opreation set" data-id={{address_id}}>设为默认</span> | 30 | + <span class="btn set-default opreation set" data-id={{id}}>设为默认</span> |
31 | {{/if}} | 31 | {{/if}} |
32 | - | 32 | + |
33 | </div> | 33 | </div> |
34 | </td> | 34 | </td> |
35 | </tr> | 35 | </tr> |
@@ -11,6 +11,8 @@ const orderModel = require('../models/order'); | @@ -11,6 +11,8 @@ const orderModel = require('../models/order'); | ||
11 | const _ = require('lodash'); | 11 | const _ = require('lodash'); |
12 | 12 | ||
13 | const helper = global.yoho.helpers; | 13 | const helper = global.yoho.helpers; |
14 | +const crypto = global.yoho.crypto; | ||
15 | +const config = global.yoho.config; | ||
14 | 16 | ||
15 | // 结算页面 | 17 | // 结算页面 |
16 | const index = (req, res, next) => { | 18 | const index = (req, res, next) => { |
@@ -93,6 +95,8 @@ const orderSub = (req, res, next) => { | @@ -93,6 +95,8 @@ const orderSub = (req, res, next) => { | ||
93 | message: '配送地址不能为空' | 95 | message: '配送地址不能为空' |
94 | }); | 96 | }); |
95 | return; | 97 | return; |
98 | + } else { | ||
99 | + other.address_id = crypto.decrypt(config.crypto.common, other.address_id); | ||
96 | } | 100 | } |
97 | 101 | ||
98 | orderModel.submit(req.user.uid, other).then(result => { | 102 | orderModel.submit(req.user.uid, other).then(result => { |
@@ -22,10 +22,10 @@ module.exports = { | @@ -22,10 +22,10 @@ module.exports = { | ||
22 | }, | 22 | }, |
23 | cookieDomain: 'yohoblk.com', | 23 | cookieDomain: 'yohoblk.com', |
24 | domains: { | 24 | domains: { |
25 | - singleApi: 'http://192.168.102.31:8092/', | 25 | + singleApi: 'http://single.yoho.cn/', |
26 | api: 'http://api.yoho.yohoops.org/', | 26 | api: 'http://api.yoho.yohoops.org/', |
27 | service: 'http://service.yoho.yohoops.org/', | 27 | service: 'http://service.yoho.yohoops.org/', |
28 | - search: 'http://192.168.102.216:8080/yohosearch/' | 28 | + search: 'http://search.yohoops.org/yohosearch/' |
29 | }, | 29 | }, |
30 | useOneapm: false, | 30 | useOneapm: false, |
31 | useCache: false, | 31 | useCache: false, |
@@ -37,10 +37,12 @@ $(function() { | @@ -37,10 +37,12 @@ $(function() { | ||
37 | 37 | ||
38 | return { | 38 | return { |
39 | id: $addressId.val(), | 39 | id: $addressId.val(), |
40 | + aid: $('#tr_' + $addressId.val()).data('addressid'), | ||
40 | consignee: $consignee.val(), | 41 | consignee: $consignee.val(), |
41 | address: $address.val(), | 42 | address: $address.val(), |
42 | mobile: $mobile.val(), | 43 | mobile: $mobile.val(), |
43 | - phone: $phone.val() | 44 | + phone: $phone.val(), |
45 | + default: $('#tr_' + $addressId.val()).data('default') === 'true' | ||
44 | }; | 46 | }; |
45 | }, | 47 | }, |
46 | 48 | ||
@@ -87,16 +89,20 @@ $(function() { | @@ -87,16 +89,20 @@ $(function() { | ||
87 | getHtml: function(info) { | 89 | getHtml: function(info) { |
88 | var html = '<tr class="table-body">'; | 90 | var html = '<tr class="table-body">'; |
89 | 91 | ||
90 | - html += '<input type="hidden" id="tr_' + info.address_id + '" value="' + info.address_id + '">' + | 92 | + html += '<input type="hidden" id="tr_' + info.address_id + '" value="' + info.address_id + |
93 | + '" data-addressid="' + info.aid + '">' + | ||
91 | '<input type="hidden" id="tr_' + info.area_code + '" value="' + info.area_code + '">' + | 94 | '<input type="hidden" id="tr_' + info.area_code + '" value="' + info.area_code + '">' + |
92 | '<td class=\'width-name\'>' + info.consignee + '</td>' + | 95 | '<td class=\'width-name\'>' + info.consignee + '</td>' + |
93 | '<td class=\'width-address\'>' + info.area + '</td>' + | 96 | '<td class=\'width-address\'>' + info.area + '</td>' + |
94 | '<td class=\'width-fulladdress\'>' + info.address + '</td>' + | 97 | '<td class=\'width-fulladdress\'>' + info.address + '</td>' + |
95 | '<td class=\'width-mobile\'><p>' + info.mobile + '</p><p>' + info.phone + '</p></td>' + | 98 | '<td class=\'width-mobile\'><p>' + info.mobile + '</p><p>' + info.phone + '</p></td>' + |
96 | '<td class=\'width-opearte\'><div><span class=\'blue opreation update-address\' data-id=\'' + | 99 | '<td class=\'width-opearte\'><div><span class=\'blue opreation update-address\' data-id=\'' + |
97 | - info.address_id + '\'>修改</span>\n<em class="op-sep">|</em>\n' + | ||
98 | - '<span class=\'blue opreation del-address\' data-id=\'' + info.address_id + '\'>删除</span>\n' + | ||
99 | - '<span class=\'btn set-default opreation set\' data-id=\'' + info.address_id + '\'>设为默认</span>' + | 100 | + info.address_id + '\'>修改</span>\n<em class="op-sep">|</em>\n'; |
101 | + if (!info.default) { | ||
102 | + html += '<span class=\'blue opreation del-address\' data-id=\'' + info.aid + '\'>删除</span>\n'; | ||
103 | + } | ||
104 | + | ||
105 | + html += '<span class=\'btn set-default opreation set\' data-id=\'' + info.aid + '\'>设为默认</span>' + | ||
100 | '</div></td>'; | 106 | '</div></td>'; |
101 | html += '</tr>'; | 107 | html += '</tr>'; |
102 | return html; | 108 | return html; |
@@ -123,7 +129,7 @@ $(function() { | @@ -123,7 +129,7 @@ $(function() { | ||
123 | $(document).on('click', '#save-address', function() { | 129 | $(document).on('click', '#save-address', function() { |
124 | var info, | 130 | var info, |
125 | area, | 131 | area, |
126 | - areaInfo; | 132 | + areaInfo, info2; |
127 | 133 | ||
128 | info = Bll.getInfo(); | 134 | info = Bll.getInfo(); |
129 | area = address.getAreaIds(); | 135 | area = address.getAreaIds(); |
@@ -132,8 +138,14 @@ $(function() { | @@ -132,8 +138,14 @@ $(function() { | ||
132 | info.area_code = area.split(',')[2]; | 138 | info.area_code = area.split(',')[2]; |
133 | info.area = areaInfo.split(',').join(' '); | 139 | info.area = areaInfo.split(',').join(' '); |
134 | 140 | ||
141 | + info2 = $.extend({}, info); | ||
142 | + info2.id = info.aid; | ||
143 | + delete info2.aid; | ||
144 | + | ||
135 | if (Bll.check(info) === true) { | 145 | if (Bll.check(info) === true) { |
136 | 146 | ||
147 | + console.log(info.id); | ||
148 | + | ||
137 | // 新增 | 149 | // 新增 |
138 | if (info.id === '') { | 150 | if (info.id === '') { |
139 | if (currentLength >= 7) { | 151 | if (currentLength >= 7) { |
@@ -146,16 +158,8 @@ $(function() { | @@ -146,16 +158,8 @@ $(function() { | ||
146 | dataType: 'json', | 158 | dataType: 'json', |
147 | data: info, | 159 | data: info, |
148 | success: function(data) { | 160 | success: function(data) { |
149 | - var html; | ||
150 | - | ||
151 | if (data.code === 200) { | 161 | if (data.code === 200) { |
152 | - html = Bll.getHtml(data.data); | ||
153 | - | ||
154 | - currentLength++; | ||
155 | - leftLength--; | ||
156 | - $('tbody').append(html); | ||
157 | - Bll.setTableTile(); | ||
158 | - Bll.clearInput(); | 162 | + location.reload(); |
159 | } else { | 163 | } else { |
160 | new _alert(data.message).show(); | 164 | new _alert(data.message).show(); |
161 | } | 165 | } |
@@ -168,14 +172,10 @@ $(function() { | @@ -168,14 +172,10 @@ $(function() { | ||
168 | type: 'POST', | 172 | type: 'POST', |
169 | url: '/me/address/update', | 173 | url: '/me/address/update', |
170 | dataType: 'json', | 174 | dataType: 'json', |
171 | - data: info, | 175 | + data: info2, |
172 | success: function(data) { | 176 | success: function(data) { |
173 | if (data.code === 200) { | 177 | if (data.code === 200) { |
174 | - info.mobile = info.mobile.substring(0, 3) + '****' + info.mobile.substring(7, 11); | ||
175 | - info.address_id = info.id; | ||
176 | - $('#tr_' + info.id).parents('tr').before(Bll.getHtml(info)).remove(); | ||
177 | - Bll.clearInput(); | ||
178 | - $('.tip em').html('新增地址'); | 178 | + location.reload(); |
179 | } else { | 179 | } else { |
180 | new _alert(data.message).show(); | 180 | new _alert(data.message).show(); |
181 | } | 181 | } |
@@ -187,14 +187,10 @@ $(function() { | @@ -187,14 +187,10 @@ $(function() { | ||
187 | type: 'POST', | 187 | type: 'POST', |
188 | url: '/me/address/update', | 188 | url: '/me/address/update', |
189 | dataType: 'json', | 189 | dataType: 'json', |
190 | - data: info, | 190 | + data: info2, |
191 | success: function(data) { | 191 | success: function(data) { |
192 | if (data.code === 200) { | 192 | if (data.code === 200) { |
193 | - info.mobile = info.mobile.substring(0, 3) + '****' + info.mobile.substring(7, 11); | ||
194 | - info.address_id = info.id; | ||
195 | - $('#tr_' + info.id).parents('tr').before(Bll.getHtml(info)).remove(); | ||
196 | - Bll.clearInput(); | ||
197 | - $('.tip em').html('新增地址'); | 193 | + location.reload(); |
198 | } else { | 194 | } else { |
199 | new _alert(data.message).show(); | 195 | new _alert(data.message).show(); |
200 | } | 196 | } |
@@ -206,8 +202,6 @@ $(function() { | @@ -206,8 +202,6 @@ $(function() { | ||
206 | } | 202 | } |
207 | } | 203 | } |
208 | 204 | ||
209 | - $('#address_id').val(''); | ||
210 | - | ||
211 | }); | 205 | }); |
212 | 206 | ||
213 | // 修改收货地址 | 207 | // 修改收货地址 |
-
Please register or login to post a comment