diff --git a/.env.development b/.env.development index a4cdf13..e856970 100644 --- a/.env.development +++ b/.env.development @@ -1,2 +1,2 @@ -# VITE_BASE_URL = 'http://192.168.1.24:8324' -VITE_BASE_URL = 'https://crmeb-test.shop.lihaink.cn' \ No newline at end of file +VITE_BASE_URL = 'http://192.168.1.16:8324' +# VITE_BASE_URL = 'https://crmeb-test.shop.lihaink.cn' \ No newline at end of file diff --git a/src/api/store.js b/src/api/store.js index a4ac42b..316713a 100644 --- a/src/api/store.js +++ b/src/api/store.js @@ -15,12 +15,55 @@ export function cartCreateApi(data) { } /** - * @description 购物车 + * @description 购物列表 */ export function cartListApi(data) { return request.get(`user/cart/lst`, { params: data }) } +/** + * @description 购物数量加减 + */ +export function cartChangeApi(id, data) { + return request.post(`user/cart/change/${id}`, data) +} + + +/** + * @description 结算 + */ +export function orderCheckApi(data) { + return request.post(`v2/order/check`, data) +} + +/** + * @description 删除商品 + */ +export function cartDeleteApi(data) { + return request.post(`user/cart/delete`, data) +} + +/** + * @description 支付 + */ +export function orderCreateApi(data) { + return request.post(`v2/order/create`, data) +} + +/** + * @description 订单状态 + */ +export function orderStatusApi(id) { + return request.get(`micropay_query`, { params: { order_id: id } }) +} + +/** + * @description 订单列表 + */ +export function orderListApi(data) { + return request.get(`/order/list`, { params: data }) +} + // /** // * @description 购物车数量 // */ diff --git a/src/layout/index.vue b/src/layout/index.vue index 0e46510..386052f 100644 --- a/src/layout/index.vue +++ b/src/layout/index.vue @@ -1,47 +1,48 @@ - \ No newline at end of file + diff --git a/src/layout/myAside.vue b/src/layout/myAside.vue index 7c46fff..053e9d1 100644 --- a/src/layout/myAside.vue +++ b/src/layout/myAside.vue @@ -1,14 +1,26 @@ @@ -31,6 +43,7 @@ &.active { background-color: #1890ff; + transition: 300ms; } } } diff --git a/src/router/index.js b/src/router/index.js index d5fd278..86ac836 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -14,7 +14,12 @@ const routes = [ path: '/home', name: 'home', component: () => import('@/views/home/index.vue'), - } + }, + { + path: '/order', + name: 'order', + component: () => import('@/views/order/index.vue'), + } ] }, { diff --git a/src/utils/axios.js b/src/utils/axios.js index ba6cfca..b589d29 100644 --- a/src/utils/axios.js +++ b/src/utils/axios.js @@ -1,4 +1,7 @@ import axios from "axios"; +import { ElMessage } from "element-plus"; +import { useRouter } from "vue-router"; +import { useUserStore } from "../store/user"; const request = axios.create({ baseURL: import.meta.env.VITE_BASE_URL + '/api', @@ -27,11 +30,34 @@ request.interceptors.request.use( request.interceptors.response.use( response => { // 对响应数据做些什么,例如解析数据、统一处理错误等 + if (response.data.status === 401 || response.data.status === 4000) { + const router = useRouter(); + ElMessage({ + message: response.data.message, + type: 'error', + }) + setTimeout(() => { + const userStore = useUserStore(); + userStore.setUserInfo({}); + userStore.setToken(''); + router.push('/login'); + }, 1000); + } + if (response.data.status === 400) { + ElMessage({ + message: response.data.message, + type: 'error', + }) + } return response.data; }, error => { // 处理响应错误 console.error(error); + ElMessage({ + message: error, + type: 'error', + }) return Promise.reject(error); } ); diff --git a/src/views/home/component/order.vue b/src/views/home/component/order.vue index bc2db2a..5cfd9a1 100644 --- a/src/views/home/component/order.vue +++ b/src/views/home/component/order.vue @@ -1,24 +1,48 @@ @@ -36,22 +69,22 @@ defineExpose({