diff --git a/src/api/app.js b/src/api/app.js index fea8bc2..c877fa9 100644 --- a/src/api/app.js +++ b/src/api/app.js @@ -221,6 +221,14 @@ export const addCoupon = (params) => { export const editCoupon = (params) => { return postBodyRequest('/mall/coupon/update', params) } + +export const upCoupon = (params) => { + return postRequest('/mall/coupon/up', params) +} + +export const downCoupon = (params) => { + return postRequest('/mall/coupon/down', params) +} //新增线路 export const addLogisticsRoute = (params) => { return postBodyRequest('/app/logisticsRoute/addLogisticsRoute', params) diff --git a/src/api/planet.js b/src/api/planet.js index 04b5274..dd99783 100644 --- a/src/api/planet.js +++ b/src/api/planet.js @@ -80,3 +80,4 @@ export const planetAdventureEventSave = (params) => postBodyRequest(`${PREFIX}/a export const planetAdventureEventDelete = (id) => postRequest(`${PREFIX}/adventure/event/delete`, { id }); export const planetAdventureRankPage = (params) => getRequest(`${PREFIX}/adventure/rank/page`, params); export const planetAdventureRewardPage = (params) => postBodyRequest('/mall/coupon/selectRewardByRegionId', params); +export const planetAdventureParticipationPage = (params) => postBodyRequest('/app/planet/adventure/participation/page', params); diff --git a/src/views/app/business/bus/addEdit.vue b/src/views/app/business/bus/addEdit.vue index 7fbbbb2..5d86c09 100644 --- a/src/views/app/business/bus/addEdit.vue +++ b/src/views/app/business/bus/addEdit.vue @@ -6,11 +6,11 @@
优惠券配置
-
+ - + @@ -21,10 +21,10 @@ - + - + 全部 外卖/买饭 快递/跑腿 @@ -33,48 +33,48 @@ - + - - + + 无门槛 - 元可使用 + 元可使用 - + - + 其他 邀新奖励 - + - - + + - + - - + + - + - - + + 固定日期 - - 领券后天有效 + + 领券后天有效 @@ -119,6 +119,70 @@ }, }, data() { + const validateIntegerRange = (value, min, max, message, callback) => { + const val = String(value === undefined || value === null ? "" : value).trim(); + if (!/^\d+$/.test(val)) { + callback(new Error(message)); + return false; + } + const num = Number(val); + if (num < min || num > max) { + callback(new Error(message)); + return false; + } + return true; + }; + const validateMinAmount = (rule, value, callback) => { + if (this.form.type !== "1") { + callback(); + return; + } + if (validateIntegerRange(this.form.minAmount, 1, 200, "满多少可用金额必须是1-200的整数", callback)) { + callback(); + } + }; + const validateDiscountAmount = (rule, value, callback) => { + const val = String(value === undefined || value === null ? "" : value).trim(); + if (!/^\d+(\.\d{1,2})?$/.test(val)) { + callback(new Error("优惠金额最多2位小数,范围0.1-200")); + return; + } + const num = Number(val); + if (num < 0.1 || num > 200) { + callback(new Error("优惠金额最多2位小数,范围0.1-200")); + return; + } + callback(); + }; + const validateLimitPerUser = (rule, value, callback) => { + if (validateIntegerRange(value, 1, 99, "每人限领数量必须是1-99的整数", callback)) { + callback(); + } + }; + const validateValidType = (rule, value, callback) => { + if (this.form.validType === "1") { + if (!this.form.validStartTime || !this.form.validEndTime) { + callback(new Error("请选择固定日期有效期")); + return; + } + const startTime = this.parseDateTime(this.form.validStartTime).getTime(); + const endTime = this.parseDateTime(this.form.validEndTime).getTime(); + const now = Date.now(); + if (!startTime || !endTime || startTime <= now || endTime <= now || endTime <= startTime) { + callback(new Error("固定日期必须设置为当前时间之后,且结束时间晚于开始时间")); + return; + } + callback(); + return; + } + if (this.form.validType === "2") { + if (validateIntegerRange(this.form.validDays, 1, 200, "领券后有效天数必须是1-200的整数", callback)) { + callback(); + } + return; + } + callback(new Error("请选择有效期")); + }; return { menkan:'', xianzhi:'', @@ -131,59 +195,170 @@ passColor: "", submitLoading: false, maxHeight: 510, - form: { - name: '', //优惠券名称 - applyScene:'', //适用场景:0-通用,1-外卖/买饭,2-快递/跑腿,3-二手物品交易、4团购 - type:'', //优惠券类型:1-满减券,2-无门槛直减券 - minAmount:'', //使用门槛金额 - discountAmount:'', //抵扣面额 - totalCount:'', //发行总数 - limitPerUser:1, //每人最多限领张数 - validType:'', //有效期类型:1-绝对时间段有效,2-领取后相对天数有效 - validStartTime:'', //有效期开始时间 - validEndTime:'', //有效期结束时间 - validDays:'', //自领取之日起有效天数 - ruleType:1, - issuerType:1, //发放方:1-平台,2-商家 - issuerId:0, //发放方ID 0-平台 - status:1, //状态:0-已下架/停发,1-发放中 - regionId:JSON.parse(this.getStore("user")).departmentId, //学校id + datePickerOptions: { + disabledDate(date) { + const today = new Date(); + today.setHours(0, 0, 0, 0); + return date && date.valueOf() < today.valueOf(); + } }, + form: this.getDefaultForm(), formValidate: { // 表单验证规则 name: [{ required: true, message: "请输入优惠券名称", trigger: "change" + }, { + max: 10, + message: "优惠券名称不能超过10个字", + trigger: "change" + }, ], + totalCount: [{ + required: true, + message: "请输入发券总数量", + trigger: "change" + }, ], + applyScene: [{ + required: true, + message: "请选择适用范围", + trigger: "change" + }, ], + type: [{ + required: true, + message: "请选择使用门槛", + trigger: "change" + }, { + validator: validateMinAmount, + trigger: "change" }, ], - contacts: [{ + discountAmount: [{ required: true, - message: "请输入联系人", + message: "请输入优惠金额", + trigger: "change" + }, { + validator: validateDiscountAmount, trigger: "change" }, ], - mobile: [{ + limitPerUser: [{ required: true, - message: "请输入手机号", + message: "请输入每人限领数量", + trigger: "change" + }, { + validator: validateLimitPerUser, + trigger: "change" + }, ], + validType: [{ + validator: validateValidType, trigger: "change" }, ], }, }; }, + computed: { + isEdit() { + return this.type == "1"; + }, + currentFormValidate() { + if (this.isEdit) { + return { + name: this.formValidate.name, + totalCount: this.formValidate.totalCount, + }; + } + return this.formValidate; + }, + }, methods: { + getDefaultForm() { + return { + name: '', //优惠券名称 + applyScene:'', //适用场景:0-通用,1-外卖/买饭,2-快递/跑腿,3-二手物品交易、4团购 + type:'', //优惠券类型:1-满减券,2-无门槛直减券 + minAmount:'', //使用门槛金额 + discountAmount:'', //抵扣面额 + totalCount:'', //发行总数 + limitPerUser:1, //每人最多限领张数 + validType:'', //有效期类型:1-绝对时间段有效,2-领取后相对天数有效 + validStartTime:'', //有效期开始时间 + validEndTime:'', //有效期结束时间 + validDays:'', //自领取之日起有效天数 + ruleType:"1", + issuerType:1, //发放方:1-平台,2-商家 + issuerId:0, //发放方ID 0-平台 + status:1, //状态:0-已下架/停发,1-发放中 + regionId:JSON.parse(this.getStore("user")).departmentId, //学校id + }; + }, init() { }, changeDate(v){ this.form.validStartTime = v[0] this.form.validEndTime = v[1] + this.$refs.form.validateField("validType"); + }, + parseDateTime(value) { + if (!value) { + return null; + } + if (value instanceof Date) { + return isNaN(value.getTime()) ? null : value; + } + const match = String(value).match(/^(\d{4})-(\d{2})-(\d{2})[ T](\d{2}):(\d{2}):(\d{2})$/); + if (match) { + const parts = match.map(Number); + const date = new Date(parts[1], parts[2] - 1, parts[3], parts[4], parts[5], parts[6]); + return isNaN(date.getTime()) ? null : date; + } + const date = new Date(value); + return isNaN(date.getTime()) ? null : date; + }, + formatDateTimeForSubmit(value) { + const date = this.parseDateTime(value); + if (!date) { + return value; + } + const pad = (num, size = 2) => String(num).padStart(size, "0"); + const offset = -date.getTimezoneOffset(); + const sign = offset >= 0 ? "+" : "-"; + const offsetHour = pad(Math.floor(Math.abs(offset) / 60)); + const offsetMinute = pad(Math.abs(offset) % 60); + return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}T${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(date.getSeconds())}.${pad(date.getMilliseconds(), 3)}${sign}${offsetHour}:${offsetMinute}`; + }, + getSubmitForm() { + const form = Object.assign({}, this.form); + if (this.type == "1") { + return { + id: form.id, + name: form.name, + totalCount: form.totalCount, + }; + } + if (this.type != "1") { + delete form.id; + } + if (form.type !== "1") { + form.minAmount = ""; + } + if (form.validType === "1") { + form.validStartTime = this.formatDateTimeForSubmit(form.validStartTime); + form.validEndTime = this.formatDateTimeForSubmit(form.validEndTime); + form.validDays = ""; + } else if (form.validType === "2") { + form.validStartTime = ""; + form.validEndTime = ""; + } + return form; }, submit() { this.$refs.form.validate((valid) => { if (valid) { + const submitForm = this.getSubmitForm(); if (this.type == "1") { // 编辑 this.submitLoading = true; - editCoupon(this.form).then((res) => { + editCoupon(submitForm).then((res) => { this.submitLoading = false; if (res.success) { this.$Message.success("操作成功"); @@ -194,7 +369,7 @@ } else { // 添加1 this.submitLoading = true; - addCoupon(this.form).then((res) => { + addCoupon(submitForm).then((res) => { this.submitLoading = false; if (res.success) { this.$Message.success("操作成功"); @@ -223,15 +398,19 @@ this.maxHeight = "100%"; } // 清空数据 - this.$refs.form.resetFields(); + if (this.$refs.form) { + this.$refs.form.resetFields(); + } + this.form = this.getDefaultForm(); if (this.type == "0" || this.type == "1") { // 回显数据 let data = this.data; // 回显 - this.form = data; + this.form = Object.assign(this.getDefaultForm(), data); this.form.applyScene = JSON.stringify(this.form.applyScene) this.form.type = JSON.stringify(this.form.type) this.form.validType = JSON.stringify(this.form.validType) + this.form.ruleType = JSON.stringify(this.form.ruleType) } this.visible = value; diff --git a/src/views/app/business/bus/bus.vue b/src/views/app/business/bus/bus.vue index 87b4a52..0772bcf 100644 --- a/src/views/app/business/bus/bus.vue +++ b/src/views/app/business/bus/bus.vue @@ -14,6 +14,12 @@ }} + + + @@ -76,15 +82,13 @@
{{couponsData.name}}
-
领到券当日开始{{couponsData.validDays}}天内有效
-
限{{getTime(couponsData.validStartTime)}}至{{getTime(couponsData.validEndTime)}}期间使用
+
{{getCouponValidText(couponsData, true)}}
有效期: - {{getTime(couponsData.validStartTime)}}至{{getTime(couponsData.validEndTime)}} - 领到券当日开始{{couponsData.validDays}}天内有效 + {{getCouponValidText(couponsData)}}
券ID:{{couponsData.id}}
@@ -132,7 +136,7 @@ 优惠券名称:{{detailCoupon.name}} 券ID:{{detailCoupon.id}} - + @@ -160,6 +164,8 @@ getCouponData, giveCoupon, getCouponIssueRecords, + upCoupon, + downCoupon, } from "@/api/app"; import addEdit from "./addEdit.vue"; export default { @@ -216,6 +222,7 @@ pageSize: 10, regionId: JSON.parse(this.getStore("user")).departmentId, applyScene: '', + status: 1, name: '' }, selectDate: null, @@ -258,6 +265,23 @@ key: "discountAmount", minWidth: 80, }, + { + title: "使用门槛", + key: "minAmount", + minWidth: 120, + render: (h, params) => { + let re = ""; + if (params.row.type == 1) { + re = params.row.minAmount ? `满${params.row.minAmount}元使用` : ""; + } else if (params.row.type == 2) { + re = "无门槛"; + } + return h( + "div", + re + ); + } + }, { title: "剩余数量", key: "remainCount", @@ -268,17 +292,9 @@ key: "validStartTime", width: 175, render: (h, params) => { - let re = "" - //有效期类型:1-绝对时间段有效,2-领取后相对天数有效 - if(params.row.validType == 1){ - re = this.getTime(params.row.validStartTime) + '-' + this.getTime(params.row.validEndTime) - }else{ - re = params.row.validDays - } - return h( "div", - re + this.getCouponValidText(params.row) ); } }, @@ -345,7 +361,7 @@ { title: "操作", key: "action", - width: 200, + width: 260, align: "center", fixed: "right", render: (h, params) => { @@ -390,6 +406,21 @@ }, "编辑" ), + h("Divider", { + props: { + type: "vertical", + }, + }), + h( + "a", { + on: { + click: () => { + this.changeCouponStatus(params.row); + }, + }, + }, + params.row.status == 1 ? "下架" : "上架" + ), ]); }, }, @@ -519,6 +550,23 @@ this.detailSearchForm.mobile = ""; this.getIssueRecords(); }, + changeCouponStatus(row) { + const isUp = row.status == 1; + const actionName = isUp ? "下架" : "上架"; + this.$Modal.confirm({ + title: `${actionName}优惠券`, + content: `确认${actionName}该优惠券吗?`, + onOk: () => { + const request = isUp ? downCoupon : upCoupon; + request({ id: row.id }).then((res) => { + if (res.success) { + this.$Message.success(`${actionName}成功`); + this.getDataList(); + } + }); + }, + }); + }, submit(){ this.loading = true; if(this.giveData.type == 0){ @@ -533,8 +581,34 @@ } }); }, + parseDateTime(v) { + if (!v) { + return null; + } + if (v instanceof Date) { + return isNaN(v.getTime()) ? null : v; + } + const str = String(v).trim(); + const match = str.match(/^(\d{4})-(\d{2})-(\d{2})(?:[ T](\d{2}):(\d{2}):(\d{2}))?/); + if (match) { + const date = new Date( + Number(match[1]), + Number(match[2]) - 1, + Number(match[3]), + Number(match[4] || 0), + Number(match[5] || 0), + Number(match[6] || 0) + ); + return isNaN(date.getTime()) ? null : date; + } + const date = new Date(str); + return isNaN(date.getTime()) ? null : date; + }, getTime(v) { - const date = new Date(v); + const date = this.parseDateTime(v); + if (!date) { + return ""; + } // 获取年份 const year = date.getFullYear(); // 获取月份 (getMonth 返回 0-11,所以需要 +1),并补齐0 @@ -550,6 +624,23 @@ // 拼接格式:年-月-日 时:分:秒 return `${year}-${month}-${day} ${hour}:${minute}:${second}`; }, + getCouponValidText(coupon, withPrefix) { + if (!coupon) { + return ""; + } + if (coupon.validType == 1) { + const startTime = this.getTime(coupon.validStartTime); + const endTime = this.getTime(coupon.validEndTime); + if (!startTime || !endTime) { + return ""; + } + return `${withPrefix ? "限" : ""}${startTime}至${endTime}${withPrefix ? "期间使用" : ""}`; + } + if (coupon.validDays !== undefined && coupon.validDays !== null && coupon.validDays !== "") { + return `领到券当日开始${coupon.validDays}天内有效`; + } + return ""; + }, getCouponStatus(status) { if (status == 0) { return "未使用"; @@ -605,10 +696,12 @@ this.selectDate = null; this.searchForm.startDate = ""; this.searchForm.endDate = ""; + this.searchForm.status = 1; // 重新加载数据 this.getDataList(); }, add() { + this.form = {}; this.showType = "2"; this.showCompany = true; }, diff --git a/src/views/app/business/logistics/logistics.vue b/src/views/app/business/logistics/logistics.vue index 53f3198..485d1b8 100644 --- a/src/views/app/business/logistics/logistics.vue +++ b/src/views/app/business/logistics/logistics.vue @@ -101,11 +101,11 @@
- +
diff --git a/src/views/app/business/logiticsCompany/addEdit.vue b/src/views/app/business/logiticsCompany/addEdit.vue index f31760f..5fc6c68 100644 --- a/src/views/app/business/logiticsCompany/addEdit.vue +++ b/src/views/app/business/logiticsCompany/addEdit.vue @@ -6,10 +6,7 @@ - - - - + @@ -72,7 +69,6 @@ export default { defaultForm() { return { categoryName: "", - categoryIcon: "", regionId: JSON.parse(this.getStore("user")).departmentId, sort: 0, status: 1, @@ -84,7 +80,11 @@ export default { if (!valid) return; this.submitLoading = true; const request = this.type == "1" ? editSeckill : addSeckill; - request(this.form).then((res) => { + const params = Object.assign({}, this.form, { + categoryName: this.form.categoryName ? this.form.categoryName.trim() : "", + categoryIcon: "", + }); + request(params).then((res) => { this.submitLoading = false; if (res.success) { this.$Message.success("操作成功"); @@ -100,12 +100,13 @@ export default { if (value === this.visible) return; this.maxHeight = Number(document.documentElement.clientHeight - 121) + "px"; this.title = this.type == "1" ? "编辑秒杀团分类" : this.type == "2" ? "新增秒杀团分类" : "秒杀团分类详情"; - this.form = this.type == "1" || this.type == "0" + const nextForm = this.type == "1" || this.type == "0" ? Object.assign(this.defaultForm(), JSON.parse(JSON.stringify(this.data || {}))) : this.defaultForm(); this.visible = value; this.$nextTick(() => { if (this.$refs.form) this.$refs.form.resetFields(); + this.form = nextForm; }); }, }, diff --git a/src/views/app/business/logiticsCompany/logiticsCompany.vue b/src/views/app/business/logiticsCompany/logiticsCompany.vue index 67d5869..cd36067 100644 --- a/src/views/app/business/logiticsCompany/logiticsCompany.vue +++ b/src/views/app/business/logiticsCompany/logiticsCompany.vue @@ -75,23 +75,7 @@ export default { fixed: "left", }, { - title: "分类图标", - key: "categoryIcon", - minWidth: 160, - render: (h, params) => { - if (!params.row.categoryIcon) return h("span", "-"); - return h("img", { - attrs: { src: params.row.categoryIcon }, - style: { - width: "60px", - height: "40px", - objectFit: "contain", - }, - }); - }, - }, - { - title: "排序", + title: "排名", key: "sort", minWidth: 100, }, diff --git a/src/views/app/business/luckey/luckey.vue b/src/views/app/business/luckey/luckey.vue index 914bc24..b3ee91d 100644 --- a/src/views/app/business/luckey/luckey.vue +++ b/src/views/app/business/luckey/luckey.vue @@ -21,13 +21,13 @@ - + @@ -62,6 +62,20 @@ @on-change="p => changePage('adventureSession', p)" size="small" show-total> + + + + + + +
+ + + +
@@ -28,9 +34,9 @@ - + @@ -143,14 +149,17 @@ contactPhone: "", shopIcon: "1111", shopAddress: "", + merchantType: "", yearFee: "", chargeTime: "", startTime: "", endTime: "", pageNumber: 1, pageSize: 10, - sort: "createTime", + sort: "shoprank", order: "desc", + sortOrder: 'shoprank', + orderOrder: 'desc', startDate: "", endDate: "", regionId:JSON.parse(this.getStore("userInfo")).departmentId, @@ -186,6 +195,18 @@ key: "shopTypeTitle", minWidth: 120, }, + { + title: "商家类型", + key: "merchantType", + minWidth: 110, + render: (h, params) => { + const typeMap = { + 1: "外卖商家", + 2: "团购商家", + }; + return h("span", typeMap[params.row.merchantType] || "-"); + }, + }, { title: "联系方式", key: "contactPhone", @@ -404,7 +425,9 @@ this.searchForm.pageSize = 10; this.searchForm.startDate = ""; this.searchForm.endDate = ""; - this.$refs.dep.clearSelect(); + if (this.$refs.dep) { + this.$refs.dep.clearSelect(); + } this.searchForm.departmentId = ""; // 重新加载数据 this.getDataList(); diff --git a/src/views/sys/order-manage/orderManage.vue b/src/views/sys/order-manage/orderManage.vue index c0fd7c4..4bc2c27 100644 --- a/src/views/sys/order-manage/orderManage.vue +++ b/src/views/sys/order-manage/orderManage.vue @@ -94,12 +94,12 @@ - + - - + @@ -116,9 +116,9 @@ - + @@ -476,6 +476,7 @@ searchType: "1", searchStatus:10, shopName: "", + receiverPhone: "", mobile:'', userId: "" }, @@ -487,10 +488,42 @@ fixed: "left", }, { - title: "订单编号", - key: "id", - width: 200, + title: "订单状态", + key: "status", + width: 130, align: "center", + render: (h, params) => { + let re = "" + if (params.row.status == 0) { + re = "待支付"; + } else if (params.row.status == 2) { + re = "待接单"; + } else if (params.row.status == 3 && params.row.deliveryType == 1) { + re = "待取货"; + } else if (params.row.status == 3 && params.row.deliveryType == 2) { + re = "待消费"; + } else if (params.row.status == 4) { + re = "待送达"; + } else if (params.row.status == 5) { + re = "已完成"; + } else if (params.row.status == 6) { + re = "已取消"; + } else if (params.row.status == 7) { + re = "待退款"; + } else if (params.row.status == 8) { + re = "已退款"; + } else if (params.row.status == 10) { + re = "待成团"; + } else if (params.row.status == 11) { + re = "售后中"; + } else if (params.row.status == 12) { + re = "已售后"; + } + return h( + "div", + re + ); + } }, { title: "预计送达时间", @@ -498,6 +531,9 @@ width: 200, align: "center", render: (h, params) => { + if (params.row.deliveryType != 1 || !params.row.deliveryInfo) { + return h("div", ""); + } return h( "div", this.formatDateTime(params.row.deliveryInfo.mustFinishTime) @@ -528,12 +564,6 @@ width: 130, align: "center", }, - { - title: "平台优惠券金额", - key: "weight", - width: 150, - align: "center", - }, { title: "完成支付时间", key: "createTime", @@ -546,44 +576,6 @@ ); } }, - { - title: "订单状态", - key: "status", - width: 130, - align: "center", - render: (h, params) => { - let re = "" - if (params.row.status == 0) { - re = "待支付"; - } else if (params.row.status == 2) { - re = "待接单"; - } else if (params.row.status == 3 && params.row.deliveryType == 1) { - re = "待取货"; - } else if (params.row.status == 3 && params.row.deliveryType == 2) { - re = "待消费"; - } else if (params.row.status == 4) { - re = "待送达"; - } else if (params.row.status == 5) { - re = "已完成"; - } else if (params.row.status == 6) { - re = "已取消"; - } else if (params.row.status == 7) { - re = "待退款"; - } else if (params.row.status == 8) { - re = "已退款"; - } else if (params.row.status == 10) { - re = "待成团"; - } else if (params.row.status == 11) { - re = "售后中"; - } else if (params.row.status == 12) { - re = "已售后"; - } - return h( - "div", - re - ); - } - }, { title: "操作", key: "action", @@ -1145,6 +1137,8 @@ }, handleReset() { this.$refs.searchForm.resetFields(); + this.searchForm.shopName = ""; + this.searchForm.receiverPhone = ""; this.searchForm.pageNum = 1; this.searchForm.pageSize = 10; this.returnForm.pageNum = 1;