Authored by TaoHuang

feat(second): pay order

@@ -35,10 +35,11 @@ import { get } from 'lodash'; @@ -35,10 +35,11 @@ import { get } from 'lodash';
35 import { createNamespacedHelpers, mapState } from 'vuex'; 35 import { createNamespacedHelpers, mapState } from 'vuex';
36 36
37 const { mapState: mapOrderState, mapActions: mapOrderAction, mapMutations: mapOrderMutations } = createNamespacedHelpers('order/orderConfirm'); 37 const { mapState: mapOrderState, mapActions: mapOrderAction, mapMutations: mapOrderMutations } = createNamespacedHelpers('order/orderConfirm');
  38 +const { mapActions: mapSecondActions } = createNamespacedHelpers('second');
38 39
39 export default { 40 export default {
40 name: 'BuyOrderConfirm', 41 name: 'BuyOrderConfirm',
41 - props: ['productId', 'storageId'], 42 + props: ['productId', 'storageId', 'type', 'skup'],
42 data() { 43 data() {
43 return { 44 return {
44 isActive: false 45 isActive: false
@@ -71,15 +72,26 @@ export default { @@ -71,15 +72,26 @@ export default {
71 computed: { 72 computed: {
72 ...mapOrderState(['address', 'orderDetail']), 73 ...mapOrderState(['address', 'orderDetail']),
73 ...mapState({ 74 ...mapState({
74 - productDetail: state => {  
75 - return {  
76 - goodImg: get(state.product.selectedProductInfo, 'product.goods_list[0].image_list[0].image_url', ''),  
77 - productName: get(state.product.selectedProductInfo, 'product.product_name', ''),  
78 - colorName: get(state.product.selectedProductInfo, 'product.goods_list[0].color_name', ''),  
79 - sizeName: get(state.product.selectedProductInfo, 'size.size_name', ''),  
80 - goodPrice: get(state.product.selectedProductInfo, 'size.least_price', ''),  
81 - skup: get(state.product.selectedProductInfo, 'size.skup', '')  
82 - }; 75 + productDetail(state) {
  76 + if (this.type === 'second') {
  77 + return {
  78 + goodImg: get(state.second.info, 'imageList[0]', ''),
  79 + productName: get(state.second.info, 'productName', ''),
  80 + colorName: get(state.second.info, 'colorName', ''),
  81 + sizeName: get(state.second.info, 'sizeName', ''),
  82 + goodPrice: get(state.second.info, 'price', ''),
  83 + skup: this.skup
  84 + };
  85 + } else {
  86 + return {
  87 + goodImg: get(state.product.selectedProductInfo, 'product.goods_list[0].image_list[0].image_url', ''),
  88 + productName: get(state.product.selectedProductInfo, 'product.product_name', ''),
  89 + colorName: get(state.product.selectedProductInfo, 'product.goods_list[0].color_name', ''),
  90 + sizeName: get(state.product.selectedProductInfo, 'size.size_name', ''),
  91 + goodPrice: get(state.product.selectedProductInfo, 'size.least_price', ''),
  92 + skup: get(state.product.selectedProductInfo, 'size.skup', '')
  93 + };
  94 + }
83 } 95 }
84 }), 96 }),
85 couponList() { 97 couponList() {
@@ -109,6 +121,7 @@ export default { @@ -109,6 +121,7 @@ export default {
109 methods: { 121 methods: {
110 ...mapOrderAction(['fetchOrderAddress', 'fetchUserStatus', 'fetchPayList', 'fetchPayment', 'computeOrder', 'buyPayAction']), 122 ...mapOrderAction(['fetchOrderAddress', 'fetchUserStatus', 'fetchPayList', 'fetchPayment', 'computeOrder', 'buyPayAction']),
111 ...mapOrderMutations([Types.CHANGE_SELECT_COUPON_LIST, Types.CHANGE_SELECT_PROMOTION, Types.CLEAR_BUY_STATUS]), 123 ...mapOrderMutations([Types.CHANGE_SELECT_COUPON_LIST, Types.CHANGE_SELECT_PROMOTION, Types.CLEAR_BUY_STATUS]),
  124 + ...mapSecondActions(['fetchDetailById']),
112 replaceBr(str) { 125 replaceBr(str) {
113 return str ? str.replace(/\n/g, '<br />') : ''; 126 return str ? str.replace(/\n/g, '<br />') : '';
114 }, 127 },
@@ -273,10 +286,14 @@ export default { @@ -273,10 +286,14 @@ export default {
273 async init() { 286 async init() {
274 this.fetchOrderAddress({ tabType: UserType.buy }); 287 this.fetchOrderAddress({ tabType: UserType.buy });
275 288
276 - await this.$store.dispatch('product/getSelectedTradeProduct', {  
277 - productId: this.productId,  
278 - storageId: this.storageId  
279 - }); 289 + if (this.type === 'second') {
  290 + await this.fetchDetailById({ skup: this.skup });
  291 + } else {
  292 + await this.$store.dispatch('product/getSelectedTradeProduct', {
  293 + productId: this.productId,
  294 + storageId: this.storageId
  295 + });
  296 + }
280 297
281 let user = await this.$sdk.getUser(); 298 let user = await this.$sdk.getUser();
282 299
@@ -30,6 +30,8 @@ export default [ @@ -30,6 +30,8 @@ export default [
30 props: route => ({ 30 props: route => ({
31 productId: route.query.productId, 31 productId: route.query.productId,
32 storageId: route.query.storageId, 32 storageId: route.query.storageId,
  33 + type: route.query.type,
  34 + skup: route.query.skup
33 }), 35 }),
34 }, 36 },
35 { 37 {
@@ -104,7 +104,7 @@ export default { @@ -104,7 +104,7 @@ export default {
104 104
105 if (this.selectedSize.size_id > 0) { 105 if (this.selectedSize.size_id > 0) {
106 if (price && secondHandPrice) { 106 if (price && secondHandPrice) {
107 - price = Math.min(this.selectedSize.least_price, secondHandPrice); 107 + price = Math.min(price, secondHandPrice);
108 } else if (price <= 0 && secondHandPrice > 0) { 108 } else if (price <= 0 && secondHandPrice > 0) {
109 price = secondHandPrice; 109 price = secondHandPrice;
110 } else if (price > 0 && secondHandPrice <= 0) { 110 } else if (price > 0 && secondHandPrice <= 0) {
@@ -123,31 +123,13 @@ export default { @@ -123,31 +123,13 @@ export default {
123 methods: { 123 methods: {
124 // 购买 124 // 购买
125 buy() { 125 buy() {
126 - // this.$refs.filtrate.show();  
127 -  
128 - /**  
129 - * 数据埋点  
130 - * 商品详情页点击出售/购买/求购按钮  
131 - * event: XY_UFO_PRD_DT_SALE_C  
132 - * params: 1.TAB_ID:1-出售,2-购买,3-求购;  
133 - * 2.PRD_ID:商品ID;  
134 - */  
135 - this.$store.dispatch('reportYas', {  
136 - params: {  
137 - appop: 'XY_UFO_PRD_DT_SALE_C',  
138 - param: {  
139 - TAB_ID: 2,  
140 - PRD_ID: this.productId  
141 - }, 126 + this.$router.push({
  127 + name: 'OrderBuyConfirm',
  128 + query: {
  129 + type: 'second',
  130 + skup: this.skup
142 } 131 }
143 }); 132 });
144 - this.resetSelectedSize();  
145 - this.selectSizeConfig = {  
146 - dest: 'OrderBuyConfirm',  
147 - type: 'buy',  
148 - title: '购买',  
149 - };  
150 - this.showSizeSelectSheet = true;  
151 } 133 }
152 }, 134 },
153 computed: { 135 computed: {
1 import actions from './actions'; 1 import actions from './actions';
2 import mutations from './mutations'; 2 import mutations from './mutations';
  3 +import skupList from './skupList';
  4 +
3 export function defaultState () { 5 export function defaultState () {
4 return { 6 return {
5 info: { 7 info: {
@@ -12,7 +14,6 @@ export function defaultState () { @@ -12,7 +14,6 @@ export function defaultState () {
12 filterList: [] // 筛选列表 14 filterList: [] // 筛选列表
13 }; 15 };
14 } 16 }
15 -import skupList from './skupList';  
16 17
17 export default function() { 18 export default function() {
18 return { 19 return {