Commit cdecb310 by 姜雷

合并冲突

parents 0e620b4f 408bd7d1
...@@ -20,21 +20,21 @@ ...@@ -20,21 +20,21 @@
"author": "", "author": "",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@tarojs/async-await": "1.3.4", "@tarojs/async-await": "1.3.14",
"@tarojs/components": "1.3.4", "@tarojs/components": "1.3.14",
"@tarojs/redux": "1.3.4", "@tarojs/redux": "1.3.14",
"@tarojs/redux-h5": "1.3.4", "@tarojs/redux-h5": "1.3.14",
"@tarojs/router": "1.3.4", "@tarojs/router": "1.3.14",
"@tarojs/taro": "1.3.4", "@tarojs/taro": "1.3.14",
"@tarojs/taro-alipay": "1.3.4", "@tarojs/taro-alipay": "1.3.14",
"@tarojs/taro-h5": "1.3.4", "@tarojs/taro-h5": "1.3.14",
"@tarojs/taro-swan": "1.3.4", "@tarojs/taro-swan": "1.3.14",
"@tarojs/taro-tt": "1.3.4", "@tarojs/taro-tt": "1.3.14",
"@tarojs/taro-weapp": "1.3.4", "@tarojs/taro-weapp": "1.3.14",
"crypto-js": "^3.1.9-1", "crypto-js": "^3.1.9-1",
"jsbarcode": "^3.11.0", "jsbarcode": "^3.11.0",
"nerv-devtools": "^1.4.3", "nerv-devtools": "^1.4.4",
"nervjs": "^1.4.3", "nervjs": "^1.4.4",
"npm": "^6.8.0", "npm": "^6.8.0",
"redux": "^4.0.0", "redux": "^4.0.0",
"redux-logger": "^3.0.6", "redux-logger": "^3.0.6",
...@@ -42,11 +42,11 @@ ...@@ -42,11 +42,11 @@
"wxbarcode": "^1.0.2" "wxbarcode": "^1.0.2"
}, },
"devDependencies": { "devDependencies": {
"@tarojs/plugin-babel": "1.3.4", "@tarojs/plugin-babel": "1.3.14",
"@tarojs/plugin-csso": "1.3.4", "@tarojs/plugin-csso": "1.3.14",
"@tarojs/plugin-sass": "1.3.4", "@tarojs/plugin-sass": "1.3.14",
"@tarojs/plugin-uglifyjs": "1.3.4", "@tarojs/plugin-uglifyjs": "1.3.14",
"@tarojs/webpack-runner": "1.3.4", "@tarojs/webpack-runner": "1.3.14",
"@types/react": "^16.4.8", "@types/react": "^16.4.8",
"@types/webpack-env": "^1.13.6", "@types/webpack-env": "^1.13.6",
"babel-eslint": "^8.2.3", "babel-eslint": "^8.2.3",
...@@ -57,10 +57,10 @@ ...@@ -57,10 +57,10 @@
"babel-preset-env": "^1.6.1", "babel-preset-env": "^1.6.1",
"cross-env": "^5.2.0", "cross-env": "^5.2.0",
"eslint": "^4.19.1", "eslint": "^4.19.1",
"eslint-config-taro": "1.3.4", "eslint-config-taro": "1.3.14",
"eslint-plugin-import": "^2.12.0", "eslint-plugin-import": "^2.12.0",
"eslint-plugin-react": "^7.8.2", "eslint-plugin-react": "^7.8.2",
"eslint-plugin-taro": "1.3.4", "eslint-plugin-taro": "1.3.14",
"eslint-plugin-typescript": "^0.12.0", "eslint-plugin-typescript": "^0.12.0",
"typescript": "^3.0.1" "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 { 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);
......
.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; ...@@ -7,7 +7,7 @@ export const ResendTime = 10;
export const BASE_SERVER_URL = 'https://dcxy-base-app.dcrym.com'; export const BASE_SERVER_URL = 'https://dcxy-base-app.dcrym.com';
export const OLD_BASE_SERVER_URL = 'https://api-selfbase.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 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 ANN_LINK_URL = 'https://wx.dcrym.com/announcement/';
export const SHOWER_APP_URL = 'https://shower-app-server.dcrym.com'; export const SHOWER_APP_URL = 'https://shower-app-server.dcrym.com';
export const SOCKET_URL = 'wss://shower-wss1.dcrym.com:9443/ws'; 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'; ...@@ -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} />;
} }
} }
......
.Feedback { .Feedback {
box-sizing: border-box;
position: relative;
flex-direction: column;
height: 100%; height: 100%;
background-color: #eee; background-color: #fff;
.Feedback-input { padding-bottom: 112px;
border-top: 1px solid #eee; .Feedback-Content-wrap {
background-color: #fff; // box-sizing: border-box;
height: 100%;
overflow-y: auto;
.Feedback-Content {
// height: 100%;
}
}
.Feedback-Footer {
position: fixed;
bottom: 0;
box-sizing: border-box; box-sizing: border-box;
padding: 20px; display: flex;
width: 100%; width: 100%;
height: 468px; padding: 0 32px;
line-height: 50px; height: 112px;
font-size: 28px; align-items: center;
} .input-placeholder {
.Feedback-btn { font-size: 28px;
margin: 40px 32px 0; 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, {
import Taro, { Component, Config } from '@tarojs/taro'; useState,
import { View, Textarea, Button } from '@tarojs/components'; useEffect,
import { fetchFeedback } from '../../api/customer'; useShareAppMessage,
import { connect } from '@tarojs/redux'; clientRectElement,
} from '@tarojs/taro';
import { View, Button, Input, ScrollView } from '@tarojs/components';
import { useSelector } from '@tarojs/redux';
import './Feedback.scss'; import './Feedback.scss';
import { shareHandle } from '@/common/shareMethod'; 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 = { function Feedback() {
areaId: number; useShareAppMessage(shareHandle);
areaName: string; const { value, onChange } = useInputValue('');
customerId: number; const userInfo = useSelector((state: any): Customer => state.userinfo);
customerName: string; const { list, fetchListHandle, pushNewMsg } = useFeedbackList(
customerPhone: string; userInfo.customerId,
}; );
type PageState = { const bottomHeight = useButtonPadding();
feedbackContent: string; const [showKeyboard, setShowKeyboard] = useState(false);
}; const addFeedbackHandle = () => {
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() {
Taro.showLoading(); Taro.showLoading();
const { feedbackContent } = this.state; if (value) {
if (feedbackContent && feedbackContent.length >= 5) { addFeedback({
const { content: value,
areaId, customerId: userInfo.customerId,
areaName,
customerId,
customerName,
customerPhone,
} = this.props;
fetchFeedback({
areaId,
areaName,
customerId,
customerName,
customerPhone,
feedbackContent,
}) })
.then(res => { .then(res => {
Taro.hideLoading(); Taro.hideLoading();
console.log(res); console.log(res);
Taro.showToast({ onChange({
title: '反馈成功', type: '',
icon: 'success', 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 => { .catch(err => {
Taro.hideLoading(); Taro.hideLoading();
...@@ -85,29 +68,86 @@ class Feedback extends Component<PageProps, PageState> { ...@@ -85,29 +68,86 @@ class Feedback extends Component<PageProps, PageState> {
icon: 'none', icon: 'none',
}); });
} }
} };
const [scrollTop, setScrollTop] = useState(0);
const systemInfo = useSystemInfo();
render() { useEffect(() => {
return ( if (compareVersion(systemInfo.SDKVersion, '2.7.0')) {
<View className='Feedback'> wx.onKeyboardHeightChange(res => {
<Textarea console.log(res.height);
className='Feedback-input' if (res.height) {
value={this.state.feedbackContent} 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字' placeholder='反馈问题不超过50字'
maxlength={50} maxLength={50}
onInput={({ detail: { value } }) => { confirmType='send'
this.setState({ onConfirm={addFeedbackHandle}
feedbackContent: value.trim(),
});
return value.trim();
}}
/> />
<Button className='Feedback-btn' onClick={this.feedbackHandle}> {!showKeyboard && (
提交 <Button className='Feedback-Footer-Btn' onClick={addFeedbackHandle}>
</Button> 发送
</Button>
)}
</View> </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 { ...@@ -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(noticeData.noticeCode)}>
onClick={() => this.geAnnDetail(annItem.items[0].id)}> <Text className='Home-Announcement-Content-title'>
<Text className='Home-Announcement-Content-title'> {noticeData.noticeTitle}
{annItem.items[0].title} </Text>
</Text> <Text className='ContentDate'>{noticeData.updateAt}</Text>
<Text className='ContentDate'> </View>
{annItem.items[0].updateTime}
</Text>
</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;
...@@ -64,6 +64,8 @@ class OrderItem extends Component { ...@@ -64,6 +64,8 @@ class OrderItem extends Component {
const { const {
data: { orderState, createAt, serviceName, payableMoney }, data: { orderState, createAt, serviceName, payableMoney },
} = this.props; } = this.props;
let moneyStr = payableMoney.toFixed(2);
return ( return (
<View className='OrderItem' onClick={this.detailHandle}> <View className='OrderItem' onClick={this.detailHandle}>
<View className='OrderItem-text'> <View className='OrderItem-text'>
...@@ -83,7 +85,7 @@ class OrderItem extends Component { ...@@ -83,7 +85,7 @@ class OrderItem extends Component {
</View> </View>
<View <View
className={`OrderItem-price ${orderState === '1' ? 'topay' : ''}`}> className={`OrderItem-price ${orderState === '1' ? 'topay' : ''}`}>
{payableMoney.toFixed(2)} {moneyStr}
</View> </View>
</View> </View>
); );
......
...@@ -8,6 +8,7 @@ const RechargeItem = (props: { data: RechargeOrder }) => { ...@@ -8,6 +8,7 @@ const RechargeItem = (props: { data: RechargeOrder }) => {
const { const {
data: { createAt, rechargeRemark, actualAmount, orderNum }, data: { createAt, rechargeRemark, actualAmount, orderNum },
} = props; } = props;
let moneyStr = actualAmount.toFixed(2);
return ( return (
<View className='RechargeItem'> <View className='RechargeItem'>
...@@ -26,7 +27,7 @@ const RechargeItem = (props: { data: RechargeOrder }) => { ...@@ -26,7 +27,7 @@ const RechargeItem = (props: { data: RechargeOrder }) => {
</View> </View>
<View <View
className={`RechargeItem-price ${actualAmount >= 0 ? 'topay' : ''}`}> className={`RechargeItem-price ${actualAmount >= 0 ? 'topay' : ''}`}>
{actualAmount.toFixed(2)} {moneyStr}
</View> </View>
</View> </View>
); );
......
...@@ -8,6 +8,7 @@ import { connect } from '@tarojs/redux'; ...@@ -8,6 +8,7 @@ import { connect } from '@tarojs/redux';
import { updateUserInfo, UserState } from '../../store/rootReducers/userinfo'; import { updateUserInfo, UserState } from '../../store/rootReducers/userinfo';
import { appLogin } from '../../api/customer'; import { appLogin } from '../../api/customer';
import { shareHandle } from '@/common/shareMethod'; import { shareHandle } from '@/common/shareMethod';
import useSystemInfo from '@/hooks/useSystemInfo';
type PageDispatchProps = { type PageDispatchProps = {
updateUserInfo: (e: UserState | { token: string }) => void; updateUserInfo: (e: UserState | { token: string }) => void;
...@@ -97,6 +98,7 @@ class Index extends Component { ...@@ -97,6 +98,7 @@ class Index extends Component {
render() { render() {
const { errorText } = this.state; const { errorText } = this.state;
useSystemInfo();
return <View className='Index'>{errorText}</View>; return <View className='Index'>{errorText}</View>;
} }
} }
......
...@@ -5,6 +5,7 @@ import ShowerReducer from '@/pages/Shower/store'; ...@@ -5,6 +5,7 @@ import ShowerReducer from '@/pages/Shower/store';
import serviceList from './rootReducers/service'; import serviceList from './rootReducers/service';
import orderState from './rootReducers/orderState'; import orderState from './rootReducers/orderState';
import showerState from './rootReducers/shower'; import showerState from './rootReducers/shower';
import systemInfo from './rootReducers/systemInfo';
export default combineReducers({ export default combineReducers({
userinfo, userinfo,
...@@ -13,4 +14,5 @@ export default combineReducers({ ...@@ -13,4 +14,5 @@ export default combineReducers({
serviceList, serviceList,
orderState, orderState,
showerState, 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 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 }>; export type UserState = StoreState<Customer & { code: string }>;
...@@ -14,7 +14,7 @@ export const INITIAL_STATE = { ...@@ -14,7 +14,7 @@ export const INITIAL_STATE = {
customerId: 0, customerId: 0,
customerName: '', customerName: '',
customerPhone: '', customerPhone: '',
customerSex: '', customerSex: CustomerSex.boy,
customerType: '', customerType: '',
email: '', email: '',
entranceDate: '', entranceDate: '',
......
export enum CustomerSex {
boy = '1',
girl = '0',
}
export type Customer = { export type Customer = {
areaId: number; areaId: number;
areaName: string; areaName: string;
...@@ -8,7 +12,7 @@ export type Customer = { ...@@ -8,7 +12,7 @@ export type Customer = {
customerId: number; customerId: number;
customerName: string; customerName: string;
customerPhone: string; customerPhone: string;
customerSex: string; customerSex: CustomerSex;
customerType: string; customerType: string;
email: string; email: string;
entranceDate: 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