Commit 50d62206 authored by 管新明's avatar 管新明 Committed by 王能飞

C client taro bugfixed 20210519

parent 7f1d3377
...@@ -68,7 +68,7 @@ export default function TasksModal(props) { ...@@ -68,7 +68,7 @@ export default function TasksModal(props) {
// 跳转任务 https://www.feizhu.com // 跳转任务 https://www.feizhu.com
jumpLink: async() => { jumpLink: async() => {
navigateToOutside(url) navigateToOutside(url)
if (browseType === 1) { if (browseType === 2) {
doCompleteTaskHandle(taskType) doCompleteTaskHandle(taskType)
} else { } else {
app.isFlashTask = true app.isFlashTask = true
......
...@@ -95,6 +95,7 @@ export const TASK_CONFIG = { ...@@ -95,6 +95,7 @@ export const TASK_CONFIG = {
orderGoods: '去完成', orderGoods: '去完成',
collectGoods: '去完成' collectGoods: '去完成'
}, },
browseType: 1, // 1 跳转即算完成 2 跳转浏览15s 才算完成 browseType: 2, // 1 跳转浏览15s 才算完成 2 跳转即算完成
browseTime: 15 // 浏览时间 browseTime: 15, // 浏览时间
jumpType: 1 // 1 浏览15s 才算完成 2 点击就算完成任务
} }
import React, { useEffect, useState } from 'react' import React, { useEffect, useState } from 'react'
import { View } from '@tarojs/components' import { View } from '@tarojs/components'
import GoodsPage from '@/components/GoodsPage/GoodsPage' import GoodsPage from '@/components/GoodsPage/GoodsPage'
import { useDidShow, useRouter } from '@tarojs/taro' import { useDidShow, useRouter, useDidHide } from '@tarojs/taro'
import API from '@/api' import API from '@/api'
import { TASK_CONFIG } from '@/const' import { TASK_CONFIG } from '@/const'
import { useRequest } from '@/hooks/useRequest' import { useRequest } from '@/hooks/useRequest'
...@@ -25,7 +25,7 @@ function BrowseGoodsPage() { ...@@ -25,7 +25,7 @@ function BrowseGoodsPage() {
const [ percent, setPercent ] = useState(0) const [ percent, setPercent ] = useState(0)
const [ isJumpLink, setIsJumpLink ] = useState(false) const [ isJumpLink, setIsJumpLink ] = useState(false)
const { browseType, browseTime } = TASK_CONFIG const { jumpType, browseTime } = TASK_CONFIG
let browserTimer = null let browserTimer = null
let usePercent = 0 let usePercent = 0
...@@ -35,16 +35,22 @@ function BrowseGoodsPage() { ...@@ -35,16 +35,22 @@ function BrowseGoodsPage() {
useEffect(() => { useEffect(() => {
listSuccess && list.length && browseGoodsTimes() listSuccess && list.length && browseGoodsTimes()
return () => clearInterval(browserTimer)
}, [ list ]) }, [ list ])
useDidShow(() => { useDidShow(() => {
// 重新回到页面开启倒计时 // 重新回到页面开启倒计时
if (!browserTimer && browseType === 1 && isJumpLink) { if (!browserTimer && jumpType === 1 && isJumpLink) {
usePercent = percent usePercent = percent
browseGoodsTimes() browseGoodsTimes()
} }
}) })
useDidHide(() => {
// 页面关闭清除定时器
clearInterval(browserTimer)
})
const onCompleteTask = async(itemId) => { const onCompleteTask = async(itemId) => {
const { success } = await API.doCompleteTask({ taskType: browseConfig.taskType, itemId }) const { success } = await API.doCompleteTask({ taskType: browseConfig.taskType, itemId })
if (success) { if (success) {
...@@ -54,10 +60,10 @@ function BrowseGoodsPage() { ...@@ -54,10 +60,10 @@ function BrowseGoodsPage() {
} }
const onOpenDetail = (itemId) => { const onOpenDetail = (itemId) => {
if (browseType === 1) { if (jumpType === 1) {
setPercent(usePercent) setPercent(usePercent)
setIsJumpLink(true) setIsJumpLink(true)
clearInterval(this.timer) clearInterval(browserTimer)
return return
} }
onCompleteTask(itemId) onCompleteTask(itemId)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment