userRecommand.js 1.07 KB
import urlAlias from '../url'
import request from '../request'

const {
  recommandList
} = urlAlias

const state = {
  recommandList: []
}

const mutations = {
  INIT: (state, list) => {
    state.recommandList = list
  }
}

let goodsList = []

const actions = {
  getRecommandList({ commit }, param) {
    request({
      url: recommandList,
      data: param,
      success: (res) => {
		console.log('ReccomandList请求结果',res.data)
        // console.log(res.data.data)
        // const Res={...res.data.data.list,...data.data.list}
        const data = res.data.data
        for (let index = 0; index < data.length; index++) {
          goodsList = [...goodsList, ...data[index].list]
        }
        commit('INIT', goodsList)
      },
      fail: (res) => {
        uni.showToast({
          title: '数据加载完了',
          icon: 'none'
        })
        console.log('fail status === > ', res)
      },
      complete: (res) => {
        console.log('complete status === > ', res)
      }
    })
  }
}

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