/
home
/
henzagold
/
oldsite
/
store
/
File Upload :
llllll
Current File: /home/henzagold/oldsite/store/wishlist.js
import axios from "~/plugins/axios" export const state = () => ({ isLogin: false, itemsId: [] }) export const mutations = { Init(state, items) { state.itemsId = items ? items.map(x=>x.product_id) : [] }, Add(state, product_id) { const index = state.itemsId.findIndex(id => id == product_id) if (index === -1) { state.itemsId.push(product_id) } }, Remove(state, product_id) { const index = state.itemsId.findIndex(id => id == product_id) if (index > -1) { state.itemsId.splice(index, 1) } }, getLogin(state,data){ if(data){ state.isLogin = true } else{ state.isLogin = false } } } export const actions = { async init({ commit, dispatch, state }) { await dispatch("getLogin") if (state.isLogin) { try { const {data} = await axios({ method: 'get', url: 'https://henzagold.com/oapi/cu/fav', headers: { 'Content-Type': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem('accessToken') } }) // console.log('salammm',data) commit('Init', data) } catch (e) { //console.log(`%c ${e} `, 'background: #222; color: #bada55;') } } }, add({ commit, state }, product_id) { commit('Add', product_id) }, remove({ commit }, product_id) { commit('Remove', product_id) }, getLogin({commit}){ commit("getLogin",localStorage.getItem("accessToken")) } } export const getters = { }
Copyright ©2k19 -
Hexid
|
Tex7ure