| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- import { defineStore } from "pinia";
- import { SHOP_CART_LIST, SHOP_ORDER_STATUS, CONTENT_FLOAT, SHOP_ADDRESS_LIST, SELLER_CART_LIsts } from "@/api";
- import { setStorage, getStorage } from '@/utils'
- const state = () => ({
- cartList: [],
- cartNum: 0,
- sellerList: [],
- sellerNum: 0,
- orderStatus: [],
- hotLink: [],
- addressList: [],
- logistics: {},
- tabParams: null
- })
- export const useShopStore = defineStore('shop', {
- state,
- getters: {
- getCartList() {
- return this.cartList
- },
- getCartNum() {
- return this.cartNum
- },
- getSellerList() {
- return this.sellerList
- },
- getSellerNum() {
- return this.sellerNum
- },
- getOrderStatus() {
- return this.orderStatus
- },
- getHotLink() {
- // if (!this.hotLink.length) {
- // this.setHotLink();
- // }
- return this.hotLink || [];
- },
- getAddressList() {
- return this.addressList || [];
- },
- getLogistics() {
- return this.logistics || {}
- },
- getTabParams() {
- return this.tabParams || null
- }
- },
- actions: {
- async setCartList(is_free) {
- try {
- const { data: { list = [], cartCount = 0 } } = await SHOP_CART_LIST(is_free);
- this.cartList = list || [];
- this.cartNum = cartCount;
- } catch (error) { }
- },
- setCartNum(_num_) {
- this.cartNum = _num_
- },
- async setSellerList() {
- try {
- const { data: { list = [], cartCount = 0 } } = await SELLER_CART_LIsts();
- this.sellerList = list || [];
- this.sellerNum = cartCount;
- } catch (error) { }
- },
- setSellerNum(_num_) {
- this.sellerNum = _num_
- },
- async setOrderStatus() {
- try {
- const res = await SHOP_ORDER_STATUS();
- let arr = Object.entries(res.data).map(([key, value]) => ({
- status: key,
- value: value
- }));
- this.orderStatus = arr
- } catch (error) { }
- },
- async setHotLink() {
- try {
- const res = await CONTENT_FLOAT({
- type: 'image-text',
- posititon: 'search'
- })
- this.hotLink = res.data
- } catch (error) { }
- },
- async setAddressList() {
- try {
- const res = await SHOP_ADDRESS_LIST()
- this.addressList = res.data
- } catch (error) { }
- },
- setLogistics(data) {
- this.logistics = data
- },
- setTabParams(params) {
- this.tabParams = params;
- }
- }
- })
|