Authored by yyq

exchange

@@ -2,13 +2,18 @@ @@ -2,13 +2,18 @@
2 * 换货 controller 2 * 换货 controller
3 */ 3 */
4 'use strict'; 4 'use strict';
  5 +const headerModel = require('../../../doraemon/models/header'); // 头部model
5 const exchangeModel = require('../models/exchange'); 6 const exchangeModel = require('../models/exchange');
6 7
7 const exchange = { 8 const exchange = {
8 exchange(req, res) { 9 exchange(req, res) {
9 res.render('refund/exchange', { 10 res.render('refund/exchange', {
10 module: 'home', 11 module: 'home',
11 - page: 'refund-exchange' 12 + page: 'refund-exchange',
  13 + pageHeader: headerModel.setNav({
  14 + navTitle: '换货申请'
  15 + }),
  16 + title: '换货申请',
12 }); 17 });
13 }, 18 },
14 19
@@ -404,3 +404,41 @@ exports.getCoupon = (req, res, next) => { @@ -404,3 +404,41 @@ exports.getCoupon = (req, res, next) => {
404 }) 404 })
405 .catch(next); 405 .catch(next);
406 }; 406 };
  407 +
  408 +// const vipLe = (key) => {
  409 +// return {
  410 +// 银卡: 1,
  411 +// 金卡: 2,
  412 +// 白金: 3,
  413 +// }[key];
  414 +// };
  415 +
  416 +/**
  417 + * [获取商品 品牌券]
  418 + */
  419 +exports.product = (req, res, next) => {
  420 + let params = {
  421 + id: _.toString(req.params[0]),
  422 + uid: req.user.uid || 0
  423 + };
  424 +
  425 + Promise.all([detailModel.getProductData(params), detailModel.getVipData(params)]).then((result) => {
  426 + // let vipPrice = [];
  427 +
  428 + // if (result[0].data.vip) {
  429 + // for (let val of result[0].data.vip) {
  430 + // vipPrice.push({
  431 + // level: vipLe(val.caption),
  432 + // price: val.price,
  433 + // currentVip: req.user.uid &&
  434 + // parseInt(result[1].data.current_vip_level, 10) === vipLe(val.caption) ?
  435 + // 'active' : ''//eslint-disable-line
  436 + // });
  437 + // }
  438 +
  439 + // result[0].data.vipPrice = vipPrice;
  440 + // }
  441 +
  442 + res.json(result[0]);
  443 + }).catch(next);
  444 +};
@@ -919,6 +919,38 @@ const getLimitProductData = (uid, limitProductCode) => { @@ -919,6 +919,38 @@ const getLimitProductData = (uid, limitProductCode) => {
919 }); 919 });
920 }; 920 };
921 921
  922 +const product = (params) => {
  923 + return api.get('', Object.assign({
  924 + method: 'app.product.data'
  925 + }, params), {
  926 + code: 200
  927 + }).then(result => {
  928 + if (result.data) {
  929 + let storage = 0; // result.storage 的 数值 不可靠,循环累加 库存
  930 + const goodsList = result.data.goods_list;
  931 +
  932 + if (goodsList) {
  933 + for (let good of goodsList) {
  934 + for (let size of good.size_list) {
  935 + storage += size.storage_number;
  936 + }
  937 + }
  938 + }
  939 +
  940 + result.data.storage = storage;
  941 + }
  942 +
  943 + return result;
  944 + });
  945 +};
  946 +
  947 +const getVipData = params => {
  948 + return api.get('', {
  949 + method: 'app.passport.vip',
  950 + uid: params.uid
  951 + }, {code: 200});
  952 +};
  953 +
922 module.exports = { 954 module.exports = {
923 getProductData, 955 getProductData,
924 getProductAsyncData, 956 getProductAsyncData,
@@ -926,5 +958,7 @@ module.exports = { @@ -926,5 +958,7 @@ module.exports = {
926 getUserProfile: _getUserProfile, 958 getUserProfile: _getUserProfile,
927 productInfoBySkns: _productInfoBySkns, 959 productInfoBySkns: _productInfoBySkns,
928 detailDataPkgAsync: _detailDataPkgAsync, 960 detailDataPkgAsync: _detailDataPkgAsync,
929 - getLimitProductData 961 + getLimitProductData,
  962 + product,
  963 + getVipData
930 }; 964 };
@@ -84,6 +84,8 @@ router.post('/detail/consultsubmit', auth, detail.consultsubmit); // 商å“å’¨è¯ @@ -84,6 +84,8 @@ router.post('/detail/consultsubmit', auth, detail.consultsubmit); // 商å“å’¨è¯
84 router.get('/detail/coupon.json', detail.brandCoupon); // 品牌券 84 router.get('/detail/coupon.json', detail.brandCoupon); // 品牌券
85 router.post('/detail/coupon/save.json', auth, detail.getCoupon); // 获得 品牌券 85 router.post('/detail/coupon/save.json', auth, detail.getCoupon); // 获得 品牌券
86 86
  87 +router.get(/\/product_([\d]+)\.json/, detail.product);
  88 +
87 router.get('/recom/maylike', recom.mayLike); // 你可能喜欢 89 router.get('/recom/maylike', recom.mayLike); // 你可能喜欢
88 90
89 91
@@ -23,12 +23,12 @@ @@ -23,12 +23,12 @@
23 </div> 23 </div>
24 </div> 24 </div>
25 25
26 - <!--<feature-selector 26 +<!-- <feature-selector
27 :is-visible="showFeatureSelector" 27 :is-visible="showFeatureSelector"
28 :entity="entity" 28 :entity="entity"
29 :on-add-to-cart="whenFeatureChange" 29 :on-add-to-cart="whenFeatureChange"
30 button-text="确定"> 30 button-text="确定">
31 - </feature-selector>--> 31 + </feature-selector> -->
32 </div> 32 </div>
33 </template> 33 </template>
34 34
@@ -37,6 +37,7 @@ @@ -37,6 +37,7 @@
37 const qs = require('yoho-qs'); 37 const qs = require('yoho-qs');
38 const Modal = require('plugin/modal'); 38 const Modal = require('plugin/modal');
39 const returnUtil = require('plugin/util'); 39 const returnUtil = require('plugin/util');
  40 + const bus = require('plugin/vue-bus');
40 41
41 const productList = require('home/return/list.vue'); 42 const productList = require('home/return/list.vue');
42 const reasonConfig = require('home/return/reason'); 43 const reasonConfig = require('home/return/reason');
@@ -68,9 +69,9 @@ @@ -68,9 +69,9 @@
68 }, 69 },
69 created() { 70 created() {
70 // 打开 更换 颜色尺码 TAR-TODO 这个可能得重写 71 // 打开 更换 颜色尺码 TAR-TODO 这个可能得重写
71 - // bus.$on('open.featureSelector', msg => {  
72 - // this.queryProductFeature(msg.pid);  
73 - // }); 72 + bus.$on('open.featureSelector', msg => {
  73 + this.queryProductFeature(msg.pid);
  74 + });
74 75
75 // 获取 换货商品 76 // 获取 换货商品
76 $.ajax({ 77 $.ajax({
@@ -275,6 +276,10 @@ @@ -275,6 +276,10 @@
275 background-color: #f6f6f6; 276 background-color: #f6f6f6;
276 } 277 }
277 278
  279 + .return-exchange .return-select > .title {
  280 + padding-top: 0;
  281 + }
  282 +
278 .exchange-info { 283 .exchange-info {
279 margin: 20px 0; 284 margin: 20px 0;
280 background-color: #fff; 285 background-color: #fff;
@@ -45,12 +45,12 @@ @@ -45,12 +45,12 @@
45 }, 45 },
46 46
47 created() { 47 created() {
48 - this.$set('product.change', { 48 + this.product.change = {
49 color: this.product.color_name, 49 color: this.product.color_name,
50 size: this.product.size_name, 50 size: this.product.size_name,
51 goodsId: this.product.goods_id, 51 goodsId: this.product.goods_id,
52 sku: this.product.product_sku 52 sku: this.product.product_sku
53 - }); 53 + };
54 } 54 }
55 }; 55 };
56 56
@@ -79,6 +79,7 @@ @@ -79,6 +79,7 @@
79 79
80 .field .right { 80 .field .right {
81 color: #b0b0b0; 81 color: #b0b0b0;
  82 + float: right;
82 } 83 }
83 84
84 .change { 85 .change {