Authored by yyq

Merge branch 'release/1.0' of git.yoho.cn:fe/yoho-blk into release/1.0

... ... @@ -7,11 +7,11 @@
<li>
<a data-key="{{key}}" href="{{brandDomain}}" target="_blank">
<img class="lazy" data-original="{{image brandIco 270 190}}">
<span>{{#if brandNameEn}}{{brandNameEn}}{{else}}{{brandName}}{{/if}}</span>
<span>{{#if brandName}}{{brandName}}{{else}}{{brandNameEn}}{{/if}}</span>
</a>
</li>
{{/each}}
</ul>
</dd>
</dl>
{{/each}}
\ No newline at end of file
{{/each}}
... ...
... ... @@ -6,6 +6,8 @@
'use strict';
const mcHandler = require('../models/menu-crumb-handler');
const addressModel = require('../models/address');
const crypto = global.yoho.crypto;
const config = global.yoho.config;
const _ = require('lodash');
... ... @@ -31,6 +33,7 @@ const index = (req, res, next) => {
for (let i = 0; i < length; i++) {
resultData[i].default = resultData[i].is_default === 'Y';
resultData[i].mobile = resultData[i].mobile.replace(reg, '$1****$2');
resultData[i].id = crypto.encryption(config.crypto.common, resultData[i].address_id + '');
}
resultData.leftLength = 7 - length;
resultData.length = length;
... ... @@ -56,6 +59,10 @@ const getAddressList = (req, res, next) => {
if (result.data) {
let defaultAd = _.find(result.data, o => o.is_default === 'Y');
_.each(result.data, (d) => {
d.address_id = crypto.encryption(config.crypto.common, d.address_id + '');
});
defaultAd && (defaultAd.focus = true);
}
res.send(result);
... ... @@ -76,6 +83,10 @@ const addAddressData = (req, res, next) => {
let isInit = req.body.init && req.body.init === 'true'; // 是否是初始地址
addressModel.addAddressData(uid, address, areaCode, consignee, mobile, phone, isInit).then(result => {
if (result.data && result.data.address_id) {
result.data.aid = crypto.encryption(config.crypto.common, result.data.address_id + '');
}
res.send(result);
}).catch(next);
};
... ... @@ -84,7 +95,7 @@ const addAddressData = (req, res, next) => {
* 修改地址
*/
const updateAddressData = (req, res, next) => {
let id = req.body.id;
let id = crypto.decrypt(config.crypto.common, req.body.id);
let uid = req.user.uid;
let address = req.body.address;
let areaCode = req.body.area_code;
... ... @@ -101,7 +112,7 @@ const updateAddressData = (req, res, next) => {
* 删除地址
*/
const delAddressData = (req, res, next) => {
let id = req.body.id;
let id = crypto.decrypt(config.crypto.common, req.body.id);
let uid = req.user.uid;
addressModel.delAddressData(id, uid).then(result => {
... ... @@ -113,7 +124,7 @@ const delAddressData = (req, res, next) => {
* 设置默认地址
*/
const setDefaultAddress = (req, res) => {
let id = req.body.id;
let id = crypto.decrypt(config.crypto.common, req.body.id);
let uid = req.user.uid;
_setDefault(id, uid).then(result => {
... ...
... ... @@ -11,7 +11,7 @@
</tr>
{{#each data}}
<tr class="table-body ">
<input type="hidden" id="tr_{{address_id}}" value="{{address_id}}">
<input type="hidden" id="tr_{{address_id}}" value="{{address_id}}" data-addressid="{{id}}" data-default="{{default}}">
<input type="hidden" id="tr_{{area_code}}" value="{{area_code}}">
<td class="width-name">{{consignee}}</td>
<td class="width-address">{{area}}</td>
... ... @@ -21,15 +21,15 @@
<td class="width-opearte">
<div>
<span class="blue opreation update-address" data-id="{{address_id}}">修改</span>
<em class="op-sep {{#if default}}hide{{/if}}">|</em>
<span class="blue opreation del-address {{#if default}}hide{{/if}}" data-id="{{address_id}}">删除</span>
<span class="blue opreation del-address {{#if default}}hide{{/if}}" data-id="{{id}}">删除</span>
{{#if default}}
<span class="btn set-default opreation current-default" data-id={{address_id}}>默认地址</span>
<span class="btn set-default opreation current-default" data-id={{id}}>默认地址</span>
{{else}}
<span class="btn set-default opreation set" data-id={{address_id}}>设为默认</span>
<span class="btn set-default opreation set" data-id={{id}}>设为默认</span>
{{/if}}
</div>
</td>
</tr>
... ...
... ... @@ -11,6 +11,8 @@ const orderModel = require('../models/order');
const _ = require('lodash');
const helper = global.yoho.helpers;
const crypto = global.yoho.crypto;
const config = global.yoho.config;
// 结算页面
const index = (req, res, next) => {
... ... @@ -90,6 +92,8 @@ const orderSub = (req, res, next) => {
message: '配送地址不能为空'
});
return;
} else {
other.address_id = crypto.decrypt(config.crypto.common, other.address_id);
}
orderModel.submit(req.user.uid, other).then(result => {
... ...
... ... @@ -22,10 +22,10 @@ module.exports = {
},
cookieDomain: 'yohoblk.com',
domains: {
singleApi: 'http://192.168.102.31:8092/',
singleApi: 'http://single.yoho.cn/',
api: 'http://api.yoho.yohoops.org/',
service: 'http://service.yoho.yohoops.org/',
search: 'http://192.168.102.216:8080/yohosearch/'
search: 'http://search.yohoops.org/yohosearch/'
},
useOneapm: false,
useCache: false,
... ...
... ... @@ -37,10 +37,12 @@ $(function() {
return {
id: $addressId.val(),
aid: $('#tr_' + $addressId.val()).data('addressid'),
consignee: $consignee.val(),
address: $address.val(),
mobile: $mobile.val(),
phone: $phone.val()
phone: $phone.val(),
default: $('#tr_' + $addressId.val()).data('default') === 'true'
};
},
... ... @@ -87,16 +89,20 @@ $(function() {
getHtml: function(info) {
var html = '<tr class="table-body">';
html += '<input type="hidden" id="tr_' + info.address_id + '" value="' + info.address_id + '">' +
html += '<input type="hidden" id="tr_' + info.address_id + '" value="' + info.address_id +
'" data-addressid="' + info.aid + '">' +
'<input type="hidden" id="tr_' + info.area_code + '" value="' + info.area_code + '">' +
'<td class=\'width-name\'>' + info.consignee + '</td>' +
'<td class=\'width-address\'>' + info.area + '</td>' +
'<td class=\'width-fulladdress\'>' + info.address + '</td>' +
'<td class=\'width-mobile\'><p>' + info.mobile + '</p><p>' + info.phone + '</p></td>' +
'<td class=\'width-opearte\'><div><span class=\'blue opreation update-address\' data-id=\'' +
info.address_id + '\'>修改</span>\n<em class="op-sep">|</em>\n' +
'<span class=\'blue opreation del-address\' data-id=\'' + info.address_id + '\'>删除</span>\n' +
'<span class=\'btn set-default opreation set\' data-id=\'' + info.address_id + '\'>设为默认</span>' +
info.address_id + '\'>修改</span>\n<em class="op-sep">|</em>\n';
if (!info.default) {
html += '<span class=\'blue opreation del-address\' data-id=\'' + info.aid + '\'>删除</span>\n';
}
html += '<span class=\'btn set-default opreation set\' data-id=\'' + info.aid + '\'>设为默认</span>' +
'</div></td>';
html += '</tr>';
return html;
... ... @@ -123,7 +129,7 @@ $(function() {
$(document).on('click', '#save-address', function() {
var info,
area,
areaInfo;
areaInfo, info2;
info = Bll.getInfo();
area = address.getAreaIds();
... ... @@ -132,8 +138,14 @@ $(function() {
info.area_code = area.split(',')[2];
info.area = areaInfo.split(',').join(' ');
info2 = $.extend({}, info);
info2.id = info.aid;
delete info2.aid;
if (Bll.check(info) === true) {
console.log(info.id);
// 新增
if (info.id === '') {
if (currentLength >= 7) {
... ... @@ -146,16 +158,8 @@ $(function() {
dataType: 'json',
data: info,
success: function(data) {
var html;
if (data.code === 200) {
html = Bll.getHtml(data.data);
currentLength++;
leftLength--;
$('tbody').append(html);
Bll.setTableTile();
Bll.clearInput();
location.reload();
} else {
new _alert(data.message).show();
}
... ... @@ -168,14 +172,10 @@ $(function() {
type: 'POST',
url: '/me/address/update',
dataType: 'json',
data: info,
data: info2,
success: function(data) {
if (data.code === 200) {
info.mobile = info.mobile.substring(0, 3) + '****' + info.mobile.substring(7, 11);
info.address_id = info.id;
$('#tr_' + info.id).parents('tr').before(Bll.getHtml(info)).remove();
Bll.clearInput();
$('.tip em').html('新增地址');
location.reload();
} else {
new _alert(data.message).show();
}
... ... @@ -187,14 +187,10 @@ $(function() {
type: 'POST',
url: '/me/address/update',
dataType: 'json',
data: info,
data: info2,
success: function(data) {
if (data.code === 200) {
info.mobile = info.mobile.substring(0, 3) + '****' + info.mobile.substring(7, 11);
info.address_id = info.id;
$('#tr_' + info.id).parents('tr').before(Bll.getHtml(info)).remove();
Bll.clearInput();
$('.tip em').html('新增地址');
location.reload();
} else {
new _alert(data.message).show();
}
... ... @@ -206,8 +202,6 @@ $(function() {
}
}
$('#address_id').val('');
});
// 修改收货地址
... ...