From d5622d5b0a4056ae7b03464fe65765f77bb35cd4 Mon Sep 17 00:00:00 2001 From: czm <2192718639@qq.com> Date: Mon, 9 May 2022 10:39:58 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/banner/index.tsx | 2 +- src/components/product/index.tsx | 2 +- src/pages/index/index.tsx | 8 +++++--- src/use/useLogin.ts | 16 +++++++++++++--- src/util/checkLogin.ts | 4 ---- 5 files changed, 20 insertions(+), 12 deletions(-) delete mode 100644 src/util/checkLogin.ts diff --git a/src/components/banner/index.tsx b/src/components/banner/index.tsx index 92f035a..594ebb8 100644 --- a/src/components/banner/index.tsx +++ b/src/components/banner/index.tsx @@ -36,7 +36,7 @@ export default (props:params) => { indicatorDots autoplay> { - list.map(item => { + list?.map(item => { return goLink(item.link)}> diff --git a/src/components/product/index.tsx b/src/components/product/index.tsx index 2f29417..64a951f 100644 --- a/src/components/product/index.tsx +++ b/src/components/product/index.tsx @@ -10,7 +10,7 @@ type Params = { export default ({desStatus = true, productList = []}:Params) => { return ( - {productList.map(item => { + {productList?.map(item => { return goLink(`/pages/details/index?id=${item.id}`)}> diff --git a/src/pages/index/index.tsx b/src/pages/index/index.tsx index f443e28..9222be9 100644 --- a/src/pages/index/index.tsx +++ b/src/pages/index/index.tsx @@ -20,7 +20,6 @@ export default () => { useDidShow(async () => { await checkLogin() - // categoryList() }) useEffect(() => { @@ -32,8 +31,11 @@ export default () => { const {fetchData} = GetProductKindListApi() const categoryList = async () => { const res = await fetchData() - setKindData({...kindData, list:res.data.list, defaultId: res.data.list[0].id}) - setFiltrate({...filtrate, product_kind_id:res.data.list[0].id}) + if(res.data?.list) { + setKindData({...kindData, list:res.data.list, defaultId: res.data.list[0].id}) + setFiltrate({...filtrate, product_kind_id:res.data.list[0].id}) + } + } //获取面料列表 diff --git a/src/use/useLogin.ts b/src/use/useLogin.ts index bced551..386657d 100644 --- a/src/use/useLogin.ts +++ b/src/use/useLogin.ts @@ -28,9 +28,19 @@ export default () => { setToken(data.token) setSessionKey(data.session_key) reslove(data) - Taro.reLaunch({ - url: router.path +'?' + qs.stringify(router.params) - }) + let params = router.params + delete params.$taroTimestamp + console.log('params::',params) + if(router.path === '/pages/index/index' || router.path === '/pages/user/index') { + Taro.reLaunch({ + url: router.path +'?' + qs.stringify(params) + }) + } else { + Taro.redirectTo({ + url: router.path +'?' + qs.stringify(params) + }) + } + } else { Taro.showToast({ title:'登录失败', diff --git a/src/util/checkLogin.ts b/src/util/checkLogin.ts deleted file mode 100644 index cc00e0b..0000000 --- a/src/util/checkLogin.ts +++ /dev/null @@ -1,4 +0,0 @@ - -export const checkLogin = () => { - -} \ No newline at end of file