index.tsx 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import React from "react";
  2. import { View, Video, Image } from "@tarojs/components";
  3. import Taro from "@tarojs/taro";
  4. import "./index.scss";
  5. import { InputBox } from "../../component/input/index";
  6. class Us extends React.Component<any, any> {
  7. static defaultProps = {};
  8. #systemInfo = Taro.getSystemInfoSync();
  9. constructor(props: any) {
  10. super(props);
  11. this.state = {
  12. height: 0,
  13. heightKf: 0,
  14. };
  15. }
  16. getImageSize = (e: any) => {
  17. this.setState({
  18. height: (this.#systemInfo.screenWidth / e.detail.width) * e.detail.height,
  19. });
  20. };
  21. getImageKf = (e: any) => {
  22. this.setState({
  23. heightKf:
  24. ((this.#systemInfo.screenWidth - 60) / e.detail.width) * e.detail.height,
  25. });
  26. };
  27. render() {
  28. // const { } = this.props;
  29. return (
  30. <View className="Us">
  31. <Image
  32. style={`width: ${this.#systemInfo.screenWidth}px;height: ${
  33. this.state.height
  34. }px;`}
  35. 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/us-top.png"
  36. onLoad={this.getImageSize}
  37. />
  38. <InputBox>123</InputBox>
  39. <Image
  40. style={`width: ${this.#systemInfo.screenWidth - 60}px;height: ${
  41. this.state.heightKf
  42. }px;display: block;margin: 0 auto`}
  43. 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/us-kf.png"
  44. onLoad={this.getImageKf}
  45. />
  46. </View>
  47. );
  48. }
  49. }
  50. export { Us };