// import { MpSplashDetail, WCUserLogin } from "../../utils/Interface"; import { Component } from "react"; import Taro from "@tarojs/taro"; // 引入 Swiper, SwiperItem 组件 import { Block, View, Text, Image, Video, Swiper, SwiperItem, Textarea, } from "@tarojs/components"; import Navbar from "@/components/navbar/navbar"; import { go, msg } from "@/utils/traoAPI"; import { InstrumentInfo,SaveMessage } from "../../utils/Interface"; import { WaterfallFlow, Popup } from '@antmjs/vantui' import PopupAlert from "@/components/popup/popup-alert"; import "taro-ui/dist/style/components/button.scss"; // 按需引入 import "./detect.less"; import type CustomTabBar from "../../custom-tab-bar"; import PopupDrawer from "@/components/popup/popup-drawer"; export default class Detect extends Component { pageCtx = Taro.getCurrentInstance().page; constructor(props) { super(props); this.state = { name: "detect", isNotRegister: false, // 是否未注册 show: false, messageCount: Taro.getStorageSync("messageCount") || 0, isRegisterBoolean: false, carouselList: [], strategyList: [], isShow: false, messageInfo: '' }; } async onLoad() { } showInit = async () => { // 判断是否登录 let mobile = Taro.getStorageSync("mobile"); if (mobile) { this.setState({ isRegisterBoolean: true }); } }; componentDidMount() { } componentWillUnmount() { } componentDidShow() { const tabbar = Taro.getTabBar(this.pageCtx); tabbar?.setSelected(2); this.showInit() this.getCarouselList() this.getStrategyList() } componentDidHide() { } async initData() { } // 是否已注册 isRegister(type = "") { if (type === "addNewDevice") { Taro.setStorageSync("isInstrumentJump", "true"); // 判断是否点击新增设备按钮,用于信息完善页判断跳转逻辑 } else { Taro.setStorageSync("isInstrumentJump", "false"); // 重置 } if (!this.state.isRegisterBoolean) { this.alertRegister(); return false; } return true; } async getCarouselList() { let res = await InstrumentInfo.find.CarouselList(); this.setState({ carouselList: res.data.rows }) } async getStrategyList() { let res = await InstrumentInfo.find.StrategyList(); this.setState({ strategyList: res.data.rows }) } public alertRegister = () => { this.setState({ isNotRegister: true }); // 打开弹窗 }; gourl = async (e) => { console.log("添加新设备", e); const { url } = e.currentTarget.dataset; console.log(url); if (this.isRegister()) { if (url === "/instrument/pages/instrument/instrument") { let { data } = await InstrumentInfo.unbindingInstrumentInfoList(); console.log(data, "查看未绑定设备"); if (data.data.length === 0) { this.setState({ show: true, }); setTimeout(() => { this.setState({ show: false }); }, 1000); // 2秒后将 show 变量置为 false } else { go(url); } } else { console.log(url, 22222222); go(url); } } }; close() { this.setState({ isShow: false }) } onChange() { this.setState({ isShow: true }) } submit = () => { let { messageInfo } = this.state; if (messageInfo.length) { this.postSaveMessage(); this.close(); } else { msg("留言内容不能为空!"); // Toast_.fail({ // message: "留言内容不能为空!", // }); } }; postSaveMessage = async () => { let { messageInfo } = this.state; let params = { source: 1, messageInfo: messageInfo, }; let res = await SaveMessage(params); if (res.data.code === 200) { msg("提交成功!"); } else { msg("提交失败!"); } }; closeAlert = () => { this.setState({ isNotRegister: false }); }; onInputTextarea = (e) => { this.setState({ messageInfo: e.detail.value }); }; render() { let { isNotRegister, messageCount, carouselList, strategyList, isShow } = this.state; return ( {messageCount ? : ""} } transparent /> { carouselList.map(item => ( )) } {/* 产品共创 更多 { carouselList.map(item => ( )) } */} 产品攻略 { return ( {item.title} ) }} /> 留言箱 如果以上内容没能解决您的问题,或您有其他的建议,可以在留言箱给小助理留言噢! 点击留言 {/* 留言箱 提交 */} } confirmButtonText='提交' textAlgin='left' close={this.close} confirm={this.submit.bind(this)} /> ); } }