Authored by biao

Merge branch 'develop' of http://git.yoho.cn/fe/yoho-blk into develop

/**
* [个人中心]首页/我的订单
* @author: xuqi<qi.xu@yoho.cn>
* @date: 2016/07/04
*/
'use strict';
/**
* 订单
*/
const index = (req, res) => {
res.render('index', {
module: 'me',
page: 'order',
isMe: true,
content: {
nav: [
{
link: '//www.yohoblk.com',
name: 'YOHO!BLK首页'
},
{
link: '//www.yohoblk.com/me',
name: '个人中心'
},
{
link: '//www.yohoblk.com/me',
name: '我的订单'
}
],
navigation: [
{
focus: true,
link: '/me/order',
name: '我的订单'
},
{
link: '/me/return',
name: '我的退/换货'
},
{
link: '/me/collection',
name: '我的收藏'
},
{
link: '/me/message',
name: '我的消息'
},
{
link: '/me/currency',
name: '我的YOHO币'
},
{
link: '/me/setting',
name: '个人设置'
},
{
link: '/me/address',
name: '收货地址'
}
],
banner: 'http://placehold.it/150x120'
}
});
};
module.exports = {
index
};
... ...
/**
* sub app me
* @author: xuqi<qi.xu@yoho.cn>
* @date: 2016/07/04
*/
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
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: 'helpers'
}));
// router
app.use(require('./router'));
module.exports = app;
... ...
/**
* router of sub app me
* @author: xuqi<qi.xu@yoho.cn>
* @date: 2016/07/04
*/
'use strict';
const router = require('express').Router(); // eslint-disable-line
const cRoot = './controllers';
// 订单
const order = require(`${cRoot}/order`);
// 个人中心首页/订单
router.get('/', order.index);
module.exports = router;
... ...
<div class="me-page blk-page clearfix">
<div class="center-content">
{{# content}}
{{!-- 头部面包屑 --}}
{{> path-nav}}
{{!-- 左侧菜单导航 --}}
<div class="me-navigation left">
<p class="title bold">MY YOHO!BLK</p>
<ul class="nav">
{{#each navigation}}
<li class="nav-row{{#if focus}} focus{{/if}}">
<a href="{{link}}">{{name}}</a>
</li>
{{/each}}
</ul>
{{#if banner}}
<img class="banner-img" data-original="{{banner}}">
{{/if}}
</div>
{{!-- 右侧页面内容 --}}
<div class="me-main left">
{{!-- 我的订单 --}}
{{#if order}}
{{> order}}
{{/if}}
{{!-- 我的退换货 --}}
{{#if return}}
{{> return}}
{{/if}}
{{!-- 我的收藏 --}}
{{#if collection}}
{{> collection}}
{{/if}}
{{!-- 我的消息 --}}
{{#if message}}
{{> message}}
{{/if}}
{{!-- 我的YOHO币 --}}
{{#if currency}}
{{> curency}}
{{/if}}
{{!-- 个人设置 --}}
{{#if setting}}
{{> setting}}
{{/if}}
{{!-- 收货地址 --}}
{{#if address}}
{{> address}}
{{/if}}
</div>
{{/ content}}
</div>
{{!-- 在线客服和返回顶部 --}}
<div class="service-top">
<a class="service" href="" target="_blank">
<span class="iconfont">&#xe61c;</span>
<span class="hover-text hide">在线<br>客服</span>
</a>
<div class="return-top">
<span class="iconfont bold">&#xe617;</span>
<span class="hover-text hide">返回<br>顶部</span>
</div>
</div>
</div>
\ No newline at end of file
... ...
I am order
\ No newline at end of file
... ...
... ... @@ -123,34 +123,38 @@
{{> icon/solid-round}}
{{> icon/collection}}
{{> icon/bookmarks}}
{{> icon/refresh}}
{{> icon/headset}}
</div>
</ul>
</div>
<p style="margin-top: 20px;">14. 区域/选择地址组件</p>
<div style="padding: 5px; height: 300px;">
<div id="address"></div>
</div>
{{/ content}}
<p class="title">14. tips</p>
<div>
<button id="change" >show or hide tip</button>
</div>
<div id="tips" style="width: 200px;">
<input style="width: 100%;" type="text" name="" id="">
</div>
<p class="title">14. tips</p>
<div>
<button id="change" >show or hide tip</button>
</div>
<div id="tips" style="width: 200px;">
<input style="width: 100%;" type="text" name="" id="">
</div>
<p class="title">15. 头像</p>
<p class="title">15. 头像</p>
<div>
<img class="avatar" src="http://devlup.com/wp-content/uploads/2013/07/images.jpg" alt="Braden Hamm">
</div>
<div>
<img class="avatar" src="http://devlup.com/wp-content/uploads/2013/07/images.jpg" alt="Braden Hamm">
</div>
<p class="title">16. 对话框(弹窗)</p>
<span class="btn alert-btn">alert</span>
<span class="btn red confirm-btn">confirm</span>
<span class="btn white dialog-btn">dialog</span>
<p class="title">16. 对话框(弹窗)</p>
<span class="btn alert-btn">alert</span>
<span class="btn red confirm-btn">confirm</span>
<span class="btn white dialog-btn">dialog</span>
{{/ content}}
</div>
</div>
\ No newline at end of file
... ...
/**
* 注册数据接口
*
* @author JiangFeng<jeff.jiang@yoho.cn>
* @date 2016/06/21
*/
'use strict';
const api = global.yoho.API;
const BindService = {
bindCheck(mobile, openId, sourceType, area) {
let params = {
method: 'app.passport.signCheck',
area: area,
mobile: mobile,
open_id: openId,
source_type: sourceType
};
return api.get('', params);
},
sendBindMsg(area, mobile) {
let params = {
method: 'app.passport.smsbind',
mobile: mobile,
area: area
};
return api.get('', params);
},
checkBindCode(area, mobile, code) {
return api.get('', {
method: 'app.register.validRegCode',
mobile: mobile,
area: area,
code: code
});
},
bindMobile(openId, sourceType, mobile, area, password, nickname) {
let params = {
method: 'app.passport.bind',
mobile: mobile,
open_id: openId,
source_type: sourceType,
area: area
};
if (password) {
params.password = password;
}
if (nickname) {
params.nickname = nickname;
}
return api.get('', params);
},
relateMobile(openId, sourceType, mobile, area) {
return api.get('', {
method: 'app.passport.relateMobile',
mobile: mobile,
openId: openId,
source_type: sourceType,
area: area
});
},
changeCheck(mobile, area) {
return api.get('', {
method: 'app.passport.changeCheck',
mobile: mobile,
area: area
});
},
changeMobile(uid, mobile, area, code) {
return api.get('', {
method: 'app.passport.changeMobile',
mobile: mobile,
uid: uid,
code: code,
area: area
});
}
};
module.exports = BindService;
... ...
/**
* Created by TaoHuang on 2016/7/1.
*/
'use strict';
const _ = require('lodash');
const Captchapng = require('captchapng');
exports.generateCaptcha = (width, height, length) => {
let min = Math.pow(10, (length - 1 || 1));
let max = Math.pow(10, (length - 1 || 1)) * 9;
let token = '' + _.random(min, max);
let png = new Captchapng(width, height, token);//
png.color(0, 0, 0, 0); // First color: background (red, green, blue, alpha)
png.color(80, 80, 80, 255); // Second color: paint (red, green, blue, alpha)
return {
image: new Buffer(png.getBase64(), 'base64'),
text: token
};
};
... ...
... ... @@ -10,5 +10,7 @@ module.exports = app => {
app.use('/partial', require('./apps/partial')); // 组件demo
// 业务模块
//app.use('/passport', require('./apps/passport'));
// app.use('/passport', require('./apps/passport'));
app.use('/me', require('./apps/me')); // 个人中心
};
... ...
... ... @@ -15,4 +15,7 @@
<p>NewPower Co. 版权所有 经营许可证编号:苏B2-20120395</p>
</div>
</div>
<div class="return-top hide">
{{> icon/up}}
</div>
</div>
\ No newline at end of file
... ...
<span class="iconfont">&#xe61c;</span>
\ No newline at end of file
... ...
<span class="iconfont">&#xe613;</span>
\ No newline at end of file
... ...
{{#if nav}}
<p class="path-nav">
{{#each pathNav}}
{{#if href}}
<a {{#if @last}}class="last"{{/if}} href="{{href}}" title="{{pathTitle}}">{{{name}}}</a>
{{#each nav}}
{{#if link}}
<a {{#if @last}}class="last"{{/if}} href="{{link}}" title="{{pathTitle}}">{{{name}}}</a>
{{^}}
<span {{#if @last}}class="last"{{/if}} title="{{pathTitle}}">{{{name}}}</span>
{{/if}}
... ...
No preview for this file type
... ... @@ -2,7 +2,7 @@
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" >
<svg xmlns="http://www.w3.org/2000/svg">
<metadata>
Created by FontForge 20120731 at Mon Jul 4 11:37:11 2016
Created by FontForge 20120731 at Mon Jul 4 15:42:03 2016
By admin
</metadata>
<defs>
... ... @@ -19,7 +19,7 @@ Created by FontForge 20120731 at Mon Jul 4 11:37:11 2016
bbox="0 -212 1303 896.303"
underline-thickness="50"
underline-position="-100"
unicode-range="U+0078-E61B"
unicode-range="U+0078-E61C"
/>
<missing-glyph horiz-adv-x="374"
d="M34 0v682h272v-682h-272zM68 34h204v614h-204v-614z" />
... ... @@ -82,6 +82,8 @@ d="M512 384zM64 384q0 91 35.5 174t95.5 143t143 95.5t174 35.5t174 -35.5t143 -95.5
d="M511 748q91 0 174 -35.5t143 -96t95.5 -143.5t35.5 -174t-35.5 -174t-96 -143t-143.5 -95.5t-173 -35.5q-92 0 -174.5 36t-142.5 96t-95.5 142.5t-36 173.5t35.5 174t96 143.5t143 96t174 35.5zM917 300q0 110 -54.5 203t-148 147.5t-203.5 54.5q-110 1 -203.5 -53.5
t-148 -148t-54.5 -203.5t54 -203.5t147.5 -148t204.5 -54.5q109 0 203 54t148.5 148t54.5 204zM536 155h-57v33q2 37 18 64q13 20 34 40q41 39 48 45q16 16 21 31q15 44 -16 81q-23 28 -60.5 32.5t-61.5 -11.5q-29 -17 -41 -55q-1 -1 -9 -32q-56 7 -61 7q2 15 3 15
q8 45 32 74q31 38 82 48q55 11 103 -5q68 -22 89 -84q21 -63 -20 -116q-6 -8 -14 -16.5t-14 -14.5t-16.5 -15.5t-14.5 -13.5q-18 -18 -26 -27q-15 -18 -17 -49q0 -2 -2 -31zM475 34v68h68v-68h-68z" />
<glyph glyph-name="uniE613" unicode="&#xe613;"
d="M795 342q0 -109 -78 -185.5t-188.5 -76.5t-189 76.5t-78.5 185t78.5 185.5t188.5 77q19 0 38 -3v75q-19 2 -38 2q-93 0 -172 -45t-125 -122.5t-46 -169t46 -169t125 -122.5t172 -45t172 45t125 122.5t46 169.5h-76zM566 790v-336l191 168z" />
<glyph glyph-name="uniE614" unicode="&#xe614;"
d="M911 725h-242v123q0 21 -13.5 34.5t-34.5 13.5h-246q-20 0 -33.5 -13.5t-13.5 -34.5v-123h-246q-21 0 -34.5 -13.5t-13.5 -34t13.5 -34t34.5 -13.5h293h243h293q21 0 34.5 13.5t13.5 34t-13.5 34t-34.5 13.5zM423 725v72h147v-72h-147zM765 579q-21 0 -34.5 -14
t-13.5 -34v-560h-441v560q0 20 -13.5 34t-34 14t-34 -14t-13.5 -34v-611q0 -21 13.5 -34.5t34.5 -13.5h536q20 0 33.5 13.5t13.5 34.5v611q3 20 -11.5 34t-35.5 14zM447 67v389q0 20 -13.5 33.5t-34 13.5t-34 -13.5t-13.5 -33.5v-389q0 -21 13.5 -34.5t34 -13.5t34 13.5
... ... @@ -105,5 +107,8 @@ t74 -31t31 -74z" />
<glyph glyph-name="uniE61B" unicode="&#xe61b;"
d="M512 -212q-104 0 -199 40.5t-163.5 109t-109 163.5t-40.5 199t40.5 199t109 163.5t163.5 109t199 40.5t199 -40.5t163.5 -109t109 -163.5t40.5 -199t-40.5 -199t-109 -163.5t-163.5 -109t-199 -40.5zM512 747q-91 0 -173.5 -35.5t-142.5 -95.5t-95.5 -142.5t-35.5 -173.5
t35.5 -173.5t95.5 -142.5t142.5 -95.5t173.5 -35.5t173.5 35.5t142.5 95.5t95.5 142.5t35.5 173.5t-35.5 173.5t-95.5 142.5t-142.5 95.5t-173.5 35.5zM482 267l-1 351h63v-319l198 -166l-39 -55z" />
<glyph glyph-name="uniE61C" unicode="&#xe61c;" horiz-adv-x="1093"
d="M1092 225v171q0 101 -39.5 193.5t-106.5 159.5t-160 107t-194 40h-92q-101 0 -193.5 -40t-159.5 -107t-107 -159.5t-40 -193.5v-173v-317q0 -14 10 -24t24 -10h175q15 0 24.5 10t9.5 24v317q0 15 -9.5 24.5t-24.5 9.5h-128v116q0 88 34 168t92 137.5t138 92t168 34.5h67
q87 0 167 -34.5t138 -92t92 -137.5t34 -168v-113h-129q-15 0 -24.5 -10t-9.5 -25v-317q0 -14 9.5 -24t24.5 -10h175q14 0 24 10t10 24z" />
</font>
</defs></svg>
... ...
No preview for this file type
No preview for this file type
# common使用规范
## 页面公共使用的前端资源
### header为页面通用头部
### return-top为返回页面顶部(通用,除个人中心页面)
* returnTopShowOrNot 是否显示返回顶部的按钮
### index暴露一些通用api,通过require('path/to/common')引用即可
* cookie 获取cookie
* setCookie 设置cookie
* queryString 解析url query
**请按需require**。此处与之前的项目不一样,接口将不直接暴露到window,需通过require去获取暴露的方法。
\ No newline at end of file
... ...
/**
* 页面公共逻辑和接口
* @author: xuqi<qi.xu@yoho.cn>
* @date: 2017/7/5
*/
function cookie(name) {
var re = new RegExp(name + '=([^;$]*)', 'i'),
matchPattern = '$1';
return re.test(decodeURIComponent(document.cookie)) ? RegExp[matchPattern] : '';
}
function setCookie(name, value, options) {
var expires = '',
path,
domain,
secure,
date;
if (typeof value !== 'undefined') {
options = options || {};
if (value === null) {
value = '';
options.expires = -1;
}
if (options.expires &&
(typeof options.expires === 'number' || options.expires.toUTCString)) {
if (typeof options.expires === 'number') {
date = new Date();
date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
} else {
date = options.expires;
}
expires = '; expires=' + date.toUTCString();
}
path = options.path ? '; path=' + options.path : '';
domain = options.domain ? '; domain=' + options.domain : '';
secure = options.secure ? '; secure' : '';
document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
}
}
function queryString() {
var vars = {},
hash,
i,
search = window.location.search,
hashes = search ? decodeURIComponent(search).slice(1).split('&') : [];
for (i = 0; i < hashes.length; i++) {
hash = hashes[i].split('=');
vars[hash[0]] = hash[1];
}
return vars;
}
module.exports = {
cookie: cookie, // 获取cookie
setCookie: setCookie, // 设置cookie
queryString: queryString // query参数解析
};
... ...
/**
* [公共底部]返回页面顶部
* @author: xuqi<qi.xu@yoho.cn>
* @date: 2016/07/05
*/
var $ = require('yoho-jquery');
var $returnTop = $('.return-top');
function showOrNot() {
if ($(window).height() > $(document).height()) {
$returnTop.addClass('hide');
}
}
$returnTop.click(function() {
$('html,body').animate({
scrollTop: 0
}, 500);
});
$(window).scroll(function() {
if ($(window).scrollTop() === 0) {
$returnTop.addClass('hide');
} else {
$returnTop.removeClass('hide');
}
});
exports.returnTopShowOrNot = showOrNot;
... ...
/**
* 个人中心布局
* @author: xuqi<qi.xu@yoho.cn>
* @date: 2016/07/04
*/
var $ = require('yoho-jquery'),
lazyLoad = require('yoho-jquery-lazyload');
// 左侧banner图片lazyload
lazyLoad($('.banner-img'));
// 浮动在线客服和返回顶部的鼠标移入移出切换效果
$('.service, .return-top').hover(function() {
$(this).find('.iconfont').addClass('hide').end().find('.hover-text').removeClass('hide');
}, function() {
$(this).find('.iconfont').removeClass('hide').end().find('.hover-text').addClass('hide');
});
... ...
/**
* [个人中心]首页/我的订单
* @author: xuqi<qi.xu@yoho.cn>
* @date: 2016/07/04
*/
require('./me');
... ...
var $ = require('yoho-jquery'),
lazyLoad = require('yoho-jquery-lazyload'),
dialog = require('../common/dialog');
dialog = require('../plugins/dialog');
var _dialog = dialog.Dialog,
_alert = dialog.Alert,
_confirm = dialog.Confirm;
var cascadingAddress = require('../plugins/cascading-address');
var tips = $('#tips');
var change = $('#change');
var show = false;
require('../plugins/tips');
$('.alert-btn').click(function() {
new _alert('购买成功<br>进入 个人中心>我的订单<br>查看门票信息').show();
});
... ... @@ -46,21 +53,15 @@ $('.dialog-btn').click(function() {
}).show();
});
require('../plugins/tips');
lazyLoad($('img.lazy'));
var tips = $('#tips');
var change = $('#change');
var show = false;
change.click(function () {
"use strict";
change.click(function() {
'use strict';
if (show) {
tips.tips('hide');
show = false;
} else {
tips.tips("show", "×该用户已存在");
tips.tips('show', '×该用户已存在');
show = true;
}
... ...
... ... @@ -88,7 +88,7 @@ function Dialog(options) {
Dialog.prototype.close = function() {
this.$mask && this.$mask.addClass('hide');
this.$el.remove();
return this;
};
... ...
... ... @@ -205,6 +205,11 @@ a {
left: 0;
}
.center-content {
width: 1150px;
margin: 0 auto;
}
.block {
display: block;
}
... ...
@import "header";
@import "sign-header";
@import "footer";
@import "dialog";
.yoho-footer {
background: #fff;
.center-content {
border-top: 2px solid #eee;
}
... ... @@ -21,4 +23,26 @@
text-align: center;
padding: 15px 0;
}
.return-top {
width: 50px;
height: 50px;
line-height: 50px;
text-align: center;
background: #000;
opacity: 0.5;
position: fixed;
left: 50%;
bottom: 20px;
margin-left: 595px;
cursor: pointer;
.iconfont {
color: #fff;
}
&.min {
margin-left: 505px;
}
}
}
... ...
.center-content {
width: 1150px;
margin: 0 auto;
}
.yoho-header {
height: 50px;
line-height: 50px;
... ...
@import "header";
@import "sign-header";
@import "footer";
@import "pagination"; /* 分页 */
@import "goods"; /* 商品 */
@import "path-nav"; /* 面包屑 */
@import "floor"; /* 楼层头部 */
@import "cascading-address"; /* 区域/地址组件 */
@import "dialog"; /* 对话框组件 */
... ...
.path-nav {
font-size: 14px;
height: 48px;
line-height: 48px;
height: 50px;
line-height: 50px;
a {
color: #666;
... ...
@charset "utf-8";
/* 公共 */
@import "common/index";
@import "base";
@import "components/index";
@import "plugin/index";
/* 模块 */
@import "base";
@import "components/index";
@import "me/index";
@import "channel/index";
... ...
.me-page {
padding-bottom: 30px;
background: #f5f5f5;
/* 个人中心布局下重置默认的底部样式 */
+ .yoho-footer .center-content {
border-top: none;
}
/* 左侧导航 */
.me-navigation {
width: 150px;
margin-right: 10px;
.title {
height: 60px;
line-height: 60px;
text-align: center;
background: #fff;
}
.nav-row {
height: 40px;
line-height: 40px;
color: #cecece;
background: #fff;
a {
display: block;
height: 100%;
width: 100%;
padding-left: 20px;
border-left: 2px solid #fff;
}
&.focus {
background: #eee;
color: #000;
a {
border-color: #000;
}
}
}
.banner-img {
width: 150px;
height: 120px;
margin-top: 10px;
}
}
.me-main {
width: 990px;
}
.service-top {
position: fixed;
left: 50%;
bottom: 20px;
border: 1px solid #eee;
background: #fff;
cursor: pointer;
z-index: 2;
margin-left: 625px;
.service,
.return-top {
display: block;
width: 50px;
height: 50px;
padding-top: 13px;
text-align: center;
&:hover {
padding-top: 8px;
}
}
.return-top {
border-top: 1px solid #eee;
}
.hover-text {
font-size: 12px;
}
}
}
... ...