Authored by 姜敏

收货地址--样式调整。出错提示修改。

... ... @@ -7,38 +7,55 @@
'use strict';
const mcHandler = require('../models/menu-crumb-handler');
// const currencyModel = require('../models/currency');
const currencyModel = require('../models/currency');
/**
* yoho币页面加载
*/
// {page: 1, limit: 15, type: 0, beginTime: new Date()}
const index = (req, res) => {
res.render('index', {
module: 'me',
page: 'currency',
isMe: true,
content: {
nav: mcHandler.getMeCrumb(),
navigation: mcHandler.getSideMenu('YOHO币'),
banner: 'http://placehold.it/150x120',
currency: true,
tabs: [
{
text: '全部明细',
isActive: true,
type: 'all'
},
{
text: '全部收入',
type: 'paying'
},
{
text: '全部支出',
type: 'delivering'
}
],
title: 'YOHO币'
}
let uid = req.body.uid;
// let date=new Date().Format('yyyy-MM-dd');
currencyModel.yohoCoinList(uid, {
page: 1,
limit: 15,
type: 0,
beginTime: '2016-01-13'
}).then(result=> {
console.log(result);
res.render('index', {
module: 'me',
page: 'currency',
isMe: true,
content: {
nav: mcHandler.getMeCrumb(),
navigation: mcHandler.getSideMenu('YOHO币'),
banner: 'http://placehold.it/150x120',
currency: true,
tabs: [
{
text: '全部明细',
isActive: true,
type: 'all'
},
{
text: '全部收入',
type: 'paying'
},
{
text: '全部支出',
type: 'delivering'
}
],
title: '我的YOHO币',
currentYear: new Date().getFullYear(),
data: result
}
});
});
};
... ...
... ... @@ -6,5 +6,43 @@
'use strict';
// const api = global.yoho.API;
const api = global.yoho.API;
/**
* yoho币列表
* @param uid
* @param condition
* @returns {*}
*/
const yohoCoinList = (uid, condition) => {
return api.get('', {
method: 'app.yohocoin.lists',
uid: uid,
page: condition.page || 1,
limit: condition.limit || 15,
queryType: condition.queryType,
beginTime: condition.beginTime
}).then(result => {
return result;
});
};
/**
* yoho币总数
* @param uid
* @returns {*}
*/
const yohoCoinTotal = (uid)=> {
return api.get('', {
method: 'app.yoho.yohocoin',
uid: uid
}).then(result => {
return result;
});
};
module.exports = {
yohoCoinList: yohoCoinList,
yohoCoinTotal: yohoCoinTotal
};
... ...
... ... @@ -29,8 +29,10 @@
</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 class="input-radio default-address opreation" data-value="N">
{{> icon/radio}}
<label class="radio-lable">设置为默认收货地址</label>
</div>
</div>
<div class="form-group">
<span class="btn opreation" id="save-address">保存</span>
... ...
<div class="user-order">
<div class="user-currency">
{{> common/subtitle}}
<div class="currency-title">
<div class="inline-block yohocoin-icon">
图标
</div>
<div class="inline-block total-yohocoin">
<div class="current-yohocoin">目前可用YOHO币:<span class="blue">1000</span></div>
<div class="left-yohocoin">{{currentYear}}年12月31日即将过期:<span class="blue">550</span></div>
</div>
</div>
{{> currency/nav}}
{{> currency/table-header}}
</div>
... ...
... ... @@ -5,7 +5,6 @@
{{/tabs}}
</ul>
<div class="search-bar">
<!-- <input class="search-ctrl" type="text" placeholder="商品名称和订单号">
<button class="search-ctrl">搜索订单</button>-->
<span class="blue">{{> icon/doubt}}什么是YOHO币</span>
</div>
</div>
... ...
<div class="table column-category">
<ul class="table-header header">
<li class="normal-width">日期</li>
<li class="normal-width">收入/支出</li>
<li class="big-width">详细说明</li>
</ul>
</div>
... ...
... ... @@ -3,6 +3,7 @@
* @author: jiangmin
* @date: 2016/07/05
*/
// todo uid为假值;编辑时设置默认;省市区重置;手机号码逆向显示
var cascadingAddress = require('../plugins/cascading-address');
var dialog = require('../plugins/dialog');
... ... @@ -13,55 +14,26 @@ var $consignee = $('#consignee');
var $address = $('#addressDetail');
var $mobile = $('#mobile');
var $phone = $('#phone');
// var $default = 'N';
var currentLength = $('.a-table').find('tr').length - 1;// 当前地址条数
var leftLength = 20 - currentLength;// 还剩地址条数
var reg = new RegExp(/^(0|86|17951)?(13[0-9]|15[012356789]|17[678]|18[0-9]|14[57])[0-9]{8}$/);// 手机号码校验
require('./me');
require('../plugins/check');
// 设置收货地址
$('.default-address').click(function() {
if ($(this).hasClass('checked')) {
$(this).removeClass('checked');
$(this).html('&#xe604;');
} else {
$(this).addClass('checked');
$(this).html('&#xe603;');
}
$('.input-radio').check({
type: 'radio'
// onChange: function(ele, checked) {
// if (checked) {
// $default = 'Y';
// } else {
// $default = 'N';
// }
// }
});
// 校验
$consignee.focus(function() {
$(this).next().hide();
});
$consignee.blur(function() {
if ($(this).val().trim() === '') {
$(this).next().show();
}
});
$address.focus(function() {
$(this).next().hide();
});
$address.blur(function() {
if ($(this).val().trim() === '') {
$(this).next().show();
}
});
$mobile.focus(function() {
$(this).next().hide();
});
$mobile.blur(function() {
if ($(this).val().trim() === '') {
$(this).next().show();
} else {
if (!reg.test(($(this).val().trim()))) {
$(this).next().show();
$(this).next().html('手机号码格式不正确');
}
}
});
$(function() {
// 运行此demo
// 1. 安装 npm i -g json-server
... ... @@ -72,10 +44,12 @@ $(function() {
resource: 'areas'
});
/**
* 公共方法
*/
var Bll = {
// 获取输入框输入的值
getInfo() {
// todo uid
var uid = '123456';
return {
... ... @@ -85,36 +59,32 @@ $(function() {
address: $address.val(),
mobile: $mobile.val(),
phone: $phone.val()
// todo 设置默认值
};
},
// 清空输入框
clearInput() {
$consignee.val('');
// todo 省市区清空
address.setAddress({
province: '', // 省
city: '', // 市
dist: '' // 区县
});
$address.val('');
$mobile.val('');
$phone.val('');
address.reset();
},
// 校验
check(info) {
let flag = true;
if (info.consignee === '' || info.address === '' || info.mobile === '') {
flag = '有必填项为空';
} else if (!reg.test(info.mobile)) {
flag = '手机号码格式不对';
} else if (typeof (info.area_code) === 'undefined') {
flag = '所在区域请选择到:区';
let addressForm = $('.form-group1');
info.consignee === '' ? $consignee.next().show() : $consignee.next().hide();
info.address === '' ? $address.next().show() : $address.next().hide();
info.mobile === '' ? $mobile.next().show() :
(!reg.test(info.mobile) ? $mobile.next().html('手机号码格式不对').show() : $mobile.next().hide());
typeof (info.area_code) === 'undefined' ? addressForm.find('.error-tips').show() :
addressForm.find('.error-tips').hide();
if (info.consignee === '' || info.address === '' || info.mobile === '' || !reg.test(info.mobile) ||
typeof (info.area_code) === 'undefined') {
flag = false;
}
return flag;
},
... ... @@ -141,8 +111,6 @@ $(function() {
setInfo(id, td) {
$addressId.val(id);
$consignee.val(td.eq(0).text());
// todo 省市区逆向展示
$address.val(td.eq(2).text());
$mobile.val(td.eq(3).children().eq(0).text());
$phone.val(td.eq(3).children().eq(1).text());
... ... @@ -185,8 +153,6 @@ $(function() {
$('tbody').append(html);
Bll.setTableTile();
Bll.clearInput();
// location.href="/me/address";
} else {
new _alert('新增接口出错了').show();
}
... ... @@ -204,19 +170,14 @@ $(function() {
info.address_id = info.id;
$('#tr_' + info.id).parent().before(Bll.getHtml(info)).remove();
Bll.clearInput();
// location.href="/me/address";
} else {
new _alert('修改接口出错了').show();
}
}
});
}
} else {
new _alert(Bll.check(info)).show();
}
}
});
// 修改收货地址
... ... @@ -224,8 +185,15 @@ $(function() {
let id = $(this).data('id');
let tr = $(this).parents('.table-body');
let td = tr.find('td');
let areaCode = tr.find('input').eq(1).val();
address.setAddress({
province: areaCode.substring(0, 2), // 省
city: areaCode.substring(0, 4), // 市
dist: areaCode // 区县
});
$('.error-tips').hide();
$('.tip').html('修改地址 电话为选填项,其他均为必填项');
Bll.setInfo(id, td);
});
... ... @@ -242,7 +210,6 @@ $(function() {
url: '/me/address/del',
dataType: 'json',
data: {
// todo uid
uid: '123456',
id: id
},
... ... @@ -272,7 +239,6 @@ $(function() {
url: '/me/address/default',
dataType: 'json',
data: {
// todo uid
uid: '123456',
id: id
},
... ...
... ... @@ -3,3 +3,26 @@
* @author: jiangmin
* @date: 2016/07/11
*/
require('./me');
$('.tabs li').on('click', function() {
var $this = $(this);
// var typeMap = {
// all: 1,
// paying: 2,
// delivering: 3
// };
// var type = typeMap[$this.data('type')];
// var page = getQueryString().page;
if (!$this.hasClass('active')) {
$('.tabs li.active').removeClass('active');
$this.addClass('active');
// todo 获取数据展示
}
});
... ...
.currency-title {
width: 100%;
height: 90px;
border: solid #eee 1px;
margin-bottom: 30px;
padding: 20px 10px;
.yohocoin-icon {
width: 90px;
text-align: center;
}
.total-yohocoin {
margin-left: 20px;
}
.current-yohocoin {
font-size: 18px;
margin-bottom: 18px;
}
.left-yohocoin {
font-size: 12px;
color: #666;
}
}
... ...