Commit 675b3a91 authored by qinhaitao's avatar qinhaitao

feat:formate

parent c8973039
export default { export default {
navigationBarTitleText: '我的奖品', navigationBarTitleText: '收藏商品',
enableSkia: 'true', enableSkia: 'true',
allowsBounceVertical: 'NO', allowsBounceVertical: 'NO',
enableShareAppMessage: true enableShareAppMessage: true
......
import React, { useEffect, useState } from 'react' import React 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 { useRequest } from '@/hooks/useRequest' import { useRequest } from '@/hooks/useRequest'
import { useDidShow, useRouter } from '@tarojs/taro' import { useRouter } from '@tarojs/taro'
import tbccTs from '@/tbcc-sdk-ts' import tbccTs from '@/tbcc-sdk-ts'
import API from '@/api' import API from '@/api'
const { throttleHandle } = tbccTs.utils; import { useThrottle } from '@/hooks/useThrottle'
const { commonToast, favorShop, navigateTo, navigateToOutside, showSharePanel } = tbccTs.tb;
const { commonToast } = tbccTs.tb
const browseConfig = { const browseConfig = {
taskType: 'collectGoods', taskType: 'collectGoods',
...@@ -17,33 +18,26 @@ const browseConfig = { ...@@ -17,33 +18,26 @@ const browseConfig = {
title: '//yun.duiba.com.cn/taobaomini/clientCTest/goods_title@2x.png', title: '//yun.duiba.com.cn/taobaomini/clientCTest/goods_title@2x.png',
collect: '//yun.duiba.com.cn/taobaomini/clientCTest/goods_collection@2x.png', collect: '//yun.duiba.com.cn/taobaomini/clientCTest/goods_collection@2x.png',
no_collect: '//yun.duiba.com.cn/taobaomini/clientCTest/collection_no_collect@2x.png', no_collect: '//yun.duiba.com.cn/taobaomini/clientCTest/collection_no_collect@2x.png',
img: '//yun.duiba.com.cn/taobaomini/clientCTest/goods_img@2x.png', img: '//yun.duiba.com.cn/taobaomini/clientCTest/goods_img@2x.png'
}, },
color: '#181818' color: '#181818'
} }
function CollectGoodsPage() { function CollectGoodsPage() {
const [ goodsList, setGoodsList ] = useState([])
const router = useRouter() const router = useRouter()
const { itemIds } = router?.params const { itemIds } = router?.params
const { data, success } = useRequest(API.getCollectGoodsList,{ itemIds }) const { data } = useRequest(API.getCollectGoodsList, { itemIds })
useEffect(() => {
success && setGoodsList(data?.list)
},[ success ])
const onCompleteTask = async (taskType,itemId) => { const onCompleteTask = useThrottle(async(taskType, itemId) => {
let { success, data } = await API.doCompleteTask({ taskType, itemId }).catch(res => { const { success } = await API.doCompleteTask({ taskType, itemId })
res && commonToast(res.message) if (success) {
}) || {}
if(success) {
commonToast('收藏成功') commonToast('收藏成功')
} }
} })
return ( return (
<View> <View>
<GoodsPage goodsList={goodsList} task={browseConfig} onCompleteTask={() => onCompleteTask} /> <GoodsPage goodsList={data?.list || []} task={browseConfig} onCompleteTask={() => onCompleteTask} />
</View> </View>
) )
} }
......
export default { export default {
navigationBarTitleText: '我的奖品', navigationBarTitleText: '下单商品',
enableSkia: 'true', enableSkia: 'true',
allowsBounceVertical: 'NO', allowsBounceVertical: 'NO',
enableShareAppMessage: true enableShareAppMessage: true
......
...@@ -2,11 +2,8 @@ import React, { useEffect, useState } from 'react' ...@@ -2,11 +2,8 @@ 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 { useRequest } from '@/hooks/useRequest' import { useRequest } from '@/hooks/useRequest'
import { useDidShow, useRouter } from '@tarojs/taro' import { useRouter } from '@tarojs/taro'
import tbccTs from '@/tbcc-sdk-ts'
import API from '@/api' import API from '@/api'
const { throttleHandle } = tbccTs.utils;
const { commonToast, favorShop, navigateTo, navigateToOutside, showSharePanel } = tbccTs.tb;
const browseConfig = { const browseConfig = {
taskType: 'orderGoods', taskType: 'orderGoods',
...@@ -17,24 +14,19 @@ const browseConfig = { ...@@ -17,24 +14,19 @@ const browseConfig = {
title: '//yun.duiba.com.cn/taobaomini/clientCTest/goods_title@2x.png', title: '//yun.duiba.com.cn/taobaomini/clientCTest/goods_title@2x.png',
collect: '//yun.duiba.com.cn/taobaomini/clientCTest/goods_collection@2x.png', collect: '//yun.duiba.com.cn/taobaomini/clientCTest/goods_collection@2x.png',
no_collect: '//yun.duiba.com.cn/taobaomini/clientCTest/collection_no_collect@2x.png', no_collect: '//yun.duiba.com.cn/taobaomini/clientCTest/collection_no_collect@2x.png',
img: '//yun.duiba.com.cn/taobaomini/clientCTest/goods_img@2x.png', img: '//yun.duiba.com.cn/taobaomini/clientCTest/goods_img@2x.png'
}, },
color: '#181818' color: '#181818'
} }
function OrderGoodsPage() { function OrderGoodsPage() {
const [ goodsList, setGoodsList ] = useState([])
const router = useRouter() const router = useRouter()
const { itemIds } = router?.params const { itemIds } = router?.params
const { data, success } = useRequest(API.getItemListByItemIds,{ itemIds }) const { data } = useRequest(API.getItemListByItemIds, { itemIds })
useEffect(() => {
success && setGoodsList(data?.list)
},[ success ])
return ( return (
<View> <View>
<GoodsPage goodsList={goodsList} task={browseConfig} /> <GoodsPage goodsList={data?.list || []} task={browseConfig} />
</View> </View>
) )
} }
......
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