| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142 |
- import { Component, PropsWithChildren, useEffect } from 'react'
- import { View, Text, Button, Input } from '@tarojs/components'
- // import './index.scss'
- import Taro, { useReady } from '@tarojs/taro'
- // import ComponentA from './component'
- import Rings from '@components/Rings';
- import SingleSelect from '@components/SingleSelect';
- import { useDispatch, useSelector } from 'react-redux';
- import { getInfoSuccess } from '@/store/user';
- import { wxPubFollow } from '@/services/permission';
- import { staticResources } from '@/services/common';
- import { use } from 'i18next';
- // import TabBar from '../../components/Tabbar';
- export default function IndexPage() {
- const dispatch = useDispatch();
- const array: any[] = []
- const user = useSelector((state: any) => state.user);
- const permission = useSelector((state: any) => state.permission);
- const common = useSelector((state: any) => state.common);
- array.push('ffff');
- array.push(<Text>ffff</Text>)
- // array.push(<Rings radius={50}/>)
- useEffect(() => {
- dispatch(staticResources() as any);
- }, [])
- useReady(async () => {
- const userData = await getStorage('userData');
- if (userData) {
- dispatch(getInfoSuccess(JSON.parse(userData as string)) as any);
- // return JSON.parse(userData as string) as UserState;
- setTimeout(() => {
- checkWXPubFollow()
- }, 200)
- }
- })
- function checkWXPubFollow() {
- wxPubFollow().then(res => {
- console.log(res);
- })
- }
- function followWxPub() {
- const resource = common.resources.filter((item: any) => {
- return item.code == 'follow_wx_pub'
- })
- Taro.showModal({
- title: '提示',
- content: '关注公众号后可接收提醒\n点击确定,前往关注',
- showCancel: true,
- success(result) {
- if (result.confirm) {
- Taro.navigateTo({
- url: '/pages/common/H5?title=fast16cc 关注服务号&url=' + resource[0].url,
- })
- }
- },
- })
- }
- async function getStorage(key: string) {
- try {
- const res = await Taro.getStorage({ key });
- return res.data;
- } catch {
- return '';
- }
- }
- function goDetail() {
- Taro.navigateTo({
- // url: '/pages/index/detail'
- //src/moduleA/pages/third.tsx
- url: '../../moduleA/pages/third'
- })
- }
- function login() {
- if (user.isLogin) {
- Taro.navigateTo({
- url: '/pages/ChooseScenario'
- })
- }
- else {
- Taro.navigateTo({
- url: '/pages/ChooseAuth'
- })
- }
- }
- return (
- <View style={{ backgroundColor: '#fff', flex: 1, flexDirection: 'column', display: 'flex' }}>
- <Text>homepage12234</Text>
- <Text>{user.isLogin ? '已登录' : '未登录'}</Text>
- <Text>{user.isLogin ? `用户昵称:${user.nickname}` : ''}</Text>
- {
- permission.wxPubFollow == false && <Text onClick={() => followWxPub()}>去关注公众号</Text>
- }
- {/* <ComponentA value="ABBBB" /> */}
- <Button onClick={() => goDetail()}>go detail</Button>
- {/* <SingleSelect items={array}></SingleSelect> */}
- <Rings radius={50} />
- <Input placeholder="请输入用户名1" style={{ textAlign: 'left', backgroundColor: 'pink' }} />
- <Text className='login' onClick={() => login()}>sss</Text>
- {/* <TabBar /> */}
- </View>
- )
- }
- // export default class Index extends Component<PropsWithChildren> {
- // componentDidMount () { }
- // componentWillUnmount () { }
- // componentDidShow () { }
- // componentDidHide () { }
- // goDetail(){
- // Taro.navigateTo({
- // url: '/pages/index/detail'
- // })
- // }
- // render () {
- // return (
- // <View className='index'>
- // <Text>Hello world123!</Text>
- // <ComponentA value="A"/>
- // <Button onClick={()=>this.goDetail()}>detail</Button>
- // </View>
- // )
- // }
- // }
|