123456789101112131415161718192021222324252627282930313233 |
- import { reactive } from 'vue'
- import * as api from '@/service/order'
- export const state = reactive({
- productList: [] as any[],
- brandList: [] as any[],
- modelList: [] as any[],
- form: {
- product_id: '',
- subscribe_type: '' as 'year' | 'month',
- discount_code: '',
- brand_id: '',
- phone_id: '',
- email: '',
- from: '',
- invitor: '',
- },
- })
- export async function initProducts() {
- if (!state.productList.length) {
- state.productList = (await api.getProductList()).results
- }
- state.form.product_id = state.productList[0].id
- }
- export async function getBrandList() {
- state.brandList = (await api.getBrands()).results
- }
- export async function getModelList() {
- state.brandList = (await api.getModels(state.form.brand_id)).results
- }
|