Commit 408bd7d1 by 姜雷

合并冲突

parents 610e4442 19920257
import { ResponseDataEntity, smaproFetch } from './index'; import { ResponseDataEntity, smaproFetch, appHomeFetch } from './index';
export enum ServiceTypeParams { export enum ServiceTypeParams {
wechatPublicV = 1, wechatPublicV = 1,
...@@ -22,3 +22,48 @@ export const fetchAreaService = ( ...@@ -22,3 +22,48 @@ export const fetchAreaService = (
smaproFetch({ smaproFetch({
url: `/smpro/areaServiceConfigs/${data.areaId}/${data.type}`, url: `/smpro/areaServiceConfigs/${data.areaId}/${data.type}`,
}); });
export enum PublishClient {
android = '1',
ios = '2',
wx = '3',
}
type NoticeParams = {
customerId: number;
publishClient: PublishClient;
};
enum NoticeState {
published = 1,
unpublished = 0,
}
export type AppHomeNoticeAppVo = {
content: string; // 内容
createAt: string; // 创建时间
id: number; // 主键ID
noticeCode: string; // 公告编码
noticeImgs: string; // 公告图片
noticeTitle: string; // 公告名称
noticeType: string; // 强弹类型 1是 2否
operateId: number; // 运营商ID
operator: string; // 操作人
publishClient: PublishClient; // 发布端
sortId: number; // 排序号
state: NoticeState; // 状态 1已发布 0未发布
updateAt: string; // 更新时间
whetherClicked: boolean; // 是否点击false为否true为是
};
export const fetchLastNotice = (
entity: NoticeParams,
): Promise<ResponseDataEntity<AppHomeNoticeAppVo>> =>
appHomeFetch({
url: '/app/home/module/newest/notice',
data: entity,
});
export const fetchNoticesData = (
entity: NoticeParams,
): Promise<ResponseDataEntity<AppHomeNoticeAppVo[]>> =>
appHomeFetch({
url: '/app/home/module/notice',
data: entity,
});
...@@ -3,13 +3,13 @@ import store from '../store/index'; ...@@ -3,13 +3,13 @@ import store from '../store/index';
import { import {
BASE_SERVER_URL, BASE_SERVER_URL,
CUSTOMER_SERVER_URL, CUSTOMER_SERVER_URL,
SCHOOL_MAIN_URL,
LogoutCode, LogoutCode,
SuccessCode, SuccessCode,
OLD_BASE_SERVER_URL, OLD_BASE_SERVER_URL,
SHOWER_APP_URL, SHOWER_APP_URL,
SMPRO_URL, SMPRO_URL,
GX_URL, GX_URL,
APP_HOME_URL,
} from '../constants/index'; } from '../constants/index';
export type ResponseDataEntity<T> = { export type ResponseDataEntity<T> = {
...@@ -62,7 +62,7 @@ const createFetch = (basePath: string) => { ...@@ -62,7 +62,7 @@ const createFetch = (basePath: string) => {
export const baseFetch = createFetch(BASE_SERVER_URL); export const baseFetch = createFetch(BASE_SERVER_URL);
export const oldBaseFetch = createFetch(OLD_BASE_SERVER_URL); export const oldBaseFetch = createFetch(OLD_BASE_SERVER_URL);
export const customerFetch = createFetch(CUSTOMER_SERVER_URL); export const customerFetch = createFetch(CUSTOMER_SERVER_URL);
export const schoolMainFetch = createFetch(SCHOOL_MAIN_URL); export const appHomeFetch = createFetch(APP_HOME_URL);
export const showerFetch = createFetch(SHOWER_APP_URL); export const showerFetch = createFetch(SHOWER_APP_URL);
export const smaproFetch = createFetch(SMPRO_URL); export const smaproFetch = createFetch(SMPRO_URL);
export const gxFetch = createFetch(GX_URL); export const gxFetch = createFetch(GX_URL);
......
...@@ -8,8 +8,7 @@ export const BASE_SERVER_URL = 'https://ex-test-dcxy-base-app.168cad.top'; ...@@ -8,8 +8,7 @@ export const BASE_SERVER_URL = 'https://ex-test-dcxy-base-app.168cad.top';
export const OLD_BASE_SERVER_URL = 'https://in-test-selfbase.168cad.top'; export const OLD_BASE_SERVER_URL = 'https://in-test-selfbase.168cad.top';
export const CUSTOMER_SERVER_URL = export const CUSTOMER_SERVER_URL =
'https://ex-test-dcxy-customer-app.168cad.top'; 'https://ex-test-dcxy-customer-app.168cad.top';
export const SCHOOL_MAIN_URL = export const APP_HOME_URL = 'https://ex-test-dcxy-home-app.168cad.top';
'https://internal-test-school-home-bg.168cad.top';
export const ANN_LINK_URL = 'https://ex-test-wx.168cad.top/announcement/'; export const ANN_LINK_URL = 'https://ex-test-wx.168cad.top/announcement/';
export const SHOWER_APP_URL = 'https://in-test-shower-app-server.168cad.top'; export const SHOWER_APP_URL = 'https://in-test-shower-app-server.168cad.top';
export const SOCKET_URL = 'wss://test-shower-wss1.168cad.top:9443/ws'; export const SOCKET_URL = 'wss://test-shower-wss1.168cad.top:9443/ws';
......
...@@ -3,12 +3,16 @@ import { ComponentClass } from 'react'; ...@@ -3,12 +3,16 @@ import { ComponentClass } from 'react';
import { View, ScrollView, Image, Text, WebView } from '@tarojs/components'; import { View, ScrollView, Image, Text, WebView } from '@tarojs/components';
import AnnIcon from '../../images/icon/ann_tongzhi_icon@2x.png'; import AnnIcon from '../../images/icon/ann_tongzhi_icon@2x.png';
import { fetchAllAnn, AnnItem } from '../../api/announcement';
import { connect } from '@tarojs/redux'; import { connect } from '@tarojs/redux';
import './Announcement.scss'; import './Announcement.scss';
import { Customer } from '@/types/Customer/Customer'; import { Customer } from '@/types/Customer/Customer';
import { shareHandle } from '@/common/shareMethod'; import { shareHandle } from '@/common/shareMethod';
import {
fetchNoticesData,
PublishClient,
AppHomeNoticeAppVo,
} from '@/api/home';
type PageStateProps = { type PageStateProps = {
userinfo: Customer; userinfo: Customer;
...@@ -17,7 +21,7 @@ type PageOwnProps = {}; ...@@ -17,7 +21,7 @@ type PageOwnProps = {};
type PageState = { type PageState = {
pageNum: number; pageNum: number;
pageSize: number; pageSize: number;
list: AnnItem[]; list: AppHomeNoticeAppVo[];
linkUrl: string; linkUrl: string;
}; };
...@@ -43,24 +47,25 @@ class Announcement extends Component { ...@@ -43,24 +47,25 @@ class Announcement extends Component {
componentWillMount() { componentWillMount() {
const { userinfo } = this.props; const { userinfo } = this.props;
const { sectionId } = this.$router.params; fetchNoticesData({
fetchAllAnn({ customerId: userinfo.customerId,
campusId: userinfo.areaId, publishClient: PublishClient.wx,
sectionId: sectionId,
}) })
.then(res => { .then(res => {
const data = res.data; const data = res.data;
this.setState({ this.setState({
...data, list: data,
}); });
}) })
.catch(err => { .catch(err => {
console.log(err); console.log(err);
}); });
} }
geAnnDetail(id: number) { geAnnDetail(id: string) {
const { userinfo } = this.props;
Taro.navigateTo({ Taro.navigateTo({
url: `/pages/Content/Content?id=${id}`, url: `/pages/Content/Content?id=${id}&customerId=${userinfo.customerId}`,
}); });
} }
render() { render() {
...@@ -70,19 +75,16 @@ class Announcement extends Component { ...@@ -70,19 +75,16 @@ class Announcement extends Component {
{linkUrl && <WebView src={linkUrl} />} {linkUrl && <WebView src={linkUrl} />}
{list.map(annItem => ( {list.map(annItem => (
<View <View
key={annItem.id} key={annItem.noticeCode}
className='Announcement-item' className='Announcement-item'
onClick={() => this.geAnnDetail(annItem.id)}> onClick={() => this.geAnnDetail(annItem.noticeCode)}>
<Image <Image className='Announcement-item-img' src={annItem.noticeImgs} />
className='Announcement-item-img'
src={annItem.linkUrls[0]}
/>
<View className='Announcement-item-Content'> <View className='Announcement-item-Content'>
<Image className='Announcement-item-icon' src={AnnIcon} /> <Image className='Announcement-item-icon' src={AnnIcon} />
<Text className='Announcement-item-title'>{annItem.title}</Text> <Text className='Announcement-item-title'>
<Text className='Announcement-item-date'> {annItem.noticeTitle}
{annItem.updateTime}
</Text> </Text>
<Text className='Announcement-item-date'>{annItem.updateAt}</Text>
</View> </View>
</View> </View>
))} ))}
......
...@@ -4,6 +4,7 @@ import { WebView } from '@tarojs/components'; ...@@ -4,6 +4,7 @@ import { WebView } from '@tarojs/components';
import { connect } from '@tarojs/redux'; import { connect } from '@tarojs/redux';
import { ANN_LINK_URL } from '../../constants'; import { ANN_LINK_URL } from '../../constants';
import { shareHandle } from '@/common/shareMethod'; import { shareHandle } from '@/common/shareMethod';
import useNotices from '../Home/hooks/useNotices';
type PageOwnProps = { type PageOwnProps = {
token: string; token: string;
...@@ -32,14 +33,18 @@ class Content extends Component { ...@@ -32,14 +33,18 @@ class Content extends Component {
getLinkUrl() { getLinkUrl() {
const { token } = this.props; const { token } = this.props;
const { id } = this.$router.params; const { id, customerId } = this.$router.params;
console.log(id);
this.setState({ this.setState({
linkUrl: `${ANN_LINK_URL}?id=${id}&token=${token}`, linkUrl: `${ANN_LINK_URL}?id=${id}&token=${token}&customerId=${customerId}`,
}); });
} }
render() { render() {
const { linkUrl } = this.state; const { linkUrl } = this.state;
console.log(linkUrl);
return linkUrl && <WebView src={linkUrl} />; return linkUrl && <WebView src={linkUrl} />;
} }
} }
......
...@@ -29,9 +29,8 @@ import { ...@@ -29,9 +29,8 @@ import {
updateUserInfo, updateUserInfo,
INITIAL_STATE as userINitState, INITIAL_STATE as userINitState,
} from '../../store/rootReducers/userinfo'; } from '../../store/rootReducers/userinfo';
import { fetchAnn, SectionItem } from '../../api/announcement';
import { appLogout } from '../../api/customer'; import { appLogout } from '../../api/customer';
import { Customer } from '@/types/Customer/Customer'; import { Customer, CustomerSex } from '@/types/Customer/Customer';
import { shareHandle } from '@/common/shareMethod'; import { shareHandle } from '@/common/shareMethod';
import { fetchAreaService, ServiceTypeParams, Service } from '@/api/home'; import { fetchAreaService, ServiceTypeParams, Service } from '@/api/home';
import MenuIconNormal from '@/components/MenuIcon/normal/MenuIconNormal'; import MenuIconNormal from '@/components/MenuIcon/normal/MenuIconNormal';
...@@ -44,6 +43,7 @@ import { ...@@ -44,6 +43,7 @@ import {
ControllerResponse, ControllerResponse,
} from '@/api/shower'; } from '@/api/shower';
import { updateShowerControlConfig } from '@/store/rootReducers/shower'; import { updateShowerControlConfig } from '@/store/rootReducers/shower';
import useNotices from './hooks/useNotices';
type PageStateProps = { type PageStateProps = {
userinfo: Customer; userinfo: Customer;
...@@ -63,7 +63,6 @@ type BeanAccount = { ...@@ -63,7 +63,6 @@ type BeanAccount = {
type PageState = { type PageState = {
barMenuVisiable: boolean; barMenuVisiable: boolean;
beanAccount: BeanAccount[]; beanAccount: BeanAccount[];
annItem: SectionItem;
filterBeanList: BeanAccount[]; filterBeanList: BeanAccount[];
}; };
type IProps = PageStateProps & PageDispatchProps; type IProps = PageStateProps & PageDispatchProps;
...@@ -100,18 +99,6 @@ class Home extends Component { ...@@ -100,18 +99,6 @@ class Home extends Component {
barMenuVisiable: false, barMenuVisiable: false,
beanAccount: [], beanAccount: [],
filterBeanList: [], filterBeanList: [],
annItem: {
id: 0,
styleType: '',
name: '',
titleTypeRemark: '',
titleType: '',
titleContent: '',
sort: 0,
updateTime: 0,
itemsCount: 0,
items: [],
},
}; };
} }
...@@ -127,7 +114,6 @@ class Home extends Component { ...@@ -127,7 +114,6 @@ class Home extends Component {
getInitData() { getInitData() {
this.getServiceList(); this.getServiceList();
this.getAnn();
} }
getServiceList() { getServiceList() {
...@@ -142,24 +128,6 @@ class Home extends Component { ...@@ -142,24 +128,6 @@ class Home extends Component {
} }
} }
getAnn() {
const { userinfo } = this.props;
fetchAnn({
campusId: userinfo.areaId,
customerId: userinfo.customerId,
})
.then(res => {
if (res) {
this.setState({
annItem: res,
});
}
})
.catch(err => {
console.error(err);
});
}
goSetting() { goSetting() {
Taro.navigateTo({ Taro.navigateTo({
url: '/pages/UserSetting/UserSetting', url: '/pages/UserSetting/UserSetting',
...@@ -171,9 +139,9 @@ class Home extends Component { ...@@ -171,9 +139,9 @@ class Home extends Component {
url: '/pages/Feedback/Feedback', url: '/pages/Feedback/Feedback',
}); });
} }
goAnn(id: number) { goAnn(code: string) {
Taro.navigateTo({ Taro.navigateTo({
url: '/pages/Announcement/Announcement?sectionId=' + id, url: '/pages/Announcement/Announcement?sectionId=' + code,
}); });
} }
...@@ -249,10 +217,10 @@ class Home extends Component { ...@@ -249,10 +217,10 @@ class Home extends Component {
let newPhone = phone.replace(/([0-9]{3})([0-9]{4})([0-9]{4})/, '$1****$3'); let newPhone = phone.replace(/([0-9]{3})([0-9]{4})([0-9]{4})/, '$1****$3');
return newPhone; return newPhone;
}; };
geAnnDetail(id: number) { geAnnDetail(code: string) {
console.log(id); const { userinfo } = this.props;
Taro.navigateTo({ Taro.navigateTo({
url: `/pages/Content/Content?id=${id}`, url: `/pages/Content/Content?id=${code}&customerId=${userinfo.customerId}`,
}); });
} }
...@@ -265,8 +233,9 @@ class Home extends Component { ...@@ -265,8 +233,9 @@ class Home extends Component {
render() { render() {
const { userinfo, serviceList } = this.props; const { userinfo, serviceList } = this.props;
const { annItem, barMenuVisiable } = this.state; const { barMenuVisiable } = this.state;
const noticeData = useNotices();
return ( return (
<View className='Home'> <View className='Home'>
{barMenuVisiable ? ( {barMenuVisiable ? (
...@@ -300,7 +269,7 @@ class Home extends Component { ...@@ -300,7 +269,7 @@ class Home extends Component {
</View> </View>
<View className='Home-UserBox-addr'>{userinfo.areaName}</View> <View className='Home-UserBox-addr'>{userinfo.areaName}</View>
</View> </View>
{userinfo.customerSex === '2' ? ( {userinfo.customerSex === CustomerSex.girl ? (
<Image <Image
className='Home-UserBox-headimg' className='Home-UserBox-headimg'
src={UserHeaderF} src={UserHeaderF}
...@@ -436,30 +405,26 @@ class Home extends Component { ...@@ -436,30 +405,26 @@ class Home extends Component {
) : null} ) : null}
</View> </View>
{annItem.id ? ( {noticeData.noticeCode ? (
<View className='Home-Announcement'> <View className='Home-Announcement'>
<Image className='bg' src={AnnouncementBg} /> <Image className='bg' src={AnnouncementBg} />
<View className='Home-Announcement-title'> <View className='Home-Announcement-title'>
<Text>最新公告</Text> <Text>最新公告</Text>
<View <View
className='Home-Announcement-more' className='Home-Announcement-more'
onClick={() => this.goAnn(annItem.id)}> onClick={() => this.goAnn(noticeData.noticeCode)}>
更多 更多
<Image className='more-icon' src={MoreIcon} /> <Image className='more-icon' src={MoreIcon} />
</View> </View>
</View> </View>
{annItem.items.length && (
<View <View
className='Home-Announcement-Content' className='Home-Announcement-Content'
onClick={() => this.geAnnDetail(annItem.items[0].id)}> onClick={() => this.geAnnDetail(noticeData.noticeCode)}>
<Text className='Home-Announcement-Content-title'> <Text className='Home-Announcement-Content-title'>
{annItem.items[0].title} {noticeData.noticeTitle}
</Text>
<Text className='ContentDate'>
{annItem.items[0].updateTime}
</Text> </Text>
<Text className='ContentDate'>{noticeData.updateAt}</Text>
</View> </View>
)}
</View> </View>
) : null} ) : null}
</View> </View>
......
import { useEffect, useState } from '@tarojs/taro';
import { fetchLastNotice, PublishClient, AppHomeNoticeAppVo } from '@/api/home';
import { useSelector } from '@tarojs/redux';
import { Customer } from '@/types/Customer/Customer';
const initState: AppHomeNoticeAppVo = {
content: '', // 内容
createAt: '', // 创建时间
id: 0, // 主键ID
noticeCode: '', // 公告编码
noticeImgs: '', // 公告图片
noticeTitle: '', // 公告名称
noticeType: '', // 强弹类型 1是 2否
operateId: 0, // 运营商ID
operator: '', // 操作人
publishClient: PublishClient.wx, // 发布端
sortId: 0, // 排序号
state: 1, // 状态 1已发布 0未发布
updateAt: '', // 更新时间
whetherClicked: false, // 是否点击false为否true为是
};
const useNotices = (): AppHomeNoticeAppVo => {
const [state, setState] = useState(initState);
const userinfo = useSelector(
(state: { userinfo: Customer }) => state.userinfo,
);
useEffect(() => {
fetchLastNotice({
customerId: userinfo.customerId,
publishClient: PublishClient.wx,
})
.then(res => {
console.log(res);
setState(res.data);
})
.catch(err => {
console.log(err);
});
}, []);
return state;
};
export default useNotices;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment