order.js 779 Bytes
import urlAlias from '../url'
import request from '../request'

const { orderBuild } = urlAlias

const state = { list: [], param: {} }

const mutations = {
  LIST: (state, list) => {
    state.list = list
  },
  SAVE: (state, param) => {
    state.param = param
  }
}

const actions = {
  build({ commit }, param) {
    return new Promise((resolve, reject) => request({
      url: orderBuild,
      data: param,
      success: (res) => {
        resolve()
      },
      fail: () => {
        uni.showModal({
          content: '订单生成失败',
          showCancel: false
        })
      }
    }))
  },
  saveParams({ commit }, param) {
    console.log('save', param)
    commit('SAVE', param)
  }
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}