123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- import React from "react";
- import { View, Video, Text, Image } from "@tarojs/components";
- import Taro from "@tarojs/taro";
- import "./index.scss";
- import base from "../../config/base";
- import { InputBox } from "../../component/input/index";
- class Home extends React.Component<any, any> {
- static defaultProps = {};
- #systemInfo = Taro.getSystemInfoSync();
- #w = this.#systemInfo.windowWidth - 60;
- #h = (this.#w / 16) * 9;
- constructor(props: any) {
- super(props);
- this.state = {
- height: 0,
- data: {},
- };
- this.getData();
- }
- getImageSize = (e: any) => {
- const systemInfo = Taro.getSystemInfoSync();
- this.setState({
- height: (systemInfo.screenWidth / e.detail.width) * e.detail.height,
- });
- };
- getData = () => {
- Taro.showLoading({
- title: "加载中",
- });
- Taro.request({
- url:
- base.baseUrlEle +
- "/topic/tool/img/%E5%B0%91%E5%84%BF%E4%B9%A6%E7%94%BB%E5%A4%A7%E8%B5%9B/home.json?data=" +
- Date.now(),
- method: "GET",
- success: (res: any) => {
- if (res.statusCode !== 200)
- return Taro.showToast({
- title: "请求失败",
- icon: "none",
- });
- this.setState({
- data: res.data || {},
- });
- Taro.hideLoading();
- },
- fail: (error: any) => {
- Taro.hideLoading();
- Taro.showToast({
- title: JSON.stringify(error),
- });
- },
- });
- };
- render() {
- // const { } = this.props;
- const sonEle = (item) => (
- <View>
- <Text className="label">· {item.title} </Text>
- <View className="content">{item.content}</View>
- </View>
- );
- return (
- <View className="home">
- <Image
- style={`width: ${this.#systemInfo.screenWidth}px;height: ${
- this.state.height
- }px;`}
- src="https://cxzx.smcic.net/topic/tool/img/%E5%B0%91%E5%84%BF%E4%B9%A6%E7%94%BB%E5%A4%A7%E8%B5%9B/home_top.jpg"
- onLoad={this.getImageSize}
- />
- <InputBox>
- <View className="mian">
- {this.#h && this.state.data.baseVideoUrl && (
- <Video
- src={this.state.data.baseVideoUrl || ""}
- controls={false}
- style={`width: ${this.#w}px;height: ${this.#h}px;`}
- autoplay={true}
- loop
- show-fullscreen-btn={true}
- show-play-btn={true}
- id="video"
- />
- )}
- {this.state.data?.textList?.map((item: any) => (
- <View className="body">
- <View className="btn">{item.title}</View>
- {item.content?.map((p: any) => sonEle(p))}
- </View>
- ))}
- </View>
- </InputBox>
- </View>
- );
- }
- }
- export { Home };
|