一杯沧海 1 year ago
commit 648198d368
  1. 16
      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. 17
      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) { if (data?.code === 0 && res?.statusCode === 200) {
resolve(data?.data) resolve(data?.data)
} else if (res.statusCode === 401) { } else if (res.statusCode === 401) {
Taro.showModal({ // Taro.showModal({
title: "登录过期,需重新登陆", // title: "登录过期,需重新登陆",
showCancel: false, // showCancel: false,
success() { // success() {
Taro.clearStorageSync() Taro.clearStorageSync()
Taro.reLaunch({url: '/pages/login/login'}) Taro.reLaunch({url: '/pages/login/login'})
} // }
}) // })
} else { } else {
reject(null) reject(null)
Taro.showToast({ Taro.showToast({

@ -1,11 +1,11 @@
export default defineAppConfig({ export default defineAppConfig({
pages: [ pages: [
'pages/home/home',
'pages/index/index', 'pages/index/index',
'pages/meeting/meeting', 'pages/meeting/meeting',
'pages/login/login', 'pages/login/login',
'pages/check/check', 'pages/check/check',
'pages/my/my', 'pages/my/my',
'pages/preview/preview',
], ],
window: { window: {
backgroundTextStyle: 'light', backgroundTextStyle: 'light',
@ -18,7 +18,13 @@ export default defineAppConfig({
selectedColor: '#45D4A8', selectedColor: '#45D4A8',
list: [ list: [
{ {
text: '课题', text: '首页',
pagePath: 'pages/home/home',
iconPath: "static/tabs/home-unselect.png",
selectedIconPath: "static/tabs/home-selected.png",
},
{
text: '学习',
pagePath: 'pages/index/index', pagePath: 'pages/index/index',
iconPath: "static/tabs/home-unselect.png", iconPath: "static/tabs/home-unselect.png",
selectedIconPath: "static/tabs/home-selected.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 { interface Props {
categoryKey: CoursesKey categoryKey: CoursesKey
ready: boolean
} }
export const VideoList: FC<Props> = ({categoryKey, ready}) => { export const VideoList: FC<Props> = ({categoryKey}) => {
const [data, setData] = useState<Courses>({ const [data, setData] = useState<Courses>({
is_finished: [], is_finished: [],
is_required: [], is_required: [],
@ -94,18 +93,14 @@ export const VideoList: FC<Props> = ({categoryKey, ready}) => {
}) })
useDidShow(() => { useDidShow(() => {
if (ready) { getData().then()
getData().then() getRecords().then()
getRecords().then()
}
}) })
useEffect(() => { useEffect(() => {
if (ready) { getData().then()
getData().then() getRecords().then()
getRecords().then() }, [page])
}
}, [page, ready])
return ( return (
<View className={'py-2 flex justify-between flex-wrap ' + styles.videoListBox}> <View className={'py-2 flex justify-between flex-wrap ' + styles.videoListBox}>
{data?.[categoryKey]?.length ? data?.[categoryKey]?.map(c => {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 Tabs, {OnChangOpt, TabList} from "@/components/tabs/tabs";
import {CoursesKey} from "@/api/public"; import {CoursesKey} from "@/api/public";
import Taro from '@tarojs/taro' import Taro from '@tarojs/taro'
import {Profile} from '@/store'
// import {Search} from "./components/search";
const Index: FC = () => { const Index: FC = () => {
const globalData = Taro.getApp().globalData const globalData = Taro.getApp().globalData
@ -18,7 +15,6 @@ const Index: FC = () => {
{title: "未完成", value: 'is_not_finished'}, {title: "未完成", value: 'is_not_finished'},
] ]
const [categoryKey, setCategoryKey] = useState<CoursesKey>('is_required') const [categoryKey, setCategoryKey] = useState<CoursesKey>('is_required')
const {token} = Profile.useContainer()
function tabChange(data: OnChangOpt) { function tabChange(data: OnChangOpt) {
setCategoryKey(data.tab?.value as CoursesKey) setCategoryKey(data.tab?.value as CoursesKey)
@ -28,9 +24,8 @@ const Index: FC = () => {
<> <>
<View className={styles.content} style={`paddingTop:${globalData.statusBarHeight}px`}> <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>} {process.env.TARO_ENV !== "h5" && <View className='text-center font-weight font-34 mt-3'></View>}
{/*<Search/>*/}
<Tabs tabList={category} onChange={tabChange} current={categoryKey}/> <Tabs tabList={category} onChange={tabChange} current={categoryKey}/>
<VideoList categoryKey={categoryKey} ready={!!token}/> <VideoList categoryKey={categoryKey}/>
</View> </View>
</> </>
) )

@ -61,7 +61,7 @@ const Login: FC = () => {
setToken(token) setToken(token)
setCompany(company) setCompany(company)
setLoading(false) setLoading(false)
Taro.switchTab({url: '/pages/index/index'}) Taro.switchTab({url: '/pages/home/home'})
} else { } else {
Taro.setStorageSync('openid', catch_key) Taro.setStorageSync('openid', catch_key)
Taro.reLaunch({url: '/pages/check/check'}) Taro.reLaunch({url: '/pages/check/check'})
@ -81,7 +81,7 @@ const Login: FC = () => {
async function TESTLOGIN() { async function TESTLOGIN() {
const res = await loginApi.testLogin() const res = await loginApi.testLogin()
Taro.setStorageSync('profile', JSON.stringify(res)) Taro.setStorageSync('profile', JSON.stringify(res))
Taro.reLaunch({url: '/pages/index/index'}) Taro.reLaunch({url: '/pages/home/home'})
} }
return ( 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 {useEffect, useState} from "react";
import {createContainer} from "unstated-next"; import {createContainer} from "unstated-next";
import Taro from "@tarojs/taro"; import Taro from "@tarojs/taro";
import {whiteList} from "@/config"; // import {whiteList} from "@/config";
function DataKey(data: any) { function DataKey(data: any) {
@ -40,11 +40,11 @@ function useProfile() {
} }
} }
if (data?.token == null) { // if (data?.token == null) {
if (!whiteList.includes(Taro.getCurrentInstance().router?.path?.split('?')?.[0] || '')) { // if (!whiteList.includes(Taro.getCurrentInstance().router?.path?.split('?')?.[0] || '')) {
Taro.reLaunch({url: '/pages/preview/preview'}) // Taro.reLaunch({url: '/pages/login/login'})
} // }
} // }
const [role, setRole] = useState<UserRole | null>(data?.role || null) const [role, setRole] = useState<UserRole | null>(data?.role || null)
const [user, setUser] = useState<User | null>(data?.user || null) const [user, setUser] = useState<User | null>(data?.user || null)

Loading…
Cancel
Save