Authored by 陈轩

exchange

@@ -42,7 +42,13 @@ const exchange = { @@ -42,7 +42,13 @@ const exchange = {
42 }, 42 },
43 43
44 // 提交 换货 44 // 提交 换货
45 - submit() { } 45 + submit(req, res, next) {
  46 + const uid = req.user.uid || 8050882;
  47 +
  48 + exchangeModel.submitExchange(uid, req.body).then(result => {
  49 + res.json(result);
  50 + }).catch(next);
  51 + }
46 }; 52 };
47 53
48 module.exports = exchange; 54 module.exports = exchange;
@@ -29,7 +29,14 @@ const exchange = { @@ -29,7 +29,14 @@ const exchange = {
29 }).then(global.yoho.camelCase); 29 }).then(global.yoho.camelCase);
30 }, 30 },
31 31
32 - submitExchangeData() {}, 32 + submitExchange(uid, params) {
  33 + const data = Object.assign({
  34 + uid,
  35 + method: 'app.change.submit'
  36 + }, params);
  37 +
  38 + return api.post('', data).then(global.yoho.camelCase);
  39 + }
33 }; 40 };
34 41
35 module.exports = exchange; 42 module.exports = exchange;
@@ -49,6 +49,7 @@ router.post('/save-logistics', refund.saveLogistics); // 退换货 - 添加寄 @@ -49,6 +49,7 @@ router.post('/save-logistics', refund.saveLogistics); // 退换货 - 添加寄
49 router.get('/exchange', exchange.exchange); 49 router.get('/exchange', exchange.exchange);
50 router.get('/exchange/order', exchange.order); // AJAX 获取订单 商品 50 router.get('/exchange/order', exchange.order); // AJAX 获取订单 商品
51 router.get('/exchange/delivery', exchange.delivery); // AJAX 获取 退货方式 51 router.get('/exchange/delivery', exchange.delivery); // AJAX 获取 退货方式
  52 +router.post('/exchange/submit', exchange.submit); // AJAX 提交换货 申请
52 53
53 router.get('/mydetails', home.mydetails); // 个人信息设置 54 router.get('/mydetails', home.mydetails); // 个人信息设置
54 router.get('/about-us', home.aboutUs); // 个人中心 - 关于我们 55 router.get('/about-us', home.aboutUs); // 个人中心 - 关于我们
@@ -31,7 +31,7 @@ @@ -31,7 +31,7 @@
31 :is-visible="showFeatureSelector" 31 :is-visible="showFeatureSelector"
32 :entity="entity" 32 :entity="entity"
33 :on-add-to-cart="whenFeatureChange" 33 :on-add-to-cart="whenFeatureChange"
34 - :config="{btnTxt:'确定'}"> 34 + buttonText="确定">
35 </feature-selector> 35 </feature-selector>
36 </div> 36 </div>
37 </template> 37 </template>
@@ -51,6 +51,7 @@ @@ -51,6 +51,7 @@
51 return { 51 return {
52 title: '请选择换货商品', 52 title: '请选择换货商品',
53 page: 'exchange', 53 page: 'exchange',
  54 + orderCode: qs.orderId,
54 showFeatureSelector: false, 55 showFeatureSelector: false,
55 entity: {}, 56 entity: {},
56 exchangeData: {}, 57 exchangeData: {},
@@ -92,7 +93,7 @@ @@ -92,7 +93,7 @@
92 $.ajax({ 93 $.ajax({
93 url: '/home/exchange/order', 94 url: '/home/exchange/order',
94 data: { 95 data: {
95 - orderId: qs.orderId 96 + orderId: this.orderCode
96 } 97 }
97 }).then(res => { 98 }).then(res => {
98 const self = this; 99 const self = this;
@@ -147,14 +148,48 @@ @@ -147,14 +148,48 @@
147 return result; 148 return result;
148 }); 149 });
149 }, 150 },
  151 +
  152 + // 生成提交数据
  153 + submitData() {
  154 + const data = {
  155 + order_code: this.orderCode,
  156 + address_id: this.address.address_id,
  157 + address: this.address.address,
  158 + consigee_name: this.address.consignee,
  159 + area_code: this.address.areaCode,
  160 + zip_code: this.address.zipCode,
  161 + mobile: this.address.mobile,
  162 + delivery_typ: this.deliveryType,
  163 + app_type: 1,
  164 + goods: []
  165 + };
  166 +
  167 + this.selectedGoods.forEach(good => {
  168 + data.goods.push({
  169 + product_skn: good.productSkn,
  170 + product_skc: good.productSku,
  171 + goods_type: good.goodsTypeId,
  172 + last_price: good.lastPrice,
  173 + exchange_reason: good.reason.id,
  174 + remark: good.remark,
  175 + evidence_images: good.imageList,
  176 + new_goods_id: good.newGoodsId,
  177 + new_product_sku: good.newProductSku
  178 + });
  179 + });
  180 +
  181 + return data;
  182 + },
  183 +
  184 + // 提交 换货
150 submit() { 185 submit() {
151 if (!this.checkSubmitData()) { 186 if (!this.checkSubmitData()) {
152 alert('请填写完整退换货信息'); 187 alert('请填写完整退换货信息');
153 } 188 }
154 $.ajax({ 189 $.ajax({
155 method: 'POST', 190 method: 'POST',
156 - url: '/home/refund/submit',  
157 - data: this.submitData 191 + url: '/home/exchange/submit',
  192 + data: this.submitData()
158 }).then(result => { 193 }).then(result => {
159 if (result.code === 200) { 194 if (result.code === 200) {
160 console.log(result); 195 console.log(result);
@@ -42,6 +42,10 @@ @@ -42,6 +42,10 @@
42 uid: this._uid 42 uid: this._uid
43 }); 43 });
44 } 44 }
  45 + },
  46 +
  47 + created() {
  48 +
45 } 49 }
46 }; 50 };
47 51