Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
yohobuy-node
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
1
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
OF1706
8 years ago
Commit
4d4e3606a246975703cec41b758daec423871313
1 parent
8138b72e
exchange and delivery js
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
200 additions
and
18 deletions
apps/home/controllers/returns.js
apps/home/models/returns-api.js
apps/home/models/returns.js
apps/home/router.js
public/js/home/returns-apply.js
apps/home/controllers/returns.js
View file @
4d4e360
...
...
@@ -6,8 +6,8 @@
const
helpers
=
global
.
yoho
.
helpers
;
const
returnsModel
=
require
(
'../models/returns'
);
/*
我的退换货-列表页
/**
* 我的退换货-列表页
*/
const
index
=
(
req
,
res
,
next
)
=>
{
const
page
=
req
.
query
.
page
;
...
...
@@ -25,8 +25,8 @@ const index = (req, res, next) => {
.
catch
(
next
);
};
/*
我的订单-退货申请页
/**
* 我的订单-退货申请页
*/
const
refundApply
=
(
req
,
res
,
next
)
=>
{
const
orderCode
=
req
.
query
.
orderCode
;
...
...
@@ -37,8 +37,8 @@ const refundApply = (req, res, next) => {
}).
catch
(
next
);
};
/*
我的订单-退货提交
/**
* 我的订单-退货提交
*/
const
saveRefund
=
(
req
,
res
,
next
)
=>
{
const
uid
=
req
.
user
.
uid
;
...
...
@@ -48,8 +48,8 @@ const saveRefund = (req, res, next) => {
}).
catch
(
next
);
};
/*
退货成功
/**
* 退货成功
*/
const
refundSuccess
=
(
req
,
res
)
=>
{
let
resData
=
{
...
...
@@ -69,8 +69,8 @@ const refundSuccess = (req, res) => {
res
.
render
(
'returns/returns-save'
,
{
returns
:
resData
});
};
/*
换货成功
/**
* 换货成功
*/
const
exchangeSuccess
=
(
req
,
res
)
=>
{
let
resData
=
{
...
...
@@ -84,8 +84,8 @@ const exchangeSuccess = (req, res) => {
res
.
render
(
'returns/returns-save'
,
{
returns
:
resData
});
};
/*
我的退换货-退货详情页
/**
* 我的退换货-退货详情页
*/
const
refundDetail
=
(
req
,
res
,
next
)
=>
{
const
code
=
req
.
query
.
id
;
...
...
@@ -101,7 +101,20 @@ const refundDetail = (req, res, next) => {
}).
catch
(
next
);
};
/*
/**
* 我的订单-提交换货申请
*/
const
saveExchange
=
(
req
,
res
,
next
)
=>
{
let
uid
=
req
.
user
.
uid
;
returnsModel
.
saveExchange
(
req
,
uid
).
then
(
result
=>
{
res
.
send
(
result
);
}).
catch
(
next
);
};
/**
* 我的退换货-换货详情页
*/
const
exchangeDetail
=
(
req
,
res
,
next
)
=>
{
...
...
@@ -118,8 +131,26 @@ const exchangeDetail = (req, res, next) => {
}).
catch
(
next
);
};
/*
我的订单-换货申请页
/**
* 我的订单-获取换货方式
*/
const
getDelivery
=
(
req
,
res
,
next
)
=>
{
let
areaCode
=
req
.
body
.
areaCode
;
// 获取必要参数
let
uid
=
req
.
user
.
uid
;
let
gender
=
req
.
yoho
.
gender
;
let
channel
=
req
.
yoho
.
channel
;
// 调用接口获得该用户支持的换货方式(白金会员可享受上门换货,偏远地区不支持上门换货)
returnsModel
.
getDelivery
(
areaCode
,
uid
,
gender
,
channel
).
then
(
result
=>
{
res
.
send
(
result
);
}).
catch
(
next
);
};
/**
* 我的订单-换货申请页
*/
const
exchangeApply
=
(
req
,
res
,
next
)
=>
{
const
orderCode
=
req
.
query
.
orderCode
;
...
...
@@ -186,9 +217,11 @@ module.exports = {
saveRefund
,
refundSuccess
,
refundDetail
,
saveExchange
,
exchangeApply
,
exchangeSuccess
,
exchangeDetail
,
getDelivery
,
cancelRefund
,
cancelChange
,
setExpressNumber
...
...
apps/home/models/returns-api.js
View file @
4d4e360
...
...
@@ -150,8 +150,62 @@ const refundSubmit = (orderCode, uid, goods, payment) =>{
};
/**
* save换货申请
* @param $orderCode
* @param $goods
* @param $consigneeName
* @param $areaCode
* @param $address
* @param $mobile
* @param $zipCode
* @param $deliveryType
* @param $uid
* @return mixed
*/
const
exchangeSubmit
=
(
orderCode
,
goods
,
consigneeName
,
areaCode
,
address
,
mobile
,
zipCode
,
deliveryType
,
uid
)
=>
{
let
options
=
{
method
:
'app.change.submit'
,
order_code
:
orderCode
,
uid
:
uid
,
goods
:
goods
,
consignee_name
:
consigneeName
,
area_code
:
areaCode
,
address
:
address
,
mobile
:
mobile
,
zip_code
:
zipCode
,
delivery_tpye
:
deliveryType
};
console
.
log
(
options
);
return
api
.
post
(
''
,
options
);
};
/**
* 获取换货方式
* @param $uid
* @param $areaCode
* @param $gender
* @param $yhChannel
* @return mixed
*/
const
getDeliveryAsync
=
(
areaCode
,
uid
,
gender
,
channel
)
=>
{
let
options
=
{
method
:
'app.change.getDelivery'
,
uid
:
uid
,
area_code
:
areaCode
,
gender
:
gender
,
yh_channel
:
channel
};
return
api
.
post
(
''
,
options
);
};
/**
* 发送站内信
*
* @param int $uid
* @param string $title
* @param int $content
...
...
@@ -179,6 +233,7 @@ const sendMessage = (uid, title, content, type, verifyKey, sendUid) =>{
module
.
exports
=
{
getRefundGoodsAsync
,
refundSubmit
,
exchangeSubmit
,
sendMessage
,
getRefundDetailAsync
,
getExchangeGoodsAsync
,
...
...
@@ -187,5 +242,6 @@ module.exports = {
getExpressCompanyAsync
,
cancelRefundAsync
,
cancelChangeAsync
,
getDeliveryAsync
,
setExpressNumberAsync
};
...
...
apps/home/models/returns.js
View file @
4d4e360
...
...
@@ -427,6 +427,83 @@ const getChangeDetail = (applyId, uid) => {
};
/**
* 提交换货申请
* @param $orderCode
* @param $uid
* @param $goods
* @param $consigneeName
* @param $areaCode
* @param $address
* @param $mobile
* @param $zipCode
* @param $deliveryType
* @return array|mixed
*/
const
saveExchange
=
(
req
,
uid
)
=>
{
let
process
=
function
*
()
{
let
orderCode
=
req
.
body
.
orderCode
,
goods
=
req
.
body
.
goods
,
consigneeName
=
req
.
body
.
consigneeName
,
areaCode
=
req
.
body
.
areaCode
,
address
=
req
.
body
.
address
,
mobile
=
req
.
body
.
mobile
,
zipCode
=
req
.
body
.
zipCode
,
deliveryType
=
req
.
body
.
deliveryType
;
console
.
log
(
'deliveryType'
+
deliveryType
);
if
(
_
.
isEmpty
(
orderCode
)
||
orderCode
<
1
||
_
.
isEmpty
(
goods
)
||
_
.
isEmpty
(
deliveryType
)
||
_
.
isEmpty
(
consigneeName
)
||
_
.
isEmpty
(
areaCode
)
||
_
.
isEmpty
(
address
)
||
_
.
isEmpty
(
mobile
))
{
return
{
code
:
203
,
message
:
'非法提交'
};
}
// 调用接口查询订单详情
let
order
=
yield
ordersAPI
.
viewOrderData
(
orderCode
,
uid
);
if
(
_
.
isEmpty
(
order
))
{
return
{
code
:
403
,
message
:
'没有找到该订单'
};
}
// 订单15天后不能换货
// if (_.get(order, 'code') === 200) {
// if ((new Date() - order.data.create_time) > 15*86400) {
// return {
// code: 400,
// message: '您的订单已经超过了换货有效期'
// }
// }
// }
// 保存换货申请
let
result
=
yield
returnAPI
.
exchangeSubmit
(
orderCode
,
goods
,
consigneeName
,
areaCode
,
address
,
mobile
,
zipCode
,
deliveryType
,
uid
);
// 组装站内信内容
let
title
=
'您有一笔订单提交换货申请:'
;
let
content
=
'您的订单'
+
orderCode
+
'申请换货,给您带来不便敬请谅解!请至订单中心查看详情!'
;
// 换货成功,返回前端相应格式,并返回换货成功页跳转链接
if
(
_
.
get
(
result
,
'code'
)
===
200
)
{
// 换货成功发送站内信
returnAPI
.
sendMessage
(
uid
,
title
,
content
);
result
.
data
.
refer
=
helpers
.
urlFormat
(
'/home/returns/exchangeSuccess'
,
{
orderCode
:
orderCode
});
}
return
result
;
};
return
co
(
process
)();
};
/**
* 换货申请页数据
* @param $orderCode
* @param $uid
...
...
@@ -504,11 +581,14 @@ const getOrderExchange = (orderCode, uid) => {
let
productList
=
yield
Promise
.
all
(
sknPromise
);
_
.
forEach
(
productList
,
(
product
,
key
)
=>
{
// 遍历得到每件商品
let
colorSize
=
[],
value
=
product
.
data
;
_
.
forEach
(
value
.
goods_list
,
val
=>
{
// 遍历商品得到每个颜色
let
size
=
[];
_
.
forEach
(
val
.
size_list
,
v
=>
{
// 遍历颜色得到每个尺码
if
(
+
v
.
storage_number
>
0
)
{
// 当某个尺码下有库存时,将该颜色及其对应的尺码加入该商品选项下
size
.
push
(
v
);
...
...
@@ -542,6 +622,12 @@ const getOrderExchange = (orderCode, uid) => {
return
co
(
process
)();
};
const
getDelivery
=
(
areaCode
,
uid
,
gender
,
channel
)
=>
{
return
returnAPI
.
getDeliveryAsync
(
areaCode
,
uid
,
gender
,
channel
).
then
((
result
)
=>
{
return
result
;
});
};
const
getCancelRefund
=
(
id
,
uid
)
=>
{
return
returnAPI
.
cancelRefundAsync
(
id
,
uid
).
then
((
result
)
=>
{
return
result
;
...
...
@@ -565,8 +651,10 @@ module.exports = {
getOrderRefund
,
// 我的订单,申请退货
saveRefund
,
// 退货提交
getRefundDetail
,
// 退货详情
saveExchange
,
// 换货提交
getChangeDetail
,
// 换货详情
getOrderExchange
,
// 我的订单,申请换货
getDelivery
,
// 获取换货方式
getCancelRefund
,
// 取消退货申请
getCancelChange
,
// 取消换货申请
setExpressNumber
// 设置快递
...
...
apps/home/router.js
View file @
4d4e360
...
...
@@ -80,12 +80,15 @@ router.get('/returns/refundrequest', tabsMiddleware.getCommonHeader, returnsCont
router
.
post
(
'/returns/saveRefund'
,
tabsMiddleware
.
getCommonHeader
,
returnsController
.
saveRefund
);
// 提交退货
router
.
get
(
'/returns/refundSuccess'
,
tabsMiddleware
.
getCommonHeader
,
returnsController
.
refundSuccess
);
// 退货成功
router
.
get
(
'/returns/refundDetail'
,
tabsMiddleware
.
getCommonHeader
,
returnsController
.
refundDetail
);
// 退货详情
router
.
post
(
'/returns/saveExchange'
,
tabsMiddleware
.
getCommonHeader
,
returnsController
.
saveExchange
);
// 提交退货
router
.
get
(
'/returns/exchangerequest'
,
tabsMiddleware
.
getCommonHeader
,
returnsController
.
exchangeApply
);
// 换货申请
router
.
get
(
'/returns/exchangeSuccess'
,
tabsMiddleware
.
getCommonHeader
,
returnsController
.
exchangeSuccess
);
// 换货成功
router
.
get
(
'/returns/exchangeDetail'
,
tabsMiddleware
.
getCommonHeader
,
returnsController
.
exchangeDetail
);
// 换货详情
router
.
post
(
'/returns/getDelivery'
,
tabsMiddleware
.
getCommonHeader
,
returnsController
.
getDelivery
);
// 获取换货方式
router
.
post
(
'/returns/cancelRefund'
,
tabsMiddleware
.
getCommonHeader
,
returnsController
.
cancelRefund
);
// 取消退货
router
.
post
(
'/returns/cancelChange'
,
tabsMiddleware
.
getCommonHeader
,
returnsController
.
cancelChange
);
// 取消换货
router
.
post
(
'/returns/setExpressNumber'
,
tabsMiddleware
.
getCommonHeader
,
returnsController
.
setExpressNumber
);
// 设置快递
router
.
get
(
'/returns/success'
,
returnsController
.
index
);
// router.get('/index', [tabsMiddleware.getCommonHeader, tabsMiddleware.getHomeNav], IndexController.index);
...
...
public/js/home/returns-apply.js
View file @
4d4e360
...
...
@@ -379,6 +379,8 @@ function packExchangeInfo() {
verifyTip
=
'请选择商品返回方式'
;
}
res
.
goods
=
JSON
.
stringify
(
res
.
goods
);
return
res
;
}
...
...
@@ -415,7 +417,7 @@ $('.save-btn').click(function() {
data
.
orderCode
=
orderCode
;
if
(
verifyTip
)
{
alert
(
verifyTip
);
alert
(
verifyTip
);
//eslint-disable-line
return
;
}
...
...
@@ -430,7 +432,7 @@ $('.save-btn').click(function() {
window
.
location
.
href
=
jsonData
.
data
.
refer
;
}
}
else
{
alert
(
jsonData
.
message
);
alert
(
jsonData
.
message
);
//eslint-disable-line
loadWaiting
(
false
);
}
});
...
...
Please
register
or
login
to post a comment