|
@@ -0,0 +1,171 @@
|
|
|
+import React, { Component } from "react";
|
|
|
+import Taro from "@tarojs/taro";
|
|
|
+import { Text, View } from "@tarojs/components";
|
|
|
+import { AtSearchBar, AtListItem, AtButton, AtIcon } from "taro-ui";
|
|
|
+import { getUserByName, getOrderByUid } from "../../utils/servers/servers";
|
|
|
+import "taro-ui/dist/style/components/search-bar.scss";
|
|
|
+import "taro-ui/dist/style/components/button.scss";
|
|
|
+import "taro-ui/dist/style/components/icon.scss";
|
|
|
+import "taro-ui/dist/style/components/list.scss";
|
|
|
+import "taro-ui/dist/style/components/icon.scss";
|
|
|
+import ListBottomStart from "../../components/common/listBottomStart";
|
|
|
+
|
|
|
+// import "../drafts/index.less";
|
|
|
+
|
|
|
+class CompanyData extends Component {
|
|
|
+ constructor(props) {
|
|
|
+ super(props);
|
|
|
+ this.state = {
|
|
|
+ value: "",
|
|
|
+ list: [],
|
|
|
+ listState: "NO_DATA",
|
|
|
+ pageNo: 1,
|
|
|
+ listVisible: false,
|
|
|
+ };
|
|
|
+ this.onChange = this.onChange.bind(this);
|
|
|
+ this.getList = this.getList.bind(this);
|
|
|
+ }
|
|
|
+
|
|
|
+ componentDidMount() {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ onReachBottom() {
|
|
|
+ this.getList(this.state.value, this.state.pageNo + 1);
|
|
|
+ }
|
|
|
+
|
|
|
+ onChange(value, lv = true) {
|
|
|
+ this.setState({
|
|
|
+ value,
|
|
|
+ });
|
|
|
+ if (value.length < 2 && !lv) {
|
|
|
+ Taro.showToast({ title: "最少输入两个字符", icon: "none" });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (value.length < 4 && lv) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this.getList(value);
|
|
|
+ }
|
|
|
+
|
|
|
+ getList(value = this.state.value, pageNo = 1) {
|
|
|
+ this.setState({
|
|
|
+ listState: "LOADING",
|
|
|
+ });
|
|
|
+ getUserByName({
|
|
|
+ name: value,
|
|
|
+ type: 1,
|
|
|
+ pageNo: pageNo,
|
|
|
+ pageSize: 20,
|
|
|
+ })
|
|
|
+ .then((msg) => {
|
|
|
+ if (msg.error.length === 0) {
|
|
|
+ if (msg.data.totalCount === 0) {
|
|
|
+ this.setState({
|
|
|
+ listState: "NO_DATA",
|
|
|
+ });
|
|
|
+ } else if (
|
|
|
+ msg.data.totalCount === this.state.list.length &&
|
|
|
+ pageNo !== 1
|
|
|
+ ) {
|
|
|
+ Taro.showToast({ title: "没有更多数据了", icon: "none" });
|
|
|
+ this.setState({
|
|
|
+ listState: "NO_MORE_DATA",
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ if (
|
|
|
+ msg.data.totalCount ===
|
|
|
+ (pageNo === 1
|
|
|
+ ? msg.data.list
|
|
|
+ : this.state.list.concat(msg.data.list)
|
|
|
+ ).length
|
|
|
+ ) {
|
|
|
+ this.setState({
|
|
|
+ listState: "NO_MORE_DATA",
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.setState({
|
|
|
+ list:
|
|
|
+ pageNo === 1
|
|
|
+ ? msg.data.list
|
|
|
+ : this.state.list.concat(msg.data.list),
|
|
|
+ pageNo: msg.data.pageNo,
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ Taro.showToast({ title: msg.error[0].message, icon: "none" });
|
|
|
+ this.setState({
|
|
|
+ listState: msg.error[0].field === "403" ? "NO_DATA" : "RELOAD",
|
|
|
+ });
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .catch(() => {
|
|
|
+ this.setState({
|
|
|
+ listState: "RELOAD",
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ render() {
|
|
|
+ const { } = this.state
|
|
|
+ return (
|
|
|
+ <>
|
|
|
+ <AtSearchBar
|
|
|
+ placeholder="请输入企业名称"
|
|
|
+ showActionButton
|
|
|
+ value={this.state.value}
|
|
|
+ onChange={this.onChange}
|
|
|
+ onActionClick={() => {
|
|
|
+ this.setState({
|
|
|
+ listVisible: false,
|
|
|
+ });
|
|
|
+ this.onChange(this.state.value, false);
|
|
|
+ }}
|
|
|
+ onConfirm={() => {
|
|
|
+ this.onChange(this.state.value, false);
|
|
|
+ }}
|
|
|
+ onClear={() => {
|
|
|
+ this.setState({
|
|
|
+ value: "",
|
|
|
+ list: [],
|
|
|
+ listState: "NO_DATA",
|
|
|
+ pageNo: 1,
|
|
|
+ listVisible: false,
|
|
|
+ });
|
|
|
+ }}
|
|
|
+ />
|
|
|
+ <View>
|
|
|
+ {!this.state.listVisible &&
|
|
|
+ this.state.list.map((v, k) => (
|
|
|
+ <View key={k}>
|
|
|
+ <AtListItem
|
|
|
+ title={v.name}
|
|
|
+ arrow="right"
|
|
|
+ iconInfo={{ size: 25, color: "#000000", value: "bookmark" }}
|
|
|
+ onClick={() => {
|
|
|
+ let pages = Taro.getCurrentPages();
|
|
|
+ let prevPage = pages[pages.length - 2];
|
|
|
+ prevPage.setData({
|
|
|
+ userNames: v.name,
|
|
|
+ });
|
|
|
+ Taro.navigateBack({
|
|
|
+ delta: 1
|
|
|
+ })
|
|
|
+ }}
|
|
|
+ />
|
|
|
+ </View>
|
|
|
+ ))}
|
|
|
+ <ListBottomStart
|
|
|
+ state={this.state.listState}
|
|
|
+ reload={() => {
|
|
|
+ this.onChange(this.state.value);
|
|
|
+ }}
|
|
|
+ />
|
|
|
+ </View>
|
|
|
+ </>
|
|
|
+ );
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+export default CompanyData;
|