From 7a72bb334998bd5e06c1f0334d9a4ef99a8e2384 Mon Sep 17 00:00:00 2001 From: sx <2427911852@qq.com> Date: Sat, 4 Jan 2025 01:44:11 +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/durian.js | 94 --- jiuyi2/api/index.js | 2 + jiuyi2/api/intergral.js | 25 - jiuyi2/components/index/disc.vue | 6 +- jiuyi2/components/index/task.vue | 4 +- jiuyi2/pages/index/durian.vue | 23 +- jiuyi2/pages/index/index.nvue | 210 ++++--- jiuyi2/readme.md | 13 + .../dist/dev/.nvue/pages/index/index.js | 181 ++++-- .../dist/dev/app-plus/app-service.js | 587 +++++++++--------- .../dist/dev/app-plus/pages/index/index.js | 181 ++++-- 11 files changed, 688 insertions(+), 638 deletions(-) diff --git a/jiuyi2/api/durian.js b/jiuyi2/api/durian.js index 7a4721c7..f07b34b5 100644 --- a/jiuyi2/api/durian.js +++ b/jiuyi2/api/durian.js @@ -25,17 +25,6 @@ export const durian = { query: param.query, }) }, - /** - * 查看我的榴莲果明细 - * @param {Object} param - */ - DurianChange(param) { - return util.request({ - url: `/home/getMyFruitLog`, - method: 'post', - query: param.query, - }) - }, /** * 榴莲果置换 * @param {Object} param @@ -48,88 +37,5 @@ export const durian = { load: true, }) }, - /** - * 交易市场 - * @param {Object} param - */ - getOrderList(param) { - return util.request({ - url: `/home/getOrderList`, - method: 'post', - query: param.query, - load: true, - }) - }, - /** - * 订单交易 - * @param {Object} param - */ - orderSale(param) { - return util.request({ - url: `/home/orderSale`, - method: 'post', - query: param.query, - load: true, - }) - }, - /** - * 榴莲果互转化 - * @param {Object} param - */ - transfer(param) { - return util.request({ - url: `/home/transfer`, - method: 'post', - query: param.query, - }) - }, - /** - * 榴莲果挂卖 - * @param {Object} param - */ - fruitForSale(param) { - return util.request({ - url: `/home/fruitForSale`, - method: 'post', - query: param.query, - load: true, - }) - }, - /** - * 取消订单 - * @param {Object} param - */ - cancelSale(param) { - return util.request({ - url: `/home/cancelSale`, - method: 'post', - query: param.query, - load: 1, - }) - }, - /** - * 入驻商家 - * @param {Object} param - */ - shopApply(param) { - return util.request({ - url: `/home/shopApply`, - method: 'post', - query: param.query, - data: param.data, - }) - }, - /** - * 榴莲果明细 - * @param {Object} param - */ - getMyFruitLog(param) { - return util.request({ - url: `/duriantreeinfo`, - method: 'GET', - path: param.path, - query: param.query, - }) - }, } export default durian \ No newline at end of file diff --git a/jiuyi2/api/index.js b/jiuyi2/api/index.js index f5a04fef..b8f75b57 100644 --- a/jiuyi2/api/index.js +++ b/jiuyi2/api/index.js @@ -30,6 +30,8 @@ const api = { team, // 积分 intergral, + // 榴莲果 + durian, // 商城模块 shop, // 上传图片地址 diff --git a/jiuyi2/api/intergral.js b/jiuyi2/api/intergral.js index 03e64f3f..21ae417f 100644 --- a/jiuyi2/api/intergral.js +++ b/jiuyi2/api/intergral.js @@ -100,31 +100,6 @@ const intergral = { data: param.data, }) }, - - /** - * 验证码生成 - * @param {Object} param - */ - myQrcode(param) { - return util.request({ - url: `/user/team/getH5Link`, - method: 'GET', - query: param.query, - responseType: 'arraybuffer', - }) - }, - - /** - * 隐藏/公开 个人昵称 - * @param {Object} param - */ - nickname(param) { - return util.request({ - url: `/home/nickname`, - method: 'post', - query: param.query, - }) - }, } export default intergral \ No newline at end of file diff --git a/jiuyi2/components/index/disc.vue b/jiuyi2/components/index/disc.vue index a7bf8932..4772330a 100644 --- a/jiuyi2/components/index/disc.vue +++ b/jiuyi2/components/index/disc.vue @@ -23,15 +23,13 @@ // 唱片样式 const discStyle = computed(() => { - let result = { + return { transform: `rotate(${rotate.value}deg)`, } - return result }) // 用户信息 const userinfo = computed(() => { - let result = uni.$store.state.userinfo - return result + return uni.$store.state.userinfo }) onMounted(() => {}) diff --git a/jiuyi2/components/index/task.vue b/jiuyi2/components/index/task.vue index 97a96050..da96d48c 100644 --- a/jiuyi2/components/index/task.vue +++ b/jiuyi2/components/index/task.vue @@ -34,7 +34,7 @@ diff --git a/jiuyi2/pages/index/durian.vue b/jiuyi2/pages/index/durian.vue index 5ab3921d..666cbc4c 100644 --- a/jiuyi2/pages/index/durian.vue +++ b/jiuyi2/pages/index/durian.vue @@ -26,9 +26,8 @@ import util from '@/common/js/util.js' // 进度 import task from '@/components/index/task' - - import intergralApi from '@/api/intergral.js'; - import durianlApi from '@/api/durian.js'; + // 接口 + import api from '@/api/index.js' const { proxy } = getCurrentInstance() @@ -36,18 +35,18 @@ const store = useStore() // 互转表单 const form = reactive({ + // 账户 account: '', - sellNum: '', + // 榴莲果数量 + fruitAmount: '', }) - //读秒记录 const viewData = ref({ seconds: 0 }) // 用户信息 const userinfo = computed(() => { - let result = store.state.userinfo - return result + return store.state.userinfo }) // 进度条 const progress = computed(() => { @@ -57,8 +56,7 @@ }) // 我的钱包 const purse = computed(() => { - let result = store.state.purse || {} - return result + return store.state.purse || {} }) onReady(() => { @@ -70,6 +68,11 @@ util.getPurse() }) + // 根据账号查询用户id + function accToId() { + // api.durian. + } + // 榴莲果交易 function transfer() { durianlApi.transfer({ @@ -80,7 +83,7 @@ }).then(rs => { if (rs.code === 200) { util.alert('操作成功') - util.getUserinfo() + util.getPurse() return } util.alert({ diff --git a/jiuyi2/pages/index/index.nvue b/jiuyi2/pages/index/index.nvue index 11c7181a..5f7cac6a 100644 --- a/jiuyi2/pages/index/index.nvue +++ b/jiuyi2/pages/index/index.nvue @@ -113,6 +113,19 @@ }) // 唱片顶部位置 const discOffsetTop = ref(0) + // 有效读秒顶部位置 + const complete2Top = ref(0) + // 结束特效配置 + const completeConfig = { + 'complete1': { + time: 2, + }, + 'complete2': { + time: 1.5, + }, + } + // 结束特效键 complete1优先任务特效 complete2有效读秒特效 + const completeKey = ref('') // 底部菜单高度 const footerMenuHeight = ref(0) // 当前任务 @@ -137,6 +150,7 @@ // 设备信息 const systemInfo = uni.getSystemInfoSync() discOffsetTop.value = systemInfo.safeAreaInsets.top + 44 + 30 + complete2Top.value = systemInfo.safeAreaInsets.top + 44 + 150 // 判断是否提醒过闹铃 if (!uni.getStorageSync('alarmAlt')) { @@ -192,11 +206,14 @@ }) onReady(() => { - // 获取视频容器节点信息 - dom.getComponentRect(proxy.$refs.containerRef[0], (option) => { - viewSize.height = option.size.height - viewSize.width = option.size.width - }) + setTimeout(() => { + // 获取视频容器节点信息 + dom.getComponentRect(proxy.$refs.containerRef[0], (option) => { + console.log('option', option) + viewSize.height = option.size.height + viewSize.width = option.size.width + }) + }, 50) }) onShow(() => { @@ -298,15 +315,16 @@ // 如果有多的视频 并且当前数据为一条 // if (obj.total > 1 && obj.data.length <= 1) getMoreRecList() + // 延时监听播放 setTimeout(() => { const pages = getCurrentPages() // 判断是否当前页 - if (pages[pages.length - 1].route == 'pages/index/index') { + if (pages[pages.length - 1].route != 'pages/index/index') { proxy.$refs[`videoRef${tabIndex.value}`][current[tabIndex.value]].playState.value = - true - proxy.$refs[`videoRef${tabIndex.value}`][current[tabIndex.value]].play() + false + proxy.$refs[`videoRef${tabIndex.value}`][current[tabIndex.value]].pause() } - }, 50) + }, 500) return } util.alert({ @@ -315,6 +333,75 @@ }) } + /** + * 观看视频记录 + * @param {Object} element 记录的视频元素对象 + */ + function browseLog(element) { + util.isLogin().then(rs => { + // if (readSecond.count == 0) return + const data = { + // 视频id + videoId: element.item.id, + // 有效读秒时间统计 + viewingDuration: Math.floor(element.item.readSecond), + // 视频秒数 + videoDescription: Math.floor(element.videoTime.currentTime), + // + task: 0, + } + console.log('browseLog data', data) + // + api.video.browseLog({ + data, + }).then(rs => { + if (rs.code == 200) { + // 计数 + const result = rs.data + // 现在的有效读秒 + const taskValue = task.value + console.log('browseLog result', rs, taskValue) + + // 如果原来任务是优先任务 当前任务是有效读秒 + if (taskValue.taskType == 0 && result.taskType == 1) { + // 优先任务完成 播放烟花动画 + console.log('优先任务完成 播放烟花动画') + handleCompleteMode('complete1') + } + // 如果原来任务任务是有效读秒 并且新返回的数据小于当前的任务进度 + else if (result.taskType == 1 && (result.viewingDuration < taskValue + .viewingDuration)) { + console.log('有效读秒完成 播放任务完成动画') + handleCompleteMode('complete2') + } + + // + uni.$store.commit('setState', { + key: 'task', + value: result, + }) + return + } else { + console.log('browseLog err', rs) + } + }) + }) + } + + /** + * 触发完成特效 + * @param {Object} mode ['complete1'|'complete2'] 需要出发的动画键 + */ + function handleCompleteMode(mode) { + // 开启对应的特效 + completeKey.value = mode + + setTimeout(() => { + // 关闭特效 + completeKey.value = '' + }, completeConfig[mode].time * 1000) + } + // 有效读秒增加 function readSecondAdd() { clearInterval(readSecond.timer) @@ -323,19 +410,21 @@ // 开启计时器 readSecond.timer = setInterval(() => { - // 当前视频有效读秒 小于等于 最大有效读秒限制 - if (item.readSecond <= Math.min(Math.floor(item.videoDuration) - 2, 20)) { + // 当前视频有效读秒 小于等于 最大有效读秒限制(视频最大时长-2s,设置的有效读秒上限) + if (item.readSecond < Math.min(Math.floor(item.videoDuration) - 2, 20)) { // 增加这条视频的有效读秒 item.readSecond++ } else { - // 清空计时器 - clearInterval(readSecond.timer) + // 暂停有效读秒的统计 + readSecondPause() } }, 1000) } - // 有效读秒暂停 + // 暂停有效读秒的统计 function readSecondPause() { + // 暂停唱片 + proxy.$refs.discRef.pause() clearInterval(readSecond.timer) } @@ -486,60 +575,6 @@ // readSecondPause() } - /** - * 观看视频记录 - * @param {Object} element 记录的视频元素对象 - */ - function browseLog(element) { - util.isLogin().then(rs => { - // if (readSecond.count == 0) return - const data = { - // 视频id - videoId: element.item.id, - // 有效读秒时间统计 - viewingDuration: Math.floor(element.item.readSecond), - // 视频秒数 - videoDescription: Math.floor(element.videoTime.currentTime), - // - task: 0, - } - console.log('browseLog data', data) - // - api.video.browseLog({ - data, - }).then(rs => { - if (rs.code == 200) { - // 计数 - const result = rs.data - // 现在的有效读秒 - const taskValue = task.value - console.log('browseLog result', rs, taskValue) - - // 如果原来任务是优先任务 当前任务是有效读秒 - if (taskValue.taskType == 0 && result.taskType == 1) { - // 优先任务完成 播放烟花动画 - console.log('优先任务完成 播放烟花动画') - } - // 如果原来任务任务是有效读秒 并且新返回的数据小于当前的任务进度 - if (result.taskType == 1 && (result.viewingDuration < taskValue.viewingDuration)) { - console.log('有效读秒完成 播放任务完成动画') - } - - // - uni.$store.commit('setState', { - key: 'task', - value: result, - }) - return - } else { - console.log('browseLog err', rs) - } - }).catch(rs => { - console.log('browseLog err fail', rs) - }) - }) - } - /** * 视频点赞 * @param {Object} param 见下 @@ -654,15 +689,25 @@ + + + + + + + +