我的页面切换公司功能

v2
一杯沧海 1 year ago
parent f1bef606a9
commit 3fe6226304
  1. 4
      .env
  2. 12
      src/api/user.ts
  3. 10
      src/pages/my/components/header/header.tsx
  4. 3
      src/pages/my/my.module.scss
  5. 60
      src/pages/my/my.tsx
  6. 4
      src/pages/preview/illness/article/article.tsx
  7. 1
      types/user.d.ts

@ -1,5 +1,5 @@
#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://mooc.yaojiankang.top
TARO_APP_API=https://shopfix.yaojiankang.top
#TARO_APP_API=https://playedu.yaojiankang.top
TARO_APP_LGOIN=true

@ -75,9 +75,6 @@ export const userApi = {
hourCourse(course_id: string, unique_ident: number) {
return request<HourCourse>(`/api/v1/course/${course_id}/info/${unique_ident}`, "GET")
},
meetingSave(data: any) {
return request<LoginData>(`/api/v1/auth/login/meeting/save`, "POST", data)
},
info(user_id: string) {
return request<User>(`/api/v1/statistics/${user_id}`, "GET")
},
@ -89,5 +86,12 @@ export const userApi = {
},
getCode(phone_number: number) {
return request('/api/v1/sms/send?phone_number=' + phone_number, "GET")
}
},
/** 公司列表 */
companyList() {
return request<unknown[]>(`/api/v1/company/mine_list`, "GET")
},
companyReplace(id: number) {
return request(`/api/v1/company/replace/${id}`, "PATCH")
},
}

@ -4,8 +4,8 @@ import styles from "@/pages/my/my.module.scss";
import avatar from "@/static/img/avatar.png"
import blacktriang from "@/static/img/blacktriangle.png"
const Header = () => {
const {user} = Profile.useContainer()
const Header = ({showCompany}:{showCompany:()=> void}) => {
const {user,company} = Profile.useContainer()
return (
<View className={styles.header}>
@ -14,8 +14,10 @@ const Header = () => {
<View className='flex-1'>
<View className='font-32'>{user?.name}</View>
<View className='flex align-center mt-2'>
<Text style={{fontSize:'24rpx',fontWeight:'500',color:'#323635'}}></Text>
<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>
</View>
{/*<View className='login font-24 mt-2 text-secondary flex justify-between content-start'>*/}

@ -127,6 +127,9 @@ page {
margin-left: 24rpx;
width:24rpx;
height:24rpx;
&.hide{
background: none;
}
}
}

@ -2,18 +2,28 @@ import {PageContainer, View, Image} from "@tarojs/components";
import Taro from "@tarojs/taro";
import styles from './my.module.scss'
import Header from "./components/header/header";
import {FC} from "react";
import {FC, useState} from "react";
import Time from "@/pages/my/components/header/time";
import Service from "@/pages/my/components/header/service";
import LoginView from "@/components/loginView";
import {Profile} from "@/store";
import {rfc33392time} from "@/utils/day";
import Img from "@/components/image/image";
import GreenNike from "@/static/img/greenNike.png"
import {userApi} from "@/api";
const My: FC = () => {
const globalData = Taro.getApp().globalData
const {token,empty} = Profile.useContainer()
const {token,company,setCompany} = Profile.useContainer()
const [companyShow,setCompanyShow] = useState(false)
const [companyList,setCompanyList] = useState<Company[]>([])
Taro.useDidShow(() => {
try {
userApi.companyList().then(res => {
setCompanyList(res as Company[])
})
} catch (e) {
}
})
return (
<View className={styles.content} style={`paddingTop:${globalData.statusBarHeight}px`}>
@ -21,26 +31,50 @@ const My: FC = () => {
<LoginView height={globalData.windowHeight-100}></LoginView>
:
<>
<Header/>
<Header showCompany={()=>{setCompanyShow(true)}}/>
<Time/>
<Service/>
</>
}
<PageContainer position={'bottom'} round={true} show={false}>
<PageContainer overlayStyle={'background:rgba(0,0,0,0.3)'} position={'bottom'} round={true} 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>
{
companyList.length >= 1 &&
companyList.map(d =>
<View className={styles.box} onClick={async () => {
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>
<View className={styles.innerBox}>
<View className={styles.title}>{d.name}</View>
<Image src={company?.id === d.id ? GreenNike: ''} className={styles.icon}></Image>
<View className={styles.box} onClick={() => {}}>
<View className={styles.image}>
<Img width={68} height={68} src={'dd'}/>
</View>
<View className={styles.innerBox}>
<View className={styles.title}></View>
<Image src={GreenNike} className={styles.icon}></Image>
</View>
</View>
</View>
)
}
</View>
</PageContainer>
</View>

@ -1,4 +1,4 @@
import {FC, useEffect, useMemo, useRef, useState} from "react";
import {FC, useEffect, useMemo, useState} from "react";
import {Image, PageContainer, Text, View} from "@tarojs/components";
import Taro, {useRouter} from "@tarojs/taro";
import {ArticleRecord, brandApi} from "@/api";
@ -8,7 +8,7 @@ import {Profile} from "@/store";
import {parse} from "@/utils/marked/marked";
const article:FC = () => {
const {token, empty} = Profile.useContainer()
const {token} = Profile.useContainer()
const {id} = useRouter().params as unknown as { id: number}
const [show,setShow] = useState(false)
const [articleInfo,setArticleInfo] = useState<ArticleRecord>()

1
types/user.d.ts vendored

@ -47,6 +47,7 @@ interface Company {
name: string
phone_number: string
updated_at: string
logo: string
}
interface CueStats {

Loading…
Cancel
Save