|
|
/**
|
|
|
* 个人中心-我的订单model
|
|
|
* @author: 赵彪<bill.zhao@yoho.cn>
|
|
|
* @date: 2016/7/19
|
|
|
*/
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
const api = global.yoho.API;
|
...
|
...
|
@@ -24,6 +30,7 @@ const paymentTypeStr = { |
|
|
4: '抵消支付'
|
|
|
};
|
|
|
|
|
|
// 订单操作按钮
|
|
|
const btnMap = {
|
|
|
all: [
|
|
|
{
|
...
|
...
|
@@ -135,11 +142,17 @@ const _convertUnixTime = src => { |
|
|
return moment.unix(src).format('YYYY-MM-DD hh:mm:ss');
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 获取订单物流信息
|
|
|
* @param { [Object] } addressList
|
|
|
* @param { String } createTime
|
|
|
* @return { [Object] }
|
|
|
*/
|
|
|
const _convertAddress = (addressList, createTime) => {
|
|
|
let addrList = [];
|
|
|
|
|
|
addressList.forEach(addr => {
|
|
|
let address = {
|
|
|
const address = {
|
|
|
time: '',
|
|
|
city: '',
|
|
|
action: ''
|
...
|
...
|
@@ -169,7 +182,11 @@ const _convertAddress = (addressList, createTime) => { |
|
|
return _.reverse(addrList);
|
|
|
};
|
|
|
|
|
|
// 根据订单状态获取当前步骤
|
|
|
/**
|
|
|
* 获取订单状态
|
|
|
* @param { String } st 订单状态
|
|
|
* @return { [Object] }
|
|
|
*/
|
|
|
const _getStepByOrderStatus = st => {
|
|
|
let steps = [
|
|
|
{
|
...
|
...
|
@@ -197,6 +214,12 @@ const _getStepByOrderStatus = st => { |
|
|
return steps;
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 获取订单详情
|
|
|
* @param { Number } uid 用户id
|
|
|
* @param { Number } code 订单编码
|
|
|
* @return { Object } Promise 对象
|
|
|
*/
|
|
|
const _getDetail = (uid, code) => {
|
|
|
return api.get('', {
|
|
|
method: 'app.SpaceOrders.detail',
|
...
|
...
|
@@ -207,6 +230,13 @@ const _getDetail = (uid, code) => { |
|
|
});
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 获取订单列表
|
|
|
* @param { Number } uid 用户id
|
|
|
* @param { String } type 订单类型
|
|
|
* @param { Number } page 当前页
|
|
|
* @return { Object } Promise 对象
|
|
|
*/
|
|
|
const _getUserOrder = (uid, type, page) => {
|
|
|
|
|
|
return api.get('', {
|
...
|
...
|
@@ -302,6 +332,12 @@ const _getUserOrder = (uid, type, page) => { |
|
|
};
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 删除订单
|
|
|
* @param { Number } uid 用户id
|
|
|
* @param { String } code 订单编码
|
|
|
* @return { Object } Promise 对象
|
|
|
*/
|
|
|
const deleteOrder = (uid, code) => {
|
|
|
return api.get('', {
|
|
|
method: 'app.SpaceOrders.delOrderByCode',
|
...
|
...
|
@@ -310,6 +346,12 @@ const deleteOrder = (uid, code) => { |
|
|
});
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 取消订单
|
|
|
* @param { Number } uid 用户id
|
|
|
* @param { Object } data 调用接口所需的数据
|
|
|
* @return { Object } Promise 对象
|
|
|
*/
|
|
|
const cancelOrder = (uid, data) => {
|
|
|
return api.get('', {
|
|
|
method: 'app.SpaceOrders.close',
|
...
|
...
|
@@ -320,6 +362,10 @@ const cancelOrder = (uid, data) => { |
|
|
});
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 获取取消订单的理由
|
|
|
* @return { Object } Promise 对象
|
|
|
*/
|
|
|
const getCancelOrderReason = () => {
|
|
|
return api.get('', {
|
|
|
method: 'app.SpaceOrders.closeReasons'
|
...
|
...
|
@@ -328,6 +374,12 @@ const getCancelOrderReason = () => { |
|
|
});
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 获取快递信息
|
|
|
* @param { Number } uid 用户id
|
|
|
* @param { String } code 订单编号
|
|
|
* @return { Object } Promise 对象
|
|
|
*/
|
|
|
const getExpressInfo = (uid, code) => {
|
|
|
return api.get('', {
|
|
|
method: 'app.express.get',
|
...
|
...
|
@@ -338,6 +390,13 @@ const getExpressInfo = (uid, code) => { |
|
|
});
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 获取全部订单
|
|
|
* @param { Number } uid 用户id
|
|
|
* @param { String } type 订单类型
|
|
|
* @param { Number } page 页码
|
|
|
* @return { Object } Promise 对象
|
|
|
*/
|
|
|
const getOrderData = (uid, type, page) => {
|
|
|
const navBar = {
|
|
|
tabs: [
|
...
|
...
|
@@ -411,10 +470,16 @@ const getOrderData = (uid, type, page) => { |
|
|
});
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 获取订单详情
|
|
|
* @param { Number } uid 用户id
|
|
|
* @param { String } code 订单编号
|
|
|
* @return { Object } Promise 对象
|
|
|
*/
|
|
|
const getOrderDetail = (uid, code) => {
|
|
|
return api.all([_getDetail(uid, code), getExpressInfo(uid, code)]).then(result => {
|
|
|
let detail = result[0] && camelCase(result[0].data);
|
|
|
let express = result[1] && camelCase(result[1].data);
|
|
|
const detail = result[0] && camelCase(result[0].data);
|
|
|
const express = result[1] && camelCase(result[1].data);
|
|
|
|
|
|
const st = parseInt(detail.status, 10);
|
|
|
|
...
|
...
|
@@ -460,6 +525,11 @@ const getOrderDetail = (uid, code) => { |
|
|
});
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 编辑订单
|
|
|
* @param { Object } data 调用接口所需的数据
|
|
|
* @return { Object } Promise 对象
|
|
|
*/
|
|
|
const editOrder = data => {
|
|
|
return api.get('', {
|
|
|
method: 'app.SpaceOrders.updateDeliveryAddress',
|
...
|
...
|
@@ -474,6 +544,12 @@ const editOrder = data => { |
|
|
});
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 重新购买
|
|
|
* @param { Number } uid 用户id
|
|
|
* @param { String } code 订单编号
|
|
|
* @return { Object } Promise 对象
|
|
|
*/
|
|
|
const reAddCart = (uid, code) => {
|
|
|
return api.get('', {
|
|
|
method: 'app.Shopping.readd',
|
...
|
...
|
@@ -483,6 +559,12 @@ const reAddCart = (uid, code) => { |
|
|
});
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 确认收货
|
|
|
* @param { Number } uid 用户id
|
|
|
* @param { String } code 订单编号
|
|
|
* @return { Object } Promise 对象
|
|
|
*/
|
|
|
const confirmReceive = (uid, code) => {
|
|
|
return api.get('', {
|
|
|
method: 'app.SpaceOrders.confirm',
|
...
|
...
|
|