actions.js 1.04 KB
import * as Types from './types';

export default {
  async fetchProduct({commit}, {orderId}) {
    commit(Types.FETCH_ORDER_PRODUCT_REQUEST);

    // const result = await this.$api.get('/getproductxxx', {orderId});
    const result = await Promise.resolve({
      code: 200,
      data: {
        name: '测试产品',
        image: 'xxx'
      }
    });

    if (result && result.code === 200) {
      commit(Types.FETCH_ORDER_PRODUCT_SUCCESS, {
        product: result.data
      });
    } else {
      commit(Types.FETCH_ORDER_PRODUCT_FAILD);
    }
  },
  async fetchOrderDetail({commit}, {orderId}) {
    commit(Types.FETCH_ORDERDETAIL_REQUEST);

    // const result = await this.$api.get('/getproductxxx', {orderId});
    const result = await Promise.resolve({
      code: 200,
      data: {
        name: '测试订单',
        image: 'xxx'
      }
    });

    if (result && result.code === 200) {
      commit(Types.FETCH_ORDERDETAIL_SUCCESS, {
        order: result.data
      });
    } else {
      commit(Types.FETCH_ORDERDETAIL_FAILD);
    }
  }
};