From 085c8683f9dac7607efef9a9d1084c3968817d18 Mon Sep 17 00:00:00 2001 From: yujialong <479214531@qq.com> Date: Wed, 12 Apr 2023 14:20:04 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E5=A4=B4=E5=83=8F=E7=AD=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- order/ordered/ordered.vue | 96 +++++++++++++++++++++------------------ pages/person/person.vue | 17 +++++-- 2 files changed, 66 insertions(+), 47 deletions(-) diff --git a/order/ordered/ordered.vue b/order/ordered/ordered.vue index e412121..19fd97f 100644 --- a/order/ordered/ordered.vue +++ b/order/ordered/ordered.vue @@ -100,6 +100,10 @@ { name: '数据产品', id: 3 + }, + { + name: '职站增值模块', + id: 4 } ], searchTimer: null, @@ -143,56 +147,60 @@ const { tabs } = this data.map(e => { const list = e.startAndEndTimeList - let connect = true // 每个订单的开始结束日期是否连续 - list.map((n, i) => { - // 第一个不用计算。用当前订单的开始日期跟上一个订单的结束日期做比较,只差一天,就表示是连续订单 - if (i) { - if (new Date(n.startTime).getTime() - 86400000 !== new Date(list[i - 1].endTime).getTime()) connect = false - } - }) - // 如果是连续订单,则取第一个订单的开始日期和最后一个订单的结束日期 - const now = Date.now() - if (now < list[0].startTime) { - e.startTime = list[0].startTime - e.endTime = connect ? list[list.length - 1].endTime : list[0].endTime - e.status = '未生效' - } else if (now > list[list.length - 1].endTime) { - e.status = '已过期' - } else { - // 连续订单 - if (connect) { + if (list && list.length) { + let connect = true // 每个订单的开始结束日期是否连续 + list.map((n, i) => { + // 第一个不用计算。用当前订单的开始日期跟上一个订单的结束日期做比较,只差一天,就表示是连续订单 + if (i) { + if (new Date(n.startTime).getTime() - 86400000 !== new Date(list[i - 1].endTime).getTime()) connect = false + } + }) + // // 如果是连续订单,则取第一个订单的开始日期和最后一个订单的结束日期 + const now = Date.now() + if (now < list[0].startTime) { e.startTime = list[0].startTime - e.endTime = list[list.length - 1].endTime - e.status = '生效中' - e.orderEnable = list[0].isEnable + e.endTime = connect ? list[list.length - 1].endTime : list[0].endTime + e.status = '未生效' + } else if (now > list[list.length - 1].endTime) { + e.status = '已过期' } else { - for (const i in list) { - const n = list[i] - if (now >= new Date(n.startTime).getTime() && now <= new Date(n.endTime).getTime()) { - // 生效中的订单,直接取该订单的开始结束日期 - e.startTime = n.startTime - e.endTime = n.endTime - e.status = '生效中' - e.orderEnable = n.isEnable - break - } else if (i && now > new Date(list[i - 1].endTime).getTime() && now < new Date(n.startTime).getTime()) { - // 当前时间位于两个订单时间之间,则取次订单的开始结束日期,并且为未生效 - e.startTime = n.startTime - e.endTime = n.endTime - e.status = '未生效' - e.orderEnable = n.isEnable - break + // 连续订单 + if (connect) { + e.startTime = list[0].startTime + e.endTime = list[list.length - 1].endTime + e.status = '生效中' + e.orderEnable = list[0].isEnable + } else { + for (const i in list) { + const n = list[i] + if (now >= new Date(n.startTime).getTime() && now <= new Date(n.endTime).getTime()) { + // 生效中的订单,直接取该订单的开始结束日期 + e.startTime = n.startTime + e.endTime = n.endTime + e.status = '生效中' + e.orderEnable = n.isEnable + break + } else if (i && list[i - 1] && now > new Date(list[i - 1].endTime).getTime() && now < new Date(n.startTime).getTime()) { + // 当前时间位于两个订单时间之间,则取次订单的开始结束日期,并且为未生效 + e.startTime = n.startTime + e.endTime = n.endTime + e.status = '未生效' + e.orderEnable = n.isEnable + break + } else { + e.status = '已过期' + } } } } + const date = new Date() + date.setHours(0) + date.setMinutes(0) + date.setSeconds(0) + if (e.startTime) e.startAndEndTime = e.startTime + ' ~ ' + e.endTime + // 1开启 0禁用(已过期的订单,或者当前生效的订单为禁用,则显示为禁用,否则是启用) + e.isEnable = (e.status === '已过期' || !e.orderEnable) ? '禁用' : '启用' } - const date = new Date() - date.setHours(0) - date.setMinutes(0) - date.setSeconds(0) - e.startAndEndTime = e.startTime + ' ~ ' + e.endTime - // 1开启 0禁用(已过期的订单,或者当前生效的订单为禁用,则显示为禁用,否则是启用) - e.isEnable = (e.status === '已过期' || !e.orderEnable) ? '禁用' : '启用' }) this.list = data this.listAll = data diff --git a/pages/person/person.vue b/pages/person/person.vue index 5c0c693..ac9a03f 100644 --- a/pages/person/person.vue +++ b/pages/person/person.vue @@ -159,9 +159,20 @@ }, // 上传头像回调 onChooseAvatar(e) { - this.avatar = e.detail.avatarUrl - updateAvatars(e.detail.avatarUrl).then(res => {}).catch(e => {}) - this.getInfo() + uni.uploadFile({ + url: 'https://huorantech.cn/nakadai/nakadai/oss/fileUpload', + filePath: e.detail.avatarUrl, + name: 'file', + header: { + token: uni.getStorageSync('token'), + }, + formData: {}, + success: ({ data }) => { + updateAvatars(JSON.parse(data).filesResult.fileUrl).then(res => { + this.getInfo() + }).catch(e => {}) + } + }) }, // 进入设置 toSet() {