From 2bb07b4957712a927dbf260af4fcbde5bc4c380b Mon Sep 17 00:00:00 2001 From: sx <2427911852@qq.com> Date: Wed, 5 Feb 2025 23:29:54 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=88=E5=B9=B6=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jiuyi2/api/video.js | 21 ++++++++--- jiuyi2/common/js/config.js | 5 +-- jiuyi2/common/js/util.js | 3 ++ jiuyi2/components/index/time.vue | 60 ++++++++++++++++++++++++++------ jiuyi2/pages/release/video.vue | 40 +++++++++++---------- jiuyi2/vite.config.js | 4 +-- 6 files changed, 95 insertions(+), 38 deletions(-) diff --git a/jiuyi2/api/video.js b/jiuyi2/api/video.js index 4e63f28d..a21aa1a4 100644 --- a/jiuyi2/api/video.js +++ b/jiuyi2/api/video.js @@ -70,7 +70,8 @@ const video = { */ setLabel(param) { return util.request({ - url: `/video/api/saveTags`, + url: `/video/tag/add`, + // url: `/video/api/saveTags`, data: param.data, method: 'POST', load: true, @@ -472,8 +473,8 @@ const video = { */ setAlarm(param) { return util.request({ - url: `/home/setAlarm`, - query: param.query, + url: `/video/clock/setAlarm`, + data: param.data, method: 'POST', }) }, @@ -483,7 +484,19 @@ const video = { */ getAlarm() { return util.request({ - url: `/home/getAlarm`, + url: `/video/clock/selectAlarm`, + method: 'GET', + }) + }, + + /** + * 删除闹铃 + * @param {Object} param + */ + delAlarm(param) { + return util.request({ + url: `/video/clock/delAlarm`, + data: param.data, method: 'POST', }) }, diff --git a/jiuyi2/common/js/config.js b/jiuyi2/common/js/config.js index 502ea993..36f1528f 100644 --- a/jiuyi2/common/js/config.js +++ b/jiuyi2/common/js/config.js @@ -2,12 +2,13 @@ const config = { // 接口域名 // #ifdef H5 - host: 'h5api', + host: 'http://localhost:5173', + // host: 'h5api', // #endif // #ifndef H5 host: 'http://91f.xyz:8080', // host: 'http://192.168.0.110:8080', - // host: 'http://192.168.0.105:8080', + // host: 'http://192.168.0.100:8080', // host: 'http://192.168.0.114:8080', // #endif // 支付方式配置 diff --git a/jiuyi2/common/js/util.js b/jiuyi2/common/js/util.js index 83ae98b8..1ad97988 100644 --- a/jiuyi2/common/js/util.js +++ b/jiuyi2/common/js/util.js @@ -135,6 +135,9 @@ const util = { // reject(res) }, + complete(rs) { + console.log('upload complete',rs) + } }) }) }, diff --git a/jiuyi2/components/index/time.vue b/jiuyi2/components/index/time.vue index 1cc833ef..e1541e53 100644 --- a/jiuyi2/components/index/time.vue +++ b/jiuyi2/components/index/time.vue @@ -28,9 +28,11 @@ const typeList = reactive([{ name: '倒计时闹钟', key: 'countDown', + type: '2', }, { name: '时间闹钟', key: 'time', + type: '1', }, ]) const typeIndex = ref(0) // 小时 @@ -44,6 +46,7 @@ // 闹铃时间 const alarm = computed(() => { let result = uni.$store.state.alarmTime + if (result) result = util.formatTime('yyyy-MM-dd HH:mm:ss', result) return result }) // 获取年月日 @@ -84,11 +87,14 @@ // 获取设置的倒计时 function getAlarm() { api.video.getAlarm().then(rs => { + console.log('getAlarm', rs) if (rs.code == 200) { const result = rs.data if (!result) return + const findIndex = typeList.findIndex(item => item.type == result.type) + if (findIndex != -1) typeIndex.value = findIndex // 结束时间 - setTime(result.endTime) + setTime(result.timestamp) return } }) @@ -204,24 +210,29 @@ endTime = util.strtotime(`+${hour[hourIndex.value]} hour`, new Date().getTime()) endTime = util.strtotime(`+${minute[minuteIndex.value]} minute`, endTime) endTime = new Date(endTime).setSeconds(0) - endTime = util.formatTime('yyyy-MM-dd HH:mm:ss', endTime) + // endTime = util.formatTime('yyyy-MM-dd HH:mm:ss', endTime) } else if (type.key == 'time') { + // 时间闹钟 endTime += ` ${util.toTwo(hour[hourIndex.value])}:${util.toTwo(minute[minuteIndex.value])}:00` // 当前时间 const currentTime = new Date(util.formatTime('yyyy-MM-dd HH:mm:ss')).valueOf() // 闹钟时间 - const alarmTime = new Date(endTime).valueOf() + endTime = new Date(endTime).valueOf() // 如果闹钟时间小于当前时间 - if (alarmTime < currentTime) { + if (endTime < currentTime) { util.alert('设置闹钟时间应大于当前时间') return } } + // 闹钟 api.video.setAlarm({ - query: { - endTime, + data: { + // 类型 + type: type.type, + // 时间 + timestamp: endTime, } }).then(rs => { if (rs.code == 200) { @@ -240,6 +251,30 @@ }) } + // 关闭闹钟 + function handleClose() { + util.alert({ + content: '确定关闭闹钟提醒?', + success: (rs) => { + if(!rs.confirm) return + api.video.delAlarm({}).then(rs => { + if (rs.code == 200) { + uni.$store.commit('setState', { + key: 'alarmTime', + value: '', + }) + close() + return + } + util.alert({ + content: rs.msg, + showCancel: false, + }) + }) + } + }) + } + // defineExpose({ open, @@ -256,7 +291,8 @@ - + {{typeList[typeIndex].name}} @@ -271,7 +307,8 @@ - + {{item}} @@ -286,7 +323,8 @@ - + {{item}} @@ -306,8 +344,8 @@ 确认 - - 关闭 + + 关闭闹钟 diff --git a/jiuyi2/pages/release/video.vue b/jiuyi2/pages/release/video.vue index 18a83349..52244958 100644 --- a/jiuyi2/pages/release/video.vue +++ b/jiuyi2/pages/release/video.vue @@ -508,32 +508,34 @@ - - 添加商品链接 + diff --git a/jiuyi2/vite.config.js b/jiuyi2/vite.config.js index 86cdde56..4f576d65 100644 --- a/jiuyi2/vite.config.js +++ b/jiuyi2/vite.config.js @@ -4,9 +4,9 @@ import { import uni from '@dcloudio/vite-plugin-uni'; // -let target = 'http://91f.xyz:8080' +// let target = 'http://91f.xyz:8080' // let target = 'http://192.168.0.110:8080' -// let target = 'http://192.168.0.105:8080' +let target = 'http://192.168.0.100:8080' // let target = 'http://192.168.0.114:8080' export default defineConfig({