Commit a13b30a6 authored by 郑云峰's avatar 郑云峰

chore: 格式化代码

parent 37904497
......@@ -6,7 +6,13 @@
* @Description: CellItem 组件
*/
import React from 'react';
import { View, Text, TouchableOpacity, ViewStyle, TextStyle } from 'react-native';
import {
View,
Text,
TouchableOpacity,
ViewStyle,
TextStyle,
} from 'react-native';
import { useTheme } from '@react-navigation/native';
import useAppStyle from '../../hooks/useAppStyle';
import { ThemeStyle } from '../../constants/theme';
......@@ -158,9 +164,7 @@ const CellItem: React.FC<CellItemProps> = (props: CellItemProps) => {
) : (
customIcon
)} */}
{!customIcon ? null : (
customIcon
)}
{!customIcon ? null : customIcon}
</View>
) : null}
<View style={myStyle['list-item-titleWrap']}>{renderTitle()}</View>
......
import React, { useState } from 'react'
import { View, ViewStyle, Modal, TouchableOpacity, GestureResponderEvent, ImageResizeMode } from 'react-native'
import ImageViewer from 'react-native-image-zoom-viewer'
import { IImageInfo } from 'react-native-image-zoom-viewer/built/image-viewer.type'
import LazyImage from '../LazyImage'
import defaultImg from '../../../assets/images/default_img.png'
import styles from './styles'
import React, { useState } from 'react';
import {
View,
ViewStyle,
Modal,
TouchableOpacity,
GestureResponderEvent,
ImageResizeMode,
} from 'react-native';
import ImageViewer from 'react-native-image-zoom-viewer';
import { IImageInfo } from 'react-native-image-zoom-viewer/built/image-viewer.type';
import LazyImage from '../LazyImage';
import defaultImg from '../../../assets/images/default_img.png';
import styles from './styles';
interface ImageBoxPropsType {
width?: number | string;
......@@ -12,14 +19,23 @@ interface ImageBoxPropsType {
source: string;
style?: ViewStyle;
resizeMode?: ImageResizeMode;
borderRadius?: number,
canPreview?: boolean,
onPress?: ((event: GestureResponderEvent) => void) | undefined
borderRadius?: number;
canPreview?: boolean;
onPress?: ((event: GestureResponderEvent) => void) | undefined;
}
const ImageBox = (props: ImageBoxPropsType) => {
const { width, height, source = "", style, borderRadius, resizeMode = 'contain', canPreview, onPress } = props
const [previewVisible, setPreviewVisible] = useState<boolean>(false)
const {
width,
height,
source = '',
style,
borderRadius,
resizeMode = 'contain',
canPreview,
onPress,
} = props;
const [previewVisible, setPreviewVisible] = useState<boolean>(false);
const showImgBg = () => {
if (canPreview && onPress) {
......@@ -29,9 +45,9 @@ const ImageBox = (props: ImageBoxPropsType) => {
style={{ width, height, borderRadius, overflow: 'hidden' }}
onPress={(e: GestureResponderEvent) => {
if (canPreview) {
setPreviewVisible(true)
setPreviewVisible(true);
} else if (onPress) {
onPress(e)
onPress(e);
}
}}
>
......@@ -42,7 +58,7 @@ const ImageBox = (props: ImageBoxPropsType) => {
resizeMode={resizeMode}
/>
</TouchableOpacity>
)
);
}
return (
<LazyImage
......@@ -51,45 +67,46 @@ const ImageBox = (props: ImageBoxPropsType) => {
style={{ width, height, borderRadius, overflow: 'hidden' }}
resizeMode={resizeMode}
/>
)
}
);
};
return (
<View style={[styles.imageBox, style]}>
{
source ? showImgBg()
: (
{source ? (
showImgBg()
) : (
<LazyImage
thumbnailSource={defaultImg}
fullSource={{ uri: source }}
style={{ width, height, borderRadius, overflow: 'hidden' }}
resizeMode={resizeMode}
/>
)
}
{
canPreview && (
)}
{canPreview && (
<Modal
visible={previewVisible}
onRequestClose={() => setPreviewVisible(false)}
transparent
>
<ImageViewer imageUrls={[{ url: source }] as unknown as IImageInfo[]} index={0} onClick={() => setPreviewVisible(false)} />
<ImageViewer
imageUrls={[{ url: source }] as unknown as IImageInfo[]}
index={0}
onClick={() => setPreviewVisible(false)}
/>
</Modal>
)
}
)}
</View>
)
}
);
};
ImageBox.defaultProps = {
width: 106,
height: 106,
style: {},
resizeMode: "cover",
resizeMode: 'cover',
borderRadius: 4,
canPreview: false,
onPress: undefined,
}
};
export default ImageBox
export default ImageBox;
import { StyleSheet } from 'react-native'
import { StyleSheet } from 'react-native';
export default StyleSheet.create({
imageBox: {
overflow: 'hidden',
},
})
});
......@@ -6,7 +6,7 @@ import {
Animated,
ImageResizeMode,
} from 'react-native';
import defaultImg from '../../../assets/images/default_img.png'
import defaultImg from '../../../assets/images/default_img.png';
interface LazyImageProps {
thumbnailSource: any;
......@@ -25,7 +25,7 @@ const styles = StyleSheet.create({
},
});
const LazyImage: React.FC<LazyImageProps> = (props) => {
const LazyImage: React.FC<LazyImageProps> = props => {
const { thumbnailSource, fullSource, style, resizeMode } = props;
const opacity = useRef(new Animated.Value(0)).current;
......@@ -39,8 +39,7 @@ const LazyImage: React.FC<LazyImageProps> = (props) => {
return (
<View style={style}>
{
fullSource.uri ? (
{fullSource.uri ? (
<Animated.Image
source={fullSource}
defaultSource={thumbnailSource}
......@@ -65,9 +64,7 @@ const LazyImage: React.FC<LazyImageProps> = (props) => {
resizeMode={resizeMode}
onLoad={onImageLoad}
/>
)
}
)}
</View>
);
};
......
......@@ -6,12 +6,7 @@
* @Description: 加载组件
*/
import React from 'react';
import {
StyleSheet,
ViewStyle,
View,
Text,
} from 'react-native';
import { StyleSheet, ViewStyle, View, Text } from 'react-native';
import useAppStyle from '../../hooks/useAppStyle';
import Spin from './Spin';
import styles from './styles';
......
......@@ -231,11 +231,7 @@ const NoticeBar: React.FC<NoticeBarProps> = (props: NoticeBarProps) => {
</View>
<View style={[myStyle['boticeBar-content']]}>{renderContent()}</View>
{hasArrow ? (
<TouchableOpacity
style={[
myStyle['boticeBar-action'],
]}
>
<TouchableOpacity style={[myStyle['boticeBar-action']]}>
{/* <Icons
size={16}
// eslint-disable-next-line no-nested-ternary
......
......@@ -191,6 +191,7 @@ const Search: React.FC<SearchProps> = React.forwardRef(
inputRef.current!.blur();
},
}),
// eslint-disable-next-line react-hooks/exhaustive-deps, array-bracket-spacing
[inputRef.current],
);
......@@ -212,10 +213,8 @@ const Search: React.FC<SearchProps> = React.forwardRef(
shape === 'round' ? myStyle['search-content__round'] : null,
])}
>
{!!label && (
<Text style={myStyle['search-label']}>{label}</Text>
)}
<View style={[myStyle['search-control']]}>
{!!label && <Text style={myStyle['search-label']}>{label}</Text>}
<View style={myStyle['search-control']}>
{/* {!customLeftIcon ? (
<Icons
type="feather"
......@@ -227,12 +226,8 @@ const Search: React.FC<SearchProps> = React.forwardRef(
) : (
customLeftIcon
)} */}
{!customLeftIcon ? null : (
customLeftIcon
)}
<View
style={myStyle['search-field-wrap']}
>
{!customLeftIcon ? null : customLeftIcon}
<View style={myStyle['search-field-wrap']}>
<TextInput
ref={inputRef}
value={value}
......@@ -248,15 +243,15 @@ const Search: React.FC<SearchProps> = React.forwardRef(
style={StyleSheet.flatten([
myStyle['search-field'],
{
paddingRight: !clearable ? themeLayout['padding-xs'] : themeLayout['padding-xs'] + 18,
paddingRight: !clearable
? themeLayout['padding-xs']
: themeLayout['padding-xs'] + 18,
},
])}
/>
{/* 为了解决 ios 点击 Input 不会触发父级点击事件的问题 */}
{!editable ? (
<View
style={myStyle['search-field-placeholder']}
/>
<View style={myStyle['search-field-placeholder']} />
) : null}
</View>
{clearable && value.length > 0 && (
......@@ -273,6 +268,7 @@ const Search: React.FC<SearchProps> = React.forwardRef(
</TouchableOpacity>
)}
</View>
</View>
{!!showAction &&
(!customAction ? (
<TouchableOpacity activeOpacity={0.8} onPress={handleCancel}>
......
......@@ -4,43 +4,51 @@
* **********
*/
import SELF_CONFIG from '../../../base.config.json'
import { RootObject } from './global'
import SELF_CONFIG from '../../../base.config.json';
import { RootObject } from './global';
interface newRootObject extends RootObject {
appMallInfo: any,
pointMallId: number | undefined,
channelPointMallId: number | undefined,
pointMallInfo: any,
channelPointMallInfo: any,
appMallInfo: any;
pointMallId: number | undefined;
channelPointMallId: number | undefined;
pointMallInfo: any;
channelPointMallInfo: any;
}
export const checkUrl = (url: any, defaultUrl: any) => {
if (url && typeof url === 'string') {
if (url.indexOf('/') > -1) {
return url.trim()
return url.trim();
}
return `/${url}`.trim()
return `/${url}`.trim();
}
return defaultUrl
}
return defaultUrl;
};
const appMallInfo = SELF_CONFIG.web.shopInfo.filter(item => item.environment === 4 && item.type === 1)[0] // app企业商城
const appMallInfo = SELF_CONFIG.web.shopInfo.filter(
item => item.environment === 4 && item.type === 1,
)[0]; // app企业商城
const pointMallInfo = SELF_CONFIG.web.shopInfo.filter(item => item.environment === 4 && item.type === 2)[0] // app积分商城
const pointMallInfo = SELF_CONFIG.web.shopInfo.filter(
item => item.environment === 4 && item.type === 2,
)[0]; // app积分商城
const channelPointMallInfo = SELF_CONFIG.web.shopInfo.filter(item => item.environment === 4 && item.type === 5)[0] // app渠道积分商城
const channelPointMallInfo = SELF_CONFIG.web.shopInfo.filter(
item => item.environment === 4 && item.type === 5,
)[0]; // app渠道积分商城
//@ts-ignore
SELF_CONFIG.appMallInfo = appMallInfo // app企业商城信息
SELF_CONFIG.appMallInfo = appMallInfo; // app企业商城信息
//@ts-ignore
SELF_CONFIG.pointMallId = pointMallInfo ? pointMallInfo.id : undefined
SELF_CONFIG.pointMallId = pointMallInfo ? pointMallInfo.id : undefined;
//@ts-ignore
SELF_CONFIG.channelPointMallId = channelPointMallInfo ? channelPointMallInfo.id : undefined
SELF_CONFIG.channelPointMallId = channelPointMallInfo
? channelPointMallInfo.id
: undefined;
//@ts-ignore
SELF_CONFIG.pointMallInfo = pointMallInfo
SELF_CONFIG.pointMallInfo = pointMallInfo;
//@ts-ignore
SELF_CONFIG.channelPointMallInfo = channelPointMallInfo
SELF_CONFIG.channelPointMallInfo = channelPointMallInfo;
//@ts-ignore
export const GlobalConfig: newRootObject = SELF_CONFIG
export const GlobalConfig: newRootObject = SELF_CONFIG;
export default {}
export default {};
......@@ -8,24 +8,24 @@ import en_US from './en_US';
import ko_KR from './ko_KR';
const localeResource: {
"zh-CN": any,
"en-US": any,
"ko-KR": any,
'zh-CN': any;
'en-US': any;
'ko-KR': any;
} = {
"zh-CN": zh_CN,
"en-US": en_US,
"ko-KR": ko_KR,
}
'zh-CN': zh_CN,
'en-US': en_US,
'ko-KR': ko_KR,
};
type Language = keyof typeof localeResource;
const LANGUAGE: Language = (env.LANGUAGE ?? 'zh-CN') as Language
const LANGUAGE: Language = (env.LANGUAGE ?? 'zh-CN') as Language;
const languageDetector = {
type: 'languageDetector',
async: true,
detect: (cb: any) => cb(LANGUAGE),
init: () => { },
cacheUserLanguage: () => { },
init: () => {},
cacheUserLanguage: () => {},
};
i18n
......@@ -37,4 +37,4 @@ i18n
resources: localeResource,
});
export default i18n
export default i18n;
export default {}
export default {};
export default {}
export default {};
......@@ -17,7 +17,7 @@ export const ROUTERS = {
Login: {
title: '登入',
component: Login,
headerShown: true
headerShown: true,
},
AccountInfo: {
title: '账号信息',
......
......@@ -8,9 +8,12 @@ const key = CryptoJS.enc.Utf8.parse('GzSsyLingxi2.0.0');
export const encryptedByAES = (source: string) => {
const password = CryptoJS.enc.Utf8.parse(source);
// @ts-ignore
const encrypted = CryptoJS.AES.encrypt(password, key, { mode: CryptoJS.mode.ECB, padding: CryptoJS.pad.Pkcs7 }) // CryptoJS.pad.Pkcs7
return encrypted.toString() // 加密后的base64
}
const encrypted = CryptoJS.AES.encrypt(password, key, {
mode: CryptoJS.mode.ECB,
padding: CryptoJS.pad.Pkcs7,
}); // CryptoJS.pad.Pkcs7
return encrypted.toString(); // 加密后的base64
};
/**
* @auth xjm
......@@ -18,6 +21,9 @@ export const encryptedByAES = (source: string) => {
*/
export const decryptedByAES = (source: string) => {
// @ts-ignore
const decrypted = CryptoJS.AES.decrypt(source, key, { mode: CryptoJS.mode.ECB, padding: CryptoJS.pad.Pkcs7 }); // CryptoJS.pad.Pkcs7
return decrypted.toString(CryptoJS.enc.Utf8) // 解密后的原始字符串
}
const decrypted = CryptoJS.AES.decrypt(source, key, {
mode: CryptoJS.mode.ECB,
padding: CryptoJS.pad.Pkcs7,
}); // CryptoJS.pad.Pkcs7
return decrypted.toString(CryptoJS.enc.Utf8); // 解密后的原始字符串
};
......@@ -2,14 +2,14 @@ import React, { useEffect, useState } from 'react';
import { View, Text, Image } from 'react-native';
// import { Text, Image, Toast } from '@linkseeks/god-mobile';
// import ModeMobile from '@/components/Modemobile';
import { setAsyncStorage } from '../../utils/storage'
import { encryptedByAES, decryptedByAES } from '../../utils/cryptoAes'
import { setAsyncStorage } from '../../utils/storage';
import { encryptedByAES, decryptedByAES } from '../../utils/cryptoAes';
import useStores from '../../store/useStores';
import {
postMemberMobileWechatAppletLoginPhone,
postMemberMobileWechatAppletLoginAccount
} from '../../services/MemberV2Api'
import { getManageContentNoticeFindWithOutContent } from '../../services/ManageV2Api'
postMemberMobileWechatAppletLoginAccount,
} from '../../services/MemberV2Api';
import { getManageContentNoticeFindWithOutContent } from '../../services/ManageV2Api';
import useAppStyle from '../../hooks/useAppStyle';
import zhongranLogo from '../../../assets/images/zhongran_logo.png';
import ImageBox from '../../components/ImageBox';
......@@ -18,14 +18,11 @@ import ImageBox from '../../components/ImageBox';
import styles from './styles';
const Login = () => {
const LoginTypeText = [
'密码登录',
'手机号码登录',
]
const [current, setcurrent] = useState(0) // 0 是账号密码登录
const LoginTypeText = ['密码登录', '手机号码登录'];
const [current, setcurrent] = useState(0); // 0 是账号密码登录
const { userStore } = useStores();
const [toggle, settoggle] = useState<boolean>(false) // 显示手机号模态框
const [countryCode, setCode] = useState('+86') // 手机区号
const [toggle, settoggle] = useState<boolean>(false); // 显示手机号模态框
const [countryCode, setCode] = useState('+86'); // 手机区号
const [phoneLength, setphoneLength] = useState(11); // 手机号码长度
const [select, setSelect] = useState(false); // 设置协议选中
const [columnTypeList, setColumnTypeList] = useState<any>([]); // 协议数据
......@@ -45,7 +42,10 @@ const Login = () => {
const onSubmit = async (data: any) => {
if (!select) {
Toast.show({ title: i18n.t('user:user.login.agreement.tips', '请阅读并同意相关协议'), icon: 'none' });
Toast.show({
title: i18n.t('user:user.login.agreement.tips', '请阅读并同意相关协议'),
icon: 'none',
});
return;
}
let fn: Function | null = null;
......@@ -53,81 +53,81 @@ const Login = () => {
switch (current) {
case 1:
fn = postMemberMobileWechatAppletLoginPhone
fn = postMemberMobileWechatAppletLoginPhone;
break;
default:
fn = postMemberMobileWechatAppletLoginAccount
fn = postMemberMobileWechatAppletLoginAccount;
obj.account = data.account;
obj.password = encryptedByAES(data.password)
obj.password = encryptedByAES(data.password);
obj.shopType = data.shopType;
break;
}
fn?.(current == 1 ? data : obj).then(res => {
if (res.code === 1000) {
setAsyncStorage('USER_INFO', res.data)
userStore.setUserInfo(res.data)
Router.reLaunch('root/home')
return
setAsyncStorage('USER_INFO', res.data);
userStore.setUserInfo(res.data);
Router.reLaunch('root/home');
return;
} else {
if (current == 1) {
obj.password = decryptedByAES(obj.password)
obj.password = decryptedByAES(obj.password);
}
Toast.show({ title: res.message, icon: 'none' });
return
}
})
return;
}
});
};
const Confirm = (flag) => {
const Confirm = flag => {
settoggle(flag);
}
};
const findAllByColumnType = async () => {
const { code, data, message } = await getManageContentNoticeFindWithOutContent({ columnType: "2" })
const { code, data, message } =
await getManageContentNoticeFindWithOutContent({ columnType: '2' });
if (code === 1000) {
setColumnTypeList(data)
setColumnTypeList(data);
} else {
Taro.showToast({ title: message, icon: 'none' });
}
}
};
const webView = (item: any) => {
Router.navigateTo('root/richtext', { id: item.id, type: 'sign' })
}
Router.navigateTo('root/richtext', { id: item.id, type: 'sign' });
};
useEffect(() => {
findAllByColumnType()
}, [])
findAllByColumnType();
}, []);
/* 选择区号回调 */
const onConfirm = (item) => {
setCode(item.code)
setphoneLength(item.phoneLength)
const onConfirm = item => {
setCode(item.code);
setphoneLength(item.phoneLength);
settoggle(false);
}
};
/* 关闭 */
const onClose = (item) => {
const onClose = item => {
settoggle(item.toggle);
}
};
return (
<View style={myStyle['container']}>
<View style={myStyle['head']}>
<Image source={zhongranLogo} style={myStyle['logo']} />
<Text style={myStyle['logoTitle']}>
欢迎来到慧售卖
</Text>
<Text style={myStyle['logoTitle']}>欢迎来到慧售卖</Text>
</View>
{/* 登录方式 */}
<View style={myStyle.loginType}>
{
LoginTypeText.map((item: any, index: number) => (
{LoginTypeText.map((item: any, index: number) => (
<View key={index} style={myStyle['loginType-item']}>
<Text
key={index}
style={[
myStyle['loginType-item-text'],
index == current ? myStyle['loginType-item-text__ative'] : undefined,
index == current
? myStyle['loginType-item-text__ative']
: undefined,
]}
onPress={() => setcurrent(index)}
>
......@@ -137,8 +137,7 @@ const Login = () => {
<View style={myStyle['loginType-item-line']} />
) : null}
</View>
))
}
))}
</View>
{/* {renderComponentByType()} */}
......@@ -149,14 +148,18 @@ const Login = () => {
{/* <Image src={select ? require('@/assets/images/Checked-@2x.png') : require('@/assets/images/Default@2x.png')} onClick={() => setSelect(!select)} /> */}
<View style={myStyle['sign-signFlex']}>
<Text style={myStyle['sign-signText']}>阅读并同意</Text>
{
columnTypeList.map((items: any) => (
<Text key={items.id} style={myStyle['sign-signRight']} onPress={() => webView(items)}>{items.title}</Text>
))
}
{columnTypeList.map((items: any) => (
<Text
key={items.id}
style={myStyle['sign-signRight']}
onPress={() => webView(items)}
>
{items.title}{' '}
</Text>
))}
</View>
</View>
</View>
)
}
);
};
export default Login;
......@@ -2,7 +2,8 @@ import { StyleSheet } from 'react-native';
import { ThemeStyle } from '../../constants/theme';
import themeLayout from '../../constants/theme/layout';
export default (theme: ThemeStyle) => StyleSheet.create({
export default (theme: ThemeStyle) =>
StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
......@@ -124,4 +125,4 @@ export default (theme: ThemeStyle) => StyleSheet.create({
color: '#fff',
paddingVertical: 10,
},
});
});
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