Authored by biao

update for change apply and fix some bugs

... ... @@ -15,7 +15,7 @@ const orderModel = require('../models/order');
const index = (req, res) => {
const type = req.query.type;
const page = req.query.page;
const uid = req.user.uid || '13549567';
const uid = req.user.uid || '10931021';
orderModel.getOrderData(uid, type, page).then(result => {
res.display('index', {
... ... @@ -32,7 +32,7 @@ const index = (req, res) => {
const detail = (req, res) => {
const code = req.query.code;
const uid = req.user.uid || '7394907';
const uid = req.user.uid || '10931021';
orderModel.getOrderDetail(uid, code).then(result => {
res.display('index', {
... ... @@ -50,7 +50,7 @@ const detail = (req, res) => {
const getOrderList = (req, res) => {
const type = req.query.type;
const page = req.query.page;
const uid = req.user.uid || '7394907';
const uid = req.user.uid || '10931021';
orderModel.getOrderData(uid, type, page).then(result => {
res.display('order-table', {
... ... @@ -65,7 +65,7 @@ const getOrderList = (req, res) => {
const getOrderTotal = (req, res) => {
const type = req.query.type;
const uid = req.user.uid || '7394907';
const uid = req.user.uid || '10931021';
orderModel.getOrderData(uid, type).then(result => {
... ... @@ -78,7 +78,7 @@ const getOrderTotal = (req, res) => {
};
const cancelOrder = (req, res) => {
const uid = req.user.uid || '7394907';
const uid = req.user.uid || '10931021';
const code = req.query.orderCode;
orderModel.cancelOrder(uid, code).then(result => {
... ... @@ -87,7 +87,7 @@ const cancelOrder = (req, res) => {
};
const deleteOrder = (req, res) => {
const uid = req.user.uid || '7394907';
const uid = req.user.uid || '10931021';
const code = req.query.orderCode;
orderModel.deleteOrder(uid, code).then(result => {
... ... @@ -96,7 +96,7 @@ const deleteOrder = (req, res) => {
};
const getExpressInfo = (req, res) => {
const uid = req.user.uid || '7394907';
const uid = req.user.uid || '10931021';
const code = req.query.orderCode;
orderModel.getExpressInfo(uid, code).then(result => {
... ... @@ -111,7 +111,7 @@ const getCancelOrderReason = (req, res) => {
};
const editOrder = (req, res) => {
const uid = req.user.uid || '7394907';
const uid = req.user.uid || '10931021';
const query = req.query;
query.uid = uid;
... ...
... ... @@ -16,19 +16,19 @@ const helpers = global.yoho.helpers;
const pageSize = 10;
const _reduceArrByProductSku = data => {
const d = [];
d.push(data[0]);
data.reduce((p, c) => { //eslint-disable-line
if (p && c && p.productSku !== c.productSku) {
d.push[c];
}
});
return d;
};
// const _reduceArrByProductSku = data => {
// const d = [];
//
// d.push(data[0]);
//
// data.reduce((p, c) => { //eslint-disable-line
// if (p && c && p.productSku !== c.productSku) {
// d.push[c];
// }
// });
//
// return d;
// };
const getUserReturn = (uid, page) => {
... ... @@ -218,23 +218,25 @@ const getProductInfo = (productId, productSkn) => {
const getChangeGoodsList = (orderCode, uid) => {
return returnsAPI.getChangeGoodsListAsync(orderCode, uid).then(result => {
const basicData = {
title: '申请退货'
title: '申请货'
};
let data;
console.log(result);
if (result && result.data) {
data = camelCase(result.data);
data.goodsList = _reduceArrByProductSku(data.goodsList);
// data.goodsList = _reduceArrByProductSku(data.goodsList);
data.hidePrice = true;
data.goodsList.forEach(good => {
good.showCheckbox = true;
good.hidePrice = true;
good.buyNumber = good.num;
// good.buyNumber = good.num;
good.buyNumber = 1;
data.goodsList[2].colorId = 1;
});
}
... ...
... ... @@ -28,7 +28,7 @@
{{#if showEditOption}}
<p class="subtext">评价晒单</p>
<p class="subtext">申请退货</p>
<a href="/return/exchange?code={{orderCode}}&id={{productId}}&skn={{productSkn}}">
<a href="/me/return/exchange/{{orderCode}}">
<p class="subtext">申请换货</p>
</a>
<p class="subtext delete">删除订单</p>
... ...
... ... @@ -9,35 +9,41 @@
<li class="change-num">换货数量</li>
</ul>
{{#goodsList}}
<div class="table-body">
<div class="goods-container no-price" data-id="{{productId}}" data-skn="{{productSkn}}">
{{# showCheckbox}}
{{> icon/checkbox}}
<!--
<span class="iconfont checkbox {{#if checked}}checked{{/if}}">{{#if checked}}&#xe602;{{^}}&#xe601;{{/if}}</span>
-->
{{/ showCheckbox}}
{{> order/good-info}}
<div class="sub-column">
退货原因
<div class="change-info-box">
<div class="table-body">
<div class="goods-container no-price" data-id="{{productId}}" data-skn="{{productSkn}}">
{{# showCheckbox}}
{{> icon/checkbox}}
<!--
<span class="iconfont checkbox {{#if checked}}checked{{/if}}">{{#if checked}}&#xe602;{{^}}&#xe601;{{/if}}</span>
-->
{{/ showCheckbox}}
{{> order/good-info}}
<div class="sub-column">
{{# ../this}}
{{> returns/change-reason}}
{{/ ../this}}
</div>
<div class="sub-column number">
<span class="minus">-</span>
<span class="value">{{changeNum}}</span>
<span class="plus">+</span>
</div>
</div>
<div class="sub-column">
数量
</div>
</div>
</div>
<div class="form">
<div class="group color">
<span class="title">
<span class="artirisk">*</span>
换货Color: <span class="color-text" data-color={{colorId}}>{{colorName}}</span>
</span>
</div>
<div class="group size">
<span class="title">
<span class="artirisk">*</span>
换货Size: <span class="size-text" data-size="{{sizeId}}">{{sizeName}}</span>
</span>
<div class="form">
<div class="group color">
<span class="title">
<span class="asterisk">*</span>
换货Color: <span class="color-text" data-color={{colorId}}>{{colorName}}</span>
</span>
</div>
<div class="group size">
<span class="title">
<span class="asterisk">*</span>
换货Size: <span class="size-text" data-size="{{sizeId}}">{{sizeName}}</span>
</span>
</div>
</div>
</div>
{{/goodsList}}
... ...
<select id="exchange-reasons" name="exchange-reasons">
<option value="0">请选择换货原因</option>
{{# exchangeReason}}
<option value="{{id}}">{{name}}</option>
{{/ exchangeReason}}
</select>
... ...
var colorTpl = require('../../tpl/me/color-list.hbs');
var sizeTpl = require('../../tpl/me/size-list.hbs');
// var scope = {
// 1: {
// min: true,
// do: function() {
// console.log('min');
// var numCtrl = {
// valueEl: $('.number .value'),
// btn: {
// minus: $('.number .minus'),
// plus: $('.number .plus')
// },
// scope: {
// 1: {
// min: true,
// do: function(t) {
// t.btn.minus.addClass('disable');
// }
// }
// },
// initNumberScope: function() {
// var maxValue = this.valueEl.text();
//
// this.btn.plus.addClass('disable');
//
// this.scope[maxValue] = {
// max: true,
// do: function(t) {
// t.btn.plus.addClass('disable');
// }
// };
// },
// bindNumberEvent: function() {
// var $val = this.valueEl;
// var val = parseInt($val.text(), 10);
// var scope = this.scope;
// var that = this;
//
//
// this.btn.minus.on('click', function() {
// if ($(this).hasClass('disable')) {
// return;
// }
//
// if (that.btn.plus.hasClass('disable')) {
// that.btn.plus.removeClass('disable');
// }
//
// val -= 1;
// $val.text(val);
//
// if (scope[val] && scope[val].min) {
// scope[val].do(that);
// }
// });
//
// this.btn.plus.on('click', function() {
// if ($(this).hasClass('disable')) {
// return;
// }
//
// if (that.btn.minus.hasClass('disable')) {
// that.btn.minus.removeClass('disable');
// }
//
// val += 1;
// $val.text(val);
//
// if (scope[val] && scope[val].max) {
// scope[val].do(that);
// }
// });
// },
// init: function() {
// this.initNumberScope();
// this.bindNumberEvent();
// }
// }
// };
function setActive($item) {
var color = $item.find('.color-text').data('color');
// var size = $item.find('.size-text').data('size');
var $colorList = $item.find('.color-list');
console.log(color);
$colorList.find('.img-box').each(function(i, box) {
var $box = $(box);
if ($box.find('img').data('color') === color) {
$box.find('.img-box').eq(i).addClass('active');
}
});
}
function renderList(data) {
var cTpl;
var sTpl;
var $c = $('.group.color');
var $s = $('.group.size');
var $el = $('.goods-container');
var resultId;
var resultSkn;
if (data) {
cTpl = colorTpl(data);
sTpl = sizeTpl(data);
$c.append(cTpl);
$s.append(sTpl);
resultId = data.productId;
resultSkn = data.productSkn;
$el.each(function(index, item) {
var $item = $(item);
var id = $item.data('id');
var skn = $item.data('skn');
var $form;
if (id === resultId && skn === resultSkn) {
$form = $item.closest('.table-body').next('.form');
if (!$form.find('.color-list').length) {
cTpl = colorTpl(data);
sTpl = sizeTpl(data);
$form.find('.group.color').append(cTpl);
$form.find('.group.size').append(sTpl);
setActive($form);
}
}
});
}
}
function bindColorEvent() {
$('.color-list img').on('click', function() {
$('.color-list img').off('clice').on('click', function() {
var $this = $(this);
var $sizeList = $('.size-list');
var $sizeList = $this.closest('.group').next('.group').find('.size-list');
var index = $this.data('index');
var colorId = $this.data('color');
var colorText = $this.attr('alt');
var $c = $('.group.color .color-text');
var $c = $this.closest('.group.color').find('.color-text');
$c.text(colorText);
$c.attr('data-color', colorId);
$this.closest('.color-list').find('.active').removeClass('active');
$this.parent().addClass('active');
$sizeList.removeClass('hide');
$sizeList.addClass('hide');
... ... @@ -51,49 +151,47 @@ function initSizeId() {
}
function bindSizeEvent() {
$('.size-list span').on('click', function() {
$('.size-list span').off('click').on('click', function() {
var $this = $(this);
var s = $this.text();
var id = $this.data('size');
var $s = $('.group.size .size-text');
var $s = $this.closest('.group.size').find('.size-text');
$this.parent().find('.active').removeClass('active');
$this.addClass('active');
$s.text(s);
$s.attr('data-size', id);
});
}
// function bindNumberEvent() {
// $('.number .minus').on('click', function() {
// var val = $('.number .value').text();
//
// if (scope[val].min) {
// scope[val].do();
// }
// });
// }
function getProductInfo() {
var $el = $('.goods-container');
var id = $el.data('id');
var skn = $el.data('skn');
if (id && skn) {
$.ajax({
url: '/me/return/getProductInfo',
data: {
productId: id,
productSkn: skn
}
}).done(function(result) {
console.log(result);
if (result.code === 200) {
renderList(result.data);
initSizeId();
bindColorEvent();
bindSizeEvent();
}
});
}
$el.each(function(index, item) {
var id = $(item).data('id');
var skn = $(item).data('skn');
if (id && skn) {
$.ajax({
url: '/me/return/getProductInfo',
data: {
productId: id,
productSkn: skn
}
}).done(function(result) {
console.log(result);
if (result.code === 200) {
renderList(result.data);
initSizeId();
bindColorEvent();
bindSizeEvent();
}
});
}
});
}
getProductInfo();
// numCtrl.init();
... ...
... ... @@ -99,6 +99,14 @@
font-size: 12px;
}
}
/* 表单必填项提示符 */
.asterisk {
position: relative;
top: 2px;
margin-right: 5px;
color: #c71814 !important;
}
}
@import "address";
... ...
... ... @@ -18,13 +18,6 @@
text-align: center !important;
}
.asterisk {
position: relative;
top: 2px;
margin-right: 5px;
color: #c71814 !important;
}
.dialog-title {
padding-bottom: $space;
border-bottom: 1px solid #f1f1f1;
... ...
.return-wrap {
&.change {
.sub-column {
margin-top: 30px;
}
.color-list {
height: 70px;
line-height: 70px;
box-sizing: border-box;
.img-box {
display: inline-block;
width: 24px;
height: 24px;
line-height: 24px;
box-sizing: border-box;
margin-right: 10px;
text-align: center;
cursor: pointer;
img {
width: 20px;
height: 20px;
}
&.active {
border: 2px solid #ccc;
position: relative;
top: -2px;
}
}
}
.asterisk {
margin-right: 0;
}
.group {
&.color {
min-height: 70px;
}
&.size {
min-height: 65px;
}
.title {
font-size: 14px;
color: #1b1b1b;
}
}
.size-list {
height: 65px;
line-height: 65px;
span {
min-width: 25px;
height: 20px;
line-height: 20px;
padding: 0 5px;
box-sizing: border-box;
margin-right: 10px;
border: 1px solid #ccc;
display: inline-block;
text-align: center;
font-size: 12px;
cursor: pointer;
&.active {
background-color: #1b1b1b;
color: #fff;
border-color: #1b1b1b;
}
}
}
}
.iconfont {
&.checkbox {
position: relative;
top: -70px;
margin-right: 10px;
font-size: 14px;
cursor: pointer;
}
}
}
... ...
... ... @@ -52,4 +52,5 @@
}
@import "list";
@import "change";
@import "refund-detail";
... ...
<div class="color-list">
{{#goodsList}}
<div class="img-box {{#if isActive}}active{{/if}}" >
<img src="{{colorImage}}" alt="{{colorName}}" data-index="{{@index}}" data-color={{colorId}}>
</div>
{{/goodsList}}
</div>
... ...