order-detail.js 1.16 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 || {}, // 物流信息
      goodsInfo: state => state.orderDetail.goodsInfo || {}, // 商品信息
      priceInfo: state => state.orderDetail.priceInfo || {}, // 价格信息
      actionList: state => state.orderDetail.buttons || {}, // 允许操作
    },
    actions: {
      /**
       * @param {
       *  owner 订单来源
       *  code 订单编码
       * }
       */
      async fetchOrderDetail({ commit }, { owner, code } = {}) {
        const res = await this.$api.get('/api/order/detail', {
          tabType: owner,
          orderCode: +code,

          // Todo 删除
          uid: 600043484,
        });

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