| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- // 用户数据模块
- import api from '@/common/request/index'
- import store from '@/store'
- import { setStorage, getStorage, removeStorage } from '@/util/index.js'
- import {
- USER_INFO,
- SET_TOKEN,
- OUT_LOGIN,
- SET_LOGINSTATE,
- USER_ADULTHOOD,
- SET_OPENID
- } from '../types.js'
- import {
- IMG_URL
- } from '@/env'
- const state = {
- likeProducts: [],
- likeSwan: [],
- }
- const actions = {
- async getLikeP({
- state,
- commit
- }, parmas ) {
- try{
- const obj = await api("app.center.getProductFavorite", {type: 1})
- commit("SET_LIKES_PRODUCT", obj.data.map(item => {
- return {...item, imgUrl: IMG_URL + item.imgUrl}
- }))
- }catch(e){
- //TODO handle the exception
- }
- },
- async getLikeS({
- state,
- commit
- }, parmas ) {
- try{
- const obj = await api("app.center.getPromotionFavorite", {type: 1})
- commit("SET_LIKES_SWAN", obj.data.map(item => {
- return {...item, imgUrl: IMG_URL + item.url}
- }))
- }catch(e){
- //TODO handle the exception
- }
- },
- }
- const mutations = {
- // 保存收藏的产品
- ["SET_LIKES_PRODUCT"](state, list) {
- state.likeProducts = list
- },
- // 保存收藏的
- ["SET_LIKES_SWAN"](state, list) {
- state.likeSwan = list
- },
- }
- const getters = {
- }
- export default {
- state,
- mutations,
- actions,
- getters
- }
|