Authored by 陈轩

merge

... ... @@ -2,12 +2,34 @@
* 换货 controller
*/
'use strict';
const exchangeModel = require('../models/exchange');
const exchange = {
exchange(req, res) {
res.render('exchange');
}
const view = {
module: 'home',
page: 'exchange'
};
res.render('exchange', view);
},
// 订单 可换货商品列表
order(req, res, next) {
const uid = req.user.uid || 8050882;
const orderId = req.query.orderId;
if (!orderId) {
return next();
}
exchangeModel.getOrderData(uid, orderId).then(result => {
res.json(result);
}).catch(next);
},
// 提交 换货
submit() { }
};
module.exports = exchange;
... ...
/**
* 换货 Model
* DOC: http://git.yoho.cn/yoho-documents/api-interfaces/blob/master/订单/exchange.md
*/
const api = global.yoho.API;
const exchange = {
// 获取 换货列表
getOrderData(uid, orderId) {
return api.get('', {
method: 'app.change.goodsList',
uid: uid,
order_code: orderId
}, {
cache: true,
code: 200
}).then(global.yoho.camelCase);
},
submitExchangeData() {},
};
module.exports = exchange;
... ...
... ... @@ -47,7 +47,7 @@ router.post('/save-logistics', refund.saveLogistics); // 退换货 - 添加寄
// 换货
router.get('/exchange', exchange.exchange);
router.get('/exchange/order', exchange.order);
router.get('/about-us', home.aboutUs); // 个人中心 - 关于我们
... ...
{{! HOME-换货}}
<div class="exchange">
<div id="exchange">
<exchange></exchange>
</div>
\ No newline at end of file
... ...
... ... @@ -84,10 +84,14 @@ exports.fetchProducts = (req, res, next) => {
code: 200
})
.then(result => {
if (!result.hasOwnProperty('code')) {
result.code = 200;
}
if (result.code === 200) {
result.data.productList = processProductList(result.data.productList);
result = camelCase(result);
}
res.json(result);
})
.catch(next);
... ...
... ... @@ -15,8 +15,8 @@ module.exports = {
port: 6004,
siteUrl: '//m.yohoblk.com',
domains: {
api: 'http://devapi.yoho.cn:58078/',
service: 'http://devservice.yoho.cn:58077/'
api: 'http://192.168.102.202:8080/gateway/',
service: 'http://192.168.102.202:8080/gateway/'
},
subDomains: {
host: '.m.yohoblk.com',
... ...
... ... @@ -49,6 +49,7 @@
"eslint": "^3.0.1",
"eslint-config-yoho": "^1.0.1",
"eslint-plugin-html": "^1.5.1",
"extract-text-webpack-plugin": "^1.0.1",
"gulp": "^3.9.1",
"gulp-cssnano": "^2.1.2",
"gulp-ftp": "^1.1.0",
... ...
const Vue = require('yoho-vue');
const lazyload = require('yoho-vue-lazyload');
const exchange = require('home/exchange.vue');
require('common/vue-filter');
Vue.use(lazyload);
new Vue({
el: '#exchange',
components: {
exchange
}
});
... ...
const Vue = require('yoho-vue');
const $ = require('yoho-jquery');
const qs = require('yoho-qs');
const search = require('product/search.vue');
$(function() {
const buildFilters = function() {
return $.get('filters.json', qs);
};
const buildSort = function() {
return [
{
... ... @@ -30,9 +26,5 @@ $(function() {
let app = new Vue(search);
buildFilters()
.then(filterConfig => {
app.filterConfig = filterConfig;
});
app.sortConfig = buildSort();
});
... ...
... ... @@ -72,3 +72,7 @@ ul {
.hide {
display: none;
}
.mr50 {
margin-right: 50px;
}
... ...
@import "reset";
@import "common";
@import "color";
@import "list";
@import "icon";
@import "tip";
@import "modal";
... ...
.list {
list-style: none;
margin: 0;
padding: 0;
background-color: #fff;
}
.list-item {
position: relative;
padding: 30px;
&:after {
content: "";
position: absolute;
left: 30px;
bottom: -1px;
width: 690px;
height: 0;
border-bottom: 1px solid #eee;
z-index: 1;
}
}
... ...
<template>
<div class="refund">
<product-list v-bind:title="title" v-bind:list="list" v-bind:refund-data="refundData"></product-list>
<div class="list exchange-info">
<div class="list-item exchange-address">
<div class="exchange-addressee">
<span class="mr50">Daisuke Obana</span>
<span>13160071768</span>
</div>
<p class="address address-region">江苏省 南京市 建邺区</p>
<p class="address address-detail">嘉陵江东街18号国家广告园5栋</p>
</div>
<div class="list-item exchange-mode">
换货方式
<i class="icon icon-right"></i>
<select>
<option value=""></option>
</select>
</div>
</div>
</div>
</template>
<script>
const $ = require('yoho-jquery');
const qs = require('yoho-qs');
const productList = require('home/refund/product-list.vue');
module.exports = {
data() {
return {
title: '请选择换货商品',
list: [],
amount: {},
refundData: {}
};
},
computed: {
submitData() {
let goods = [];
this.list.forEach(product => {
if (product.checked) {
goods.push({
last_price: product.lastPrice,
remark: product.remark || '',
returned_reason: this.refundData.returnReason[product.reason.id].id + '',
evidence_images: product.imageList || [],
goods_type: product.goodsTypeId + '',
product_skn: product.productSkn,
product_skc: product.productSkc,
product_sku: product.productSku
});
}
});
return {
order_code: qs.orderId,
goods: JSON.stringify(goods),
payment: JSON.stringify(this.amount)
};
}
},
created() {
$.ajax({
url: '/home/exchange/order',
data: {
orderId: qs.orderId
}
}).then(res => {
if (res.data && res.data.goodsList) {
res.data.goodsList.forEach(product => {
product.checked = false;
product.reason = {
id: 0
};
product.imageList = [];
});
res.data.returnAmountMode.forEach(mode => {
if (mode.isDefault === 'Y') {
this.$set('amount.return_amount_mode', mode.id);
}
});
this.list = res.data.goodsList;
this.refundData = res.data;
}
});
},
methods: {
checkSubmitData() {
const data = this.submitData;
if (!data.order_code) {
return false;
}
// 退到银行卡
if (this.amount.return_amount_mode === 2) {
if (!this.amount.bank_name || !this.amount.bank_card || !this.amount.payee_name) {
return false;
}
}
// 退到支付宝
if (this.amount.return_amount_mode === 3) {
if (!this.amount.alipay_account || !this.amount.alipay_name) {
return false;
}
}
return true;
},
submit() {
if (!this.checkSubmitData()) {
alert('请填写完整退换货信息');
}
$.ajax({
method: 'POST',
url: '/home/refund/submit',
data: this.submitData
}).then(result => {
if (result.code === 200) {
console.log(result);
} else {
alert(result.message);
}
});
}
},
components: {
productList
}
};
</script>
<style>
body {
background-color: #f6f6f6;
}
.exchange-info {
margin: 30px 0;
}
</style>
... ...
... ... @@ -3,7 +3,7 @@
<ul class="cardlist card-large clearfix">
<li class="card" v-for="item in data">
<div class="card-pic">
<a href="/product/{{item.id}}">
<a href="/product/{{item.productId}}">
<img v-lazy="item.goodsList[0].imagesUrl | resize 372 499" alt="{{item.productName}}">
</a>
</div>
... ...