import { Component, PropsWithChildren, useEffect, useState } from "react";
import Taro from "@tarojs/taro";
import { Block, View, Text } from "@tarojs/components";

import Navbar from "../../components/navbar/navbar";

import { GetAboutUs } from "../../utils/Interface";

import "./about.less";

export default class About extends Component<any, any> {
  constructor(props) {
    super(props);
    this.state = {
      name: "更多设置",
      version: "",
    };
  }

  async onLoad() {
    this.initData();
  }
  componentDidMount() {}

  componentWillUnmount() {}

  componentDidShow() {}

  componentDidHide() {}

  async initData() {
    // let res = await GetAboutUs();
    // if (res.data.code === 200) {
    //   this.setState({ version: res.data.data.value });
    // }
    const accountInfo = Taro.getAccountInfoSync();
    console.log("accountInfo", accountInfo);
    if (accountInfo?.miniProgram?.version) {
      this.setState({
        version: accountInfo?.miniProgram?.version || "暂无",
      });
    }
  }

  render() {
    let { version } = this.state;
    return (
      <Block>
        <Navbar titleSlot="更多设置" isBack={true} />
        <View className="cell flex aitems sb" style="margin-top:20rpx;">
          <View className="label">版本管理</View>
          <View className="value">{version}</View>
        </View>
      </Block>
    );
  }
}
