websoft-uniapp仓库模板
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

82 lines
1.7 KiB

/**
* 购物车 store
*/
import { defineStore } from 'pinia';
import { Order } from '@/api/shop/order/model';
import { OrderInfo } from '@/api/shop/orderInfo/model';
import { UserAddress } from '@/api/shop/userAddress/model';
import { Goods } from '@/api/shop/goods';
import { Merchant } from '@/api/shop/merchent';
export interface CarState {
merchantId: Number | null;
merchantName: String | null;
merchantCode: Number | null;
merchant: Merchant | null;
order: Order | null;
orderInfo: OrderInfo[] | null;
goodsList: Goods[] | null;
totalPrice: Number | null;
carNum: Number | null;
type: Number | 1;
dateTime: String | null;
address: UserAddress | null;
}
export const useCarStore = defineStore({
id: 'car',
state: (): CarState => ({
// 场馆ID
merchantId: null,
// 场馆名称
merchantName: null,
// 场馆编号
merchantCode: null,
// 场馆信息
merchant: null,
// 订单信息
order: null,
// 场地信息
orderInfo: [],
// 订单总金额
totalPrice: null,
// 购物车数量
carNum: null,
// 1全场 2半场
type: null,
// 下单日期
dateTime: null,
// 商品信息
goodsList: [],
// 用户收货地址
address: null
}),
getters: {},
actions: {
/**
* 添加购物车
*/
AddCar(value: OrderInfo) {
this.orderInfo.push(value);
},
/**
* 移除购物车
*/
DelCard(value: OrderInfo) {
const index = this.orderInfo.findIndex((d) => d.fid == value.fid);
this.orderInfo.splice(index, 1);
},
setOrder(value: Order){
this.order = value
},
setMerchant(value: Merchant){
this.merchant = value
},
setGoodsList(value: Goods[]) {
this.goodsList = value;
},
setAddress(value: UserAddress) {
this.address = value;
}
}
});