order-detail.js 1.34 KB
export default function() {
  return {
    namespaced: true,
    state: {
      orderDetail: {},
    },
    mutations: {
      initData(state, data) {
        state.orderDetail = data;
      },
    },
    getters: {
      userAddress: state => state.orderDetail.userAddress || {}, // 用户使用地址
      statusDetail: state => state.orderDetail.statusDetail || {}, // 订单状态
      lastExpressInfo: state => state.orderDetail.lastExpressInfo || null, // 物流信息
      goodsInfo: state => state.orderDetail.goodsInfo || {}, // 商品信息
      priceInfo: state => state.orderDetail.priceInfo || {}, // 价格信息
      actionList: state => state.orderDetail.buttons || {}, // 允许操作
      // 卖家订单价格字段
      platformFee: state => state.orderDetail.platformFee || {},

      // 鉴定平台地址
      appraiseAddress: state => state.orderDetail.appraiseAddress || null,
    },
    actions: {
      /**
       * @param {
       *  owner 订单来源
       *  code 订单编码
       * }
       */
      async fetchOrderDetail({ commit }, { owner, code } = {}) {
        const res = await this.$api.get('/api/order/detail', {
          tabType: owner,
          orderCode: +code,
        });

        if (res.code === 200) {
          commit('initData', res.data);
        }
        return res.data || {};
      },
    },
  };
}