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

C client taro bugfixed 20210519

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