import { Component } from "react";
import Taro from "@tarojs/taro";
import { View } from "@tarojs/components";
import SearchBar from "../../components/index/SearchBar"; //搜索框
import "./index.less";
export default class Index extends Component {
  state = {};
  handleSearch = (value) => {
    if (value.trim() === '') {
      Taro.showToast({
        title: '请输入搜索内容',
        icon: 'none'
      })
      return;
    }else{
      Taro.navigateTo({
        url: `/pages/indexSub/searchList/index?keyword=${value}`
      })
    }
  }
  handleChange = (value) => {
    this.setState({ value });  // 更新状态
  }
  render() {
    return (
      <View className="index">
        {/* 搜索框 */}
        <SearchBar
          value={this.state.value}
          onChange={this.handleChange}
          onSearch={this.handleSearch}
          placeholder="搜索商品"
          disabled={false}
        />
      </View>
    );
  }
}
