Commit cdecb310 by 姜雷

合并冲突

parents 0e620b4f 408bd7d1
......@@ -20,21 +20,21 @@
"author": "",
"license": "MIT",
"dependencies": {
"@tarojs/async-await": "1.3.4",
"@tarojs/components": "1.3.4",
"@tarojs/redux": "1.3.4",
"@tarojs/redux-h5": "1.3.4",
"@tarojs/router": "1.3.4",
"@tarojs/taro": "1.3.4",
"@tarojs/taro-alipay": "1.3.4",
"@tarojs/taro-h5": "1.3.4",
"@tarojs/taro-swan": "1.3.4",
"@tarojs/taro-tt": "1.3.4",
"@tarojs/taro-weapp": "1.3.4",
"@tarojs/async-await": "1.3.14",
"@tarojs/components": "1.3.14",
"@tarojs/redux": "1.3.14",
"@tarojs/redux-h5": "1.3.14",
"@tarojs/router": "1.3.14",
"@tarojs/taro": "1.3.14",
"@tarojs/taro-alipay": "1.3.14",
"@tarojs/taro-h5": "1.3.14",
"@tarojs/taro-swan": "1.3.14",
"@tarojs/taro-tt": "1.3.14",
"@tarojs/taro-weapp": "1.3.14",
"crypto-js": "^3.1.9-1",
"jsbarcode": "^3.11.0",
"nerv-devtools": "^1.4.3",
"nervjs": "^1.4.3",
"nerv-devtools": "^1.4.4",
"nervjs": "^1.4.4",
"npm": "^6.8.0",
"redux": "^4.0.0",
"redux-logger": "^3.0.6",
......@@ -42,11 +42,11 @@
"wxbarcode": "^1.0.2"
},
"devDependencies": {
"@tarojs/plugin-babel": "1.3.4",
"@tarojs/plugin-csso": "1.3.4",
"@tarojs/plugin-sass": "1.3.4",
"@tarojs/plugin-uglifyjs": "1.3.4",
"@tarojs/webpack-runner": "1.3.4",
"@tarojs/plugin-babel": "1.3.14",
"@tarojs/plugin-csso": "1.3.14",
"@tarojs/plugin-sass": "1.3.14",
"@tarojs/plugin-uglifyjs": "1.3.14",
"@tarojs/webpack-runner": "1.3.14",
"@types/react": "^16.4.8",
"@types/webpack-env": "^1.13.6",
"babel-eslint": "^8.2.3",
......@@ -57,10 +57,10 @@
"babel-preset-env": "^1.6.1",
"cross-env": "^5.2.0",
"eslint": "^4.19.1",
"eslint-config-taro": "1.3.4",
"eslint-config-taro": "1.3.14",
"eslint-plugin-import": "^2.12.0",
"eslint-plugin-react": "^7.8.2",
"eslint-plugin-taro": "1.3.4",
"eslint-plugin-taro": "1.3.14",
"eslint-plugin-typescript": "^0.12.0",
"typescript": "^3.0.1"
}
......
import { customerFetch, ResponseDataEntity } from '.';
type FetchFeedbackListParams = {
pageNum: number;
customerId: number;
pageSize: number;
lastId?: number;
};
type CustomerFeedbackDetailVo = {
feedbackId: number;
replayAt: string;
replayContent: string;
};
export type FeedbackItem = {
content: string;
createDate: string;
id: number;
replayList: CustomerFeedbackDetailVo[];
};
export const fetchFeedbackList = (
params: FetchFeedbackListParams,
): Promise<ResponseDataEntity<FeedbackItem[]>> =>
customerFetch({
url: '/dcxy/customerFeedback/customerFeedback',
data: params,
});
type AddFeedbackParams = {
content: string;
customerId: number; // 会员id
deviceInfo?: string;
state?: number;
};
export const addFeedback = (params: AddFeedbackParams) =>
customerFetch({
url: '/dcxy/customerFeedback/customerFeedback',
method: 'POST',
data: params,
});
import { ResponseDataEntity, smaproFetch } from './index';
import { ResponseDataEntity, smaproFetch, appHomeFetch } from './index';
export enum ServiceTypeParams {
wechatPublicV = 1,
......@@ -22,3 +22,48 @@ export const fetchAreaService = (
smaproFetch({
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';
import {
BASE_SERVER_URL,
CUSTOMER_SERVER_URL,
SCHOOL_MAIN_URL,
LogoutCode,
SuccessCode,
OLD_BASE_SERVER_URL,
SHOWER_APP_URL,
SMPRO_URL,
GX_URL,
APP_HOME_URL,
} from '../constants/index';
export type ResponseDataEntity<T> = {
......@@ -62,7 +62,7 @@ const createFetch = (basePath: string) => {
export const baseFetch = createFetch(BASE_SERVER_URL);
export const oldBaseFetch = createFetch(OLD_BASE_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 smaproFetch = createFetch(SMPRO_URL);
export const gxFetch = createFetch(GX_URL);
......
.Message {
display: flex;
margin: 10px 32px;
&.user {
justify-content: flex-end;
.Message-Content {
background-color: #8c95fa;
border-radius: 20px 0 20px 20px;
color: #fff;
}
.Message-Content-time {
text-align: right;
}
}
&.replay {
.Message-Content {
background-color: #f7f7f7;
border-radius: 0 20px 20px 20px;
color: #333;
}
}
.Message-UserHeader {
width: 80px;
height: 80px;
.Message-UserHeader-img {
width: 100%;
height: 100%;
}
}
.Message-Content {
box-sizing: border-box;
width: 486px;
margin: 40px 20px 0;
padding: 20px;
font-size: 28px;
.Message-Content-time {
margin-top: 12px;
font-size: 24px;
}
}
}
import { View, Image } from '@tarojs/components';
import BoyIcon from '../../images/home/bg_touxiang_boy@2x.png';
import GirlIcon from '../../images/home/bg_touxiang_girl@2x.png';
import ReplayIcon from '../../images/home/ic_fankui_kefu@2x.png';
import './Message.scss';
import { CustomerSex } from '@/types/Customer/Customer';
export enum MessageType {
user = 'user',
replay = 'replay',
}
const Message = ({
type,
content,
time,
userData,
}: {
type: MessageType;
content: string;
time: string;
userData: {
customerHead: null | string;
customerSex: string;
};
}) => {
return (
<View
className={`Message ${type === MessageType.user ? 'user' : 'replay'}`}>
{type === MessageType.replay && (
<View className='Message-UserHeader'>
<Image className='Message-UserHeader-img' src={ReplayIcon} />
</View>
)}
<View className='Message-Content'>
<View className='Message-Content-msg'>{content}</View>
<View className='Message-Content-time'>{time}</View>
</View>
{type === MessageType.user && (
<View className='Message-UserHeader'>
{userData.customerHead ? (
<Image
className='Message-UserHeader-img'
src={userData.customerHead}
/>
) : userData.customerSex === CustomerSex.boy ? (
<Image className='Message-UserHeader-img' src={BoyIcon} />
) : (
<Image className='Message-UserHeader-img' src={GirlIcon} />
)}
</View>
)}
</View>
);
};
export default Message;
......@@ -7,7 +7,7 @@ export const ResendTime = 10;
export const BASE_SERVER_URL = 'https://dcxy-base-app.dcrym.com';
export const OLD_BASE_SERVER_URL = 'https://api-selfbase.dcrym.com';
export const CUSTOMER_SERVER_URL = 'https://dcxy-customer-app.dcrym.com';
export const SCHOOL_MAIN_URL = 'https://api-schoolhome.dcrym.com';
export const APP_HOME_URL = 'https://dcxy-home-app.dcrym.com';
export const ANN_LINK_URL = 'https://wx.dcrym.com/announcement/';
export const SHOWER_APP_URL = 'https://shower-app-server.dcrym.com';
export const SOCKET_URL = 'wss://shower-wss1.dcrym.com:9443/ws';
......
import Taro, { useEffect, useState } from '@tarojs/taro';
const useButtonPadding = () => {
const [state, setState] = useState(0);
useEffect(() => {
const res = Taro.getSystemInfoSync();
if (/iPhone X(\w)?/.test(res.model)) {
console.log('is iphone X');
setState(34);
}
}, []);
return state;
};
export default useButtonPadding;
import { useReducer } from '@tarojs/taro';
import Actions from '@/types/Store/Actions';
type Pagination = {
pageNum: number;
pageSize: number;
total: number;
};
const initState: Pagination = {
pageNum: 1,
pageSize: 10,
total: 0,
};
const reducer = (state: Pagination, action: Actions): Pagination => {
switch (action.type) {
case 'updatePagination':
return { ...state, ...action.payload };
default:
return state;
}
};
const usePagination = (
initData?: Pagination,
): [Pagination, (e: Pagination) => void] => {
const [state, dispatch] = useReducer(reducer, { ...initState, ...initData });
const updatePagination = (e: Pagination) => {
dispatch({ type: 'updatePagination', payload: e });
};
return [state, updatePagination];
};
export default usePagination;
import { useSelector, useDispatch } from '@tarojs/redux';
import Taro, { useEffect } from '@tarojs/taro';
import { updateSystemInfo } from '@/store/rootReducers/systemInfo';
const useSystemInfo = () => {
const systemInfo = useSelector(
(state: { systemInfo: Taro.getSystemInfo.Promised }) => state.systemInfo,
);
const dispatch = useDispatch();
useEffect(() => {
if (!systemInfo.SDKVersion) {
Taro.getSystemInfo().then(res => {
dispatch(updateSystemInfo(res));
});
}
}, []);
return systemInfo;
};
export default useSystemInfo;
......@@ -3,12 +3,16 @@ import { ComponentClass } from 'react';
import { View, ScrollView, Image, Text, WebView } from '@tarojs/components';
import AnnIcon from '../../images/icon/ann_tongzhi_icon@2x.png';
import { fetchAllAnn, AnnItem } from '../../api/announcement';
import { connect } from '@tarojs/redux';
import './Announcement.scss';
import { Customer } from '@/types/Customer/Customer';
import { shareHandle } from '@/common/shareMethod';
import {
fetchNoticesData,
PublishClient,
AppHomeNoticeAppVo,
} from '@/api/home';
type PageStateProps = {
userinfo: Customer;
......@@ -17,7 +21,7 @@ type PageOwnProps = {};
type PageState = {
pageNum: number;
pageSize: number;
list: AnnItem[];
list: AppHomeNoticeAppVo[];
linkUrl: string;
};
......@@ -43,24 +47,25 @@ class Announcement extends Component {
componentWillMount() {
const { userinfo } = this.props;
const { sectionId } = this.$router.params;
fetchAllAnn({
campusId: userinfo.areaId,
sectionId: sectionId,
fetchNoticesData({
customerId: userinfo.customerId,
publishClient: PublishClient.wx,
})
.then(res => {
const data = res.data;
this.setState({
...data,
list: data,
});
})
.catch(err => {
console.log(err);
});
}
geAnnDetail(id: number) {
geAnnDetail(id: string) {
const { userinfo } = this.props;
Taro.navigateTo({
url: `/pages/Content/Content?id=${id}`,
url: `/pages/Content/Content?id=${id}&customerId=${userinfo.customerId}`,
});
}
render() {
......@@ -70,19 +75,16 @@ class Announcement extends Component {
{linkUrl && <WebView src={linkUrl} />}
{list.map(annItem => (
<View
key={annItem.id}
key={annItem.noticeCode}
className='Announcement-item'
onClick={() => this.geAnnDetail(annItem.id)}>
<Image
className='Announcement-item-img'
src={annItem.linkUrls[0]}
/>
onClick={() => this.geAnnDetail(annItem.noticeCode)}>
<Image className='Announcement-item-img' src={annItem.noticeImgs} />
<View className='Announcement-item-Content'>
<Image className='Announcement-item-icon' src={AnnIcon} />
<Text className='Announcement-item-title'>{annItem.title}</Text>
<Text className='Announcement-item-date'>
{annItem.updateTime}
<Text className='Announcement-item-title'>
{annItem.noticeTitle}
</Text>
<Text className='Announcement-item-date'>{annItem.updateAt}</Text>
</View>
</View>
))}
......
......@@ -4,6 +4,7 @@ import { WebView } from '@tarojs/components';
import { connect } from '@tarojs/redux';
import { ANN_LINK_URL } from '../../constants';
import { shareHandle } from '@/common/shareMethod';
import useNotices from '../Home/hooks/useNotices';
type PageOwnProps = {
token: string;
......@@ -32,14 +33,18 @@ class Content extends Component {
getLinkUrl() {
const { token } = this.props;
const { id } = this.$router.params;
const { id, customerId } = this.$router.params;
console.log(id);
this.setState({
linkUrl: `${ANN_LINK_URL}?id=${id}&token=${token}`,
linkUrl: `${ANN_LINK_URL}?id=${id}&token=${token}&customerId=${customerId}`,
});
}
render() {
const { linkUrl } = this.state;
console.log(linkUrl);
return linkUrl && <WebView src={linkUrl} />;
}
}
......
.Feedback {
box-sizing: border-box;
position: relative;
flex-direction: column;
height: 100%;
background-color: #eee;
.Feedback-input {
border-top: 1px solid #eee;
background-color: #fff;
background-color: #fff;
padding-bottom: 112px;
.Feedback-Content-wrap {
// box-sizing: border-box;
height: 100%;
overflow-y: auto;
.Feedback-Content {
// height: 100%;
}
}
.Feedback-Footer {
position: fixed;
bottom: 0;
box-sizing: border-box;
padding: 20px;
display: flex;
width: 100%;
height: 468px;
line-height: 50px;
font-size: 28px;
}
.Feedback-btn {
margin: 40px 32px 0;
padding: 0 32px;
height: 112px;
align-items: center;
.input-placeholder {
font-size: 28px;
color: #d4d7fd;
}
.Feedback-Footer-Input {
background-color: #8c95fa;
border-radius: 16px;
flex: 1;
height: 92px;
line-height: 92px;
color: #fff;
padding-left: 40px;
}
.Feedback-Footer-Btn {
width: 128px;
margin-left: 20px;
background-color: #ffab3e;
border-radius: 16px;
font-size: 28px;
height: 92px;
line-height: 92px;
}
}
}
import { ComponentClass } from 'react';
import Taro, { Component, Config } from '@tarojs/taro';
import { View, Textarea, Button } from '@tarojs/components';
import { fetchFeedback } from '../../api/customer';
import { connect } from '@tarojs/redux';
import Taro, {
useState,
useEffect,
useShareAppMessage,
clientRectElement,
} from '@tarojs/taro';
import { View, Button, Input, ScrollView } from '@tarojs/components';
import { useSelector } from '@tarojs/redux';
import './Feedback.scss';
import { shareHandle } from '@/common/shareMethod';
import useInputValue from '@/hooks/useInputValue';
import { Customer } from '@/types/Customer/Customer';
import useFeedbackList from './useFeedbackList';
import { addFeedback } from '@/api/feedback';
import useButtonPadding from '@/hooks/useButtonPadding';
import FeedbackItem from './components/FeedbackItem/FeedbackItem';
import { formatDate } from '@/utils/time';
import useSystemInfo from '@/hooks/useSystemInfo';
import { compareVersion } from '@/utils/version';
type PageProps = {
areaId: number;
areaName: string;
customerId: number;
customerName: string;
customerPhone: string;
};
type PageState = {
feedbackContent: string;
};
interface Feedback {
props: PageProps;
state: PageState;
}
@connect(({ userinfo }) => ({
areaId: userinfo.areaId,
areaName: userinfo.areaName,
customerId: userinfo.customerId,
customerName: userinfo.customerName,
customerPhone: userinfo.customerPhone,
}))
class Feedback extends Component<PageProps, PageState> {
config: Config = {
navigationBarTitleText: '意见反馈',
};
constructor(props) {
super(props);
this.state = {
feedbackContent: '',
};
}
onShareAppMessage = shareHandle;
feedbackHandle() {
function Feedback() {
useShareAppMessage(shareHandle);
const { value, onChange } = useInputValue('');
const userInfo = useSelector((state: any): Customer => state.userinfo);
const { list, fetchListHandle, pushNewMsg } = useFeedbackList(
userInfo.customerId,
);
const bottomHeight = useButtonPadding();
const [showKeyboard, setShowKeyboard] = useState(false);
const addFeedbackHandle = () => {
Taro.showLoading();
const { feedbackContent } = this.state;
if (feedbackContent && feedbackContent.length >= 5) {
const {
areaId,
areaName,
customerId,
customerName,
customerPhone,
} = this.props;
fetchFeedback({
areaId,
areaName,
customerId,
customerName,
customerPhone,
feedbackContent,
if (value) {
addFeedback({
content: value,
customerId: userInfo.customerId,
})
.then(res => {
Taro.hideLoading();
console.log(res);
Taro.showToast({
title: '反馈成功',
icon: 'success',
onChange({
type: '',
detail: { value: '', cursor: 0, keyCode: 0 },
timeStamp: 0,
target: this,
currentTarget: this,
preventDefault: () => {},
stopPropagation: () => {},
});
pushNewMsg({
id: 0,
content: value,
createDate: formatDate(new Date()),
replayList: [],
});
setTimeout(() => {
Taro.navigateBack();
}, 2000);
})
.catch(err => {
Taro.hideLoading();
......@@ -85,29 +68,86 @@ class Feedback extends Component<PageProps, PageState> {
icon: 'none',
});
}
}
};
const [scrollTop, setScrollTop] = useState(0);
const systemInfo = useSystemInfo();
render() {
return (
<View className='Feedback'>
<Textarea
className='Feedback-input'
value={this.state.feedbackContent}
useEffect(() => {
if (compareVersion(systemInfo.SDKVersion, '2.7.0')) {
wx.onKeyboardHeightChange(res => {
console.log(res.height);
if (res.height) {
setShowKeyboard(true);
} else {
setShowKeyboard(false);
}
});
} else {
console.log('in focus');
}
}, []);
useEffect(() => {
Taro.createSelectorQuery()
.select('.Feedback-Content')
.boundingClientRect((rect: clientRectElement) => {
console.log(rect);
if (rect) setScrollTop(rect.height);
})
.exec();
}, [list.length]);
const scrollToUpperHandle = () => {
if (list.length) {
fetchListHandle(list[0].id);
}
};
return (
<View
className='Feedback'
style={`padding-bottom: ${Taro.pxTransform(112 + bottomHeight)}`}>
<ScrollView
className='Feedback-Content-wrap'
scrollY
scrollWithAnimation
upperThreshold={-40}
onScrollToUpper={scrollToUpperHandle}
scrollTop={scrollTop}>
<View className='Feedback-Content'>
{list.map(item => (
<FeedbackItem
key={item.id}
msgData={item}
userData={{
customerHead: userInfo.customerHead,
customerSex: userInfo.customerSex,
}}
/>
))}
</View>
</ScrollView>
<View
className='Feedback-Footer'
style={`bottom: ${Taro.pxTransform(bottomHeight)}`}>
<Input
className='Feedback-Footer-Input'
value={value}
onInput={onChange}
placeholder='反馈问题不超过50字'
maxlength={50}
onInput={({ detail: { value } }) => {
this.setState({
feedbackContent: value.trim(),
});
return value.trim();
}}
maxLength={50}
confirmType='send'
onConfirm={addFeedbackHandle}
/>
<Button className='Feedback-btn' onClick={this.feedbackHandle}>
提交
</Button>
{!showKeyboard && (
<Button className='Feedback-Footer-Btn' onClick={addFeedbackHandle}>
发送
</Button>
)}
</View>
);
}
</View>
);
}
export default Feedback as ComponentClass<PageProps, PageState>;
Feedback.config = {
navigationBarTitleText: '意见反馈',
};
export default Feedback;
import { View } from '@tarojs/components';
import Message, { MessageType } from '../../../../components/Message/Message';
import { FeedbackItem } from '@/api/feedback';
const FeedbackItem = ({
msgData,
userData,
}: {
msgData: FeedbackItem;
userData: {
customerHead: null | string;
customerSex: string;
};
}) => {
return (
<View className='FeedbackItem'>
{msgData && (
<Message
type={MessageType.user}
content={msgData.content}
time={msgData.createDate}
userData={userData}
/>
)}
{msgData &&
msgData.replayList.map(replay => (
<Message
key={replay.feedbackId}
type={MessageType.replay}
content={replay.replayContent}
time={replay.replayAt}
userData={userData}
/>
))}
</View>
);
};
export default FeedbackItem;
import Taro, { useEffect, useState, useReducer } from '@tarojs/taro';
import { fetchFeedbackList, FeedbackItem } from '@/api/feedback';
import usePagination from '@/hooks/usePagination';
import Actions from '@/types/Store/Actions';
const reducer = (state: FeedbackItem[], action: Actions): FeedbackItem[] => {
switch (action.type) {
case 'getMoreList':
return [...action.payload, ...state];
case 'refreshList':
return action.payload;
case 'addNewMessage':
return [...state, action.payload];
default:
return state;
}
};
const initState: FeedbackItem[] = [];
const useFeedbackList = (customerId: number) => {
const [lastId, setLastId] = useState(0);
const [pagination, setPaination] = usePagination();
const fetchListHandle = (lastId: number) => setLastId(lastId);
const [feedbackList, dispatch] = useReducer(reducer, initState);
useEffect(() => {
Taro.showLoading();
fetchFeedbackList(
lastId
? {
pageNum: pagination.pageNum + 1,
pageSize: pagination.pageSize,
customerId,
lastId,
}
: {
pageNum: 1,
pageSize: pagination.pageSize,
customerId,
},
)
.then(res => {
console.log(res);
if (res.data.length) {
let list = res.data.map(item => ({
...item,
replayList: item.replayList.reverse(),
}));
if (lastId) {
dispatch({
type: 'getMoreList',
payload: list,
});
setPaination({ ...pagination, pageNum: pagination.pageNum + 1 });
} else {
dispatch({
type: 'refreshList',
payload: list,
});
}
}
Taro.hideLoading();
})
.catch(err => {
Taro.hideLoading();
Taro.showToast({
title: err.msg || '请求失败',
icon: 'none',
});
});
}, [lastId]);
const pushNewMsg = (msgData: FeedbackItem) =>
dispatch({
type: 'addNewMessage',
payload: msgData,
});
return { list: feedbackList, fetchListHandle, pushNewMsg };
};
export default useFeedbackList;
......@@ -29,9 +29,8 @@ import {
updateUserInfo,
INITIAL_STATE as userINitState,
} from '../../store/rootReducers/userinfo';
import { fetchAnn, SectionItem } from '../../api/announcement';
import { appLogout } from '../../api/customer';
import { Customer } from '@/types/Customer/Customer';
import { Customer, CustomerSex } from '@/types/Customer/Customer';
import { shareHandle } from '@/common/shareMethod';
import { fetchAreaService, ServiceTypeParams, Service } from '@/api/home';
import MenuIconNormal from '@/components/MenuIcon/normal/MenuIconNormal';
......@@ -44,6 +43,7 @@ import {
ControllerResponse,
} from '@/api/shower';
import { updateShowerControlConfig } from '@/store/rootReducers/shower';
import useNotices from './hooks/useNotices';
type PageStateProps = {
userinfo: Customer;
......@@ -63,7 +63,6 @@ type BeanAccount = {
type PageState = {
barMenuVisiable: boolean;
beanAccount: BeanAccount[];
annItem: SectionItem;
filterBeanList: BeanAccount[];
};
type IProps = PageStateProps & PageDispatchProps;
......@@ -100,18 +99,6 @@ class Home extends Component {
barMenuVisiable: false,
beanAccount: [],
filterBeanList: [],
annItem: {
id: 0,
styleType: '',
name: '',
titleTypeRemark: '',
titleType: '',
titleContent: '',
sort: 0,
updateTime: 0,
itemsCount: 0,
items: [],
},
};
}
......@@ -127,7 +114,6 @@ class Home extends Component {
getInitData() {
this.getServiceList();
this.getAnn();
}
getServiceList() {
......@@ -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() {
Taro.navigateTo({
url: '/pages/UserSetting/UserSetting',
......@@ -171,9 +139,9 @@ class Home extends Component {
url: '/pages/Feedback/Feedback',
});
}
goAnn(id: number) {
goAnn(code: string) {
Taro.navigateTo({
url: '/pages/Announcement/Announcement?sectionId=' + id,
url: '/pages/Announcement/Announcement?sectionId=' + code,
});
}
......@@ -249,10 +217,10 @@ class Home extends Component {
let newPhone = phone.replace(/([0-9]{3})([0-9]{4})([0-9]{4})/, '$1****$3');
return newPhone;
};
geAnnDetail(id: number) {
console.log(id);
geAnnDetail(code: string) {
const { userinfo } = this.props;
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 {
render() {
const { userinfo, serviceList } = this.props;
const { annItem, barMenuVisiable } = this.state;
const { barMenuVisiable } = this.state;
const noticeData = useNotices();
return (
<View className='Home'>
{barMenuVisiable ? (
......@@ -300,7 +269,7 @@ class Home extends Component {
</View>
<View className='Home-UserBox-addr'>{userinfo.areaName}</View>
</View>
{userinfo.customerSex === '2' ? (
{userinfo.customerSex === CustomerSex.girl ? (
<Image
className='Home-UserBox-headimg'
src={UserHeaderF}
......@@ -436,30 +405,26 @@ class Home extends Component {
) : null}
</View>
{annItem.id ? (
{noticeData.noticeCode ? (
<View className='Home-Announcement'>
<Image className='bg' src={AnnouncementBg} />
<View className='Home-Announcement-title'>
<Text>最新公告</Text>
<View
className='Home-Announcement-more'
onClick={() => this.goAnn(annItem.id)}>
onClick={() => this.goAnn(noticeData.noticeCode)}>
更多
<Image className='more-icon' src={MoreIcon} />
</View>
</View>
{annItem.items.length && (
<View
className='Home-Announcement-Content'
onClick={() => this.geAnnDetail(annItem.items[0].id)}>
<Text className='Home-Announcement-Content-title'>
{annItem.items[0].title}
</Text>
<Text className='ContentDate'>
{annItem.items[0].updateTime}
</Text>
</View>
)}
<View
className='Home-Announcement-Content'
onClick={() => this.geAnnDetail(noticeData.noticeCode)}>
<Text className='Home-Announcement-Content-title'>
{noticeData.noticeTitle}
</Text>
<Text className='ContentDate'>{noticeData.updateAt}</Text>
</View>
</View>
) : null}
</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;
......@@ -64,6 +64,8 @@ class OrderItem extends Component {
const {
data: { orderState, createAt, serviceName, payableMoney },
} = this.props;
let moneyStr = payableMoney.toFixed(2);
return (
<View className='OrderItem' onClick={this.detailHandle}>
<View className='OrderItem-text'>
......@@ -83,7 +85,7 @@ class OrderItem extends Component {
</View>
<View
className={`OrderItem-price ${orderState === '1' ? 'topay' : ''}`}>
{payableMoney.toFixed(2)}
{moneyStr}
</View>
</View>
);
......
......@@ -8,6 +8,7 @@ const RechargeItem = (props: { data: RechargeOrder }) => {
const {
data: { createAt, rechargeRemark, actualAmount, orderNum },
} = props;
let moneyStr = actualAmount.toFixed(2);
return (
<View className='RechargeItem'>
......@@ -26,7 +27,7 @@ const RechargeItem = (props: { data: RechargeOrder }) => {
</View>
<View
className={`RechargeItem-price ${actualAmount >= 0 ? 'topay' : ''}`}>
{actualAmount.toFixed(2)}
{moneyStr}
</View>
</View>
);
......
......@@ -8,6 +8,7 @@ import { connect } from '@tarojs/redux';
import { updateUserInfo, UserState } from '../../store/rootReducers/userinfo';
import { appLogin } from '../../api/customer';
import { shareHandle } from '@/common/shareMethod';
import useSystemInfo from '@/hooks/useSystemInfo';
type PageDispatchProps = {
updateUserInfo: (e: UserState | { token: string }) => void;
......@@ -97,6 +98,7 @@ class Index extends Component {
render() {
const { errorText } = this.state;
useSystemInfo();
return <View className='Index'>{errorText}</View>;
}
}
......
......@@ -5,6 +5,7 @@ import ShowerReducer from '@/pages/Shower/store';
import serviceList from './rootReducers/service';
import orderState from './rootReducers/orderState';
import showerState from './rootReducers/shower';
import systemInfo from './rootReducers/systemInfo';
export default combineReducers({
userinfo,
......@@ -13,4 +14,5 @@ export default combineReducers({
serviceList,
orderState,
showerState,
systemInfo,
});
import Actions from '@/types/Store/Actions';
const INITIAL_STATE = {
brand: '',
model: '',
pixelRatio: '',
screenWidth: 0,
screenHeight: 0,
windowWidth: 0,
windowHeight: 0,
statusBarHeight: 0,
language: '',
version: '',
system: '',
platform: '',
fontSizeSetting: 0,
SDKVersion: '',
};
export const updateSystemInfo = (
entity: Taro.getSystemInfo.Promised,
): Actions => ({
type: 'UPDATE_SYSTEMINFO',
payload: entity,
});
export default function systemInfo(
state: Taro.getSystemInfo.Promised = INITIAL_STATE,
actions: Actions,
): Taro.getSystemInfo.Promised {
switch (actions.type) {
case 'UPDATE_SYSTEMINFO':
return {
...state,
...actions.payload,
};
default:
return state;
}
}
import Action from '../../types/Store/Actions';
import { Customer } from '../../types/Customer/Customer';
import { Customer, CustomerSex } from '../../types/Customer/Customer';
export type UserState = StoreState<Customer & { code: string }>;
......@@ -14,7 +14,7 @@ export const INITIAL_STATE = {
customerId: 0,
customerName: '',
customerPhone: '',
customerSex: '',
customerSex: CustomerSex.boy,
customerType: '',
email: '',
entranceDate: '',
......
export enum CustomerSex {
boy = '1',
girl = '0',
}
export type Customer = {
areaId: number;
areaName: string;
......@@ -8,7 +12,7 @@ export type Customer = {
customerId: number;
customerName: string;
customerPhone: string;
customerSex: string;
customerSex: CustomerSex;
customerType: string;
email: string;
entranceDate: string;
......
export const formatDate = (date: Date, fmt = 'yyyy-MM-dd hh:mm:ss'): string => {
if (!date) {
return '无';
}
if (typeof date === 'string') {
date = new Date(date);
// date = new Date(date.replace('-', '/'));
}
if (/(y+)/.test(fmt)) {
fmt = fmt.replace(
RegExp.$1,
(date.getFullYear() + '').substr(4 - RegExp.$1.length),
);
}
let o = {
'M+': date.getMonth() + 1,
'd+': date.getDate(),
'h+': date.getHours(),
'm+': date.getMinutes(),
's+': date.getSeconds(),
};
for (let k in o) {
if (new RegExp(`(${k})`).test(fmt)) {
let str = o[k] + '';
fmt = fmt.replace(
RegExp.$1,
RegExp.$1.length === 1 ? str : ('00' + str).substr(str.length),
);
}
}
return fmt;
};
export function compareVersion(v1: string, v2: string): boolean {
let v1Arr = v1.split('.');
let v2Arr = v2.split('.');
const len = Math.max(v1.length, v2.length);
while (v1.length < len) {
v1Arr.push('0');
}
while (v2.length < len) {
v2Arr.push('0');
}
for (let i = 0; i < len; i++) {
const num1 = parseInt(v1[i]);
const num2 = parseInt(v2[i]);
if (num1 > num2) {
return true;
} else if (num1 < num2) {
return false;
}
}
return true;
}
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