Commit 610e4442 by 姜雷

Merge branch 'develop' into test

parents 9b30b361 ac3c884d
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;
......@@ -16,6 +16,8 @@ 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';
function Feedback() {
useShareAppMessage(shareHandle);
......@@ -68,7 +70,10 @@ function Feedback() {
}
};
const [scrollTop, setScrollTop] = useState(0);
const systemInfo = useSystemInfo();
useEffect(() => {
if (compareVersion(systemInfo.SDKVersion, '2.7.0')) {
wx.onKeyboardHeightChange(res => {
console.log(res.height);
if (res.height) {
......@@ -77,6 +82,9 @@ function Feedback() {
setShowKeyboard(false);
}
});
} else {
console.log('in focus');
}
}, []);
useEffect(() => {
Taro.createSelectorQuery()
......
......@@ -41,16 +41,20 @@ const useFeedbackList = (customerId: number) => {
.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: res.data,
payload: list,
});
setPaination({ ...pagination, pageNum: pagination.pageNum + 1 });
} else {
dispatch({
type: 'refreshList',
payload: res.data,
payload: list,
});
}
}
......
......@@ -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 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