Commit 73da6ea5 authored by qinhaitao's avatar qinhaitao

style: 💄 格式优化

parent 5acdca3f
......@@ -14,7 +14,7 @@ import { useState, useEffect } from 'react'
}
* @return {*}
*/
export function useRequest(api, params = {}, config = { manual: false }) {
export function useRequest(api, defaultParams = {}, config = { manual: false }) {
const [ data, setData ] = useState({})
const [ code, setCode ] = useState('')
const [ success, setSuccess ] = useState(false)
......@@ -22,7 +22,7 @@ export function useRequest(api, params = {}, config = { manual: false }) {
const [ loading, setLoading ] = useState(false)
const [ error, setError ] = useState(null)
const request = async() => {
const request = async(params = defaultParams) => {
setLoading(true)
try {
const { data: resData, success: resSuccess, message: resMsg, code: resCode } = await api(params, config)
......
......@@ -5,84 +5,6 @@ import { useRequest } from './useRequest'
export function useTasks() {
const { data, run: fetchTaskList } = useRequest(API.getTaskList, {}, { manual: false })
// const mockTaskList = [
// {
// taskType: 'follow',
// title: '关注店铺',
// taskRateType: 1,
// times: 1,
// completeTimes: 0,
// status: 1,
// rewards: 1
// },
// {
// taskType: 'member',
// title: '加入会员',
// taskRateType: 1,
// times: 1,
// completeTimes: 0,
// status: 1,
// rewards: 1
// },
// {
// taskType: 'invites',
// title: '邀请好友入会',
// taskRateType: 1,
// times: 3,
// completeTimes: 0,
// status: 1,
// rewards: 1
// },
// {
// taskType: 'jumpLink',
// title: '浏览店铺15s',
// taskRateType: 2,
// times: 1,
// completeTimes: 0,
// status: 1,
// rewards: 1
// },
// {
// taskType: 'browseGoods',
// itemIds: '617724147979,617724563528,617300295119',
// title: '浏览商品',
// taskRateType: 2,
// times: 1,
// completeTimes: 0,
// status: 1,
// rewards: 1
// },
// {
// taskType: 'orderGoods',
// itemIds: '617724147979,617724563528,617300295119',
// title: '下单任务',
// taskRateType: 2,
// times: 1,
// completeTimes: 0,
// status: 1,
// rewards: 1
// },
// {
// taskType: 'collectGoods',
// title: '收藏商品',
// itemIds: '617724147979,617724563528,617300295119',
// taskRateType: 2,
// times: 1,
// todayCompleteTimes: 0,
// status: 1,
// rewards: 1
// },
// {
// taskType: 'sign',
// title: '每日签到',
// taskRateType: 2,
// times: 1,
// todayCompleteTimes: 0,
// status: 1,
// rewards: 1
// }
// ]
return {
taskList: data?.list || [],
fetchTaskList
......
......@@ -8,7 +8,6 @@ import API from '@/api'
import RuleModal from '@/components/RuleModal/RuleModal'
import DoHelpModal from '@/components/DoHelpModal/DoHelpModal'
import TasksModal from '@/components/TasksModal/TasksModal'
import styles from './index.module.less'
const INDEX_CONFIG = {
......@@ -31,11 +30,8 @@ function Index() {
const [ taskFlag, setTaskFlag ] = useState(0)
const fetchActivityInfo = async() => {
const res = await API.getActivityBaseInfoById()
const { data } = res
if (res?.success) {
setActivityInfoAndStatus(data)
}
const { success, data } = await API.getActivityBaseInfoById()
success && setActivityInfoAndStatus(data)
}
// 授权登录完成
useLogin(() => {
......
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