From 708caca9676c7cda24dda16e8793519ee840538c Mon Sep 17 00:00:00 2001 From: sx <2427911852@qq.com> Date: Sun, 12 Jan 2025 22:17:52 +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/news.js | 22 +++-- jiuyi2/common/js/util.js | 1 + jiuyi2/pages/index/index.nvue | 5 +- jiuyi2/pages/news/chat/chat.vue | 83 +++++++++---------- .../news/chat/components/news-temp/index.vue | 4 +- jiuyi2/readme.md | 3 +- jiuyi2/vite.config.js | 24 +++--- 7 files changed, 74 insertions(+), 68 deletions(-) diff --git a/jiuyi2/api/news.js b/jiuyi2/api/news.js index f3235eaf..24f8a137 100644 --- a/jiuyi2/api/news.js +++ b/jiuyi2/api/news.js @@ -134,15 +134,25 @@ export const news = { }, // 红包详情 - getRedbag(param) { + getRedPacketInfo(param) { return util.request({ - url: `/home/getRedbag`, - method: 'POST', - query: param.data - + url: `/user/getRedPacketInfo`, + method: 'GET', + query: param.query, + load: 1, }) }, - + + // 领红包 + getRedPacket(param) { + return util.request({ + url: `/user/getRedPacket`, + method: 'POST', + data: param.data, + query: param.query, + }) + }, + // 红包记录 grabredLog(param) { return util.request({ diff --git a/jiuyi2/common/js/util.js b/jiuyi2/common/js/util.js index 89dbe01c..ac9341b4 100644 --- a/jiuyi2/common/js/util.js +++ b/jiuyi2/common/js/util.js @@ -238,6 +238,7 @@ const util = { }, // 请求失败返回 fail: res => { + console.log('request fail', url, res, params.data ? params.data : '') // 关闭加载效果 if (params.load) { uni.hideLoading() diff --git a/jiuyi2/pages/index/index.nvue b/jiuyi2/pages/index/index.nvue index fde325d7..12ccc7ae 100644 --- a/jiuyi2/pages/index/index.nvue +++ b/jiuyi2/pages/index/index.nvue @@ -289,6 +289,8 @@ console.log('getRecList then rs', rs) // 设置列表 setList(rs, recList) + }).catch(rs => { + console.log('getRecList', rs) }) } @@ -321,8 +323,7 @@ const pages = getCurrentPages() // 判断是否当前页 if (pages[pages.length - 1].route != 'pages/index/index') { - proxy.$refs[`videoRef${tabIndex.value}`][current[tabIndex.value]].playState.value = - false + proxy.$refs[`videoRef${tabIndex.value}`][current[tabIndex.value]].playState.value = false proxy.$refs[`videoRef${tabIndex.value}`][current[tabIndex.value]].pause() } }, 500) diff --git a/jiuyi2/pages/news/chat/chat.vue b/jiuyi2/pages/news/chat/chat.vue index 62af4714..60ec845e 100644 --- a/jiuyi2/pages/news/chat/chat.vue +++ b/jiuyi2/pages/news/chat/chat.vue @@ -73,8 +73,6 @@ const top = ref(0) // 工具条的高度 const toolHeight = ref(0) - // 页码 - const page = ref(1) // 当前操作的元素 const messageItem = ref({}) // 工具栏状态 voice录音 input输入框 emoji表情 plus加号菜单 @@ -83,6 +81,8 @@ const videoUrl = ref('') // 视频上下文 const videoContext = ref(null) + // 红包对象 + const redPacket = reactive({}) onLoad(option => { // 标题 @@ -187,7 +187,6 @@ let request = api.news.getUserMsgHistory // 如果是群聊 获取群聊聊天记录 if (msg.type == 'GROUP') request = api.news.getGroupMsgHistory - console.log('getHistory') // 获取历史记录 request({ @@ -216,9 +215,9 @@ return item })) } + console.log('getHostory', list.data) // 总数 list.total = result.total - console.log('list', list.data) nextTick(() => { param.callback && param.callback() }) @@ -322,36 +321,20 @@ } /** - * 打开红包 + * 打开红包详情 * @param {Object} ev */ function handleRedPacket(ev) { messageItem.value = ev - api.news.getRedbag({ - data: { + api.news.getRedPacketInfo({ + query: { // 红包id - bagId: ev.payload.data.id + redPacketId: ev.callbackData.callback_json[0].businessId } }).then(rs => { - console.log('getRedbag', rs) if (rs.code == 200) { - const result = rs.data - messageItem.value.payload.data = { - ...result, - businessID: 'redPacket', - } - - // 同步修改消息 - let message = { - ...messageItem.value - } - message.payload.data = JSON.stringify(msg.payload.data) - - uni.$chat.modifyMessage(message).then(rs => { - console.log('modifyMessage success', rs) - }).catch(rs => { - console.log('modifyMessage catch', rs) - }) + proxy.$refs.RedPacketRef.open() + Object.assign(redPacket, rs.data) return } util.alert({ @@ -359,22 +342,30 @@ showCancel: false, }) }) - proxy.$refs.RedPacket.open() } // 领取红包 function handleOpenReadPacket() { - // - if (messageItem.value.payload.data.status != 0) return + // 如果不能领取 + if (redPacket.redStatus == false) return + // 红包过期 + // if (redPacket.isStale == 1) return - api.news.grabred({ - data: { + + // 抢红包 + api.news.getRedPacket({ + query: { // 红包id - id: messageItem.value.payload.data.id + redPacketId: redPacket.id, + // 领取人id + userId: userinfo.value.id, } }).then(rs => { if (rs.code == 200) { - handleRedPacket(messageItem.value) + // 修改领取状态 + redPacket.redStatus = false + // 获取金额 + redPacket.amount = rs.data return } util.alert({ @@ -518,36 +509,40 @@ - +