diff --git a/src/api/account/common.ts b/src/api/account/common.ts index babf297..4aaca6f 100644 --- a/src/api/account/common.ts +++ b/src/api/account/common.ts @@ -55,11 +55,11 @@ const CommonApi = { /** * 发送验证码 */ - sms(data: smsRequest) { + sms(params: smsRequest) { return request({ url: `${baseURL}/sms`, - method: "post", - data: data, + method: "get", + params }); }, }; diff --git a/src/api/account/coupon.ts b/src/api/account/coupon.ts index 410dcde..23bd466 100644 --- a/src/api/account/coupon.ts +++ b/src/api/account/coupon.ts @@ -32,9 +32,24 @@ const API = { data: data, }); }, + // 查找优惠券 生成订单后使用 + findCoupon(params: findCouponRequest) { + return request({ + url: `${baseURL}/findCoupon`, + method: "get", + params + }); + }, } export default API; - +export interface findCouponRequest { + /** + * 店铺用户Id + */ + shopUserId: number; + type?: number; + [property: string]: any; +} export interface queryReceive { /** * 优惠券id diff --git a/src/api/order/credit.ts b/src/api/order/credit.ts new file mode 100644 index 0000000..2be67ab --- /dev/null +++ b/src/api/order/credit.ts @@ -0,0 +1,52 @@ +import request from "@/utils/request"; +import { Order_BaseUrl } from "@/api/config"; +const baseURL = Order_BaseUrl + "/admin/order/credit/buyer"; +const Api = { + getList(params: any) { + return request({ + url: `${baseURL}/page`, + method: "get", + params + }); + }, + get(params: any) { + return request({ + url: `${baseURL}`, + method: "get", + params + }); + }, + add(data: any) { + return request({ + url: `${baseURL}`, + method: "post", + data + }); + }, + edit(data: any) { + return request({ + url: `${baseURL}`, + method: "put", + data + }); + }, + + delete(id: string | number) { + return request({ + url: `${baseURL}/` + id, + method: "delete", + }); + }, + // 还款 + + repayment(data: any) { + return request({ + url: `${baseURL}/repayment`, + method: "post", + data + }); + }, +}; + +export default Api; + diff --git a/src/router/index.ts b/src/router/index.ts index be7b8b7..f392696 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -66,7 +66,7 @@ export const constantRoutes: RouteRecordRaw[] = [ { path: "credit", name: "creditStatistics", - component: () => import("@/views/data/credit.vue"), + component: () => import("@/views/data/credit/index.vue"), meta: { title: "挂账管理", affix: false, diff --git a/src/store/modules/carts.ts b/src/store/modules/carts.ts index 006e9d8..4245091 100644 --- a/src/store/modules/carts.ts +++ b/src/store/modules/carts.ts @@ -18,7 +18,7 @@ export const useCartsStore = defineStore("carts", () => { //是否启用会员价 const useVipPrice = computed(() => { - return shopUser.userInfo.isMemberPrice && vipUser.value.id && vipUser.value.isVip + return (shopUser.userInfo.isMemberPrice && vipUser.value.id && vipUser.value.isVip) ? true : false }) //台桌id @@ -380,7 +380,6 @@ export const useCartsStore = defineStore("carts", () => { for (let i in data) { newData[i] = data[i].map((v: any) => { const skuData = getProductDetails({ product_id: v.productId, sku_id: v.skuId }) - console.log(v) return { ...skuData, placeNum: v.placeNum, diff --git a/src/utils/websocket.ts b/src/utils/websocket.ts index 71ca7d8..c0272cc 100644 --- a/src/utils/websocket.ts +++ b/src/utils/websocket.ts @@ -38,7 +38,7 @@ class WebSocketManager { private reconnectAttempts = 0; private maxReconnectAttempts = 3; // 自定义最大重试次数 private reconnectDelay = 5000; // 重试延迟(单位:毫秒) - + private timer: any | null = null; // 初始化 WebSocket 客户端 setupWebSocket() { const endpoint = import.meta.env.VITE_APP_WS_ENDPOINT; @@ -60,8 +60,13 @@ class WebSocketManager { console.log("WebSocket 连接已建立"); // ElNotification.success('WebSocket 连接已建立') this.sendMessage(this.initParams) + clearTimeout(this.timer) + this.timer = setInterval(() => { + this.sendMessage({ "type": "ping_interval" }) + }, 1000 * 10); }; this.client.onclose = () => { + clearTimeout(this.timer) if (!this.connected) { // ElMessageBox.alert('WebSocket 连接已断开', 'Title', { // confirmButtonText: '立即重连', @@ -74,6 +79,7 @@ class WebSocketManager { console.log("WebSocket 连接已断开"); }; this.client.onerror = (error) => { + clearTimeout(this.timer) console.error("WebSocket 发生错误:", error); // ElNotification({ // title: "提示", diff --git a/src/views/application/marketing/coupon/components/add.vue b/src/views/application/marketing/coupon/components/add.vue index 445aabd..4af1490 100644 --- a/src/views/application/marketing/coupon/components/add.vue +++ b/src/views/application/marketing/coupon/components/add.vue @@ -295,7 +295,25 @@ export default { methods: { reset() { this.$refs.form.resetFields(); - this.form = this.resetForm; + this.form = { + id: "", + shopId: "", + type: "1", + title: "", + fullAmount: null, + discountAmount: null, + validityType: "fixed", + validStartTime: "", + validEndTime: "", + userDays: [], + validDays: "", + useTimeType: "all", + useStartTime: "", + useEndTime: "", + proId: "", + proName: "", + number: "", + }; this.form.type = 1; }, async open(data) { diff --git a/src/views/data/credit.vue b/src/views/data/credit.vue deleted file mode 100644 index e5e6a79..0000000 --- a/src/views/data/credit.vue +++ /dev/null @@ -1,3 +0,0 @@ - \ No newline at end of file diff --git a/src/views/data/credit/config/add.ts b/src/views/data/credit/config/add.ts new file mode 100644 index 0000000..5dee9c9 --- /dev/null +++ b/src/views/data/credit/config/add.ts @@ -0,0 +1,80 @@ +import creditApi from "@/api/order/credit"; +import { returnOptions } from "./config"; +import type { IModalConfig } from "@/components/CURD/types"; + +const modalConfig: IModalConfig = { + pageName: "sys:user", + dialog: { + title: "创建挂账人", + width: 800, + draggable: true, + }, + form: { + labelWidth: 140, + }, + formAction: function (data) { + return creditApi.add({ ...data }); + }, + beforeSubmit(data) { + console.log("提交之前处理", data); + }, + formItems: [ + { + label: "状态", + prop: "status", + type: 'switch', + attrs: { + activeText: '开启', + inactiveText: '关闭', + activeValue: 1, + inactiveValue: 0 + }, + initialValue: 1 + }, + + { + label: "挂账人", + prop: "debtor", + rules: [{ required: true, message: "请输入挂账人", trigger: "blur" }], + attrs: { + placeholder: "请输入挂账人", + }, + }, + { + label: "手机号", + prop: "mobile", + rules: [{ required: true, message: "请输入挂账人手机号", trigger: "blur" }], + attrs: { + placeholder: "请输入挂账人手机号", + }, + }, + { + label: "职务", + prop: "position", + rules: [{ required: false, message: "请输入挂账人职务", trigger: "blur" }], + attrs: { + placeholder: "请输入挂账人职务", + }, + }, + { + label: "挂账额度", + prop: "creditAmount", + type: "input-number", + rules: [{ required: true, message: "请输入挂账额度", trigger: "blur" }], + attrs: { + placeholder: "请输入挂账额度", + }, + initialValue: 0 + }, + { + label: "还款方式", + prop: "repaymentMethod", + type: "radio-button", + options: returnOptions('repaymentMethod'), + initialValue: returnOptions('repaymentMethod')[0].value + }, + ], +}; + +// 如果有异步数据会修改配置的,推荐用reactive包裹,而纯静态配置的可以直接导出 +export default reactive(modalConfig); diff --git a/src/views/data/credit/config/config.ts b/src/views/data/credit/config/config.ts new file mode 100644 index 0000000..eacaf63 --- /dev/null +++ b/src/views/data/credit/config/config.ts @@ -0,0 +1,26 @@ + +const options: Record = { + repaymentMethod: [ + { label: '按总金额还款', value: "total" }, + { label: '按订单还款', value: "order" }, + ] +}; + +export function returnOptions(type: keyof typeof options) { + return options[type]; +} + +export function returnOptionsLabel(optionsType: optionsType, value: string | number) { + const options = returnOptions(optionsType); + if (!options) { + return ""; + } + const option = options.find((item) => item.value === value); + return option ? option.label : ""; +} + +export interface options { + label: string; + value: string | number; + [property: string]: any; +} diff --git a/src/views/data/credit/config/content.ts b/src/views/data/credit/config/content.ts new file mode 100644 index 0000000..93af92e --- /dev/null +++ b/src/views/data/credit/config/content.ts @@ -0,0 +1,102 @@ +import creditApi from "@/api/order/credit"; +import type { IContentConfig } from "@/components/CURD/types"; + +const contentConfig: IContentConfig = { + pageName: "sys:user", + table: { + border: true, + highlightCurrentRow: true, + }, + pagination: { + background: true, + layout: "prev,pager,next,jumper,total,sizes", + pageSize: 20, + pageSizes: [10, 20, 30, 50], + }, + indexAction: function (params) { + return creditApi.getList(params); + }, + deleteAction: creditApi.delete, + // modifyAction: function (data) { + // // return creditApi.edit(data); + // }, + pk: "id", + toolbar: ["add"], + defaultToolbar: ["refresh", "filter", "search"], + cols: [ + { + label: "挂账编码", + align: "center", + prop: "id", + }, + { + label: "状态", + align: "center", + prop: "status", + templet: 'custom', + slotName: 'status', + width: 120, + }, + { + label: "挂账人", + align: "center", + prop: "debtor", + }, + { + label: "手机号", + align: "center", + prop: "mobile", + }, + { + label: "挂账额度(元)", + align: "center", + prop: "creditAmount", + }, + { + label: "已挂账金额(元)", + align: "center", + prop: "owedAmount", + }, + { + label: "剩余挂账额度(元)", + align: "center", + prop: "owedAmount", + }, + { + label: "账户余额", + align: "center", + prop: "accountBalance", + }, + { + label: "操作", + align: "center", + fixed: "right", + width: 300, + templet: "tool", + operat: [ + { + text: "查看明细", + name: 'detail' + }, + { + text: "编辑", + name: 'edit' + }, + { + text: "还款", + name: 'huankuan' + }, + { + text: "还款记录", + name: 'huankuan_detail' + }, + { + text: "删除", + name: 'delete' + }, + ], + }, + ], +}; + +export default contentConfig; diff --git a/src/views/data/credit/config/edit.ts b/src/views/data/credit/config/edit.ts new file mode 100644 index 0000000..e1f6bb0 --- /dev/null +++ b/src/views/data/credit/config/edit.ts @@ -0,0 +1,80 @@ +import creditApi from "@/api/order/credit"; +import { returnOptions } from "./config"; +import type { IModalConfig } from "@/components/CURD/types"; + +const modalConfig: IModalConfig = { + pageName: "sys:user", + dialog: { + title: "编辑挂账人", + width: 800, + draggable: true, + }, + form: { + labelWidth: 140, + }, + formAction: function (data) { + return creditApi.edit({ ...data }); + }, + beforeSubmit(data) { + console.log("提交之前处理", data); + }, + formItems: [ + { + label: "状态", + prop: "status", + type: 'switch', + attrs: { + activeText: '开启', + inactiveText: '关闭', + activeValue: 1, + inactiveValue: 0 + }, + initialValue: 1 + }, + + { + label: "挂账人", + prop: "debtor", + rules: [{ required: true, message: "请输入挂账人", trigger: "blur" }], + attrs: { + placeholder: "请输入挂账人", + }, + }, + { + label: "手机号", + prop: "mobile", + rules: [{ required: true, message: "请输入挂账人手机号", trigger: "blur" }], + attrs: { + placeholder: "请输入挂账人手机号", + }, + }, + { + label: "职务", + prop: "position", + rules: [{ required: false, message: "请输入挂账人职务", trigger: "blur" }], + attrs: { + placeholder: "请输入挂账人职务", + }, + }, + { + label: "挂账额度", + prop: "creditAmount", + type: "input-number", + rules: [{ required: true, message: "请输入挂账额度", trigger: "blur" }], + attrs: { + placeholder: "请输入挂账额度", + }, + initialValue: 0 + }, + { + label: "还款方式", + prop: "repaymentMethod", + type: "radio-button", + options: returnOptions('repaymentMethod'), + initialValue: returnOptions('repaymentMethod')[0].value + }, + ], +}; + +// 如果有异步数据会修改配置的,推荐用reactive包裹,而纯静态配置的可以直接导出 +export default reactive(modalConfig); diff --git a/src/views/data/credit/config/search.ts b/src/views/data/credit/config/search.ts new file mode 100644 index 0000000..2d6533d --- /dev/null +++ b/src/views/data/credit/config/search.ts @@ -0,0 +1,39 @@ +import type { ISearchConfig } from "@/components/CURD/types"; + +const searchConfig: ISearchConfig = { + pageName: "sys:user", + formItems: [ + { + type: "input", + label: "挂账人", + prop: "keywords", + attrs: { + placeholder: "请输入挂账人或手机号", + clearable: true, + style: { + width: "200px", + }, + }, + }, + { + type: "select", + label: "还款状态", + prop: "repaymentStatus", + attrs: { + placeholder: "请选择还款状态", + clearable: true, + style: { + width: "200px", + }, + }, + initialValue: '', + options: [ + { label: "未还款", value: 'unpaid' }, + { label: "部分还款", value: 'partial' }, + { label: "已还清", value: 'paid' }, + ], + }, + ], +}; + +export default searchConfig; diff --git a/src/views/data/credit/index.vue b/src/views/data/credit/index.vue new file mode 100644 index 0000000..6743c61 --- /dev/null +++ b/src/views/data/credit/index.vue @@ -0,0 +1,131 @@ + + + diff --git a/src/views/online-shop/index.vue b/src/views/online-shop/index.vue index db64e76..f99c749 100644 --- a/src/views/online-shop/index.vue +++ b/src/views/online-shop/index.vue @@ -14,7 +14,7 @@
-
+