Authored by 姜枫

handle merge

/**
* 品牌
* @author: zxr<xiaoru.zhang@yoho.cn>
* @date: 2016/7/8
*/
'use strict';
const index = (req, res) => {
res.display('index', {
module: 'brand',
page: 'index',
title: '品牌',
brand: {
nav: [
{
link: '//guang.yohobuy.com/index/index?type=0',
pathTitle: '首页',
name: 'MEN首页'
},
{
link: '/',
pathTitle: '品牌',
name: 'Brand品牌'
}
],
tabs: [
{
url: '#',
name: '',
src: '#'
},
{
url: '#',
name: '',
src: '#'
},
{
url: '#',
name: '',
src: '#'
}
],
navigation: [
{
name: 'A'
},
{
name: 'B'
},
{
name: 'B'
},
{
name: 'A'
},
{
name: 'B'
},
{
name: 'B'
},
{
name: 'B'
}
],
category: [
{
key: 'A',
brandList: [
{
key: 'A',
href: '#',
name: 'edhwke'
},
{
key: 'A',
href: '#',
name: 'edhwke'
},
{
key: 'A',
href: '#',
name: 'edhwke'
},
{
key: 'A',
href: '#',
name: 'edhwke'
},
{
key: 'A',
href: '#',
name: 'edhwke'
},
{
key: 'A',
href: '#',
name: 'edhwke'
}
]
},
{
key: 'A',
brandList: [
{
key: 'A',
href: '#',
name: 'edhwke'
},
{
key: 'A',
href: '#',
name: 'edhwke'
},
{
key: 'A',
href: '#',
name: 'edhwke'
},
{
key: 'A',
href: '#',
name: 'edhwke'
},
{
key: 'A',
href: '#',
name: 'edhwke'
},
{
key: 'A',
href: '#',
name: 'edhwke'
}
]
}
]
},
helpers: {
// import component, path depends on your project
pagination: require('../../../doraemon/components/pagination/pagination').createPagination
}
});
};
module.exports = {
index // 组件demo页
};
... ...
/**
* sub app partial
* @author: zhangxiaoru<xiaoru.zhang@yoho.cn>
* @date: 2016/07/8
*/
'use strict';
var express = require('express'),
path = require('path'),
hbs = require('express-handlebars');
var app = express();
// set view engin
var doraemon = path.join(__dirname, '../../doraemon/views'); // parent view root
// var partials = path.join(__dirname, './views'); // parent view root
app.on('mount', function(parent) {
delete parent.locals.settings; // 不继承父 App 的设置
Object.assign(app.locals, parent.locals);
});
app.set('views', path.join(__dirname, 'views/action'));
app.engine('.hbs', hbs({
extname: '.hbs',
defaultLayout: 'layout',
layoutsDir: doraemon,
partialsDir: [path.join(__dirname, 'views/partial'), `${doraemon}/partial`],
helpers: global.yoho.helpers
}));
// router
app.use(require('./router'));
module.exports = app;
... ...
'use strict';
... ...
/**
* router of sub app channel
* @author: zhangxiaoru<xiaoru.zhang@yoho.cn>
* @date: 2016/07/04
*/
'use strict';
const router = require('express').Router(); // eslint-disable-line
const cRoot = './controllers';
const brand = require(cRoot + '/brand');
router.get('/', brand.index); // 品牌首页
module.exports = router;
... ...
<div class="brand-page blk-page center-content">
{{# brand}}
{{> path-nav}}
<div class="brands-tabs height-initial">
<ul class="clearfix">
{{#each tabs}}
<li>
<a href="{{url}}" target="_blank">
<div class="g-mask"></div>
<p class="tips">{{name}}</p>
<img class="lazy" data-original="{{src}}"/>
</a>
</li>
{{/each}}
</ul>
</div>
<div class="brands-category">
<div class="category-nav">
{{#each navigation}}
<a href="#{{name}}">{{name}}</a>
{{/each}}
</div>
</div>
<div class="brands-list" >
{{> list}}
</div>
{{/ brand}}
</div>
\ No newline at end of file
... ...
{{#each category}}
<dl class="clearfix" name="{{key}}">
<dt>{{key}}</dt>
<dd>
<ul class="clearfix">
{{#each brandList}}
<li>
<a data-key="{{key}}" href="{{href}}" target="_blank">
<img class="lazy" data-original="{{href}}">
<span>{{name}}</span>
</a>
</li>
{{/each}}
</ul>
</dd>
</dl>
{{/each}}
\ No newline at end of file
... ...
... ... @@ -8,7 +8,7 @@
const editorialModel = require('../models/editorial');
const index = (req, res,next) => {
const index = (req, res, next) => {
let pageNum = req.query.page || 1;
let type = req.query.type || 0;
... ... @@ -27,20 +27,20 @@ const index = (req, res,next) => {
{
link: '/editorial?type=1',
pathTitle: '资讯',
name: '咨询'
name: '资讯'
},
{
link: '/',
pathTitle: '资讯',
name: '咨询'
name: '资讯'
}
],
msgTypes: result.msgTypes,
msg: result.msg,
paginationOpts: {
page: pageNum, // current page: http://host/?page=2
limit: 10, // per_page records' number
total: 100, // total page number
limit: 20, // per_page records' number
total: 300, // total page number
queryParams: req.query
}
},
... ...
... ... @@ -4,8 +4,11 @@ const serviceAPI = global.yoho.ServiceAPI;
// const api = global.yoho.API;
const camelCase = global.yoho.camelCase;
const _ = require('lodash');
// const moment = require('moment');
const logger = global.yoho.logger;
//const helpers = global.yoho.helpers;
// const helpers = global.yoho.helpers;
const _processNavData = (list, type) => {
let formatData = [];
... ... @@ -15,38 +18,25 @@ const _processNavData = (list, type) => {
_.forEach(list, (data, index) => {
data.url = `//127.0.0.1:6003/editorial?type=${data.id}`;
if (index === _.parseInt(type)) {
data.isActive = true;
} else {
data.isActive = false;
}
data.isActive = index === parseInt(type, 10) ? true : false;
formatData.push(data);
});
console.log(formatData);
return formatData;
};
const _processListData = (list) => {
//let formatData = [];
list = list || [];
//list = camelCase(list);
list = list || [];
list = camelCase(list);
'2016年06月02日 15:56'.match(/^(\d+)(\d+)(\d+)(\d+):(\d+)$/, function(data) {
console.log(data);
});
// let data = moment('2016年06月02日 15:56', 'YYYY年MM月DD日 HH:mm').format('YYYY/MM/DD HH:mm');
let artList = list.list.artList.map(data =>{
// let time = data.publish_time.match(/^(\d+)年(\d+)月(\d+)日 (\d+):(\d+)$/);
// data.publishTime = `${time[1]}/${time[2]}/${time[3]} ${time[4]}:${time[5]}`
data.publishTime = data.publish_time.replace(/年|月/g, '/');
data.publishTime = data.publishTime.replace(/年|月/g, '/');
data.publishTime = data.publishTime.replace(/日/g, '');
return data;
... ... @@ -60,7 +50,9 @@ const _getResources = (type) => {
if (result && result.code === 200) {
return _processNavData(result.data, type);
} else {
logger.error('资讯首页导航数据返回 code 不是 200');
return {};
}
});
... ... @@ -77,8 +69,8 @@ const _getBreakingSort = () => {
});
};
const getIndexData = () => {
return Promise.all([_getResources(), _getBreakingSort()])
const getIndexData = (type) => {
return Promise.all([_getResources(type), _getBreakingSort()])
.then((result) => {
return {
... ...
... ... @@ -3,7 +3,7 @@
<div class="msg-right">
<a class="msg-title" href="{{url}}" target="_blank">{{title}}</a>
<a href="{{url}}" target="_blank">
<img class="lazy" data-original="{{img}}">
<img class="lazy" data-original="{{src}}">
</a>
<div class="content">{{intro}}</div>
<div class="msg-app">
... ...
/**
* [个人中心]收货地址
* @author: jiangmin
* @date: 2016/07/05
*/
'use strict';
const mcHandler = require('../models/menu-crumb-handler');
const addressModel = require('../models/address');
/**
* 收货地址页面加载
*/
const index = (req, res) => {
addressModel.getAddressDataAsync('123456', 20).then(result => {
for (let i = 0; i < result.data.length; i++) {
result.data[i].default = result.data[i].is_default === 'Y';
}
result.data.leftLength = 20 - result.data.length;
res.render('index', {
module: 'me',
page: 'address',
isMe: true,
content: {
nav: mcHandler.getMeCrumb(),
navigation: mcHandler.getSideMenu('收货地址'),
banner: 'http://placehold.it/150x120',
address: true,
title: '收货地址',
data: result.data
}
});
});
};
/**
* 添加地址
*/
const addAddressData = (req, res) => {
let uid = req.body.uid;
let address = req.body.address;
let areaCode = req.body.area_code;
let consignee = req.body.consignee;
let mobile = req.body.mobile;
let phone = req.body.phone;
addressModel.addAddressData(uid, address, areaCode, consignee, mobile, phone).then(result => {
res.send(result);
});
};
/**
* 修改地址
*/
const updateAddressData = (req, res) => {
let id = req.body.id;
let uid = req.body.uid;
let address = req.body.address;
let areaCode = req.body.area_code;
let consignee = req.body.consignee;
let mobile = req.body.mobile;
let phone = req.body.phone;
addressModel.updateAddressData(id, uid, address, areaCode, consignee, mobile, phone).then(result => {
res.send(result);
});
};
/**
* 删除地址
*/
const delAddressData = (req, res) => {
let id = req.body.id;
let uid = req.body.uid;
addressModel.delAddressData(id, uid).then(result => {
res.send(result);
});
};
/**
* 设置默认地址
*/
const setDefaultAddress = (req, res) => {
let id = req.body.id;
let uid = req.body.uid;
addressModel.setDefaultAddress(id, uid).then(result => {
res.send(result);
});
};
module.exports = {
index,
addAddressData,
updateAddressData,
delAddressData,
setDefaultAddress
};
... ...
... ... @@ -38,7 +38,8 @@ const getOrderList = (req, res) => {
layout: false,
page: 'order',
isMe: true,
orderList: result.order.orderList
orderList: result.order.orderList,
paginationOpts: result.order.paginationOpts
});
});
};
... ...
/**
* [个人中心]收货地址
* @author: jiangmin
* @date: 2016/07/05
*/
'use strict';
const api = global.yoho.API;
/**
* 地址列表数据
*
* @param uid 用户ID
* @param limit 分页大小参数(默认10条)
* @return array 地址接口返回的数据
*/
const getAddressDataAsync = (uid, limit) => {
return api.get('', {
method: 'app.address.gethidden',
uid: uid,
limit: limit
}).then(result => {
// console.log('列表结果result', result);
if (result.code === '200') {
return result.data;
}
return result;
});
};
/**
* 保存地址数据
*
* @param uid 用户ID
* @param address 地址信息
* @param areaCode 城市码
* @param consignee 收货人
* @param mobile 手机号码
* @param phone 电话号码
* @return array 地址接口返回的数据
*/
const addAddressData = (uid, address, areaCode, consignee, mobile, phone) => {
return api.get('', {
method: 'app.address.add',
uid: uid,
address: address,
area_code: areaCode,
consignee: consignee,
mobile: mobile,
phone: phone
}).then(result => {
// console.log("添加result",result);
return result;
});
};
/**
* 修改地址数据
*
* @param id 地址id
* @param uid 用户ID
* @param address 地址信息
* @param areaCode 城市码
* @param consignee 收货人
* @param mobile 手机号码
* @param phone 电话号码
* @return array 地址接口返回的数据
*/
const updateAddressData = (id, uid, address, areaCode, consignee, mobile, phone) => {
return api.get('', {
method: 'app.address.update',
id: id,
uid: uid,
address: address,
area_code: areaCode,
consignee: consignee,
mobile: mobile,
phone: phone
}).then(result => {
// console.log("修改result", result);
return result;
});
};
/**
* 删除地址数据
*
* @param id 地址id
* @param uid 用户ID
* @return array 地址接口返回的数据
*/
const delAddressData = (id, uid) => {
return api.get('', {
method: 'app.address.del',
id: id,
uid: uid
}).then(result => {
// console.log("删除result",result);
return result;
});
};
/**
* 设置默认地址
*
* @param id 地址id
* @param uid 用户ID
* @return array 地址接口返回的数据
*/
const setDefaultAddress = (id, uid) => {
return api.get('', {
method: 'app.address.setdefault',
id: id,
uid: uid
}).then(result => {
// console.log('设置默认result', result);
return result;
});
};
module.exports = {
getAddressDataAsync: getAddressDataAsync,
addAddressData: addAddressData,
updateAddressData: updateAddressData,
delAddressData: delAddressData,
setDefaultAddress: setDefaultAddress
};
... ...
'use strict';
const api = global.yoho.API;
const camelCase = global.yoho.camelCase;
... ... @@ -9,9 +11,21 @@ const _getUserOrder = (type, page) => {
page: page || 1,
limit: 10
}).then(result => {
const orderList = result && result.data && result.data.order_list || [];
let orderList = [];
let total = false;
let curPage = 1;
if (result && result.data) {
orderList = result.data.order_list;
total = result.data.total;
curPage = result.data.page;
}
return camelCase(orderList);
return {
orderList: camelCase(orderList),
total: total,
curPage: curPage
};
});
};
... ... @@ -41,11 +55,19 @@ const getOrderData = (type, page) => {
};
const order = Object.assign(fakeData, {
orderList: result.length && result || false
orderList: result.orderList.length && result.orderList || false
}, navBar);
const paginationOpts = {
paginationOpts: {
total: result.total,
page: result.curPage,
limit: 10
}
};
return {
order: order
order: Object.assign(order, paginationOpts)
};
});
};
... ...
... ... @@ -11,9 +11,17 @@ const cRoot = './controllers';
// 订单
const order = require(`${cRoot}/order`);
const address = require(`${cRoot}/address`);
// 个人中心首页/订单
router.get(['/', '/order'], order.index);
router.get('/getOrderList', order.getOrderList);
// 个人中心首页/收货地址
router.get('/address', address.index);
router.post('/address/add', address.addAddressData);
router.post('/address/update', address.updateAddressData);
router.post('/address/del', address.delAddressData);
router.post('/address/default', address.setDefaultAddress);
module.exports = router;
... ...
<div class="user-order">
{{> common/subtitle}}
{{> address/content}}
{{> address/table}}
</div>
... ...
<form id="address-form" name="address-form">
<div class="address-page">
<span class="blue tip">新增地址 电话为选填项,其他均为必填项</span>
<div class="add-address-detail">
<div class="form-group">
<label class="label-name">&nbsp;&nbsp;收货人:</label>
<input id="address_id" type="hidden" value="">
<input id="consignee" class="input width-190" type="text" placeholder="请输入您的姓名" maxlength="10">
<span class="blue error-tips">{{> icon/error-round}}收件人不能为空</span>
</div>
<div class="form-group">
<label class="label-name">所在区域:</label>
<div id="address"></div>
<span class="blue error-tips">{{> icon/error-round}}所在区域不能为空</span>
</div>
<div class="form-group">
<label class="label-name">详细地址:</label>
<input id="addressDetail" class="input width-275" type="text" placeholder="街道名称或小区名称" maxlength="60">
<span class="blue error-tips">{{> icon/error-round}}详细地址不能为空</span>
</div>
<div class="form-group">
<label class="label-name">手机号码:</label>
<input id="mobile" class="input width-190" type="text" placeholder="请输入手机号码(重要必填)" maxlength="11">
<span class="blue error-tips">{{> icon/error-round}}手机号码不能为空</span>
</div>
<div class="form-group">
<label class="label-name">电话号码:</label>
<input id="phone" class="input width-190" type="text" placeholder="请输入电话号码(选填)">
</div>
<div class="form-group ">
<label class="label-name"></label>
<span class="iconfont radio default-address opreation">&#xe604;</span>
<label class="radio-lable">设置为默认收货地址</label>
</div>
<div class="form-group">
<span class="btn opreation" id="save-address">保存</span>
</div>
</div>
</div>
</form>
... ...
<div class="address-table">
<span class="blue table-title">已保存了{{data.length}}条地址,还能保存{{data.leftLength}}条地址</span>
<table class="a-table">
<tr class="table-head">
<th class="width-80">收货人</th>
<th class="width-195">所在区域</th>
<th class="width-280">详细地址</th>
<th class="width-120">手机/电话</th>
<th class="width-260">操作</th>
</tr>
{{#each data}}
<tr class="table-body">
<input type="hidden" id="tr_{{address_id}}" value="{{address_id}}">
<td class="width-80">{{consignee}}</td>
<td class="width-195">{{area}}</td>
<td class="width-255">{{address}}</td>
<td class="width-120"><p>{{mobile}}</p><p>{{phone}}</p></td>
<td class="width-260">
<div>
<span class="blue opreation update-address" data-id="{{address_id}}">修改</span>
|
<span class="blue opreation del-address" data-id="{{address_id}}">删除</span>
{{#if default}}
<span class="btn set-default opreation current-default ">默认地址</span>
{{else}}
<span class="btn set-default opreation " data-id="{{address_id}}">设为默认</span>
{{/if}}
</div>
</td>
</tr>
{{/each}}
</table>
</div>
... ...
... ... @@ -54,6 +54,7 @@
</div>
</div>
{{/orderList}}
{{{ pagination paginationOpts }}}
{{^}}
<div class="bg"></div>
<div class="msg">
... ...
... ... @@ -19,7 +19,7 @@ module.exports = {
},
cookieDomain: 'yohoblk.com',
domains: {
api: 'http://api.yoho.yohoops.org/', // devapi.yoho.cn:58078 testapi.yoho.cn:28078 devapi.yoho.cn:58078
api: 'http://devapi.yoho.cn:58078/', // devapi.yoho.cn:58078 testapi.yoho.cn:28078 devapi.yoho.cn:58078
service: 'http://devservice.yoho.cn:28077/', // testservice.yoho.cn:28077 devservice.yoho.cn:58077
search: 'http://192.168.102.216:8080/yohosearch/'
},
... ...
... ... @@ -16,4 +16,5 @@ module.exports = app => {
app.use('/me', require('./apps/me')); // 个人中心
app.use('/editorial', require('./apps/editorial')); // 资讯
app.use('/product', require('./apps/product'));
app.use('/brand', require('./apps/brand')); // 资讯
};
... ...
/**
* 品牌页
* @author: zxr<xiaoru.zhang@yoho.cn>
* @date: 2016/07/09
*/
var $ = require('yoho-jquery'),
lazyLoad = require('yoho-jquery-lazyload');
require('../common/header');
require('../common/return-top');
lazyLoad($('#msg-list img.lazy'));
... ...
... ... @@ -7,26 +7,22 @@
var $ = require('yoho-jquery'),
lazyLoad = require('yoho-jquery-lazyload');
// var prising;
require('../common/header');
require('../common/return-top');
lazyLoad($('#msg-list img.lazy'));
$('.msg-nav li').on('click', function() {
// var activeTab = $(this).attr('data-type'),
// href = $(this).find('a').attr('href');
$('.msg-nav li').removeClass('active');
$(this).addClass('active');
});
$('.editorial-index-page').on('click', '.like-icon', function() {
var $this = $(this);
// msgId = $this.closest('.content-msg').data().id;
$this.toggleClass('liked');
var $this = $(this),
num = parseInt($this.next().html(), 10);
if ($this.hasClass('liked')) {
$this.removeClass('liked');
num = num - 1;
} else {
$this.addClass('liked');
num = num + 1;
console.log(num);
}
$this.next().html(num);
});
require('../common/header');
require('../common/return-top');
... ...
/**
* [个人中心]收货地址
* @author: jiangmin
* @date: 2016/07/05
*/
var cascadingAddress = require('../plugins/cascading-address');
var dialog = require('../plugins/dialog');
var _confirm = dialog.Confirm;
var $addressId = $('#address_id');
var $consignee = $('#consignee');
var $address = $('#addressDetail');
var $mobile = $('#mobile');
var $phone = $('#phone');
var currentLength = $('.a-table').find('tr').length - 1;// 当前地址条数
var leftLength = 20 - currentLength;// 还剩地址条数
var Bll = {
// 获取输入框输入的值
getInfo() {
// todo uid
var uid = '123456';
return {
id: $addressId.val(),
uid: uid,
consignee: $consignee.val(),
// todo 地址码
address: $address.val(),
mobile: $mobile.val(),
phone: $phone.val()
// todo 设置默认值
};
},
// 清空输入框
clearInput() {
$consignee.val('');
// todo 省市区清空
$address.val('');
$mobile.val('');
$phone.val('');
},
// 校验
check(info) {
let flag = true;
let reg = new RegExp(/^(0|86|17951)?(13[0-9]|15[012356789]|17[678]|18[0-9]|14[57])[0-9]{8}$/);
if (info.consignee === '' || info.address === '' || info.mobile === '') {
flag = '有必填项为空';
} else if (!reg.test(info.mobile)) {
flag = '手机号码格式不对';
}
return flag;
},
// 拼接一条数据的html
getHtml(info) {
var html = '<tr class="table-body">';
html += '<input type="hidden" id="tr_' + info.address_id + '" value="' + info.address_id + '">' +
'<td class=\'width-80\'>' + info.consignee + '</td>' +
'<td class=\'width-195\'>' + info.area + '</td>' +
'<td class=\'width-280\'>' + info.address + '</td>' +
'<td class=\'width-120\'><p>' + info.mobile + '</p><p>' + info.phone + '</p></td>' +
'<td class=\'width-260\'><div><span class=\'blue opreation update-address\'>修改</span>\n|\n' +
'<span class=\'blue opreation del-address\' data-id=\'' + info.address_id + '\'>删除</span>\n' +
'<span class=\'btn set-default opreation \' data-id=\'' + info.address_id + '\'>设为默认</span></div></td>';
html += '</tr>';
return html;
},
// 获取一条数据
setInfo(id, td) {
$addressId.val(id);
$consignee.val(td.eq(0).text());
// todo 省市区逆向展示
// $areaCode.val(td.eq(1).text());
$address.val(td.eq(2).text());
$mobile.val(td.eq(3).children().eq(0).text());
$phone.val(td.eq(3).children().eq(1).text());
},
// 设置表格头部
setTableTile() {
$('.table-title').text('已保存了' + currentLength +
'条地址,还能保存' + leftLength + '条地址');
}
};
require('./me');
// 设置收货地址
$('.default-address').click(function() {
if ($(this).hasClass('checked')) {
$(this).removeClass('checked');
$(this).html('&#xe604;');
} else {
$(this).addClass('checked');
$(this).html('&#xe603;');
}
});
// 校验
$consignee.keydown(function() {
$(this).next().hide();
});
$consignee.blur(function() {
if ($(this).val().trim() === '') {
$(this).next().show();
}
});
$address.keydown(function() {
$(this).next().hide();
});
$address.blur(function() {
if ($(this).val().trim() === '') {
$(this).next().show();
}
});
$mobile.keydown(function() {
$(this).next().hide();
});
$mobile.blur(function() {
if ($(this).val().trim() === '') {
$(this).next().show();
} else {
let reg = new RegExp(/^(0|86|17951)?(13[0-9]|15[012356789]|17[678]|18[0-9]|14[57])[0-9]{8}$/);
if (!reg.test(($(this).val().trim()))) {
$(this).next().show();
$(this).next().html('手机号码格式不正确');
}
}
});
// 保存收货地址
$(document).on('click', '#save-address', function() {
var info = Bll.getInfo();
var area = $('#address-form').serialize();
info.area_code = area.substring(area.length - 6);
if (Bll.check(info) === true) {
// 新增
if (info.id === '') {
$.ajax({
type: 'POST',
url: '/me/address/add',
dataType: 'json',
data: info,
success: function(data) {
let html = Bll.getHtml(data.data);
currentLength++;
leftLength--;
$('tbody').append(html);
Bll.setTableTile();
Bll.clearInput();
}
});
} else { // 修改
console.log('上传info', info);
$.ajax({
type: 'POST',
url: '/me/address/update',
dataType: 'json',
data: info,
success: function(data) {
if (data.code === 200) {
$('#tr_' + info.id).parent().before(Bll.getHtml(info)).remove();
Bll.clearInput();
} else {
// alert('修改出错!');
}
}
});
}
} else {
alert(Bll.check(info));
}
});
// 修改收货地址
$('.update-address').click(function() {
let id = $(this).data('id');
let tr = $(this).parents('.table-body');
let td = tr.find('td');
Bll.setInfo(id, td);
});
// 删除收货地址
$('.del-address').click(function() {
let id = $(this).data('id');
var tr = $(this).parents('.table-body');
var a = new _confirm({
content: '您确定要删除收货地址吗?',
cb: function() {
$.ajax({
type: 'POST',
url: '/me/address/del',
dataType: 'json',
data: {
// todo uid
uid: '123456',
id: id
},
success: function() {
currentLength--;
leftLength++;
tr.remove();
Bll.setTableTile();
a.close();
}
});
}
}).show();
});
// 设置默认收货地址
$(document).on('click', '.set-default', function() {
var tr = $(this).parents('.table-body');
var tbody = tr.parent();
let id = $(this).data('id');
var self = this;
$.ajax({
type: 'POST',
url: '/me/address/default',
dataType: 'json',
data: {
// todo uid
uid: '123456',
id: id
},
success: function() {
$('.current-default').removeClass('current-default').text('设为默认');
$(self).addClass('current-default').text('默认地址');
tbody.find('.table-body').eq(0).before('<tr class=\'table-body\'>' + tr.html() + '</tr>');
tr.remove();
}
});
});
$(function() {
// 运行此demo
// 1. 安装 npm i -g json-server
// 2. json-server --watch mock/address.json
cascadingAddress({
el: '#address',
url: 'http://localhost:3000/areas/0',
resource: 'areas'
});
});
... ...
... ... @@ -29,12 +29,12 @@ function getOrderList(type, page) {
}
}).done(function(res) {
tableOperation.appendBody(res);
bindPaginationClick(); // eslint-disable-line
}).fail(function(err) {
console.log(err);
});
}
function getQueryString() {
var queryArr = location.search.substr(1).split('&');
var query = {};
... ... @@ -49,6 +49,24 @@ function getQueryString() {
return query;
}
function bindPaginationClick() {
$('.blk-pagination li').off('click').on('click', function(e) {
var $this = $(this);
var page = $this.find('a').attr('href').split('=')[1];
var type = getQueryString().type;
e.preventDefault();
if (!$this.hasClass('active')) {
$('.blk-pagination li.active').removeClass('active');
$this.addClass('active');
getOrderList(type, page);
}
});
}
$('.tabs li').on('click', function() {
var $this = $(this);
var typeMap = {
... ... @@ -62,7 +80,11 @@ $('.tabs li').on('click', function() {
if (!$this.hasClass('active')) {
$('.tabs li.active').removeClass('active');
$this.addClass('active');
getOrderList(type, page);
}
getOrderList(type, page);
});
bindPaginationClick();
... ...
.brand-page {
padding-bottom: 80px;
.brands-tabs {
position: relative;
a {
display: block;
width: 370px;
height: 304px;
img {
width: 100%;
height: 100%;
display: block;
}
.g-mask {
width: 100%;
height: 100%;
display: block;
position: absolute;
z-index: 1;
background: #ffec07;
border: 1px solid #ffec07;
opacity: 0;
}
}
li {
float: left;
margin-left: 20px;
position: relative;
p {
display: block;
font-size: 30px;
text-align: center;
color: #ffec07;
position: absolute;
top: 50%;
width: 100%;
margin-top: -15px;
z-index: 3;
}
}
li:first-child {
margin-left: 0;
}
li:hover {
.g-mask {
opacity: 0.3;
}
}
}
.category-nav {
margin-top: 20px;
border-top: 1px solid #eee;
border-bottom: 1px solid #eee;
padding-left: 16px;
height: 44px;
line-height: 44px;
font-size: 12px;
font-weight: bold;
position: relative;
z-index: 100;
background-color: #fff;
a {
display: inline-block;
padding: 0 7px;
text-align: center;
color: #222;
cursor: pointer;
}
a:hover {
color: #379ed6;
}
}
.brands-list {
dt {
height: 70px;
line-height: 70px;
font-weight: bold;
font-size: 24px;
}
dd {
li {
float: left;
display: block;
width: 275px;
height: 250px;
margin-right: 15px;
border: 1px solid #eee;
margin-top: 20px;
}
li:nth-child(4n) {
margin-right: 0;
}
li:nth-child(-n+4) {
margin-top: 0;
}
a {
font-size: 16px;
display: block;
width: 100%;
height: 100%;
img {
width: 275px;
height: 190px;
}
span {
display: block;
height: 60px;
line-height: 60px;
text-align: center;
font-size: 16px;
}
}
}
}
}
... ...
... ... @@ -13,7 +13,5 @@
@import "product/index";
@import "channel/index";
@import "passport/index";
/* 资讯 */
@import "editorial/index";
@import "brand/brand";
... ...
.address-page {
.title {
font-size: 30px;
height: 100px;
line-height: 100px;
text-align: left;
}
.tip {
font-size: 14px;
}
.add-address-detail {
padding: 15px 0 0;
.form-group {
clear: both;
margin-bottom: 20px;
.default-address,
#address,
.btn {
margin-left: 83px;
}
.label-name {
font-size: 14px;
text-align: left;
float: left;
line-height: 26px;
}
.width-190 {
width: 190px;
margin-left: 20px;
}
.width-275 {
width: 275px;
margin-left: 20px;
}
.iconfont {
font-size: 14px;
}
.radio-lable {
font-size: 14px;
}
.error-tips {
font-size: 12px;
height: 26px;
line-height: 26px;
margin-left: 20px;
.iconfont {
font-size: 12px;
margin-right: 5px;
}
}
.opreation {
cursor: pointer;
}
}
}
}
.address-table {
.table-title {
font-size: 10px;
height: 40px;
line-height: 40px;
}
.a-table {
tr,
th,
td {
font-size: 15px;
border: 1px solid #eee;
padding: 0 5px;
text-align: left;
}
.opreation {
cursor: pointer;
}
.table-head {
background: #f5f5f5;
height: 30px;
}
.table-body td {
padding: 8px 5px;
}
.width-80 {
width: 80px;
}
.width-195 {
width: 195px;
}
.width-255 {
width: 255px;
word-break: break-all;
}
.width-120 {
width: 120px;
p:first-child {
margin-bottom: 5px;
}
}
.width-260 {
width: 260px;
}
.current-default,
.set-default {
display: inline-block;
margin-left: 20px;
}
}
}
... ...
... ... @@ -101,4 +101,5 @@
}
}
@import "address";
@import "order/index";
... ...
... ... @@ -207,5 +207,10 @@
}
}
}
.blk-pagination {
margin: $bigSpace auto -$bigSpace;
text-align: center;
}
}
... ...