Commit ff8493af authored by XieZhiXiong's avatar XieZhiXiong

feat: 搬运登录页面部分

parent c6658d56
module.exports = { module.exports = {
SITE_ID: 1, SITE_ID: 1,
BACK_GATEWAY: 'http://lingxi-scm-gateway-test-1030.shushangyun.com:12880', BACK_GATEWAY: 'https://api-2b-uat.zrhsh.com', // 暂时使用uat的地址
IS_DEV: 'TRUE', IS_DEV: 'TRUE',
H5_LINK: 'http://pt-h5.shushangyun.com:13880', H5_LINK: 'http://pt-h5.shushangyun.com:13880',
INFO_DETAIL_LINK: 'http://download-h5.shushangyun.com:13880/information/detail', INFO_DETAIL_LINK: 'http://download-h5.shushangyun.com:13880/information/detail',
......
...@@ -14,21 +14,27 @@ ...@@ -14,21 +14,27 @@
"lint": "eslint . --ext .js,.jsx,.ts,.tsx" "lint": "eslint . --ext .js,.jsx,.ts,.tsx"
}, },
"dependencies": { "dependencies": {
"@linkseeks/god-mobile": "^1.0.4",
"@react-native-async-storage/async-storage": "^1.17.11", "@react-native-async-storage/async-storage": "^1.17.11",
"@react-navigation/bottom-tabs": "^6.4.0", "@react-navigation/bottom-tabs": "^6.4.0",
"@react-navigation/native": "^6.0.13", "@react-navigation/native": "^6.0.13",
"@react-navigation/native-stack": "^6.9.1", "@react-navigation/native-stack": "^6.9.1",
"@react-navigation/stack": "^6.3.4", "@react-navigation/stack": "^6.3.4",
"@types/qs": "^6.9.7",
"crypto-es": "^1.2.7",
"expo-blur": "~8.2.0",
"i18next": "^20.5.0",
"mobx": "^6.7.0", "mobx": "^6.7.0",
"mobx-react": "^7.6.0", "mobx-react": "^7.6.0",
"mobx-react-lite": "^3.4.0", "mobx-react-lite": "^3.4.0",
"qs": "^6.9.4",
"react": "18.1.0", "react": "18.1.0",
"react-i18next": "^11.11.4",
"react-native": "0.70.6", "react-native": "0.70.6",
"react-native-fetch-polyfill": "^1.1.3",
"react-native-image-zoom-viewer": "^3.0.1",
"react-native-safe-area-context": "^4.4.1", "react-native-safe-area-context": "^4.4.1",
"react-native-screens": "^3.18.2", "react-native-screens": "^3.18.2",
"react-native-storage": "^1.0.1", "react-native-storage": "^1.0.1"
"expo-blur": "~8.2.0"
}, },
"devDependencies": { "devDependencies": {
"@babel/core": "^7.12.9", "@babel/core": "^7.12.9",
......
import BottomTabs from './BottomTabs'; import BottomTabs from './BottomTabs';
import TestDetailsScreen from '../views/Test/TestDetailsScreen'; import TestDetailsScreen from '../views/Test/TestDetailsScreen';
import Login from '../views/Login';
export const ROUTERS = { export const ROUTERS = {
BottomTabs: { BottomTabs: {
...@@ -10,4 +11,8 @@ export const ROUTERS = { ...@@ -10,4 +11,8 @@ export const ROUTERS = {
title: '测试详情', title: '测试详情',
component: TestDetailsScreen, component: TestDetailsScreen,
}, },
Login: {
title: '登入',
component: Login,
},
}; };
\ No newline at end of file
...@@ -14,6 +14,7 @@ export type StackRouteType = React.ComponentProps<typeof Stack.Screen>; ...@@ -14,6 +14,7 @@ export type StackRouteType = React.ComponentProps<typeof Stack.Screen>;
export type RootStackParamList = { export type RootStackParamList = {
BottomTabs: NavigatorScreenParams<RootTabParamList>; BottomTabs: NavigatorScreenParams<RootTabParamList>;
TestDetailsScreen: undefined; TestDetailsScreen: undefined;
Login: undefined;
}; };
export type RootStackScreenProps<Screen extends keyof RootStackParamList> = export type RootStackScreenProps<Screen extends keyof RootStackParamList> =
......
import qs from 'qs'; import qs from 'qs';
import fetch from 'react-native-fetch-polyfill'; import fetch from 'react-native-fetch-polyfill';
import { navigate } from '../../routers/navigationRef';
import { methodTypes, requestHeaders } from './types'; import { methodTypes, requestHeaders } from './types';
import i18n from '../../locales'; import i18n from '../../locales';
import { mergeConfig } from './utils'; import { mergeConfig } from './utils';
......
...@@ -6,24 +6,23 @@ ...@@ -6,24 +6,23 @@
* @Description: In User Settings Edit * @Description: In User Settings Edit
* @FilePath: \lingxi-mobile-app\src\services\basic\requestService.ts * @FilePath: \lingxi-mobile-app\src\services\basic\requestService.ts
*/ */
import { Toast } from '@linkseeks/god-mobile';
import Config from 'react-native-config';
import { requestFetch, RequestFetchOptions } from './requestFetch' import { requestFetch, RequestFetchOptions } from './requestFetch'
import { RequestFactoryModel, IRequestSuccess, requestHeaders } from './types' import { RequestFactoryModel, IRequestSuccess, requestHeaders } from './types'
import { GlobalConfig } from '../../constants/global' import { GlobalConfig } from '../../constants/global'
import { mergeConfig } from './utils' import { mergeConfig } from './utils'
import { getAsyncStorage } from '../../utils/storage' import { getAsyncStorage } from '../../utils/storage'
import { TOKEN } from '../../constants/index' import { TOKEN } from '../../constants/index'
import * as navigation from '../../routers/navigationRef' // import * as navigation from '../../routers/navigationRef'
import Store from '../../store' import Store from '../../store'
import { navigate } from '../../routers/navigationRef';
const env = require('../../../.projectEnv/env')
/** /**
* 使用dotenv动态引入 * 使用dotenv动态引入
* extra可在dev和prod都生效 * extra可在dev和prod都生效
* 如需修改 可查看文件目录下的.projectEnv文件夹 * 如需修改 可查看文件目录下的.projectEnv文件夹
*/ */
const requestBaseUrl = Config.BACK_GATEWAY || 'http://10.0.0.17:8100'; const requestBaseUrl = env.BACK_GATEWAY || 'http://10.0.0.17:8100';
const defaultHeaders: requestHeaders = { const defaultHeaders: requestHeaders = {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
source: 2, source: 2,
...@@ -40,25 +39,20 @@ class RequestFactory implements RequestFactoryModel { ...@@ -40,25 +39,20 @@ class RequestFactory implements RequestFactoryModel {
paramsConfig: RequestFetchOptions, paramsConfig: RequestFetchOptions,
): Promise<IRequestSuccess<T>> { ): Promise<IRequestSuccess<T>> {
const headers = { ...defaultHeaders }; const headers = { ...defaultHeaders };
const Token = await getAsyncStorage(TOKEN); // const Token = await getAsyncStorage(TOKEN);
// console.log('Token', Token)
if (Token) { // console.log('TokenTokenToken', Token)
headers.token = Token;
} // if (Token) {
const shopId = Store.userStore.currentSelfMallInfo?.shopRuleDetailId || Store.userStore.shopAndSite?.shopId // headers.token = Token;
const shopGroupId = Store.userStore.shopAndSite?.shopGroupId // }
if (shopId) {
headers.shopId = shopId
}
if (shopGroupId) {
headers.shopGroupId = shopGroupId
}
const config: RequestFetchOptions = paramsConfig; const config: RequestFetchOptions = paramsConfig;
config.headers = config.headers ? mergeConfig(headers, config.headers) : headers; config.headers = config.headers ? mergeConfig(headers, config.headers) : headers;
// console.log(requestBaseUrl, url, config); console.log('请求地址:', `${requestBaseUrl + url}`, config);
console.log('请求参数:', config);
/** /**
* @todo 此处可添加中间件 * @todo 此处可添加中间件
*/ */
...@@ -67,8 +61,8 @@ class RequestFactory implements RequestFactoryModel { ...@@ -67,8 +61,8 @@ class RequestFactory implements RequestFactoryModel {
.then((res: IRequestSuccess<T>) => { .then((res: IRequestSuccess<T>) => {
// 未登录 // 未登录
if (res.code === 1101) { if (res.code === 1101) {
Store.userStore.removeUserInfo(); // Store.userStore.removeUserInfo();
navigation.dispatch("Login"); // navigation.dispatch("Login");
reject(res); reject(res);
return; return;
} }
...@@ -79,7 +73,7 @@ class RequestFactory implements RequestFactoryModel { ...@@ -79,7 +73,7 @@ class RequestFactory implements RequestFactoryModel {
&& res.message && res.message
) { ) {
if (config.showError !== false) { if (config.showError !== false) {
Toast.show(res.message); // Toast.show(res.message);
console.error(url, config, res); console.error(url, config, res);
} }
} }
...@@ -87,7 +81,7 @@ class RequestFactory implements RequestFactoryModel { ...@@ -87,7 +81,7 @@ class RequestFactory implements RequestFactoryModel {
}) })
.catch((err) => { .catch((err) => {
if (config.showError !== false) { if (config.showError !== false) {
Toast.show(err.code); // Toast.show(err.code);
} }
// if (err?.status === 3000) { // if (err?.status === 3000) {
// navigate("Network", {}); // navigate("Network", {});
......
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 useStores from '../../store/useStores';
import {
postMemberMobileWechatAppletLoginPhone,
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';
// import MobileView from './components/Mobile'
// import SingView from './components/Sing'
import styles from './styles';
const Login = () => {
const LoginTypeText = [
'密码登录',
'手机号码登录',
]
const [current, setcurrent] = useState(0) // 0 是账号密码登录
const { userStore } = useStores();
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>([]); // 协议数据
const myStyle = useAppStyle(styles);
// const renderComponentByType = () => {
// switch (current) {
// case 0:
// return <SingView submit={onSubmit} />
// case 1:
// return <MobileView submit={onSubmit} phoneLength={phoneLength} Confirm={Confirm} countryCode={countryCode} />
// default:
// return null
// }
// }
const onSubmit = async (data: any) => {
if (!select) {
Toast.show({ title: i18n.t('user:user.login.agreement.tips', '请阅读并同意相关协议'), icon: 'none' });
return;
}
let fn: Function | null = null;
let obj: any = {};
switch (current) {
case 1:
fn = postMemberMobileWechatAppletLoginPhone
break;
default:
fn = postMemberMobileWechatAppletLoginAccount
obj.account = data.account;
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
} else {
if (current == 1) {
obj.password = decryptedByAES(obj.password)
}
Toast.show({ title: res.message, icon: 'none' });
return
}
})
}
const Confirm = (flag) => {
settoggle(flag);
}
const findAllByColumnType = async () => {
const { code, data, message } = await getManageContentNoticeFindWithOutContent({ columnType: "2" })
if (code === 1000) {
setColumnTypeList(data)
} else {
Taro.showToast({ title: message, icon: 'none' });
}
}
const webView = (item: any) => {
Router.navigateTo('root/richtext', { id: item.id, type: 'sign' })
}
useEffect(() => {
findAllByColumnType()
}, [])
/* 选择区号回调 */
const onConfirm = (item) => {
setCode(item.code)
setphoneLength(item.phoneLength)
settoggle(false);
}
/* 关闭 */
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>
</View>
{/* 登录方式 */}
<View style={myStyle.loginType}>
{
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,
]}
onPress={() => setcurrent(index)}
>
{item}
</Text>
{index == current ? (
<View style={myStyle['loginType-item-line']} />
) : null}
</View>
))
}
</View>
{/* {renderComponentByType()} */}
{/* <ModeMobile containerClassName={styles['mobileModel']} toggle={toggle} onConfirm={onConfirm} onClose={onClose} /> */}
{/* 忘记密码 */}
<View style={myStyle['sign']}>
{/* <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>
))
}
</View>
</View>
</View>
)
}
export default Login;
\ No newline at end of file
import { StyleSheet } from 'react-native';
import { ThemeStyle } from '../../constants/theme';
import themeLayout from '../../constants/theme/layout';
export default (theme: ThemeStyle) => StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
paddingVertical: 0,
paddingHorizontal: 23,
backgroundColor: '#FFFFFF',
},
Text: {
color: '#c0c4cc',
fontSize: 14,
},
head: {
marginTop: 32,
},
logo: {
width: 115.03,
height: 36,
},
logoTitle: {
fontSize: 24,
color: '#303133',
marginTop: 12,
},
loginType: {
marginTop: 20,
flexDirection: 'row',
},
'loginType-item': {
position: 'relative',
},
'loginType-item-text': {
fontSize: 14,
paddingVertical: 5,
marginRight: 12,
color: '#909399',
},
'loginType-item-text__ative': {
color: '#252d37',
fontWeight: '900',
},
'loginType-item-line': {
position: 'absolute',
bottom: 0,
width: '40%',
left: '30%',
backgroundColor: '#EA5504',
height: 3,
},
sign: {
flexDirection: 'row',
alignItems: 'center',
marginTop: 182,
},
'sign-signFlex': {
flexDirection: 'row',
flex: 1,
},
'sign-signText': {
fontSize: 12,
color: '#909399',
},
'sign-signRight': {
color: '#000',
fontSize: 12,
},
mobileView: {},
'mobileView-fromItem': {
marginTop: 16,
alignItems: 'center',
flexDirection: 'row',
backgroundColor: '#f5f6f7',
borderRadius: 8,
paddingHorizontal: 8,
},
'mobileView-fromItem-code': {
fontSize: 14,
},
'mobileView-fromItem-input': {
fontSize: 14,
paddingVertical: 12,
},
'mobileView-fromItem-placeholderText': {
fontSize: 14,
paddingVertical: 12,
},
'mobileView-fromItem-fill': {
paddingHorizontal: 10,
borderRightWidth: 1,
borderColor: '#c8cacd',
borderStyle: 'dashed',
alignItems: 'center',
marginRight: 12,
},
'mobileView-fromItem-fill-image': {
width: 16,
height: 16,
},
'mobileView-fromFlex': {
marginTop: 16,
alignItems: 'center',
flexDirection: 'row',
backgroundColor: '#f5f6f7',
borderRadius: 8,
paddingHorizontal: 8,
justifyContent: 'space-between',
},
'mobileView-imgbox': {
width: 40,
height: 40,
justifyContent: 'flex-end',
alignItems: 'center',
},
'mobileView-submit': {
marginTop: 30,
backgroundColor: '#EA5504',
borderRadius: 8,
textAlign: 'center',
fontSize: 14,
color: '#fff',
paddingVertical: 10,
},
});
declare module '*.css';
declare module '*.less';
declare module "*.png";
declare module "*.mp4";
declare module "classnames";
declare module "*.json";
declare module '*.svg'
declare module 'react-native-echarts-pro';
This diff is collapsed.
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