xuxueyang
2024-07-23 89de2bbaf2e81ab3fa7a8c2aad3b76bc81033d3d
store/index.js
@@ -1,21 +1,11 @@
import http from '../plugins/http'
import storage from '../plugins/storage.js'
import message from '../plugins/message.js'
// #ifndef VUE3
import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)
const store = new Vuex.Store({
         // #endif
         // #ifdef VUE3
         import {
            createStore
         } from 'vuex'
         const store = createStore({
            // #endif
            state: {
               hasLogin: false,
               isUniverifyLogin: false,
@@ -37,6 +27,7 @@
                  'enterprise': 0,
                  'info': 0,
                  'flower': 0,
            'shopping': 0,
               },
               defaultaddress: {}
            },
@@ -163,9 +154,7 @@
               }) {
                  //把权限获取到
                  // console.log('getCurrentInfo,getCurrentInfo')
                  const currentInfo = await http.request('get', '/api/current/user', {
                  })
            const currentInfo = await http.request('get', '/api/current/user', {})
                  if (currentInfo && currentInfo.code == 0) {
                     // state.cMenu = cMenu
                     // state.roles = currentInfo.data.roles || []
@@ -405,6 +394,22 @@
                  }
               },
        submitShopping: async function ({commit, dispatch}, data) {
            const resp = await http.request('post', '/api/api/customer/flower/cart/change-num', {
                    data: {
                        id: data.id,
                        num: 1
                    }
                }
            )
            if (resp && resp.code === 0) {
                message.showToast('添加购物车成功')
                dispatch('sign_add', 'shopping')
            } else {
            }
            return resp
        },
            }
         })