Commit 7f1d3377 authored by 管新明's avatar 管新明

fix: 收藏商品成功后更新收藏列表

parent 555c0714
This diff is collapsed.
export default { export default {
env: 'test', // 云函数环境 test 测试环境 online 线上环境 env: 'test', // 云函数环境 test 测试环境 online 线上环境
requestType: 'tornadoAPI', // cloud: 云函数, yapi: yapi 接口, ams: ams接口,tornadoAPI: 风驰台接口 requestType: 'yapi', // cloud: 云函数, yapi: yapi 接口, ams: ams接口,tornadoAPI: 风驰台接口
cloudName: 'luolai', // 主云函数项目名 CommonToC cloudName: 'CommonToC', // 主云函数项目名 CommonToC
sellerId: '2207644377875', sellerId: '2207644377875',
tornadoAPI: 'https://tornado.duibadev.com.cn/tbServer/api?db=db3000000038851072&proxyIp=172.16.130.158', // 新增:当requestType: 'tornadoAPI'时,找服务端提供地址 tornadoAPI: 'https://tornado.duibadev.com.cn/tbServer/api?db=db3000000038851072&proxyIp=172.16.130.158', // 新增:当requestType: 'tornadoAPI'时,找服务端提供地址
defaultActivityId: '60642aafc752d118247c2a2d' // 默认活动id defaultActivityId: '60642aafc752d118247c2a2d' // 默认活动id
......
import React from 'react' import React, { useState, useEffect } 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 { 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'
...@@ -25,19 +24,29 @@ const browseConfig = { ...@@ -25,19 +24,29 @@ const browseConfig = {
function CollectGoodsPage() { function CollectGoodsPage() {
const router = useRouter() const router = useRouter()
const [goodsList, setGoodsList] = useState([])
const { itemIds } = router?.params const { itemIds } = router?.params
const { data } = useRequest(API.getCollectGoodsList, { itemIds })
useEffect(() => {
getGoodsList()
}, [])
const getGoodsList = async () => {
const { data } = await API.getCollectGoodsList({ itemIds })
setGoodsList(data?.list || [])
}
const onCompleteTask = useThrottle(async(taskType, itemId) => { const onCompleteTask = useThrottle(async(taskType, itemId) => {
const { success } = await API.doCompleteTask({ taskType, itemId }) const { success } = await API.doCompleteTask({ taskType, itemId })
if (success) { if (success) {
getGoodsList()
commonToast('收藏成功') commonToast('收藏成功')
} }
}) })
return ( return (
<View> <View>
<GoodsPage goodsList={data?.list || []} task={browseConfig} onCompleteTask={() => onCompleteTask} /> <GoodsPage goodsList={goodsList} task={browseConfig} onCompleteTask={() => onCompleteTask} />
</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