add locale request
This commit is contained in:
+10
-1
@@ -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 是将要会渲染的页面
|
||||
|
||||
+13
-1
@@ -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',
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user