From 00567505c20e5b44bb4fa9281507c76e93555b98 Mon Sep 17 00:00:00 2001 From: weipengfei <2187978347@qq.com> Date: Fri, 5 Apr 2024 13:44:36 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.development | 2 +- src/api/shop.js | 22 +++ src/api/store.js | 43 +++-- src/components/pay.vue | 288 +++++++++++++++++++++++++++++ src/layout/index.vue | 4 + src/layout/myAside.vue | 5 + src/layout/myHeader.vue | 2 +- src/router/index.js | 13 +- src/utils/axios.js | 8 +- src/utils/ws.js | 32 ++++ src/views/home/component/order.vue | 24 ++- src/views/home/component/pay.vue | 182 ------------------ src/views/home/component/pupop.vue | 61 ++++-- src/views/home/component/shop.vue | 75 ++++++-- src/views/home/index.vue | 52 ++++-- src/views/login/index.vue | 6 + src/views/notFound/index.vue | 24 +++ src/views/order/index.vue | 213 ++++++++++++++++----- src/views/shop/index.vue | 178 ++++++++++++++++++ 19 files changed, 933 insertions(+), 301 deletions(-) create mode 100644 src/api/shop.js create mode 100644 src/components/pay.vue create mode 100644 src/utils/ws.js delete mode 100644 src/views/home/component/pay.vue create mode 100644 src/views/notFound/index.vue create mode 100644 src/views/shop/index.vue diff --git a/.env.development b/.env.development index e856970..60a7958 100644 --- a/.env.development +++ b/.env.development @@ -1,2 +1,2 @@ -VITE_BASE_URL = 'http://192.168.1.16:8324' +VITE_BASE_URL = 'http://192.168.1.22:8324' # VITE_BASE_URL = 'https://crmeb-test.shop.lihaink.cn' \ No newline at end of file diff --git a/src/api/shop.js b/src/api/shop.js new file mode 100644 index 0000000..9b61767 --- /dev/null +++ b/src/api/shop.js @@ -0,0 +1,22 @@ +import request from '@/utils/axios.js' + +/** + * @description 商品列表 + */ +export function storeListApi(id, data) { + return request.get(`server/${id}/product/lst`, { params: data }) +} + +/** + * @description 商品详情 + */ +export function getAttrValue(id, data) { + return request.get(`store/product/detail/${id}`, { params: data }) +} + +/** + * @description 免审编辑 + */ +export function userFreeTrialApi(id, data) { + return request.post(`user_free_trial/${id}`, data) +} diff --git a/src/api/store.js b/src/api/store.js index 316713a..7b2e8c4 100644 --- a/src/api/store.js +++ b/src/api/store.js @@ -1,12 +1,5 @@ import request from '@/utils/axios.js' -/** - * @description 商品列表 - */ -export function storeListApi(id, data) { - return request.get(`server/${id}/product/lst`, { params: data }) -} - /** * @description 加入购物车 */ @@ -22,7 +15,7 @@ export function cartListApi(data) { } /** - * @description 购物数量加减 + * @description 编辑购物车数据 */ export function cartChangeApi(id, data) { return request.post(`user/cart/change/${id}`, data) @@ -50,23 +43,37 @@ export function orderCreateApi(data) { return request.post(`v2/order/create`, data) } +/** + * @description 重新支付 + */ +export function orderPayApi(id, data) { + return request.post(`order/pay/${id}`, data) +} + /** * @description 订单状态 */ -export function orderStatusApi(id) { - return request.get(`micropay_query`, { params: { order_id: id } }) +export function orderStatusApi(data) { + return request.get(`micropay_query`, { params: data }) } /** * @description 订单列表 */ -export function orderListApi(data) { - return request.get(`/order/list`, { params: data }) +export function orderListApi(id, data) { + return request.get(`admin/${id}/order_list`, { params: data }) } -// /** -// * @description 购物车数量 -// */ -// export function cartListApi(id, data) { -// return request.get(`count`, { params: data }) -// } \ No newline at end of file +/** + * @description 未支付订单列表 + */ +export function groupOrderListApi(id, data) { + return request.get(`admin/${id}/group_order_list`, { params: data }) +} + +/** + * @description 提单 + */ +export function orderLadingApi(data) { + return request.get(`order_lading`, { params: data }) +} \ No newline at end of file diff --git a/src/components/pay.vue b/src/components/pay.vue new file mode 100644 index 0000000..6b0a0ef --- /dev/null +++ b/src/components/pay.vue @@ -0,0 +1,288 @@ + + + + + + 选择支付方式 + + + + + + 微信 + + + 现金收款 + + + 应收金额(元): + + ¥{{ form.total_price }} + + + + + + + 现金收款正在开发中 + + + + + + + 取消收款 + + + + + + diff --git a/src/layout/index.vue b/src/layout/index.vue index 7f2b3b9..8ebbb8e 100644 --- a/src/layout/index.vue +++ b/src/layout/index.vue @@ -1,6 +1,10 @@ diff --git a/src/layout/myAside.vue b/src/layout/myAside.vue index 053e9d1..2353d58 100644 --- a/src/layout/myAside.vue +++ b/src/layout/myAside.vue @@ -21,6 +21,10 @@ const navTo = (name) => { 订单 + + + 商品 + @@ -35,6 +39,7 @@ const navTo = (name) => { width: 4.5rem; height: 4.5rem; border-radius: 0.7rem; + cursor: pointer; display: flex; flex-direction: column; justify-content: center; diff --git a/src/layout/myHeader.vue b/src/layout/myHeader.vue index 6ff53b5..5698cd8 100644 --- a/src/layout/myHeader.vue +++ b/src/layout/myHeader.vue @@ -36,7 +36,7 @@ const onLogout = () => { - 里海收银系统 diff --git a/src/router/index.js b/src/router/index.js index 86ac836..7d2bfa2 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -19,7 +19,12 @@ const routes = [ path: '/order', name: 'order', component: () => import('@/views/order/index.vue'), - } + }, + { + path: '/shop', + name: 'shop', + component: () => import('@/views/shop/index.vue'), + } ] }, { @@ -27,6 +32,12 @@ const routes = [ name: 'login', component: () => import('@/views/login/index.vue'), }, + // 注意:通配符路由要放在最后 + { + path: '/:catchAll(.*)', + name: 'notFound', + component: () => import('@/views/notFound/index.vue') // 使用 404 页面组件 + } ]; const router = createRouter({ diff --git a/src/utils/axios.js b/src/utils/axios.js index b589d29..30c265e 100644 --- a/src/utils/axios.js +++ b/src/utils/axios.js @@ -5,7 +5,7 @@ import { useUserStore } from "../store/user"; const request = axios.create({ baseURL: import.meta.env.VITE_BASE_URL + '/api', - timeout: 5000 + timeout: 10000 }) // 请求拦截器 @@ -30,7 +30,7 @@ request.interceptors.request.use( request.interceptors.response.use( response => { // 对响应数据做些什么,例如解析数据、统一处理错误等 - if (response.data.status === 401 || response.data.status === 4000) { + if (response.data.status === 401 || response.data.status === 40000) { const router = useRouter(); ElMessage({ message: response.data.message, @@ -41,7 +41,7 @@ request.interceptors.response.use( userStore.setUserInfo({}); userStore.setToken(''); router.push('/login'); - }, 1000); + }, 800); } if (response.data.status === 400) { ElMessage({ @@ -55,7 +55,7 @@ request.interceptors.response.use( // 处理响应错误 console.error(error); ElMessage({ - message: error, + message: error.response?.data?.message || error, type: 'error', }) return Promise.reject(error); diff --git a/src/utils/ws.js b/src/utils/ws.js new file mode 100644 index 0000000..c02b954 --- /dev/null +++ b/src/utils/ws.js @@ -0,0 +1,32 @@ + +export const initWS = (token)=>{ + let ws = new WebSocket('ws://192.168.1.22:8324?type=mer&token='+token); + + ws.onopen = function (e) { + console.log('WebSocket 连接已建立'); + // 开始发送心跳 + startHeartbeat(); + } + + ws.onclose = () => { + console.log('WebSocket 连接已关闭'); + // 停止发送心跳 + stopHeartbeat(); + }; + + let heartbeatTimer = null; + // 开始发送心跳 + const startHeartbeat = () => { + heartbeatTimer = setInterval(() => { + console.log('发送心跳消息'); + ws.send(JSON.stringify({ type: 'heartbeat' })); + }, 30*1000); + } + + // 停止发送心跳 + const stopHeartbeat = () => { + clearInterval(heartbeatTimer); + } + + return ws; +} \ No newline at end of file diff --git a/src/views/home/component/order.vue b/src/views/home/component/order.vue index 09c854d..9f834ee 100644 --- a/src/views/home/component/order.vue +++ b/src/views/home/component/order.vue @@ -43,7 +43,7 @@ const getList = () => { }; getList(); -const emit = defineEmits(["goPay"]); +const emit = defineEmits(["goPay","editAttr"]); const goPay = () => { emit("goPay"); @@ -60,9 +60,20 @@ const changeCartNum = (val, old) => { }); }; +const editAttr = (data)=>{ + emit("editPupop", data); +} + +const editItem = (id, data)=>{ + cartChangeApi(id, data).then((res) => { + getList() + }); +} + defineExpose({ getList, list, + editItem }); @@ -79,7 +90,7 @@ defineExpose({ - {{ item.spu.store_name }} 删除 - 设备规格 + + 商品规格: {{ item.productAttr.sku || '默认规格' }} + ¥{{ item.productAttr.price }} @@ -127,11 +140,11 @@ defineExpose({ - 改价 + - 立即结账 @@ -203,6 +216,7 @@ defineExpose({ } } .order-item-sku { + cursor: pointer; font-size: 0.8rem; color: #999; } diff --git a/src/views/home/component/pay.vue b/src/views/home/component/pay.vue deleted file mode 100644 index a4a3d1c..0000000 --- a/src/views/home/component/pay.vue +++ /dev/null @@ -1,182 +0,0 @@ - - - - - - - 选择支付方式 - - - - - 微信 - 现金收款 - - 应收金额(元): - ¥{{ form.total_price }} - - - - - - 现金收款正在开发中 - - - - - - - 取消收款 - - - - - - - diff --git a/src/views/home/component/pupop.vue b/src/views/home/component/pupop.vue index 48b42df..118a202 100644 --- a/src/views/home/component/pupop.vue +++ b/src/views/home/component/pupop.vue @@ -1,6 +1,7 @@ @@ -27,30 +63,28 @@ defineExpose({ title="商品规格" width="650" > - - + + - + - 香奈儿(Chanel)五号香水(经典)50ml(礼盒装)送女 香奈儿(Chanel)五号香水(经典)50ml(礼盒装)送女 香奈儿(Chanel)五号香水(经典)50ml(礼盒装)送女香奈儿(Chanel)五号香水(经典)50ml(礼盒装)送女 - 库存100 - ¥{{0.10}} + {{ form.store_name }} + 库存{{ form.sku[active]?.stock || 0 }} + ¥{{form.sku[active]?.price || form.price}} 产品 - 大 - 中 - 小 + {{ item || '默认规格' }} - +