123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. import React, { useEffect, useMemo, useState } from 'react'
  2. // import { useEffect, useLayoutEffect, useReducer, useState, useContext, useRef, useCallback, useMemo } from '@tarojs/taro'
  3. import Taro, { useDidShow, useShareAppMessage } from "@tarojs/taro";
  4. import { useSelector, } from 'react-redux'
  5. import { View, Input, Text, Image } from '@tarojs/components'
  6. import Layout from '../../layout/index'
  7. import Tab from '../../compents/tab/index'
  8. import Container from '../../compents/container/index'
  9. import locationicon from '../../assets/locationicon.png'
  10. import Tags from '../../compents/tags/index'
  11. import request from '../../util/request'
  12. import NoData from '@/compents/NoData'
  13. import './index.scss'
  14. // Page({
  15. // data: {
  16. // text: 'init data',
  17. // array: [{ msg: '1' }, { msg: '2' }]
  18. // }
  19. // })
  20. const index = (props) => {
  21. let [arrList, setArrList] = useState({})
  22. const [labelList, setLabelList] = useState([])
  23. const [list, setList] = useState([])
  24. useEffect(() => {
  25. // console.log(page, 'page')
  26. }, [])
  27. useDidShow(() => {
  28. getMateTagGroupList()
  29. })
  30. const getMateTagGroupList = () => {
  31. request({ url: '/taMateTagGroup', params: { pageSize: 1, pageSize: 9999 } }).then((res) => {
  32. const { records, ...page } = res.data.data
  33. setList(records)
  34. })
  35. }
  36. const onTabClick = (e) => {
  37. console.log(e, '111')
  38. setUserRole(e)
  39. }
  40. const onLabelChange = (e, index) => {
  41. let newArrArrList={
  42. ...arrList,
  43. [index]: e
  44. }
  45. setArrList(newArrArrList)
  46. console.log(newArrArrList, 'arrList')
  47. let newArr = Object.values(newArrArrList).reduce((pre, cur) => {
  48. return pre.concat(cur)
  49. }, [])
  50. setLabelList(newArr)
  51. console.log(newArr, 'newArr')
  52. // console.log(e, index, 'onLabelChange')
  53. // arrList[index] = e
  54. // // const [arrList, setArrList] = useState([[],[],[]])
  55. // setLabelList(arrList.flat())
  56. // console.log(arrList.flat(), 'labelList')
  57. }
  58. const onClick = () => {
  59. const query = labelList.map(x=>x.tagId).join(',')
  60. console.log(query, '', 'eeee')
  61. Taro.navigateTo({
  62. url: `/pages/imglist/index?query=${query}`
  63. })
  64. // Taro.showModal({
  65. // title: '修改成功',
  66. // content: '点击确认按钮,返回上级菜单',
  67. // showCancel: false,
  68. // success: function (res) {
  69. // if (res.confirm) {
  70. // console.log('用户点击确定')
  71. // Taro.navigateBack({
  72. // delta: 1
  73. // })
  74. // } else if (res.cancel) {
  75. // console.log('用户点击取消')
  76. // }
  77. // }
  78. // })
  79. }
  80. return <View className='material'>
  81. <Layout>
  82. <NoData nodata={!list.length}>
  83. {
  84. list.map((item,index) => {
  85. return <View className='material-card' key={index}>
  86. <Text>{item.name}</Text>
  87. <Tags list={item.taMateTagList} onChange={(e) => onLabelChange(e, index)} > </Tags>
  88. </View>
  89. })
  90. }
  91. </NoData>
  92. {/* <View className='inputstyle-view'>
  93. <Text className='title'>入住人数</Text>
  94. <Container className='inputstyle-view-card ' style={{ borderRadius: '20rpx', padding: '0 40rpx' }} >
  95. <Input placeholderClass='placeholderinput' className='input' type='text' placeholder='' />
  96. </Container>
  97. </View>
  98. <View className='inputstyle-view'>
  99. <Text className='title'>入住日期</Text>
  100. <Container className='inputstyle-view-card ' style={{ borderRadius: '20rpx', padding: '0 40rpx' }} >
  101. <Input placeholderClass='placeholderinput' className='input' type='text' placeholder='' />
  102. </Container>
  103. </View>
  104. <View className='inputstyle-view'>
  105. <Text className='title'>离店日期</Text>
  106. <Container className='inputstyle-view-card ' style={{ borderRadius: '20rpx', padding: '0 40rpx' }} >
  107. <Input placeholderClass='placeholderinput' className='input' type='text' placeholder='' />
  108. </Container>
  109. </View> */}
  110. </Layout>
  111. {/* className='addhousetab' */}
  112. <Tab pageState='3' value={['取消', '开始查询']} onClick={[(e) => setPageState('2'), (e) => onClick(e)]}></Tab>
  113. </View>
  114. }
  115. export default index