add locale request
parent
1907f1e967
commit
00977db512
|
|
@ -29,7 +29,7 @@ export default {
|
|||
success: true,
|
||||
data: {
|
||||
token: 'token_test',
|
||||
lang: 'zn_CN',
|
||||
lang: 'en_US',
|
||||
},
|
||||
},
|
||||
'POST /user/locale/update': {
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@
|
|||
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.5",
|
||||
"@tarojs/cli": "3.6.24",
|
||||
"@tarojs/plugin-mock": "^0.0.9",
|
||||
"@tarojs/plugin-platform-h5": "^3.6.24",
|
||||
"@tarojs/plugin-platform-h5": "3.6.24",
|
||||
"@tarojs/taro-loader": "3.6.24",
|
||||
"@tarojs/test-utils-react": "^0.1.1",
|
||||
"@tarojs/webpack5-runner": "3.6.24",
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@
|
|||
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.5",
|
||||
"@tarojs/cli": "3.6.24",
|
||||
"@tarojs/plugin-mock": "^0.0.9",
|
||||
"@tarojs/plugin-platform-h5": "^3.6.24",
|
||||
"@tarojs/plugin-platform-h5": "3.6.24",
|
||||
"@tarojs/taro-loader": "3.6.24",
|
||||
"@tarojs/test-utils-react": "^0.1.1",
|
||||
"@tarojs/webpack5-runner": "3.6.24",
|
||||
|
|
|
|||
11
src/app.ts
11
src/app.ts
|
|
@ -1,11 +1,20 @@
|
|||
import { PropsWithChildren } from 'react';
|
||||
import { useLaunch } from '@tarojs/taro';
|
||||
import Taro, { useLaunch } from '@tarojs/taro';
|
||||
import { getUrl } from '@/service';
|
||||
import pt from '@/plain-text';
|
||||
import 'taro-ui/dist/style/index.scss';
|
||||
import './app.scss';
|
||||
|
||||
function App({ children }: PropsWithChildren<any>) {
|
||||
useLaunch(() => {
|
||||
console.log('App launched.');
|
||||
Taro.request({
|
||||
url: getUrl('/user/locale/get'),
|
||||
method: 'GET',
|
||||
}).then(res => {
|
||||
console.log(res.data);
|
||||
pt.setLang(res.data.data.lang);
|
||||
});
|
||||
});
|
||||
|
||||
// children 是将要会渲染的页面
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import { AtList, AtListItem } from 'taro-ui';
|
||||
import { Component, ReactNode } from 'react';
|
||||
import { View, Picker, Image, Text } from '@tarojs/components';
|
||||
import { getUrl } from '@/service';
|
||||
import Taro from '@tarojs/taro';
|
||||
import type CustomTabBar from '@/custom-tab-bar';
|
||||
import PageFooter from '@/components/PageFooter/PageFooter';
|
||||
|
|
@ -35,7 +36,18 @@ export default class UserPage extends Component {
|
|||
this.setState({
|
||||
selectorChecked: this.state.selector[e.detail.value],
|
||||
});
|
||||
pt.setLang(this.showLangDict[this.state.selector[e.detail.value]]);
|
||||
let currentLang = this.showLangDict[this.state.selector[e.detail.value]];
|
||||
pt.setLang(currentLang);
|
||||
Taro.request({
|
||||
url: getUrl('/user/locale/update'),
|
||||
method: 'POST',
|
||||
data: {
|
||||
token: 'token_test',
|
||||
lang: currentLang,
|
||||
},
|
||||
}).then(res => {
|
||||
console.log(res.data);
|
||||
});
|
||||
Taro.reLaunch({
|
||||
url: '/pages/user/user',
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue