Authored by weiqingting

个人中心首页

1 -'use strict';  
2 -  
3 -class cClass{  
4 - constructor(){}  
5 -}  
6 -module.exports = cClass;  
@@ -4,29 +4,36 @@ const Promise = require('bluebird'); @@ -4,29 +4,36 @@ const Promise = require('bluebird');
4 const co = Promise.coroutine; 4 const co = Promise.coroutine;
5 5
6 const OrderData = require('../models/OrderData'); 6 const OrderData = require('../models/OrderData');
7 -const orderDate=new OrderData();  
8 const IndexModel = require('../models/Index'); 7 const IndexModel = require('../models/Index');
9 -const indexModel=new IndexModel();  
10 const helpers = global.yoho.helpers; 8 const helpers = global.yoho.helpers;
11 9
12 -class Account extends global.cClass{  
13 10
14 - index(req,res,next){  
15 - let $uid= '8041246';//req.user.uid;  
16 - let $udid= 'abcdrf';//req.sessionID; 11 +const index=(req,res,next)=>{
  12 + let $uid= '8041246';//req.user.uid;
  13 + let $udid= 'abcdrf';//req.sessionID;
17 14
18 - co(function * (){  
19 - let pall= yield Promise.all([orderDate.closeReasons(),indexModel.getInfoNumData($uid, $udid)]);  
20 - let $cancelReason=pall[0].data?pall[0].data:'';  
21 - res.render("home/index/index",{  
22 - cancelReason:$cancelReason,  
23 - content:[  
24 - {messages:pall[1]},  
25 - {latestOrders:{}}  
26 - ],  
27 - helpUsUrl:''  
28 - });  
29 - })().catch(next);  
30 - } 15 + co(function * (){
  16 + let pall= yield Promise.all([OrderData.closeReasons(),IndexModel.getInfoNumData($uid, $udid)]);
  17 + let $cancelReason=pall[0].data?pall[0].data:'';
  18 + console.log(pall[2]);
  19 + res.render("home/index/index",{
  20 + cancelReason:$cancelReason,
  21 + content:[
  22 + {messages:pall[1]},
  23 + {
  24 + latestOrders:{},
  25 + favBrand:{
  26 + more:'/brands',
  27 + brands:'brand'
  28 + },
  29 + newArrival:'new'
  30 + }
  31 + ],
  32 + helpUsUrl:''
  33 + });
  34 + })().catch(next);
31 } 35 }
32 -module.exports=Account; 36 +
  37 +module.exports = {
  38 + index
  39 +};
@@ -26,8 +26,6 @@ app.engine('.hbs', hbs({ @@ -26,8 +26,6 @@ app.engine('.hbs', hbs({
26 helpers: global.yoho.helpers 26 helpers: global.yoho.helpers
27 })); 27 }));
28 28
29 -global.mClass=require("./mClass");  
30 -global.cClass=require("./cClass");  
31 // router 29 // router
32 app.use(require('./router')); 30 app.use(require('./router'));
33 31
1 -'use strict';  
2 -  
3 -var logger = global.yoho.logger;  
4 -var api = global.yoho.API;  
5 -var SearchAPI = global.yoho.SearchAPI;  
6 -const helpers = global.yoho.helpers;  
7 -  
8 -class mClass{  
9 - constructor(){  
10 - this.API=api;  
11 - this.SearchAPI=SearchAPI;  
12 - this.logger=logger;  
13 - this.helpers=helpers;  
14 - }  
15 -  
16 - cb(logs,options){  
17 - return (result)=>{  
18 - if (result && result.code === 200) {  
19 - return result.data;  
20 - } else {  
21 - logger.error(`${logs+JSON.stringify(options)} 接口返回数据错误`);  
22 - return false;  
23 - }  
24 - }  
25 - }  
26 -}  
27 -  
28 -module.exports = mClass;  
29 -  
30 -  
1 'use strict'; 1 'use strict';
  2 +
2 const Promise = require('bluebird'); 3 const Promise = require('bluebird');
3 const co = Promise.coroutine; 4 const co = Promise.coroutine;
  5 +const OrderData=require('./OrderData');
  6 +const helpers = global.yoho.helpers;
  7 +const api = global.yoho.API;
4 8
5 -class IndexModel extends global.mClass{  
6 - getPendingOrderCount($uid){  
7 - let options={  
8 - method:'web.SpaceOrders.getPendingOrderCount',  
9 - uid:$uid  
10 - };  
11 - return this.API.get('', options); 9 +// class IndexModel extends global.mClass{
  10 +const getPendingOrderCount=($uid)=>{
  11 + let options={
  12 + method:'web.SpaceOrders.getPendingOrderCount',
  13 + uid:$uid
  14 + };
  15 + return api.get('', options);
  16 +}
  17 +const infoNum=($uid, $udid)=>{
  18 + let options={
  19 + method:'app.home.getInfoNum',
  20 + uid:$uid,
  21 + udid:$udid
12 } 22 }
13 - infoNum($uid, $udid){  
14 - let options={  
15 - method:'app.home.getInfoNum',  
16 - uid:$uid,  
17 - udid:$udid  
18 - }  
19 - return this.API.get('', options); 23 + return api.get('', options);
  24 +}
  25 +const notCommentRecordCount=($uid)=>{
  26 + let options={
  27 + method:'show.notCommentRecordCount',
  28 + uid:$uid
20 } 29 }
21 - notCommentRecordCount($uid){  
22 - let options={  
23 - method:'show.notCommentRecordCount',  
24 - uid:$uid 30 + return api.get('', options);
  31 +}
  32 +const getInfoNumData=($uid, $udid)=>{
  33 + let $result=[
  34 + {href:helpers.urlFormat('/home/orders'),name:'待处理订单','count':0},
  35 + {href:helpers.urlFormat('/home/message'),name:'未读消息','count':0},
  36 + {href:helpers.urlFormat('/home/comment'),name:'待评论商品','count':0}
  37 + ];
  38 + return co(function * (){
  39 + let $getPendingOrderCount = yield getPendingOrderCount($uid);//待处理订单
  40 + console.log($getPendingOrderCount);
  41 + let $infoNumData = yield infoNum($uid, $udid); //未读消息
  42 + let $notCommentRecordCount = yield notCommentRecordCount($uid);//待评论商品
  43 + $result[0]['count']=$getPendingOrderCount.data.count?$getPendingOrderCount.data.count:0;
  44 + $result[1]['count']=$infoNumData.data.inbox_total?$infoNumData.data.inbox_total:0;
  45 + $result[2]['count']=$notCommentRecordCount.data?$notCommentRecordCount.data:0;
  46 + return $result;
  47 + })();
  48 +}
  49 +const getByNodeContent=($node, $mode)=>{
  50 + $mode=$mode||'release';
  51 + let options={
  52 + method:'web.html.content',
  53 + mode:$mode,
  54 + node:$node
  55 + };
  56 + return api.get('', options);
  57 +}
  58 +const getFooterBanner=($code)=>{
  59 +
  60 + $code=$code||'20110609-152143';
  61 + return co(function *(){
  62 + let result="";
  63 + let $banner=yield getByNodeContent($code);
  64 + if($banner.code&&$banner.data){
  65 + result=$banner.data.replace('http://','//');
25 } 66 }
26 - return this.API.get('', options);  
27 - }  
28 - getInfoNumData($uid, $udid){  
29 - var that=this;  
30 - let $result=[  
31 - {href:this.helpers.urlFormat('/home/orders'),name:'待处理订单','count':0},  
32 - {href:this.helpers.urlFormat('/home/message'),name:'未读消息','count':0},  
33 - {href:this.helpers.urlFormat('/home/comment'),name:'待评论商品','count':0}  
34 - ];  
35 - return co(function * (){  
36 - let $getPendingOrderCount = yield that.getPendingOrderCount($uid);//待处理订单  
37 - let $infoNumData = yield that.infoNum($uid, $udid); //未读消息  
38 - let $notCommentRecordCount = yield that.notCommentRecordCount($uid);//待评论商品  
39 - $result[0]['count']=$getPendingOrderCount.data.count?$getPendingOrderCount.data.count:0;  
40 - $result[1]['count']=$infoNumData.data.inbox_total?$infoNumData.data.inbox_total:0;  
41 - $result[2]['count']=$notCommentRecordCount.data?$notCommentRecordCount.data:0;  
42 - return $result;  
43 - })();  
44 - }  
45 - getFooterBanner($code){  
46 - $code=$code||'20110609-152143'; 67 + return result;
  68 + })()
  69 +}
  70 + /**
  71 + * 订单状态
  72 + * @param type $isCancel
  73 + * @param type $status
  74 + * @param type $payType
  75 + * @param type $payStatus
  76 + * @return string
  77 + */
  78 +// const getOrderStatus=($isCancel, $status, $payType, $payStatus)=>{
  79 +// //初始化:未取消,待付款
  80 +// let $ret={cancel:false,keyName:'noPay',statusStr:'待付款'};
  81 +// if ($isCancel == 'Y') {
  82 +// $ret = {cancel:true,statusStr:'已取消'};
  83 +// }else{
  84 +// switch ($status) {
  85 +// case 0:
  86 +// //'订单已成功,等待付款'
  87 +// if ($payType != 2 && $payStatus == 'N') {
  88 +// $ret['keyName'] = 'noPay';
  89 +// $ret['statusStr'] = '待付款';
  90 +// }
  91 +// //'订单已付款,等待备货中'
  92 +// else if ($payType != 2 && $payStatus == 'Y') {
  93 +// $ret['keyName'] = 'paid';
  94 +// $ret['statusStr'] = '备货中';
  95 +// }
  96 +// //'订单已成功,等待备货中'-货到付款
  97 +// else if ($payType == 2 && $payStatus == 'N') {
  98 +// $ret['keyName'] = 'complete';
  99 +// $ret['statusStr'] = '备货中';
  100 +// }
  101 +// break;
  102 +// case 1:
  103 +// case 2:
  104 +// case 3:
  105 +// //'订单已付款,等待备货中'
  106 +// $ret['keyName'] = 'paid';
  107 +// $ret['statusStr'] = '备货中';
  108 +// break;
  109 +// case 4:
  110 +// case 5:
  111 +// //'订单已发货'
  112 +// $ret['keyName'] = 'shipped';
  113 +// $ret['statusStr'] = '待收货';
  114 +// break;
  115 +// case 6:
  116 +// //'交易完成';
  117 +// $ret['keyName'] = 'reback';
  118 +// $ret['statusStr'] = '交易完成';
  119 +// break;
  120 +// }
  121 +// }
  122 +// return $ret;
  123 +// }
  124 +// const getExpressInfo=($orderCode, $uid, $paymetType, $createTime, $isDetail)=>{
  125 +// $isDetail=$isDetail||false;
  126 +// let $result={};
  127 +// $result['logisticsUrl'] = '';
  128 +// $result['logisticsImg'] = '';
  129 +// $result['logisticsCompany'] = '';
  130 +// $result['courierNumbe'] = '';
  131 +
  132 +// if ($paymetType == 1) {
  133 +// if ($isDetail) {
  134 +// $result['logistics'] = [new Date($createTime), ' ', '您的订单已提交,等待付款'];
  135 +// }
  136 +// else {
  137 +// $result['logistics'] = new Date($createTime) + ' ' + '您的订单已提交,等待付款';
  138 +// }
  139 +// }
  140 +// if ($paymetType == 2) {
  141 +// if ($isDetail) {
  142 +// $result['logistics'] = [new Date($createTime), ' ', '您的订单已提交,等待审核'];
  143 +// }
  144 +// else {
  145 +// $result['logistics'] = new Date($createTime) +' ' + '您的订单已提交,等待审核';
  146 +// }
  147 +// }
  148 +// //有物流
  149 +// if ($orderCode && typeof _.isNumber($uid)) {
  150 +// let $logistics = yield OrderData.getLogisticsData($orderCode, $uid);
  151 +// if ($logistics['data']) {
  152 +// $result['logisticsUrl'] = $logistics['data']['url'] ? this.helper.getUrlSafe($logistics['data']['url']) : '';
  153 +// $result['logisticsImg'] = $logistics['data']['logo'] ? $logistics['data']['logo'] : '';
  154 +// $result['logisticsCompany'] = $logistics['data']['caption'] ? $logistics['data']['caption'] : '';
  155 +// $result['courierNumbe'] = $logistics['data']['express_number']? $logistics['data']['express_number'] : '';
  156 +// let $expressDetail = $logistics['data']['express_detail'] ? $logistics['data']['express_detail'] : {};
  157 +// if ($expressDetail) {
  158 +// $logisticsTmp = $result['logistics'][0]; //暂存
  159 +// $result['logistics'] = array();
  160 +// foreach ($expressDetail as $value) {
  161 +// $pos =$value['accept_address'].indexOf(' ') / 3;
  162 +// $city = $value['accept_address'].substr(0,$pos);
  163 +// $exInfo = $value['accept_address'].substr($pos);
  164 +// if ($isDetail) {
  165 +// $result['logistics'] = [$value['acceptTime'], $city, $exInfo];
  166 +// }
  167 +// else {
  168 +// $result['logistics'] = $value['acceptTime'] + $city + $exInfo;
  169 +// }
  170 +// }
  171 +// //把最初的处理放最后
  172 +// $result['logistics'] = $logisticsTmp;
  173 +// }
  174 +// }
  175 +// }
  176 +// return $result;
  177 +// }
  178 + /**
  179 + * 商品属性标签
  180 + * @param type $attribute
  181 + * @param type $goodsType
  182 + * @return string
  183 + */
  184 +// const getGoodsTag=($attribute, $goodsType)=>{
  185 +// let $goodsTagName = '';
  186 +// switch ($goodsType) {
  187 +// //赠品
  188 +// case 'gift':
  189 +// $goodsTagName = 'freebie';
  190 +// break;
  191 +// //加价购
  192 +// case 'price_gift':
  193 +// $goodsTagName = 'advanceBuy';
  194 +// break;
  195 +// //预售
  196 +// case 'advance':
  197 +// $goodsTagName = 'preSaleGood';
  198 +// break;
  199 +// //outlet
  200 +// case 'outlet':
  201 +// $goodsTagName = '';
  202 +// break;
  203 +// //免单
  204 +// case 'free':
  205 +// $goodsTagName = '';
  206 +// break;
  207 +// //电子
  208 +// case 'ticket':
  209 +// $goodsTagName = '';
  210 +// break;
  211 +// default:
  212 +// break;
  213 +// }
  214 +// //虚拟
  215 +// if ($attribute == 3) {
  216 +// $goodsTagName = 'virtualGood';
  217 +// }
  218 +// return $goodsTagName;
  219 +// }
  220 + /**
  221 + * 获取我的订单列表数据-分页
  222 + * @param type $uid
  223 + * @param type $page
  224 + * @param type $limit
  225 + * @param type $type 获取订单类型 type=1全部,type=2待付款,type=3待发货,type=4待收货,type=5待评论(已成功) 7取消
  226 + */
  227 +// const getOrders=($uid, $page, $limit, $type, $isPage)=>{
  228 +
  229 +// return co(function *(){
  230 +// $isPage=$isPage||false;
  231 +// let getOrderDescStr={
  232 +// 1:'您还没有任何订单',
  233 +// 5:'您目前还没有成功的订单',
  234 +// 7:'您还没有任何取消的订单'
  235 +// }
  236 +// let $descStr=getOrderDescStr[$type]||'';
  237 +// let $orders={empty:$descStr};
  238 +// let $orderInfo=yield OrderData.getUserOrders($uid, $page, $limit, $type);
  239 +// if($orderInfo.data&&$orderInfo.data.order_list){
  240 +// $orders={};
  241 +// $orderInfo.data.order_list.forEach(function($orderV,$orderK){
  242 +// $orders[$orderK]['orderNum'] = $orderV['order_code']; //订单标识
  243 +// $orders[$orderK]['orderTime'] = new Date($orderV['create_time']);
  244 +// let $statusInfo = getOrderStatus($orderV['is_cancel'], $orderV['status'], $orderV['payment_type'], $orderV['payment_status']);
  245 +
  246 +// //订单状态
  247 +// if ($statusInfo['cancel']) {
  248 +// $orders[$orderK]['cancel'] = $statusInfo['cancel'];
  249 +// }
  250 +// else {
  251 +// if ($statusInfo['keyName']) {
  252 +// $orders[$orderK][$statusInfo['keyName']] = true;
  253 +// //已发货,物流信息
  254 +// if ($statusInfo['keyName'] == 'shipped') {
  255 +// let $expressInfo = getExpressInfo($orderV['order_code'], $uid, $orderV['payment_type'], $orderV['create_time']);
  256 +// $orders[$orderK]['logistics'] = $expressInfo['logistics'];
  257 +// }
  258 +// }
  259 +// }
  260 +
  261 +// //订单商品相关信息
  262 +// let $opRefundStatus = true; //订单不可操作退换货
  263 +// if ($orderV['order_goods'] && $orderV['order_goods']) {
  264 +// let $goods={},$refundFlag={};
  265 +// $orderV['order_goods'].forEach(function($goval,$gokey){
  266 +// $goods[$gokey]['href'] = helpers.getUrlBySkc($goval['product_id'], $goval['goods_id'], $goval['cn_alphabet']);
  267 +// $goods[$gokey]['thumb'] = $goval['goods_image'] && $goval['goods_image'] ? global.utils.getImageUrl($goval['goods_image'], 100, 100) : '';
  268 +// $goods[$gokey]['name'] = $goval['product_name'];
  269 +// $goods[$gokey]['color'] = $goval['color_name'];
  270 +// $goods[$gokey]['size'] = $goval['size_name'];
  271 +// $goods[$gokey]['price'] = $goval['goods_price'];
  272 +// let $buyNum = Number($goval['buy_number']);
  273 +// let $refundNum = Number($goval['refund_num']);
  274 +// $goods[$gokey]['count'] = $buyNum;
  275 +// $refundStatus = ($refundNum > 0) ? true : false; //只要发生一件退换,退换过的标记
  276 +// $goods[$gokey]['refundStatus'] = $refundStatus;
  277 +// $refundFlag = (($buyNum == $refundNum) && $refundNum > 0) ? 'finished' : 'unfinished'; //某一件商品全部退换结束
  278 +// $goods[$gokey]['arrivalDate'] = $goval['expect_arrival_time'];
  279 +// let $goodsTagName = self::getGoodsTag($orderV['attribute'], $goval['goods_type']);
  280 +// if ($goodsTagName) {
  281 +// $goods[$gokey][$goodsTagName] = true;
  282 +// }
  283 +// $orders[$orderK]['goods'] = $goods;
  284 +// });
  285 +
  286 +// if($refundFlag.indexOf('unfinished')){
  287 +// $opRefundStatus = false;
  288 +// }
  289 +// $orders[$orderK]['pay'] = $orderV['amount']; //付款数
  290 +// $orders[$orderK]['fregit'] = $orderV['shipping_cost']; //邮费
  291 +// }
  292 +// //操作
  293 +// $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);
  294 +
  295 +// });
  296 +// if ($isPage) {
  297 +// $orders['pager']['total'] = $orderInfo['data']['total'];
  298 +// $orders['pager']['pageTotal'] = $orderInfo['data']['page_total'];
  299 +// $orders['pager']['page'] = $orderInfo['data']['page'];
  300 +// }
  301 +// return $orders;
  302 +// }
  303 +// })();
  304 +// }
  305 +// const latestOrders=($uid)=>{
  306 +
  307 +// return co(function *(){
  308 +// let $orders=yield getOrders($uid, 1, 2, 1)
  309 +// return {
  310 +// more : helpers.url('/home/orders'),
  311 +// orders:$orders
  312 +// }
  313 +// })();
  314 +// }
  315 +
  316 +module.exports = {
  317 + getInfoNumData,
  318 + getFooterBanner
  319 +};
47 320
48 - }  
49 // getBrandListUrl(){ 321 // getBrandListUrl(){
50 // return this.SearchAPI.get('/yohosearch/brand/list.json', {},{cache:true}); 322 // return this.SearchAPI.get('/yohosearch/brand/list.json', {},{cache:true});
51 // } 323 // }
@@ -112,7 +384,7 @@ class IndexModel extends global.mClass{ @@ -112,7 +384,7 @@ class IndexModel extends global.mClass{
112 // return $hotBrands; 384 // return $hotBrands;
113 // } 385 // }
114 // homeData(){ 386 // homeData(){
115 - // let that=this; 387 + //
116 // return co(function * (){ 388 // return co(function * (){
117 // let $result = {}; 389 // let $result = {};
118 // let $url={}; 390 // let $url={};
@@ -123,5 +395,5 @@ class IndexModel extends global.mClass{ @@ -123,5 +395,5 @@ class IndexModel extends global.mClass{
123 // // $result.brand=$data.fav_brand&&!$data.fav_brand? 395 // // $result.brand=$data.fav_brand&&!$data.fav_brand?
124 // }(); 396 // }();
125 // } 397 // }
126 -}  
127 -module.exports = IndexModel; 398 +// }
  399 +// module.exports = IndexModel;
1 'use strict'; 1 'use strict';
2 2
3 -class OrderData extends global.mClass{ 3 +const api = global.yoho.API;
4 /** 4 /**
5 * 我的订单-分页 5 * 我的订单-分页
6 * @param type $uid 6 * @param type $uid
@@ -9,7 +9,7 @@ class OrderData extends global.mClass{ @@ -9,7 +9,7 @@ class OrderData extends global.mClass{
9 * @param type $type 获取订单类型 type=1全部,type=2待付款,type=3待发货,type=4待收货,type=5待评论(已成功) 7取消 9 * @param type $type 获取订单类型 type=1全部,type=2待付款,type=3待发货,type=4待收货,type=5待评论(已成功) 7取消
10 * @return type 10 * @return type
11 */ 11 */
12 - getUserOrders($uid, $page, $limit, $type){ 12 +exports.getUserOrders=($uid, $page, $limit, $type)=>{
13 $page=$page||1; 13 $page=$page||1;
14 $limit=$limit||1; 14 $limit=$limit||1;
15 $type=$type||1; 15 $type=$type||1;
@@ -20,7 +20,7 @@ class OrderData extends global.mClass{ @@ -20,7 +20,7 @@ class OrderData extends global.mClass{
20 page:$page, 20 page:$page,
21 limit:$limit 21 limit:$limit
22 } 22 }
23 - return this.API.get('', options); 23 + return api.get('', options);
24 } 24 }
25 /** 25 /**
26 * 订单详情 26 * 订单详情
@@ -28,13 +28,13 @@ class OrderData extends global.mClass{ @@ -28,13 +28,13 @@ class OrderData extends global.mClass{
28 * @param type $orderCode 28 * @param type $orderCode
29 * @return type 29 * @return type
30 */ 30 */
31 - getOrderDetail($uid, $orderCode){ 31 +exports.getOrderDetail=($uid, $orderCode)=>{
32 let options={ 32 let options={
33 method: 'app.SpaceOrders.detail', 33 method: 'app.SpaceOrders.detail',
34 uid:$uid, 34 uid:$uid,
35 order_code:$orderCode 35 order_code:$orderCode
36 } 36 }
37 - return this.API.get('',options); 37 + return api.get('',options);
38 } 38 }
39 /** 39 /**
40 * 取消订单 40 * 取消订单
@@ -42,7 +42,7 @@ class OrderData extends global.mClass{ @@ -42,7 +42,7 @@ class OrderData extends global.mClass{
42 * @param type $orderCode 42 * @param type $orderCode
43 * @return type 43 * @return type
44 */ 44 */
45 - cancelUserOrder($uid, $orderCode, $reason, $reasonId){ 45 +exports.cancelUserOrder=($uid, $orderCode, $reason, $reasonId)=>{
46 $reason=$reason||false; 46 $reason=$reason||false;
47 $reasonId=$reasonId||false; 47 $reasonId=$reasonId||false;
48 48
@@ -57,7 +57,7 @@ class OrderData extends global.mClass{ @@ -57,7 +57,7 @@ class OrderData extends global.mClass{
57 reasons:$reason 57 reasons:$reason
58 }); 58 });
59 } 59 }
60 - return this.API.get('',options); 60 + return api.get('',options);
61 } 61 }
62 /** 62 /**
63 * 确认订单 63 * 确认订单
@@ -65,25 +65,25 @@ class OrderData extends global.mClass{ @@ -65,25 +65,25 @@ class OrderData extends global.mClass{
65 * @param type $orderCode 65 * @param type $orderCode
66 * @return type 66 * @return type
67 */ 67 */
68 - confirmUserOrder($uid, $orderCode){ 68 +exports.confirmUserOrder=($uid, $orderCode)=>{
69 let options={ 69 let options={
70 method:'app.SpaceOrders.confirm', 70 method:'app.SpaceOrders.confirm',
71 uid:$uid, 71 uid:$uid,
72 order_code:$orderCode 72 order_code:$orderCode
73 } 73 }
74 - return this.API.get('',options); 74 + return api.get('',options);
75 } 75 }
76 /** 76 /**
77 * 获取虚拟订单ticketCode 77 * 获取虚拟订单ticketCode
78 * @param type $orderCode 78 * @param type $orderCode
79 * @return type 79 * @return type
80 */ 80 */
81 - getTicketCode($orderCode){ 81 +exports.getTicketCode=($orderCode)=>{
82 let options={ 82 let options={
83 method:'app.SpaceOrders.getQrByOrderCode', 83 method:'app.SpaceOrders.getQrByOrderCode',
84 order_code:$orderCode 84 order_code:$orderCode
85 } 85 }
86 - return this.API.get('',options); 86 + return api.get('',options);
87 } 87 }
88 /** 88 /**
89 * 我的订单-查看物流 89 * 我的订单-查看物流
@@ -92,13 +92,13 @@ class OrderData extends global.mClass{ @@ -92,13 +92,13 @@ class OrderData extends global.mClass{
92 * @param int $uid 用户ID 92 * @param int $uid 用户ID
93 * @return array 93 * @return array
94 */ 94 */
95 - getLogisticsData($orderCode, $uid){ 95 +exports.getLogisticsData=($orderCode, $uid)=>{
96 let options={ 96 let options={
97 method:'app.express.li', 97 method:'app.express.li',
98 order_code:$orderCode, 98 order_code:$orderCode,
99 uid:$uid 99 uid:$uid
100 }; 100 };
101 - return this.API.get('',options); 101 + return api.get('',options);
102 } 102 }
103 /** 103 /**
104 * 获取历史订单 104 * 获取历史订单
@@ -106,7 +106,7 @@ class OrderData extends global.mClass{ @@ -106,7 +106,7 @@ class OrderData extends global.mClass{
106 * @param type $page 106 * @param type $page
107 * @param type $limit 107 * @param type $limit
108 */ 108 */
109 - getHistoryOrders($uid, $page , $limit){ 109 +exports.getHistoryOrders=($uid, $page , $limit)=>{
110 $page=$page||1; 110 $page=$page||1;
111 $limit=$limit||10; 111 $limit=$limit||10;
112 let options={ 112 let options={
@@ -115,7 +115,7 @@ class OrderData extends global.mClass{ @@ -115,7 +115,7 @@ class OrderData extends global.mClass{
115 page:$page, 115 page:$page,
116 limit:$limit 116 limit:$limit
117 } 117 }
118 - return this.API.get('',options); 118 + return api.get('',options);
119 } 119 }
120 /** 120 /**
121 * 更新订单的支付方式 121 * 更新订单的支付方式
@@ -125,24 +125,24 @@ class OrderData extends global.mClass{ @@ -125,24 +125,24 @@ class OrderData extends global.mClass{
125 * @param int $uid 用户ID 125 * @param int $uid 用户ID
126 * @return array 126 * @return array
127 */ 127 */
128 - updateOrderPayment($orderCode, $payment, $uid){ 128 +exports.updateOrderPayment=($orderCode, $payment, $uid)=>{
129 let options={ 129 let options={
130 method:'app.SpaceOrders.updateOrdersPaymentByCode', 130 method:'app.SpaceOrders.updateOrdersPaymentByCode',
131 order_code:Number($orderCode), 131 order_code:Number($orderCode),
132 payment:$payment, 132 payment:$payment,
133 uid:$uid 133 uid:$uid
134 } 134 }
135 - return this.API.get('',options); 135 + return api.get('',options);
136 } 136 }
137 /** 137 /**
138 * 取消订单原因列表 138 * 取消订单原因列表
139 * @return type 139 * @return type
140 */ 140 */
141 - closeReasons(){ 141 +exports.closeReasons=()=>{
142 let options={ 142 let options={
143 method:'app.SpaceOrders.closeReasons' 143 method:'app.SpaceOrders.closeReasons'
144 } 144 }
145 - return this.API.get('',options); 145 + return api.get('',options);
146 } 146 }
147 /** 147 /**
148 * 订单详情页——地址修改 148 * 订单详情页——地址修改
@@ -150,7 +150,7 @@ class OrderData extends global.mClass{ @@ -150,7 +150,7 @@ class OrderData extends global.mClass{
150 * @param type $address_id 150 * @param type $address_id
151 * @return type 151 * @return type
152 */ 152 */
153 - updateDeliveryAddress($order_code, $user_name, $area_code, $address, $mobile, $phone){ 153 +exports.updateDeliveryAddress=($order_code, $user_name, $area_code, $address, $mobile, $phone)=>{
154 let options={ 154 let options={
155 method:'app.SpaceOrders.updateDeliveryAddress', 155 method:'app.SpaceOrders.updateDeliveryAddress',
156 order_code:$order_code, 156 order_code:$order_code,
@@ -162,7 +162,7 @@ class OrderData extends global.mClass{ @@ -162,7 +162,7 @@ class OrderData extends global.mClass{
162 if($phone){ 162 if($phone){
163 Object.assign(options,{phone:$phone}) 163 Object.assign(options,{phone:$phone})
164 } 164 }
165 - return this.API.get('',options); 165 + return api.get('',options);
166 } 166 }
167 /** 167 /**
168 * 查看订单详情 168 * 查看订单详情
@@ -172,15 +172,12 @@ class OrderData extends global.mClass{ @@ -172,15 +172,12 @@ class OrderData extends global.mClass{
172 * @param string $sessionKey 用户会话 172 * @param string $sessionKey 用户会话
173 * @return array 173 * @return array
174 */ 174 */
175 - viewOrderData($orderCode, $uid, $sessionKey){ 175 +exports.viewOrderData=($orderCode, $uid, $sessionKey)=>{
176 let options={ 176 let options={
177 method:'app.SpaceOrders.info', 177 method:'app.SpaceOrders.info',
178 order_code:$order_code, 178 order_code:$order_code,
179 uid:$uid, 179 uid:$uid,
180 session_key:$sessionKey 180 session_key:$sessionKey
181 } 181 }
182 - return this.API.get('',options); 182 + return api.get('',options);
183 } 183 }
184 -}  
185 -  
186 -module.exports = OrderData;  
@@ -49,8 +49,6 @@ const homeNav = [ @@ -49,8 +49,6 @@ const homeNav = [
49 } 49 }
50 ]; 50 ];
51 51
52 -const OrderData = require('./models/OrderData');  
53 -const orderDate=new OrderData();  
54 52
55 const getHomeNav = (req, res, next) => { 53 const getHomeNav = (req, res, next) => {
56 res.locals.path=[{href:helpers.urlFormat('/'),name:'YOHO!BUY 有货首页'},{name:'个人中心'}]; 54 res.locals.path=[{href:helpers.urlFormat('/'),name:'YOHO!BUY 有货首页'},{name:'个人中心'}];
@@ -90,9 +88,9 @@ const sessionEffective = (req, res, next) => { @@ -90,9 +88,9 @@ const sessionEffective = (req, res, next) => {
90 // 查看二维码 88 // 查看二维码
91 router.get('/QRcode', [getCommonHeader, getHomeNav], personalController.QRcode); 89 router.get('/QRcode', [getCommonHeader, getHomeNav], personalController.QRcode);
92 90
93 -var Account=require(`${cRoot}/Index`);  
94 -let account=new Account(); 91 +var Index=require(`${cRoot}/Index`);
95 92
96 -router.get('/index', account.index); 93 +
  94 +router.get('/index', Index.index);
97 95
98 module.exports = router; 96 module.exports = router;