1.修改个人中心手机号和新增上传头像

2.工具服务登录后权限渲染
3.切换公司仅只有一个公司时不进行操作
4.修改首页切换和加载更多样式
v2
king 1 year ago
parent 19e01cf623
commit 54e581f2ae
  1. 4
      .env
  2. 4
      src/api/user.ts
  3. 1
      src/components/navigationBar/navigationBar.module.scss
  4. 2
      src/components/popPut/popPut.tsx
  5. 25
      src/hooks/eventsIndex.ts
  6. 11
      src/pages/business/courType/courType.tsx
  7. 59
      src/pages/business/userInfo/userInfo.tsx
  8. 2
      src/pages/business/videoInfo/videoInfo.tsx
  9. 35
      src/pages/index/components/videoList.tsx
  10. 2
      src/pages/index/index.tsx
  11. 43
      src/pages/my/components/header/header.tsx
  12. 36
      src/pages/my/components/header/service.tsx
  13. 81
      src/pages/my/my.tsx

@ -1,5 +1,5 @@
#TARO_APP_API=https://yjx.dev.yaojiankang.top
TARO_APP_API=https://mooc.yaojiankang.top
TARO_APP_API=https://yjx.dev.yaojiankang.top
#TARO_APP_API=https://mooc.yaojiankang.top
#TARO_APP_API=https://shopfix.yaojiankang.top
#TARO_APP_API=https://playedu.yaojiankang.top
TARO_APP_LGOIN=true

@ -94,4 +94,8 @@ export const userApi = {
companyReplace(id: number) {
return request(`/api/v1/company/replace/${id}`, "PATCH")
},
// /** 上传头像 */
// putAvatar(file: string) {
// return request('/api/v1/user/avatar', "PUT", {file})
// }
}

@ -15,6 +15,7 @@
left: 0;
bottom: 0;
align-items: center;
z-index: 1;
}
.text {

@ -52,8 +52,8 @@ const PopPut: FC<Props> = ({title, chevron, content, image, isProp, children, sh
</View>
<View className='card-content'>
<View>{content}</View>
{!chevron && <Icon name='chevron-right'/>}
{image && <Img src={image} mode='scaleToFill' className='image' width={68} height={68}/>}
{!chevron && <Icon name='chevron-right'/>}
</View>
</View>
{

@ -1,25 +0,0 @@
import Taro from "@tarojs/taro";
/**
*
* -
*/
const KEY = 'REFRESH_INDEX'
interface RefreshIndex {
id: number
}
function on(fn: (arg: RefreshIndex) => void) {
Taro.eventCenter.on(KEY, fn)
}
function trigger(data: RefreshIndex) {
Taro.eventCenter.trigger(KEY, data)
}
export default {
on,
trigger
}

@ -5,7 +5,6 @@ import {courseApi} from "@/api";
import VideoCover from "@/components/videoCover/videoCover";
import {formatMinute} from "@/utils/time";
import Empty from "@/components/empty/empty";
import eventsIndex from "@/hooks/eventsIndex";
const CourType: FC = () => {
const params = useRouter().params
@ -46,16 +45,6 @@ const CourType: FC = () => {
}
}
eventsIndex.on(({id}) => {
if (id == null && params.type === "4") return;
for (const [index, notFinished] of data.entries()) {
if (notFinished.id === id) {
data.splice(index, 1)
return
}
}
})
useEffect(() => {
getData()

@ -1,6 +1,5 @@
import {useState} from "react";
import {Profile} from '@/store'
import avatar from "@/static/img/avatar.png"
import PopPut from "@/components/popPut/popPut";
import {Input, View} from "@tarojs/components";
import Taro from "@tarojs/taro";
@ -10,7 +9,7 @@ import MyButton from "@/components/button/MyButton";
const List = () => {
const {empty, user, setUser} = Profile.useContainer()
const {empty, user, setUser, token} = Profile.useContainer()
const [show, setShow] = useState(false)
const [name, setName] = useState<string>(user?.name || '')
@ -45,17 +44,67 @@ const List = () => {
Taro.showModal({
title: '是否确定退出登录',
success({confirm}) {
confirm && empty(true,true)
confirm && empty(true, true)
}
})
}
function putAvatar(filePath: string) {
Taro.showLoading({title: "正在上传图片"})
Taro.uploadFile({
url: process.env.TARO_APP_API + '/api/v1/user/avatar',
filePath,
name: 'file',
header: {
'Authorization': `Bearer ${token}`
},
success(res) {
Taro.hideLoading()
if (res.statusCode === 200) {
const data: User = JSON.parse(res.data).data
setUser(data)
Taro.showToast({title: "图片上传成功"})
} else {
Taro.showToast({title: "图片上传失败", icon: 'error'})
}
},
fail() {
Taro.showToast({title: "图片上传失败", icon: 'error'})
}
})
}
function selectAvatar() {
Taro.chooseImage({
count: 1,
sizeType: ['original', 'compressed'],
sourceType: ['album', 'camera'],
success: async (res) => {
if (!res.tempFiles.length) return;
const file = res.tempFiles[0]
if (file.size > 40960000) {
Taro.compressImage({
src: file.path,
quality: 50,
compressedWidth: 50,
compressHeight: 50,
success(res) {
putAvatar(res.tempFilePath)
}
})
} else {
putAvatar(file.path)
}
}
})
}
return (
<>
<View className={styles.box}>
<PopPut title='头像' image={avatar} chevron no_border/>
<PopPut title='手机号' content={user?.phone_number} chevron no_border/>
<PopPut title='头像' image={user?.avatar} no_border onClick={selectAvatar}/>
<PopPut title='手机号' content={user?.phone_number?.replace(user?.phone_number.slice(3, 7), "****")} chevron
no_border/>
<PopPut title='昵称' content={user?.name} isProp show={show} no_border>
<View className='p-2'>
<View className='text-center font-weigh mb-3'></View>

@ -5,7 +5,6 @@ import './videoInfo.scss'
import Catalogue from "./components/catalogue";
import Course from "./components/course";
import Taro from "@tarojs/taro";
import eventsIndex from "@/hooks/eventsIndex";
import {formatMinute} from "@/utils/time";
import videoEvents from "@/hooks/videoEvents";
import unique_ident from "@/hooks/unique_ident";
@ -52,7 +51,6 @@ const VideoInfo: FC = () => {
const flats: Hour[] = Object.values(data?.hours || {}).flat(Infinity) as Hour[]
if (playId === flats?.[flats.length - 1]?.id && !preview) {
Taro.showModal({title: '当前课程结束'})
eventsIndex.trigger({id: Number(id)})
return;
}
for (const [index, flat] of flats.entries()) {

@ -19,8 +19,6 @@ export const VideoList: FC<Props> = ({categoryKey, setCategoryKey}) => {
const [data, setData] = useState<Courses>({
is_required: [],
is_not_required: [],
// is_finished: [],
// is_not_finished: [],
})
const [page, setPage] = useState(1)
const [records, setRecords] = useState<LearnRecord[]>([])
@ -45,8 +43,6 @@ export const VideoList: FC<Props> = ({categoryKey, setCategoryKey}) => {
setData({
is_required: screen(old.is_required, res.is_required || []),
is_not_required: screen(old.is_not_required, res.is_not_required || []),
// is_finished: screen(old.is_finished, res.is_finished || []),
// is_not_finished: screen(old.is_not_finished, res.is_not_finished || []),
})
} catch (e) {
}
@ -76,16 +72,6 @@ export const VideoList: FC<Props> = ({categoryKey, setCategoryKey}) => {
}
}
// eventsIndex.on(({id}) => {
// if (id == null) return;
// for (const [index, notFinished] of data.is_not_finished.entries()) {
// if (notFinished.id === id) {
// data.is_finished.push(notFinished)
// data.is_not_finished.splice(index, 1)
// return
// }
// }
// })
const fetchData = () => {
getData().then()
@ -114,12 +100,11 @@ export const VideoList: FC<Props> = ({categoryKey, setCategoryKey}) => {
Object.entries(data).map(([key, value]) => <SwiperItem>
<ScrollView scrollY className={styles.swiper} onScrollToLower={() => setPage(page + 1)} enhanced
showScrollbar={false}>
<View className='py-2 flex justify-between flex-wrap'>
{
!token
&& key === 'is_required'
? <LoginView onSuccess={fetchData}/> : value?.length ?
<>
{
!token && key === 'is_required'
? <LoginView onSuccess={fetchData}/> : value?.length ?
<>
<View className='py-2 flex justify-between flex-wrap'>
{
value?.map(c =>
<VideoCover
@ -132,11 +117,11 @@ export const VideoList: FC<Props> = ({categoryKey, setCategoryKey}) => {
content={rateOfLearning(c.id, c.class_hour)}
/>)
}
<View className='text-center text-muted flex-1'></View>
</>
: <Empty name='暂无课程'/>
}
</View>
</View>
<View className='text-center text-muted'></View>
</>
: <Empty name='暂无课程'/>
}
</ScrollView>
</SwiperItem>)
}

@ -10,8 +10,6 @@ const Index: FC = () => {
const category: TabList[] = [
{title: "必修", value: 'is_required'},
{title: "选修", value: 'is_not_required'},
// {title: "已完成", value: 'is_finished'},
// {title: "未完成", value: 'is_not_finished'},
]
const [categoryKey, setCategoryKey] = useState<CoursesKey>('is_required')

@ -3,39 +3,32 @@ import {Image, Text, View} from "@tarojs/components";
import styles from "@/pages/my/my.module.scss";
import avatar from "@/static/img/avatar.png"
import blacktriang from "@/static/img/blacktriangle.png"
import {FC} from "react";
const Header = ({showCompany}:{showCompany:()=> void}) => {
const {token,user,company,empty} = Profile.useContainer()
interface Props {
companyList: Company[]
showCompany: () => void
}
const Header: FC<Props> = ({companyList, showCompany}) => {
const {token, user, company, empty} = Profile.useContainer()
return (
<View className={styles.header}>
<View className='flex'>
<Image src={user?.avatar || avatar} className={styles.avatar}/>
{
token ?
<Image src={user?.avatar || avatar} className={styles.avatar}/>:
<Image src={avatar} className={styles.avatar}/>
}
{ token ?
<View className='flex-1'>
<View className='font-32'>{user?.name}</View>
<View className='flex align-center mt-2' onClick={()=>{
showCompany()
}}>
<Text style={{fontSize:'24rpx',fontWeight:'500',color:'#323635'}}>{company?.name}</Text>
<Image src={blacktriang} style={{width:'20rpx',height:'20rpx'}}></Image>
token ? <View className='flex-1'>
<View className='font-32'>{user?.name}</View>
<View className='flex align-center mt-2' onClick={showCompany}>
<Text style={{fontSize: '24rpx', fontWeight: '500', color: '#323635'}}>{company?.name}</Text>
{companyList.length > 2 && <Image src={blacktriang} style={{width: '20rpx', height: '20rpx'}}></Image>}
</View>
</View>
: <View className='flex-1'>
<View className='font-32 mt-2' onClick={() => empty()}></View>
</View>
</View>:
<View className='flex-1'>
<View className='font-32 mt-2' onClick={()=>{
empty()
}}></View>
</View>
}
{/*<View className='login font-24 mt-2 text-secondary flex justify-between content-start'>*/}
{/* <Text>手机号:{user?.phone_number}</Text>*/}
{/*</View>*/}
</View>
</View>
)

@ -1,4 +1,4 @@
import {useEffect, useState} from "react";
import {useState} from "react";
import {Image, View} from "@tarojs/components";
import Taro from "@tarojs/taro";
import {Profile} from '@/store/profile'
@ -22,7 +22,7 @@ const Service = () => {
{title: '个人中心', src: userInfo, router: '/pages/business/userInfo/userInfo'},
])
const {token,user, setUser} = Profile.useContainer()
const {token, user, setUser} = Profile.useContainer()
Taro.useDidShow(async () => {
if (user?.id) {
@ -31,24 +31,26 @@ const Service = () => {
}
})
useEffect(() => {
const oldList: List[] = JSON.parse(JSON.stringify(list))
if(token){
if ([1, 2].includes(user?.role_type || 0)) {
oldList.unshift(...[
{title: '部门管理', src: dep, router: '/pages/manage/depAdmin/depAdmin'},
// {title: '课程市场', src: buy, router: '/pages/manage/curriculum/curriculum'},
{title: '现场会', src: spotMeeting, router: '/pages/manage/spotMeeting/spotMeeting'},
{title: '课程管理', src: course, router: '/pages/manage/courseAdmin/courseAdmin'},
])
setList(oldList)
}
Taro.useDidShow(() => {
if ([1, 2].includes(user?.role_type || 0)) {
setList([
{title: '部门管理', src: dep, router: '/pages/manage/depAdmin/depAdmin'},
{title: '现场会', src: spotMeeting, router: '/pages/manage/spotMeeting/spotMeeting'},
{title: '课程管理', src: course, router: '/pages/manage/courseAdmin/courseAdmin'},
{title: '个人中心', src: userInfo, router: '/pages/business/userInfo/userInfo'},
{title: '历史记录', src: cur, router: '/pages/business/history/history'},
])
} else {
setList([
{title: '历史记录', src: cur, router: '/pages/business/history/history'},
{title: '个人中心', src: userInfo, router: '/pages/business/userInfo/userInfo'},
])
}
}, [])
})
function jump(url: string) {
if(!token){
Taro.navigateTo({url:'/pages/login/login'})
if (!token) {
Taro.navigateTo({url: '/pages/login/login'})
return
}
Taro.navigateTo({url})

@ -16,58 +16,57 @@ const My: FC = () => {
const [companyShow, setCompanyShow] = useState(false)
const [companyList, setCompanyList] = useState<Company[]>([])
Taro.useDidShow(() => {
if(token){
try {
userApi.companyList().then(res => {
setCompanyList(res as Company[])
})
} catch (e) {
}
}
token && userApi.companyList().then(res => {
setCompanyList(res as Company[])
})
})
return (
<View className={styles.content} style={`paddingTop:${globalData.statusBarHeight}px`}>
<Header showCompany={()=>{
companyList.length >= 2 && setCompanyShow(true)
}}/>
<Time/>
<Service/>
<Header companyList={companyList} showCompany={() => companyList.length >= 2 && setCompanyShow(true)}/>
<Time/>
{token && <Service/>}
<PageContainer overlayStyle={'background:rgba(0,0,0,0.3)'} position={'bottom'} round={true} show={companyShow}
onClickOverlay={() => setCompanyShow(false)}>
<PageContainer
overlayStyle={'background:rgba(0,0,0,0.3)'}
position='bottom'
round
show={companyShow}
onClickOverlay={() => setCompanyShow(false)}>
<View className="px-3 py-5">
<View className="font-32 pb-3"
style={{display: 'flex', justifyContent: 'center', borderBottom: '2rpx solid #f5f8f7'}}></View>
style={{
display: 'flex',
justifyContent: 'center',
borderBottom: '2rpx solid #f5f8f7'
}}></View>
{
companyList.length >= 1 &&
companyList.map((d,idx) =>
<View className={`${styles.box} ${companyList.length-1 === idx && styles.noBorder} ` } onClick={async () => {
if(company?.id === d.id){
return
}
Taro.showLoading({
title: '切换公司中',
mask: true,
})
const data = await userApi.companyReplace(d.id)
Taro.hideLoading()
!data && setCompany(d)
!data && Taro.showModal({
title: '友情提示',
content: '切换公司成功,需要重新进入',
showCancel: false,
success: function (res) {
if (res.confirm) {
Taro.reLaunch({url: '/pages/my/my'})
}
}
})
setCompanyShow(false)
}}>
companyList.map((d, idx) =>
<View className={`${styles.box} ${companyList.length - 1 === idx && styles.noBorder} `}
onClick={async () => {
if (company?.id === d.id) return;
Taro.showLoading({
title: '切换公司中',
mask: true,
})
const data = await userApi.companyReplace(d.id)
Taro.hideLoading()
!data && setCompany(d)
!data && Taro.showModal({
title: '友情提示',
content: '切换公司成功,需要重新进入',
showCancel: false,
success: function (res) {
if (res.confirm) {
Taro.reLaunch({url: '/pages/my/my'})
}
}
})
setCompanyShow(false)
}}>
<View className={styles.image}>
<Img width={68} height={68} src={d.logo}/>
</View>

Loading…
Cancel
Save