|
|
'use strict';
|
|
|
|
|
|
const Promise = require('bluebird');
|
|
|
const co = Promise.coroutine;
|
|
|
const OrderData=require('./OrderData');
|
|
|
const helpers = global.yoho.helpers;
|
|
|
const api = global.yoho.API;
|
|
|
|
|
|
class IndexModel extends global.mClass{
|
|
|
getPendingOrderCount($uid){
|
|
|
let options={
|
|
|
method:'web.SpaceOrders.getPendingOrderCount',
|
|
|
uid:$uid
|
|
|
};
|
|
|
return this.API.get('', options);
|
|
|
// class IndexModel extends global.mClass{
|
|
|
const getPendingOrderCount=($uid)=>{
|
|
|
let options={
|
|
|
method:'web.SpaceOrders.getPendingOrderCount',
|
|
|
uid:$uid
|
|
|
};
|
|
|
return api.get('', options);
|
|
|
}
|
|
|
const infoNum=($uid, $udid)=>{
|
|
|
let options={
|
|
|
method:'app.home.getInfoNum',
|
|
|
uid:$uid,
|
|
|
udid:$udid
|
|
|
}
|
|
|
infoNum($uid, $udid){
|
|
|
let options={
|
|
|
method:'app.home.getInfoNum',
|
|
|
uid:$uid,
|
|
|
udid:$udid
|
|
|
}
|
|
|
return this.API.get('', options);
|
|
|
return api.get('', options);
|
|
|
}
|
|
|
const notCommentRecordCount=($uid)=>{
|
|
|
let options={
|
|
|
method:'show.notCommentRecordCount',
|
|
|
uid:$uid
|
|
|
}
|
|
|
notCommentRecordCount($uid){
|
|
|
let options={
|
|
|
method:'show.notCommentRecordCount',
|
|
|
uid:$uid
|
|
|
return api.get('', options);
|
|
|
}
|
|
|
const getInfoNumData=($uid, $udid)=>{
|
|
|
let $result=[
|
|
|
{href:helpers.urlFormat('/home/orders'),name:'待处理订单','count':0},
|
|
|
{href:helpers.urlFormat('/home/message'),name:'未读消息','count':0},
|
|
|
{href:helpers.urlFormat('/home/comment'),name:'待评论商品','count':0}
|
|
|
];
|
|
|
return co(function * (){
|
|
|
let $getPendingOrderCount = yield getPendingOrderCount($uid);//待处理订单
|
|
|
console.log($getPendingOrderCount);
|
|
|
let $infoNumData = yield infoNum($uid, $udid); //未读消息
|
|
|
let $notCommentRecordCount = yield notCommentRecordCount($uid);//待评论商品
|
|
|
$result[0]['count']=$getPendingOrderCount.data.count?$getPendingOrderCount.data.count:0;
|
|
|
$result[1]['count']=$infoNumData.data.inbox_total?$infoNumData.data.inbox_total:0;
|
|
|
$result[2]['count']=$notCommentRecordCount.data?$notCommentRecordCount.data:0;
|
|
|
return $result;
|
|
|
})();
|
|
|
}
|
|
|
const getByNodeContent=($node, $mode)=>{
|
|
|
$mode=$mode||'release';
|
|
|
let options={
|
|
|
method:'web.html.content',
|
|
|
mode:$mode,
|
|
|
node:$node
|
|
|
};
|
|
|
return api.get('', options);
|
|
|
}
|
|
|
const getFooterBanner=($code)=>{
|
|
|
|
|
|
$code=$code||'20110609-152143';
|
|
|
return co(function *(){
|
|
|
let result="";
|
|
|
let $banner=yield getByNodeContent($code);
|
|
|
if($banner.code&&$banner.data){
|
|
|
result=$banner.data.replace('http://','//');
|
|
|
}
|
|
|
return this.API.get('', options);
|
|
|
}
|
|
|
getInfoNumData($uid, $udid){
|
|
|
var that=this;
|
|
|
let $result=[
|
|
|
{href:this.helpers.urlFormat('/home/orders'),name:'待处理订单','count':0},
|
|
|
{href:this.helpers.urlFormat('/home/message'),name:'未读消息','count':0},
|
|
|
{href:this.helpers.urlFormat('/home/comment'),name:'待评论商品','count':0}
|
|
|
];
|
|
|
return co(function * (){
|
|
|
let $getPendingOrderCount = yield that.getPendingOrderCount($uid);//待处理订单
|
|
|
let $infoNumData = yield that.infoNum($uid, $udid); //未读消息
|
|
|
let $notCommentRecordCount = yield that.notCommentRecordCount($uid);//待评论商品
|
|
|
$result[0]['count']=$getPendingOrderCount.data.count?$getPendingOrderCount.data.count:0;
|
|
|
$result[1]['count']=$infoNumData.data.inbox_total?$infoNumData.data.inbox_total:0;
|
|
|
$result[2]['count']=$notCommentRecordCount.data?$notCommentRecordCount.data:0;
|
|
|
return $result;
|
|
|
})();
|
|
|
}
|
|
|
getFooterBanner($code){
|
|
|
$code=$code||'20110609-152143';
|
|
|
return result;
|
|
|
})()
|
|
|
}
|
|
|
/**
|
|
|
* 订单状态
|
|
|
* @param type $isCancel
|
|
|
* @param type $status
|
|
|
* @param type $payType
|
|
|
* @param type $payStatus
|
|
|
* @return string
|
|
|
*/
|
|
|
// const getOrderStatus=($isCancel, $status, $payType, $payStatus)=>{
|
|
|
// //初始化:未取消,待付款
|
|
|
// let $ret={cancel:false,keyName:'noPay',statusStr:'待付款'};
|
|
|
// if ($isCancel == 'Y') {
|
|
|
// $ret = {cancel:true,statusStr:'已取消'};
|
|
|
// }else{
|
|
|
// switch ($status) {
|
|
|
// case 0:
|
|
|
// //'订单已成功,等待付款'
|
|
|
// if ($payType != 2 && $payStatus == 'N') {
|
|
|
// $ret['keyName'] = 'noPay';
|
|
|
// $ret['statusStr'] = '待付款';
|
|
|
// }
|
|
|
// //'订单已付款,等待备货中'
|
|
|
// else if ($payType != 2 && $payStatus == 'Y') {
|
|
|
// $ret['keyName'] = 'paid';
|
|
|
// $ret['statusStr'] = '备货中';
|
|
|
// }
|
|
|
// //'订单已成功,等待备货中'-货到付款
|
|
|
// else if ($payType == 2 && $payStatus == 'N') {
|
|
|
// $ret['keyName'] = 'complete';
|
|
|
// $ret['statusStr'] = '备货中';
|
|
|
// }
|
|
|
// break;
|
|
|
// case 1:
|
|
|
// case 2:
|
|
|
// case 3:
|
|
|
// //'订单已付款,等待备货中'
|
|
|
// $ret['keyName'] = 'paid';
|
|
|
// $ret['statusStr'] = '备货中';
|
|
|
// break;
|
|
|
// case 4:
|
|
|
// case 5:
|
|
|
// //'订单已发货'
|
|
|
// $ret['keyName'] = 'shipped';
|
|
|
// $ret['statusStr'] = '待收货';
|
|
|
// break;
|
|
|
// case 6:
|
|
|
// //'交易完成';
|
|
|
// $ret['keyName'] = 'reback';
|
|
|
// $ret['statusStr'] = '交易完成';
|
|
|
// break;
|
|
|
// }
|
|
|
// }
|
|
|
// return $ret;
|
|
|
// }
|
|
|
// const getExpressInfo=($orderCode, $uid, $paymetType, $createTime, $isDetail)=>{
|
|
|
// $isDetail=$isDetail||false;
|
|
|
// let $result={};
|
|
|
// $result['logisticsUrl'] = '';
|
|
|
// $result['logisticsImg'] = '';
|
|
|
// $result['logisticsCompany'] = '';
|
|
|
// $result['courierNumbe'] = '';
|
|
|
|
|
|
// if ($paymetType == 1) {
|
|
|
// if ($isDetail) {
|
|
|
// $result['logistics'] = [new Date($createTime), ' ', '您的订单已提交,等待付款'];
|
|
|
// }
|
|
|
// else {
|
|
|
// $result['logistics'] = new Date($createTime) + ' ' + '您的订单已提交,等待付款';
|
|
|
// }
|
|
|
// }
|
|
|
// if ($paymetType == 2) {
|
|
|
// if ($isDetail) {
|
|
|
// $result['logistics'] = [new Date($createTime), ' ', '您的订单已提交,等待审核'];
|
|
|
// }
|
|
|
// else {
|
|
|
// $result['logistics'] = new Date($createTime) +' ' + '您的订单已提交,等待审核';
|
|
|
// }
|
|
|
// }
|
|
|
// //有物流
|
|
|
// if ($orderCode && typeof _.isNumber($uid)) {
|
|
|
// let $logistics = yield OrderData.getLogisticsData($orderCode, $uid);
|
|
|
// if ($logistics['data']) {
|
|
|
// $result['logisticsUrl'] = $logistics['data']['url'] ? this.helper.getUrlSafe($logistics['data']['url']) : '';
|
|
|
// $result['logisticsImg'] = $logistics['data']['logo'] ? $logistics['data']['logo'] : '';
|
|
|
// $result['logisticsCompany'] = $logistics['data']['caption'] ? $logistics['data']['caption'] : '';
|
|
|
// $result['courierNumbe'] = $logistics['data']['express_number']? $logistics['data']['express_number'] : '';
|
|
|
// let $expressDetail = $logistics['data']['express_detail'] ? $logistics['data']['express_detail'] : {};
|
|
|
// if ($expressDetail) {
|
|
|
// $logisticsTmp = $result['logistics'][0]; //暂存
|
|
|
// $result['logistics'] = array();
|
|
|
// foreach ($expressDetail as $value) {
|
|
|
// $pos =$value['accept_address'].indexOf(' ') / 3;
|
|
|
// $city = $value['accept_address'].substr(0,$pos);
|
|
|
// $exInfo = $value['accept_address'].substr($pos);
|
|
|
// if ($isDetail) {
|
|
|
// $result['logistics'] = [$value['acceptTime'], $city, $exInfo];
|
|
|
// }
|
|
|
// else {
|
|
|
// $result['logistics'] = $value['acceptTime'] + $city + $exInfo;
|
|
|
// }
|
|
|
// }
|
|
|
// //把最初的处理放最后
|
|
|
// $result['logistics'] = $logisticsTmp;
|
|
|
// }
|
|
|
// }
|
|
|
// }
|
|
|
// return $result;
|
|
|
// }
|
|
|
/**
|
|
|
* 商品属性标签
|
|
|
* @param type $attribute
|
|
|
* @param type $goodsType
|
|
|
* @return string
|
|
|
*/
|
|
|
// const getGoodsTag=($attribute, $goodsType)=>{
|
|
|
// let $goodsTagName = '';
|
|
|
// switch ($goodsType) {
|
|
|
// //赠品
|
|
|
// case 'gift':
|
|
|
// $goodsTagName = 'freebie';
|
|
|
// break;
|
|
|
// //加价购
|
|
|
// case 'price_gift':
|
|
|
// $goodsTagName = 'advanceBuy';
|
|
|
// break;
|
|
|
// //预售
|
|
|
// case 'advance':
|
|
|
// $goodsTagName = 'preSaleGood';
|
|
|
// break;
|
|
|
// //outlet
|
|
|
// case 'outlet':
|
|
|
// $goodsTagName = '';
|
|
|
// break;
|
|
|
// //免单
|
|
|
// case 'free':
|
|
|
// $goodsTagName = '';
|
|
|
// break;
|
|
|
// //电子
|
|
|
// case 'ticket':
|
|
|
// $goodsTagName = '';
|
|
|
// break;
|
|
|
// default:
|
|
|
// break;
|
|
|
// }
|
|
|
// //虚拟
|
|
|
// if ($attribute == 3) {
|
|
|
// $goodsTagName = 'virtualGood';
|
|
|
// }
|
|
|
// return $goodsTagName;
|
|
|
// }
|
|
|
/**
|
|
|
* 获取我的订单列表数据-分页
|
|
|
* @param type $uid
|
|
|
* @param type $page
|
|
|
* @param type $limit
|
|
|
* @param type $type 获取订单类型 type=1全部,type=2待付款,type=3待发货,type=4待收货,type=5待评论(已成功) 7取消
|
|
|
*/
|
|
|
// const getOrders=($uid, $page, $limit, $type, $isPage)=>{
|
|
|
|
|
|
// return co(function *(){
|
|
|
// $isPage=$isPage||false;
|
|
|
// let getOrderDescStr={
|
|
|
// 1:'您还没有任何订单',
|
|
|
// 5:'您目前还没有成功的订单',
|
|
|
// 7:'您还没有任何取消的订单'
|
|
|
// }
|
|
|
// let $descStr=getOrderDescStr[$type]||'';
|
|
|
// let $orders={empty:$descStr};
|
|
|
// let $orderInfo=yield OrderData.getUserOrders($uid, $page, $limit, $type);
|
|
|
// if($orderInfo.data&&$orderInfo.data.order_list){
|
|
|
// $orders={};
|
|
|
// $orderInfo.data.order_list.forEach(function($orderV,$orderK){
|
|
|
// $orders[$orderK]['orderNum'] = $orderV['order_code']; //订单标识
|
|
|
// $orders[$orderK]['orderTime'] = new Date($orderV['create_time']);
|
|
|
// let $statusInfo = getOrderStatus($orderV['is_cancel'], $orderV['status'], $orderV['payment_type'], $orderV['payment_status']);
|
|
|
|
|
|
// //订单状态
|
|
|
// if ($statusInfo['cancel']) {
|
|
|
// $orders[$orderK]['cancel'] = $statusInfo['cancel'];
|
|
|
// }
|
|
|
// else {
|
|
|
// if ($statusInfo['keyName']) {
|
|
|
// $orders[$orderK][$statusInfo['keyName']] = true;
|
|
|
// //已发货,物流信息
|
|
|
// if ($statusInfo['keyName'] == 'shipped') {
|
|
|
// let $expressInfo = getExpressInfo($orderV['order_code'], $uid, $orderV['payment_type'], $orderV['create_time']);
|
|
|
// $orders[$orderK]['logistics'] = $expressInfo['logistics'];
|
|
|
// }
|
|
|
// }
|
|
|
// }
|
|
|
|
|
|
// //订单商品相关信息
|
|
|
// let $opRefundStatus = true; //订单不可操作退换货
|
|
|
// if ($orderV['order_goods'] && $orderV['order_goods']) {
|
|
|
// let $goods={},$refundFlag={};
|
|
|
// $orderV['order_goods'].forEach(function($goval,$gokey){
|
|
|
// $goods[$gokey]['href'] = helpers.getUrlBySkc($goval['product_id'], $goval['goods_id'], $goval['cn_alphabet']);
|
|
|
// $goods[$gokey]['thumb'] = $goval['goods_image'] && $goval['goods_image'] ? global.utils.getImageUrl($goval['goods_image'], 100, 100) : '';
|
|
|
// $goods[$gokey]['name'] = $goval['product_name'];
|
|
|
// $goods[$gokey]['color'] = $goval['color_name'];
|
|
|
// $goods[$gokey]['size'] = $goval['size_name'];
|
|
|
// $goods[$gokey]['price'] = $goval['goods_price'];
|
|
|
// let $buyNum = Number($goval['buy_number']);
|
|
|
// let $refundNum = Number($goval['refund_num']);
|
|
|
// $goods[$gokey]['count'] = $buyNum;
|
|
|
// $refundStatus = ($refundNum > 0) ? true : false; //只要发生一件退换,退换过的标记
|
|
|
// $goods[$gokey]['refundStatus'] = $refundStatus;
|
|
|
// $refundFlag = (($buyNum == $refundNum) && $refundNum > 0) ? 'finished' : 'unfinished'; //某一件商品全部退换结束
|
|
|
// $goods[$gokey]['arrivalDate'] = $goval['expect_arrival_time'];
|
|
|
// let $goodsTagName = self::getGoodsTag($orderV['attribute'], $goval['goods_type']);
|
|
|
// if ($goodsTagName) {
|
|
|
// $goods[$gokey][$goodsTagName] = true;
|
|
|
// }
|
|
|
// $orders[$orderK]['goods'] = $goods;
|
|
|
// });
|
|
|
|
|
|
// if($refundFlag.indexOf('unfinished')){
|
|
|
// $opRefundStatus = false;
|
|
|
// }
|
|
|
// $orders[$orderK]['pay'] = $orderV['amount']; //付款数
|
|
|
// $orders[$orderK]['fregit'] = $orderV['shipping_cost']; //邮费
|
|
|
// }
|
|
|
// //操作
|
|
|
// $orders[$orderK]['operation'] = getOperateInfo($orderV['attribute'], $orderV['is_cancel'], $orderV['status'], $orderV['payment_status'], $orderV['update_time'], $orderV['order_type'], $orderV['refund_status'], $orderV['payment_type'], $orderV['order_code'], $opRefundStatus);
|
|
|
|
|
|
// });
|
|
|
// if ($isPage) {
|
|
|
// $orders['pager']['total'] = $orderInfo['data']['total'];
|
|
|
// $orders['pager']['pageTotal'] = $orderInfo['data']['page_total'];
|
|
|
// $orders['pager']['page'] = $orderInfo['data']['page'];
|
|
|
// }
|
|
|
// return $orders;
|
|
|
// }
|
|
|
// })();
|
|
|
// }
|
|
|
// const latestOrders=($uid)=>{
|
|
|
|
|
|
// return co(function *(){
|
|
|
// let $orders=yield getOrders($uid, 1, 2, 1)
|
|
|
// return {
|
|
|
// more : helpers.url('/home/orders'),
|
|
|
// orders:$orders
|
|
|
// }
|
|
|
// })();
|
|
|
// }
|
|
|
|
|
|
module.exports = {
|
|
|
getInfoNumData,
|
|
|
getFooterBanner
|
|
|
};
|
|
|
|
|
|
}
|
|
|
// getBrandListUrl(){
|
|
|
// return this.SearchAPI.get('/yohosearch/brand/list.json', {},{cache:true});
|
|
|
// }
|
...
|
...
|
@@ -112,7 +384,7 @@ class IndexModel extends global.mClass{ |
|
|
// return $hotBrands;
|
|
|
// }
|
|
|
// homeData(){
|
|
|
// let that=this;
|
|
|
//
|
|
|
// return co(function * (){
|
|
|
// let $result = {};
|
|
|
// let $url={};
|
...
|
...
|
@@ -123,5 +395,5 @@ class IndexModel extends global.mClass{ |
|
|
// // $result.brand=$data.fav_brand&&!$data.fav_brand?
|
|
|
// }();
|
|
|
// }
|
|
|
}
|
|
|
module.exports = IndexModel; |
|
|
// }
|
|
|
// module.exports = IndexModel; |
...
|
...
|
|