Blame view

src/store/modules/orderRead.js 1.26 KB
37ccd9675   尹聃   订单详情页获取数据
1
2
  import urlAlias from '../url'
  import request from '../request'
9a8f39ae3   BigBoss   订单
3

37ccd9675   尹聃   订单详情页获取数据
4
  const {
7c039b6f9   范牧   订单详情页规格修改
5
6
    orderRead,
    detailStandardList,
37ccd9675   尹聃   订单详情页获取数据
7
  } = urlAlias
9a8f39ae3   BigBoss   订单
8
9
  
  const state = {
7c039b6f9   范牧   订单详情页规格修改
10
11
    orderInfo: {},
    skuList: [],
37ccd9675   尹聃   订单详情页获取数据
12
  }
9a8f39ae3   BigBoss   订单
13
14
15
  
  const mutations = {
    INIT: (state, orderInfo) => {
37ccd9675   尹聃   订单详情页获取数据
16
      state.orderInfo = orderInfo
7c039b6f9   范牧   订单详情页规格修改
17
18
19
20
    },
    SKU: (state, skuList) => {
      state.skuList = skuList
    },
37ccd9675   尹聃   订单详情页获取数据
21
  }
9a8f39ae3   BigBoss   订单
22
23
24
  
  const actions = {
    getOrderInfo({ commit }, param) {
7c039b6f9   范牧   订单详情页规格修改
25
      return new Promise((resolve) => request({
37ccd9675   尹聃   订单详情页获取数据
26
27
        url: orderRead,
        data: param,
7c039b6f9   范牧   订单详情页规格修改
28
29
30
31
32
        success: (res) => {
          console.log(res)
          commit('INIT', res.data.data)
          resolve(res.data.data)
        },
36e559203   BigBoss   逻辑完善
33
      }))
7c039b6f9   范牧   订单详情页规格修改
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
    },
    goodDetails({ commit, rootState }, param) {
      return new Promise((resolve) => request({
        url: detailStandardList,
        data: param,
        success: ({ data }) => {
          const { data: { skuList: list } } = data
          const { skId } = param
          const { skuList } = rootState.orderRead
          console.log('data', list, skId)
          for (let index = 0; index < list.length; index++) {
            const element = list[index]
            if (skId === element.sk_id) {
              skuList.push(element)
            }
          }
          commit('SKU', skuList)
          resolve()
        },
      }))
    },
37ccd9675   尹聃   订单详情页获取数据
55
  }
9a8f39ae3   BigBoss   订单
56
57
58
59
60
  
  export default {
    namespaced: true,
    state,
    mutations,
7c039b6f9   范牧   订单详情页规格修改
61
    actions,
37ccd9675   尹聃   订单详情页获取数据
62
  }