import Taro from "@tarojs/taro"; import classnames from "classnames"; import { Component, PropsWithChildren, useEffect, useState } from "react"; import { Block, View, Text, Image, Input, Button, ScrollView, Swiper, SwiperItem, } from "@tarojs/components"; import "./index.less"; import Navbar from "../../components/navbar/navbar"; import { InstrumentInfo } from "../../utils/Interface"; import { go, msg, setStorageSync } from "../../utils/traoAPI"; export default class InstrumentManage extends Component { constructor(props) { super(props); this.state = { name: "InstrumentManage", userinfo: {}, imgUrl: "", imgUrl2: "", list: [], bindList: [], unBindList: [], page: 1, isback: false, //全局参数 appdata: {}, tipshow: false, FR200LIST: [], devinfo: {}, current: 0, }; } async onLoad() { this.initData(); } componentDidMount() { } componentWillUnmount() { } componentDidShow() { } componentDidHide() { } async initData() { this.bindingInstrumentList(); this.unbindingInstrumentInfoList(); } // 获取已绑定仪器列表 bindingInstrumentList = async () => { Taro.showLoading({ title: "请求中...", mask: true, }); let { data: res } = await InstrumentInfo.bindingInstrumentList(); Taro.hideLoading(); if (res.code === 200) { this.setState({ bindList: res.data }); } else { // 仪器列表失败todo } }; // 获取未绑定仪器列表 unbindingInstrumentInfoList = async () => { Taro.showLoading({ title: "请求中...", mask: true, }); let { data: res } = await InstrumentInfo.unbindingInstrumentInfoList(); Taro.hideLoading(); if (res.code === 200) { this.setState({ unBindList: res.data }); } else { // 仪器列表失败todo } }; goIntro(item) { let bindid = item.id; go("/pages/introduce/introduce?id=" + bindid); } goBind(item) { let bindid = item.id; go("/pages/instrument/instrument?id=" + bindid); } goBindInfo(item) { // let bindid = item.id; setStorageSync("instrument_detail", JSON.stringify(item)); go("/pages/instrument_detail/index"); } async lesgobuy(item) { console.log(item); // if (item.programs_json) { // item.programs_json = JSON.parse(item.programs_json); // // console.log(item.programs_json) // Taro.navigateToMiniProgram({ // appId: item.programs_json.buylink, // path: item.programs_json.buypath, // envVersion: "release", // success(res) { // // 打开成功 // }, // fail() {}, // }); // } else { // msg("暂无购买链接"); // } } render() { let { bindList, unBindList, current } = this.state; return ( {bindList.length > 0 && 我的设备 {bindList.map((item: any, index: number) => { return ( 已绑定 仪器介绍 {item.name} 查看绑定信息 ); })} {/* {bindList.map((item, index) => { if (item.status === 0) { return ( 已绑定 仪器介绍 {item.name} 查看绑定信息 ); } })} */} } 未绑定的仪器 {unBindList.map((item, index) => { if (item.status === 0) { return ( {item.name} 立即购买 前往绑定 ); } })} ); } }