Authored by xuqi

replace hbs with webpack loader

... ... @@ -203,58 +203,7 @@
{{/ shopping_cart_data}}
</div>
<script id="balance-tpl" type="text/html">
\{{#each promotion_formula_list}}
<li>
<span class="balance-title">\{{promotion}}</span>
<span class="balance-cost">\{{promotion_amount}}</span>
</li>
\{{/each}}
<li class="need-pay">
<span class="balance-title">应付金额\{{#if shipping_cost}}(含运费)\{{/if}}:</span>
<span id="balance-cost" class="balance-cost" data-cost="{{last_order_amount}}">¥<em>\{{round last_order_amount 2}}</em></span>
</li>
<li>
<span id="submit-order" class="btn submit-order">提交订单</span>
</li>
</script>
<script id="address-list-tpl" type="text/html">
\{{#each address}}
<li class="address\{{#isY is_default}} default\{{/isY}}\{{#if focus}} focus\{{/if}}"
data-id="\{{address_id}}" data-name="\{{consignee}}" data-mobile="\{{mobile}}"
data-phone="\{{phone}}" data-areacode="\{{area_code}}" data-area="\{{area}}"" data-address="\{{address}}">
<div class="address-header"></div>
<div class="address-content">
<p class="default-or-not">
<span class="default-tag">默认地址</span>
<span class="set-default">设为默认</span>
</p>
<p class="name-and-phone">
\{{consignee}}
<span class="phone bold">\{{mobile}}</span>
</p>
<p class="address-area bold">\{{area}}</p>
<p class="address-detail">\{{address}}</p>
<p class="address-opration">
<span class="modify">修改</span>
<span class="delete">删除</span>
</p>
</div>
<span class="address-chosed iconfont">&#xe63b;</span>
</li>
\{{/each}}
\{{#if hasNew}}
<li class="new-address-block">
<span class="iconfont">&#xe645;</span>
增加收货地址
</li>
\{{/if}}
</script>
{{!-- 服务端渲染,客户端使用 --}}
<script id="invoice-dialog-tpl" type="text/html">
<p class="dialog-title">发票信息</p>
<ul class="invoice-tab">
... ... @@ -303,101 +252,6 @@
</div>
</div>
</script>
<script id="address-dialog-tpl" type="text/html">
<p class="dialog-title">
\{{#if updateAddress}}
修改地址
\{{^}}
新增地址
\{{/if}}
</p>
<form id="address-form" name="address-form">
<div class="address-page">
<span class="tip">
<em class="blue">
\{{#if updateAddress}}
修改地址
\{{^}}
新增地址
\{{/if}}
</em>
电话为选填项,其他均为必填项
</span>
<div class="add-address-detail" data-id="\{{id}}">
<div class="form-group">
<label class="label-name">
<em class="required-mark">*</em>
收货人:
</label>
<input class="input address-name" type="text" placeholder="请输入您的姓名" maxlength="12" value="\{{name}}">
<span class="blue error-tips">
{{> icon/error-round}}
<em></em>
</span>
</div>
<div class="form-group clearfix">
<label class="label-name">
<em class="required-mark">*</em>
所在区域:
</label>
<div id="address" class="clearfix"></div>
<span class="blue error-tips">
{{> icon/error-round}}
请填写完整的省市区信息
</span>
</div>
<div class="form-group">
<label class="label-name">
<em class="required-mark">*</em>
详细地址:
</label>
<input class="input address-detail" type="text" placeholder="街道名称或小区名称" maxlength="60" value="\{{detail}}">
<span class="blue error-tips">
{{> icon/error-round}}
<em></em>
</span>
</div>
<div class="form-group">
<label class="label-name">
<em class="required-mark">*</em>
手机号码:
</label>
<input class="input address-mobile" type="text" placeholder="请输入手机号码(重要必填)" maxlength="11" value="\{{mobile}}">
<span class="blue error-tips">
{{> icon/error-round}}
<em></em>
</span>
</div>
<div class="form-group">
<label class="label-name">电话号码:</label>
<input class="input address-phone" type="text" placeholder="请输入电话号码(选填)" value="\{{phone}}" maxlength="15">
<span class="blue error-tips">
{{> icon/error-round}}
<em></em>
</span>
</div>
</div>
</div>
</form>
</script>
<script id="checked-invoice-show-tpl" type="text/html">
<div class="invoice-radio">
\{{#if checked}}
<span class="iconfont radio checked">&#xe603;</span>
\{{^}}
<span class="iconfont radio">&#xe604;</span>
\{{/if}}
<label>发票开具</label>
</div>
\{{#if invoiceTitle}}
<p class="invoice-detail" data-title="\{{invoiceTitle}}" data-content="\{{content}}">
<em>\{{invoiceTitle}}</em><em>\{{invoiceContent}}</em>
<span class="modify-invoice btn white">修改</span>
</p>
\{{/if}}
</script>
</div>
{{/ content}}
</div>
\ No newline at end of file
... ...
/**
* 判断值是否是'Y'
* @author: xuqi<qi.xu@yoho.cn>
* @date: 2016/7/27
*/
module.exports = function(value, options) {
if (value === 'Y') {
return options.fn(this);
} else {
return options.inverse(this);
}
};
... ...
/**
* 精确n位小数
* @author: xuqi<qi.xu@yoho.cn>
* @date: 2016/7/27
*/
/**
* @param num 数字
* @param precision 精确度,默认2
*/
module.exports = function(num, precision) {
precision = precision ? parseInt(precision, 10) : 2;
num = (num === +num) ? (+num).toFixed(precision) : (Math.round(num, precision)).toFixed(precision);
return num;
};
... ...
... ... @@ -5,7 +5,6 @@
*/
var $ = require('yoho-jquery'),
Hbs = require('yoho-handlebars'),
lazyLoad = require('yoho-jquery-lazyload');
var Alert = require('../plugins/dialog').Alert;
... ... @@ -34,7 +33,7 @@ var $printPrice = $('#print-price');
var $invoice = $('#invoice-content');
var balanceTpl = Hbs.compile($('#balance-tpl').html());
var balanceTpl = require('../../tpl/shopping/balance.hbs');
var pkgCache = {};
... ... @@ -47,13 +46,6 @@ require('../plugins/check'); // before 地址和发票
require('./order/address'); // 地址
require('./order/invoice'); // 发票
// clint helper round
Hbs.registerHelper('round', function(num, precision) {
precision = precision ? parseInt(precision, 10) : 2;
num = (num === +num) ? (+num).toFixed(precision) : (Math.round(num, precision)).toFixed(precision);
return num;
});
lazyLoad($('img.lazy'));
// dot
... ...
... ... @@ -5,7 +5,6 @@
*/
var $ = require('yoho-jquery'),
Hbs = require('yoho-handlebars'),
cascadingAddress = require('../../plugins/cascading-address'),
common = require('../../common'),
popup = require('../../plugins/dialog');
... ... @@ -41,17 +40,8 @@ function setAllOfAddress() {
}
}
// 判断是否是Y
Hbs.registerHelper('isY', function(value, options) {
if (value === 'Y') {
return options.fn(this);
} else {
return options.inverse(this);
}
});
addressDialogTpl = Hbs.compile($('#address-dialog-tpl').html());
addressTpl = Hbs.compile($('#address-list-tpl').html());
addressDialogTpl = require('../../../tpl/shopping/address-dialog.hbs');
addressTpl = require('../../../tpl/shopping/address-list.hbs');
// address dialog 数据验证
function validateAddress($el) {
... ...
... ... @@ -5,10 +5,9 @@
*/
var $ = require('yoho-jquery'),
hbs = require('yoho-handlebars'),
Dialog = require('../../plugins/dialog').Dialog;
var checkedInvoiceTpl = hbs.compile($('#checked-invoice-show-tpl').html());
var checkedInvoiceTpl = require('../../../tpl/shopping/checked-invoice-show.hbs');
var $invoiceContent = $('#invoice-content');
... ...
<p class="dialog-title">
{{#if updateAddress}}
修改地址
{{^}}
新增地址
{{/if}}
</p>
<form id="address-form" name="address-form">
<div class="address-page">
<span class="tip">
<em class="blue">
{{#if updateAddress}}
修改地址
{{^}}
新增地址
{{/if}}
</em>
电话为选填项,其他均为必填项
</span>
<div class="add-address-detail" data-id="{{id}}">
<div class="form-group">
<label class="label-name">
<em class="required-mark">*</em>
收货人:
</label>
<input class="input address-name" type="text" placeholder="请输入您的姓名" maxlength="12" value="{{name}}">
<span class="blue error-tips">
{{> error-round}}
<em></em>
</span>
</div>
<div class="form-group clearfix">
<label class="label-name">
<em class="required-mark">*</em>
所在区域:
</label>
<div id="address" class="clearfix"></div>
<span class="blue error-tips">
{{> error-round}}
请填写完整的省市区信息
</span>
</div>
<div class="form-group">
<label class="label-name">
<em class="required-mark">*</em>
详细地址:
</label>
<input class="input address-detail" type="text" placeholder="街道名称或小区名称" maxlength="60" value="{{detail}}">
<span class="blue error-tips">
{{> error-round}}
<em></em>
</span>
</div>
<div class="form-group">
<label class="label-name">
<em class="required-mark">*</em>
手机号码:
</label>
<input class="input address-mobile" type="text" placeholder="请输入手机号码(重要必填)" maxlength="11" value="{{mobile}}">
<span class="blue error-tips">
{{> error-round}}
<em></em>
</span>
</div>
<div class="form-group">
<label class="label-name">电话号码:</label>
<input class="input address-phone" type="text" placeholder="请输入电话号码(选填)" value="{{phone}}" maxlength="15">
<span class="blue error-tips">
{{> error-round}}
<em></em>
</span>
</div>
</div>
</div>
</form>
\ No newline at end of file
... ...
{{#each address}}
<li class="address{{#isY is_default}} default{{/isY}}{{#if focus}} focus{{/if}}"
data-id="{{address_id}}" data-name="{{consignee}}" data-mobile="{{mobile}}"
data-phone="{{phone}}" data-areacode="{{area_code}}" data-area="{{area}}"" data-address="{{address}}">
<div class="address-header"></div>
<div class="address-content">
<p class="default-or-not">
<span class="default-tag">默认地址</span>
<span class="set-default">设为默认</span>
</p>
<p class="name-and-phone">
{{consignee}}
<span class="phone bold">{{mobile}}</span>
</p>
<p class="address-area bold">{{area}}</p>
<p class="address-detail">{{address}}</p>
<p class="address-opration">
<span class="modify">修改</span>
<span class="delete">删除</span>
</p>
</div>
<span class="address-chosed iconfont">&#xe63b;</span>
</li>
{{/each}}
{{#if hasNew}}
<li class="new-address-block">
<span class="iconfont">&#xe645;</span>
增加收货地址
</li>
{{/if}}
\ No newline at end of file
... ...
{{#each promotion_formula_list}}
<li>
<span class="balance-title">{{promotion}}</span>
<span class="balance-cost">{{promotion_amount}}</span>
</li>
{{/each}}
<li class="need-pay">
<span class="balance-title">应付金额{{#if shipping_cost}}(含运费){{/if}}</span>
<span id="balance-cost" class="balance-cost" data-cost="{{last_order_amount}}">¥<em>{{round last_order_amount 2}}</em></span>
</li>
<li>
<span id="submit-order" class="btn submit-order">提交订单</span>
</li>
\ No newline at end of file
... ...
<div class="invoice-radio">
{{#if checked}}
<span class="iconfont radio checked">&#xe603;</span>
{{^}}
<span class="iconfont radio">&#xe604;</span>
{{/if}}
<label>发票开具</label>
</div>
{{#if invoiceTitle}}
<p class="invoice-detail" data-title="{{invoiceTitle}}" data-content="{{content}}">
<em>{{invoiceTitle}}</em><em>{{invoiceContent}}</em>
<span class="modify-invoice btn white">修改</span>
</p>
{{/if}}
\ No newline at end of file
... ...
<span class="iconfont">&#xe60c;</span>
\ No newline at end of file
... ...
... ... @@ -39,7 +39,7 @@ module.exports = {
loaders: [
{
test: /\.hbs$/,
loader: 'handlebars-loader'
loader: `handlebars-loader?helperDirs[]=${__dirname}/helper`
}
]
},
... ...