一杯沧海 1 year ago
commit 648198d368
  1. 12
      src/api/request.ts
  2. 10
      src/app.config.ts
  3. 4
      src/pages/home/home.config.ts
  4. 10
      src/pages/home/home.tsx
  5. 9
      src/pages/index/components/videoList.tsx
  6. 7
      src/pages/index/index.tsx
  7. 4
      src/pages/login/login.tsx
  8. 4
      src/pages/preview/preview.config.ts
  9. 14
      src/pages/preview/preview.tsx
  10. 12
      src/store/profile.ts

@ -83,14 +83,14 @@ export function request<T = unknown>(
if (data?.code === 0 && res?.statusCode === 200) {
resolve(data?.data)
} else if (res.statusCode === 401) {
Taro.showModal({
title: "登录过期,需重新登陆",
showCancel: false,
success() {
// Taro.showModal({
// title: "登录过期,需重新登陆",
// showCancel: false,
// success() {
Taro.clearStorageSync()
Taro.reLaunch({url: '/pages/login/login'})
}
})
// }
// })
} else {
reject(null)
Taro.showToast({

@ -1,11 +1,11 @@
export default defineAppConfig({
pages: [
'pages/home/home',
'pages/index/index',
'pages/meeting/meeting',
'pages/login/login',
'pages/check/check',
'pages/my/my',
'pages/preview/preview',
],
window: {
backgroundTextStyle: 'light',
@ -18,7 +18,13 @@ export default defineAppConfig({
selectedColor: '#45D4A8',
list: [
{
text: '课题',
text: '首页',
pagePath: 'pages/home/home',
iconPath: "static/tabs/home-unselect.png",
selectedIconPath: "static/tabs/home-selected.png",
},
{
text: '学习',
pagePath: 'pages/index/index',
iconPath: "static/tabs/home-unselect.png",
selectedIconPath: "static/tabs/home-selected.png",

@ -0,0 +1,4 @@
export default definePageConfig({
navigationBarTitleText: '首页',
navigationStyle: 'custom',
})

@ -0,0 +1,10 @@
import {FC} from "react";
import {View} from "@tarojs/components";
const Home: FC = () => {
return (
<View>2</View>
)
}
export default Home

@ -11,10 +11,9 @@ import eventsIndex from "@/hooks/eventsIndex";
interface Props {
categoryKey: CoursesKey
ready: boolean
}
export const VideoList: FC<Props> = ({categoryKey, ready}) => {
export const VideoList: FC<Props> = ({categoryKey}) => {
const [data, setData] = useState<Courses>({
is_finished: [],
is_required: [],
@ -94,18 +93,14 @@ export const VideoList: FC<Props> = ({categoryKey, ready}) => {
})
useDidShow(() => {
if (ready) {
getData().then()
getRecords().then()
}
})
useEffect(() => {
if (ready) {
getData().then()
getRecords().then()
}
}, [page, ready])
}, [page])
return (
<View className={'py-2 flex justify-between flex-wrap ' + styles.videoListBox}>
{data?.[categoryKey]?.length ? data?.[categoryKey]?.map(c =>

@ -5,9 +5,6 @@ import {VideoList} from "@/pages/index/components/videoList";
import Tabs, {OnChangOpt, TabList} from "@/components/tabs/tabs";
import {CoursesKey} from "@/api/public";
import Taro from '@tarojs/taro'
import {Profile} from '@/store'
// import {Search} from "./components/search";
const Index: FC = () => {
const globalData = Taro.getApp().globalData
@ -18,7 +15,6 @@ const Index: FC = () => {
{title: "未完成", value: 'is_not_finished'},
]
const [categoryKey, setCategoryKey] = useState<CoursesKey>('is_required')
const {token} = Profile.useContainer()
function tabChange(data: OnChangOpt) {
setCategoryKey(data.tab?.value as CoursesKey)
@ -28,9 +24,8 @@ const Index: FC = () => {
<>
<View className={styles.content} style={`paddingTop:${globalData.statusBarHeight}px`}>
{process.env.TARO_ENV !== "h5" && <View className='text-center font-weight font-34 mt-3'></View>}
{/*<Search/>*/}
<Tabs tabList={category} onChange={tabChange} current={categoryKey}/>
<VideoList categoryKey={categoryKey} ready={!!token}/>
<VideoList categoryKey={categoryKey}/>
</View>
</>
)

@ -61,7 +61,7 @@ const Login: FC = () => {
setToken(token)
setCompany(company)
setLoading(false)
Taro.switchTab({url: '/pages/index/index'})
Taro.switchTab({url: '/pages/home/home'})
} else {
Taro.setStorageSync('openid', catch_key)
Taro.reLaunch({url: '/pages/check/check'})
@ -81,7 +81,7 @@ const Login: FC = () => {
async function TESTLOGIN() {
const res = await loginApi.testLogin()
Taro.setStorageSync('profile', JSON.stringify(res))
Taro.reLaunch({url: '/pages/index/index'})
Taro.reLaunch({url: '/pages/home/home'})
}
return (

@ -1,4 +0,0 @@
export default definePageConfig({
navigationBarTitleText:'医学道',
onReachBottomDistance: 30
})

@ -1,14 +0,0 @@
import {FC} from "react";
import {View, Navigator} from "@tarojs/components";
const Preview: FC = () => {
return (
<View>
.....
<Navigator url='/pages/login/login'></Navigator>
</View>
)
}
export default Preview

@ -1,7 +1,7 @@
import {useEffect, useState} from "react";
import {createContainer} from "unstated-next";
import Taro from "@tarojs/taro";
import {whiteList} from "@/config";
// import {whiteList} from "@/config";
function DataKey(data: any) {
@ -40,11 +40,11 @@ function useProfile() {
}
}
if (data?.token == null) {
if (!whiteList.includes(Taro.getCurrentInstance().router?.path?.split('?')?.[0] || '')) {
Taro.reLaunch({url: '/pages/preview/preview'})
}
}
// if (data?.token == null) {
// if (!whiteList.includes(Taro.getCurrentInstance().router?.path?.split('?')?.[0] || '')) {
// Taro.reLaunch({url: '/pages/login/login'})
// }
// }
const [role, setRole] = useState<UserRole | null>(data?.role || null)
const [user, setUser] = useState<User | null>(data?.user || null)

Loading…
Cancel
Save