Authored by 沈志敏

Merge branch 'feature/home' into develop

... ... @@ -23,10 +23,7 @@ const fav = {
}
},
favpaging: (req, res, next) => {
let uid = req.user.uid;
uid = 20000134; // 测试uid
const uid = req.user.uid || 14459668;
const tab = req.query.tab;
const page = req.query.page;
... ... @@ -43,10 +40,7 @@ const fav = {
}
},
deletefav: (req, res, next) => {
let uid = req.user.uid;
uid = 20000134; // 测试uid
const uid = req.user.uid || 14459668;
const favId = req.body.favId;
const type = req.body.type;
... ...
... ... @@ -13,9 +13,7 @@ const helpers = global.yoho.helpers;
*/
const component = {
index: (req, res, next) => {
let uid = req.user.uid;
uid = 8050378; // 测试uid
const uid = req.user.uid || 14459668;
if (!uid && req.xhr) {
return res.json({
... ... @@ -29,13 +27,10 @@ const component = {
const result = {
module: 'home',
page: 'index',
noLocalJS: true,
noLocalCSS: true,
head_ico: proData && proData.head_ico ? helpers.image(proData.head_ico, 200, 200) : '',
profile_name: proData ? proData.profile_name : '登录/注册',
userinfourl: proData ? '/home/mydetails' : helpers.urlFormat('/signin.html', {
refer: req.originalUrl
}),
userinfourl: proData ? '/home/mydetails' : '',
serviceUrl: 'http://chat8.live800.com/live800/chatClient/chatbox.jsp?companyID=620092&configID=149091&jid=8732423409&'
};
... ... @@ -43,9 +38,7 @@ const component = {
}).catch(next);
},
mydetails: (req, res) => {
let uid = req.user.uid;
uid = 14459668; // 测试uid
const uid = req.user.uid || 14459668;
homeModel.getUserProfileData(uid).then(data => {
res.render('mydetails', {
... ... @@ -56,7 +49,7 @@ const component = {
gender: data.gender === '1' ? 'men' : 'women',
birthday: data.birthday
});
})
});
},
help: (req, res, next) => {
homeModel.getHelpInfo().then(helpList => {
... ... @@ -91,11 +84,11 @@ const component = {
page: 'feedback',
suggestSub: true,
noLocalCSS: true
})
});
},
saveFeedback: (req, res, next) => {
let saveFeedbackPara = {
uid: '13549737',
uid: '14459668',
content: req.body.content,
suggest_type: 2
};
... ... @@ -113,8 +106,6 @@ const component = {
}
homeModel.saveFeedback(saveFeedbackPara).then(result => {
console.log(result);
if (result.code === 200) {
return res.json({
code: 200,
... ...
... ... @@ -7,7 +7,7 @@
const orderModel = require('../models/order');
const notLoginCode = 400;
const notLoginTip = '抱歉,您暂未登录!';
const testUid = 8050378;// 测试uid
const testUid = 8041886;// 8039836; //8050882;// 测试uid
const isBLK = 1;
const order = {
... ... @@ -44,7 +44,7 @@ const order = {
let page = req.query.page;
let type = req.query.type;
let limit = req.query.limit;
let isend = true;
let isEnd = true;
uid = testUid;
if (!uid && req.xhr) {
... ... @@ -62,10 +62,10 @@ const order = {
};
orderModel.getOrders(param).then(result => {
if (result && page < result.page_total) {
isend = false;
if (result && page < result.data.pageTotal) {
isEnd = false;
}
return res.json(Object.assign({isend: isend}, result));
return res.json(Object.assign({isEnd: isEnd}, result));
});
},
getOrderDetailData: (req, res) => {
... ... @@ -122,7 +122,10 @@ const order = {
coin: (req, res, next) => {
let uid = req.user.id;
uid = testUid;
orderModel.getCoins(uid).then(result => {
// console.log(result)
res.render('coin', {
module: 'home',
page: 'coin',
... ...
... ... @@ -24,7 +24,7 @@ const _ = require('lodash');
exports.getOrders = (param) => {
param = Object.assign({method: 'app.SpaceOrders.get'}, param);
return api.get('978c6bad6c379086.json', param).then(camelCase);
return api.get('', param).then(camelCase);
};
/**
... ... @@ -34,7 +34,7 @@ exports.getOrders = (param) => {
* @returns {Promise.<T>|*}
*/
exports.getOrderDetail = (uid, orderCode) => {
return api.get('621e0b505983ac8a.json', {
return api.get('', {
method: 'app.SpaceOrders.detail',
order_code: orderCode,
uid: uid
... ... @@ -127,9 +127,9 @@ exports.getOrderLogisticdate = (params) => {
* @returns {*|Promise.<T>}
*/
exports.getCoins = (uid) => {
return api.get('978c6bad6c379086.json', {
return api.get('', {
uid: uid,
app_type: 'app.yohocoin.total'
method: 'app.yohocoin.total'
}).then(camelCase);
};
... ... @@ -141,7 +141,7 @@ exports.getCoins = (uid) => {
* @returns {*|Promise.<T>}
*/
exports.getCoinDetail = (uid, page, limit) => {
return api.get('26573a88a2958702.json', {
return api.get('', {
uid: uid,
page: page,
limit: limit,
... ...
<div class="my-page">
<div class="my-header">
<a class="user-info" href={{userinfourl}}>
<a class="user-info" id="user-info" {{#if userinfourl}} href='{{userinfourl}}' {{/if}}>
<span class="user-avatar" {{#if head_ico}} style="background-image: url('{{head_ico}}');" {{/if}}></span>
<br><span class="username">{{profile_name}}</span>
</a>
</div>
<div class="my-order">
<a class="order-title" href="/home/orders">
<a class="order-title" href="/home/orders?type=1">
我的订单
<span class="read-order">
查看全部订单 <span class="icon icon-right"></span>
... ... @@ -44,7 +44,7 @@
</div>
</div>
<div class="group-list">
<a class="list-item" href="/home/address">
<a class="list-item" id="address">
地址管理
<span class="num">{{address_num}} <span class="icon icon-right"></span></span>
</a>
... ...
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>{{title}} {{#unless noYohoTitle}}{{yohoTitle}}{{/unless}}</title>
<meta name="keywords" content="{{keywords}}">
<meta name="description" content="{{description}}">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta content="telephone=no" name="format-detection">
<meta content="email=no" name="format-detection">
<link rel="dns-prefetch" href="//cdn.yoho.cn">
<link rel="dns-prefetch" href="//static.yohobuy.com">
<script type="text/javascript">
(function(d,c){var e=d.documentElement,a="orientationchange" in window?"orientationchange":"resize",b=function(){var f=e.clientWidth;if(!f){return}if(f>=750){e.style.fontSize="40px"}else{e.style.fontSize=40*(f/750)+"px"}};if(!d.addEventListener){return}b();c.addEventListener(a,b,false);d.addEventListener("DOMContentLoaded",b,false)})(document,window);
</script>
{{#if devEnv}}
<link rel="stylesheet" href="//localhost:5004/css/index.css">
{{#unless noLocalCSS}}
<link rel="stylesheet" href="//localhost:5004/{{module}}.{{page}}.css">
{{/unless}}
{{^}}
<link rel="stylesheet" href="//cdn.yoho.cn/yohoblk-wap/{{version}}/index.css">
{{#unless noLocalCSS}}
<link rel="stylesheet" href="//cdn.yoho.cn/yohoblk-wap/{{version}}/{{module}}.{{page}}.css">
{{/unless}}
{{/if}}
</head>
<body {{#if isPassportPage}}class=passport-body{{/if}} {{#if isStarIndexPage}} class="star-index-bg"{{/if}} {{#if isStarDetailPage}}class="star-class-body"{{/if}}>
<div class="main-wrap">
{{{body}}}
</div>
{{#wechatShare}}
<script type="text/javascript" src="//res.wx.qq.com/open/js/jweixin-1.1.0.js"></script>
{{/wechatShare}}
{{#if devEnv}}
<script src="//localhost:5004/libs.js"></script>
{{#unless noLocalJS}}
<script src="//localhost:5004/{{module}}.{{page}}.js"></script>
{{/unless}}
{{^}}
<script src="//cdn.yoho.cn/yohoblk-wap/{{version}}/libs.js"></script>
{{#unless noLocalJS}}
<script src="//cdn.yoho.cn/yohoblk-wap/{{version}}/{{module}}.{{page}}.js"></script>
{{/unless}}
{{/if}}
{{#unless devEnv}}
{{> analysis}}
{{/unless}}
</body>
</html>
This diff could not be displayed because it is too large.
/**
* countDown.js.
* @author hgwang
* @date 2016-07-27
*/
'use strict';
let Vue = require('yoho-vue');
Vue.directive('countDown', {
acceptStatement: true,
params: ['left-time', 'callback', 'end-time'],
update: function() {
// 结束时间
let value = this.params.endTime || 0;
let callbackFn = this.params.callback;
// 如果不为0的话根据剩余的秒数计算时间
let leftTime = parseInt(this.params.leftTime);
let newValue;
if (leftTime !== 0) {
newValue = new Date() - 0 + leftTime * 1000;
} else {
if (value) {
newValue = value.replace(/-/g, '/').substring(0, 19);
} else {
return '';
}
}
if (new Date(newValue) === 'Invalid Date') {
return console.error('The param of directive "v-time-down" must be a date string!');
}
let timerSS = null;
let el = this.el;
let hDom = document.createElement('span');
hDom.setAttribute('class', 'timeDown-H');
el.appendChild(hDom);
let last = 0;
function format(val) {
let result = '00:00:00';
if (val === 0) {
return result;
}
let h = parseInt(val / 3600);
let m = parseInt((val - h * 3600) / 60);
let s = parseInt(val - h * 3600 - m * 60);
h = h < 10 ? '0' + h : h;
m = m < 10 ? '0' + m : m;
s = s < 10 ? '0' + s : s;
if (h === 0) {
result = m + ':' + s;
} else {
result = h + ':' + m + ':' + s;
}
return result;
}
function countdown() {
last = (new Date(newValue)).getTime() - (new Date()).getTime();
last = last / 1000;
if (last <= 0) {
clearInterval(timerSS);
last = 0;
callbackFn && callbackFn();
}
el.querySelector('.timeDown-H').innerHTML = format(last);
}
countdown();
timerSS = setInterval(countdown, 1000);
}
});
... ...
... ... @@ -57,7 +57,7 @@ function Select(items) {
overlay.hide();
elem.hide();
}
}
};
}
module.exports = Select;
... ...
... ... @@ -69,7 +69,7 @@ Vue.filter('goodsUrl', productId => {
Vue.filter('convertOrderState', (value) => {
let stateTxt = '';
if (typeof value === 'undefined') {
if (typeof value !== 'undefined') {
value = parseInt(value, 10);
}
switch (value) {
... ...
var yoho = require('yoho');
var $ = require('yoho-jquery');
var interceptClick = require('common/intercept-click');
$('.my-page').on('click', 'a', function() {
// 拦截跳转
var href = $(this).attr('href');
if (href) {
interceptClick(href);
return false;
}
});
// 跳转登录页
$('#user-info').on('click', function() {
var href = $(this).attr('href');
if (!href) {
yoho.goLogin();
}
})
// 地址管理
$('#address').on('click', function() {
yoho.goAddress({
'type': '2'
});
});
... ...
... ... @@ -9,6 +9,7 @@ const Vue = require('yoho-vue');
const OrderDetail = require('home/order-detail.vue');
require('common/vue-filter');
require('common/count-down');
new Vue({
el: '#order-detail',
... ...
... ... @@ -12,6 +12,7 @@ const infiniteScroll = require('yoho-vue-infinite-scroll');
Vue.use(infiniteScroll);
require('common/vue-filter');
require('common/count-down');
new Vue({
el: '#home-order-list',
... ...
$black: #000;
$white: #fff;
html,
body {
height: 100%;
}
.main-wrap {
height: 100%;
background: #f6f6f6;
}
.order-detail {
padding-bottom: 170px;
> div {
background: $white;
... ... @@ -152,7 +159,7 @@ $white: #fff;
label {
display: inline-block;
width: 150px;
width: 180px;
text-align: left;
color: #b0b0b0;
}
... ...
... ... @@ -14,13 +14,14 @@
<span class="down" v-if="item.down">品牌已下架</span>
</div>
</a>
<div class="fav-del-right" id="del-{{$index}}" @click="delItem($index, item.fav_id)">
<span class="fav-del-btn"></span>
<div class="fav-del-right hide" id="del-{{$index}}" @click="delItem($index, item.fav_id)">
<span class="icon icon-delete"></span>
<br/>
<span class="fav-del-txt">删除</span>
</div>
</li>
</ul>
<div class="fav-null-box {{ nullbox }}">
<span class="fav-null">您暂无收藏任何品牌</span>
<a slot="go-shopping" class="go-shopping" :href="brandUrl">随便逛逛</a>
... ... @@ -84,10 +85,12 @@
let width = delBtn.width();
$('#li-' + index).css('transform', 'translateX(-' + width + 'px)');
delBtn.removeClass('hide');
},
hideDelBth() {
this.brandData.forEach(function(d, index) {
$('#li-' + index).css('transform', 'translateX(0px)');
$('#del-' + index).addClass('hide');
});
},
delItem(index, id) {
... ... @@ -134,7 +137,6 @@
li {
height: 135px;
overflow: hidden;
margin-top: 20px;
border-bottom: 1px solid #e0e0e0;
}
... ... @@ -168,22 +170,24 @@
right: -126px;
background: #ff3b30;
width: 126px;
height: 125px;
height: 100%;
text-align: center;
.fav-del-btn {
.icon-delete {
display: inline-block;
width: 35px;
height: 43px;
color: white;
font-size: 35px;
margin-top: 30px;
background: resolve("home/fav/fav-del-btn.png");
background-size: 100%;
}
.fav-del-txt {
font-size: 24px;
color: #fff;
}
.hide {
display: none;
}
}
.fav-img-box {
... ... @@ -243,7 +247,7 @@
display: block;
width: 188px;
height: 171px;
background: resolve("home/fav/fav-null.png");
background: resolve("home/fav-null.png");
background-size: 100% 100%;
margin: 0 auto 45px;
}
... ...
... ... @@ -22,8 +22,8 @@
</div>
</div>
</a>
<div class="fav-del-right" id="del-{{$index}}" @click="delItem($index, item.fav_id)">
<span class="fav-del-btn"></span>
<div class="fav-del-right hide" id="del-{{$index}}" @click="delItem($index, item.fav_id)">
<span class="icon icon-delete"></span>
<br/>
<span class="fav-del-txt">删除</span>
</div>
... ... @@ -91,10 +91,12 @@
let width = delBtn.width();
$('#li-' + index).css('transform', 'translateX(-' + width + 'px)');
delBtn.removeClass('hide');
},
hideDelBth() {
this.productData.forEach(function(d, index) {
$('#li-' + index).css('transform', 'translateX(0px)');
$('#del-' + index).addClass('hide');
});
},
delItem(index, id) {
... ... @@ -141,7 +143,6 @@
li {
height: 205px;
overflow: hidden;
margin-top: 20px;
}
.fav-del-left {
... ... @@ -177,19 +178,21 @@
height: 200px;
text-align: center;
.fav-del-btn {
.icon-delete {
display: inline-block;
width: 35px;
height: 43px;
margin-top: 50px;
background: resolve("home/fav/fav-del-btn.png");
background-size: 100%;
color: white;
font-size: 35px;
margin-top: 55px;
}
.fav-del-txt {
font-size: 24px;
color: #fff;
}
.hide {
display: none;
}
}
.fav-img-box {
... ... @@ -211,7 +214,6 @@
font-size: 24px;
border-bottom: 1px solid #e0e0e0;
padding-bottom: 20px;
margin-right: 5px;
height: 203px;
overflow: hidden;
position: relative;
... ... @@ -269,7 +271,7 @@
display: block;
width: 188px;
height: 171px;
background: resolve("home/fav/fav-null.png");
background: resolve("home/fav-null.png");
background-size: 100% 100%;
margin: 0 auto 45px;
}
... ...
<template>
<div class="order-status">
<p>{{order.status | convertOrderState}}</p>
<p v-if="order.status == 0">剩余: 订单将被取消</p>
<p v-if="order.status == 0 && order.payLefttime != 0">剩余: <span v-count-down v-bind:left-time="order.payLefttime"></span>,订单将被取消</p>
</div>
<div class="order-address">
<p><span>{{order.userName}}</span><span>{{order.phone}}</span></p>
<p><span>{{order.userName}}</span><span>{{order.mobile}}</span></p>
<p>{{order.area}} <br>{{order.address}}</p>
</div>
<div class="order-code">
... ... @@ -34,15 +34,15 @@
</div>
<div class="order-amount">
<ul>
<li><label>商品:</label><span>{{order.goodsTotalAmount}}</span></li>
<li><label>YOHO币:</label><span>{{order.yohoCoinNum}}</span></li>
<li><label>运费:</label><span>{{order.shippingCost}}</span></li>
<li><label>总计:</label><span>&yen;{{order.paymentAmount}}</span></li>
<li v-for="promotion in order.promotionFormulas">
<label>{{promotion.promotion}}:</label><span>{{promotion.promotionAmount}}</span>
</li>
<li><label>总计:</label><span>{{order.amount}}</span></li>
</ul>
</div>
<div class="order-button">
<div class="order-button" v-show="order.status != 1 && order.status != 2 && order.status != 3">
<button v-if="order.status == 0" @click="cancelOrder(order.orderCode)">取消订单</button>
<button v-if="order.status == 0 " class="countdown" @click="goBuy()">去支付 11:58:12</button>
<button v-if="order.status == 0 " class="countdown" @click="goBuy(order.orderCode)">去支付 <span v-count-down v-bind:left-time="order.payLefttime" v-bind:callback="autoCancel(order.orderCode)"></span></button>
<button v-if="order.status == 4 || order.status == 5 ">查看物流</button>
<button v-if="order.status == 4 || order.status == 5 " class="black" @click="confirmGoods(order.orderCode)">确认收货</button>
<button v-if="order.status == 6" @click="deleteOrder(order,index)">删除订单</button>
... ... @@ -55,6 +55,7 @@
const $ = require('yoho-jquery');
const tip = require('common/tip');
const Modal = require('common/modal');
const yohoAPI = require('yoho');
module.exports = {
data() {
... ... @@ -73,28 +74,50 @@
orderCode: this.$parent.$data.orderCode
}
}).then(result => {
if (result) {
if (result.code === 200) {
this.$set('order', result.data);
} else {
tip(result.message);
}
}).fail(() => {
tip('网络错误');
});
},
cancelOrder(code) {
Modal.confirm('订单取消后不能恢复,确认取消订单吗?', '', function() {
orderDetail() {
return {
cancel(code, success, fail) {
$.ajax({
url: '/home/cancel-order',
type: 'post',
data: {
orderCode: code
}
}).then(result => {
}).then(success).fail(fail);
}
};
},
autoCancel(code) {
let _that = this;
return () => {
_that.orderDetail().cancel(code, (result) => {
if (result.code === 200) {
location.href = '/home/orders';
location.href = '/home/orders?type=2';
}
});
};
},
cancelOrder(code) {
let _that = this;
Modal.confirm('订单取消后不能恢复,确认取消订单吗?', '', function() {
_that.orderDetail().cancel(code, (result) => {
if (result.code === 200) {
location.href = '/home/orders?type=2';
} else {
tip(result.message);
}
}).fail(() => {
}, () => {
tip('操作失敗');
});
});
... ... @@ -135,8 +158,8 @@
tip('操作失敗');
});
},
goBuy() {
location.href = '';
goBuy(code) {
yohoAPI.goPay({orderid: code});
},
seeExpress() {
location.href = '';
... ...
... ... @@ -29,7 +29,7 @@
<div class="goods-total">合计: <b>&yen;{{order.amount}}</b></div>
<div class="options">
<button v-if="order.status === 0" @click="cancelOrder(order.orderCode)">取消订单</button>
<button v-if="order.status === 0 " class="countdown" @click="goBuy()">去支付 11:58:12</button>
<button v-if="order.status === 0 " class="countdown" @click="goBuy(order.orderCode)">去支付 <span v-count-down v-bind:left-time="order.payLefttime" v-bind:callback="autoCancel(order.orderCode)"></span></button>
<button v-if="order.status === 4 || order.status === 5 ">查看物流</button>
<button v-if="order.status === 4 || order.status === 5 " class="black" @click="confirmGoods(order.orderCode)">确认收货</button>
<button v-if="order.status === 6" @click="deleteOrder(order,index)">删除订单</button>
... ... @@ -47,6 +47,7 @@
const $ = require('yoho-jquery');
const tip = require('common/tip');
const Modal = require('common/modal');
const yohoAPI = require('yoho');
module.exports = {
data() {
... ... @@ -77,7 +78,7 @@
}
}).then(result => {
if (result.code === 200) {
if (result.isend) {
if (result.isEnd) {
_that.busy = true;
} else {
_that.busy = false;
... ... @@ -90,21 +91,41 @@
tip('网络错误');
});
},
cancelOrder(code) {
Modal.confirm('订单取消后不能恢复,确认取消订单吗?', '', function() {
autoCancel(code) {
let _that = this;
return () => {
_that.order().cancel(code, (result) => {
if (result.code === 200) {
location.reload();
}
});
};
},
order() {
return {
cancel(code, success, fail) {
$.ajax({
url: '/home/cancel-order',
type: 'post',
data: {
orderCode: code
}
}).then(result => {
}).then(success).fail(fail);
}
};
},
cancelOrder(code) {
let _that = this;
Modal.confirm('订单取消后不能恢复,确认取消订单吗?', '', function() {
_that.order().cancel(code, (result) => {
if (result.code === 200) {
location.reload();
} else {
tip(result.message);
}
}).fail(() => {
}, () => {
tip('操作失敗');
});
});
... ... @@ -147,8 +168,8 @@
tip('操作失敗');
});
},
goBuy() {
location.href = '';
goBuy(code) {
yohoAPI.goPay({orderid: code});
},
seeExpress() {
location.href = '';
... ...