index.jsx 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. import React, { useEffect, useMemo, useState, useRef } from 'react'
  2. import Taro from '@tarojs/taro'
  3. import './index.scss'
  4. import { View, Text, Input, Image } from '@tarojs/components'
  5. import ContainerLayout from '../../compents/container/index'
  6. import Tab from '../../compents/tab/index'
  7. import Layout from '../../layout/index'
  8. const house = (props) => {
  9. const [list, setList] = useState([])
  10. const [radioHouse, setRadioHouse] = useState()
  11. const ref = useRef();
  12. useEffect(() => {
  13. ref.current = 3;
  14. });
  15. const radioHouseState = useMemo(() => props.radioHouseState, [props.radioHouseState])
  16. wx.setNavigationBarTitle({
  17. title: '民宿房源管理'
  18. })
  19. console.log(props, radioHouseState)
  20. useEffect(() => {
  21. setList([
  22. {
  23. id: 1,
  24. name: 'zhou',
  25. phone: '177',
  26. user: {
  27. name: '张三',
  28. phone: '17777777777',
  29. wxid: 'hhh',
  30. number: '3'
  31. }
  32. },
  33. {
  34. id: 2,
  35. name: 'zhou',
  36. phone: '177',
  37. user: {
  38. name: '张三',
  39. phone: '17777777777',
  40. wxid: 'hhh',
  41. number: '3',
  42. user: {
  43. name: '张三',
  44. phone: '17777777777',
  45. wxid: 'hhh',
  46. number: '3'
  47. }
  48. }
  49. },
  50. {
  51. id: 3,
  52. name: 'zhou',
  53. phone: '177',
  54. user: {
  55. name: '张三',
  56. phone: '17777777777',
  57. wxid: 'hhh',
  58. number: '3',
  59. user: {
  60. name: '张三',
  61. phone: '17777777777',
  62. wxid: 'hhh',
  63. number: '3'
  64. }
  65. }
  66. }
  67. ])
  68. }, [])
  69. const onDelete = (row) => {
  70. Taro.showModal({
  71. title: '确定删除该标签组吗?',
  72. content: row.user.name,
  73. cancelColor:'#d2d2d2',
  74. confirmColor:"#274191",
  75. success: function (res) {
  76. if (res.confirm) {
  77. console.log('用户点击确定')
  78. Taro.showModal({
  79. title: `改标签组有${row.user.number}个标签仍在使用。请先清空标签,再删除标签组`,
  80. showCancel:false,
  81. // cancelColor:'#d2d2d2',
  82. confirmColor:"#274191",
  83. success: function (res) {
  84. if (res.confirm) {
  85. console.log('用户点击确定')
  86. } else if (res.cancel) {
  87. console.log('用户点击取消')
  88. }
  89. }
  90. })
  91. } else if (res.cancel) {
  92. console.log('用户点击取消')
  93. }
  94. }
  95. })
  96. }
  97. return <View className='account'>
  98. <Layout>
  99. {list.map((x, index) => {
  100. return <View className='account-view'>
  101. <Text className='account-view-title'>标签组编号:{index + 1}</Text>
  102. <ContainerLayout className='account-view-card'>
  103. <View className='top' onClick={() => { if (!radioHouseState) Taro.navigateTo({ url: `/pages/house/index?=${x.id}` }) }}>
  104. <View>标签组名称:{x.user.name}</View>
  105. <View>房源数:{x.user.name}</View>
  106. </View>
  107. <View className='bottom'>
  108. <Text onClick={() => { Taro.navigateTo({ url: `/pages/label/edit/index?=${x.id}` }) }}>编辑</Text>
  109. <Text onClick={()=>onDelete(x)}>删除</Text>
  110. </View>
  111. </ContainerLayout>
  112. </View>
  113. })}
  114. </Layout>
  115. {/* onClick={(e)=>(e) */}
  116. <Tab value={['+新增标签组']} color='#ffffff' onClick={() => { Taro.navigateTo({ url: `/pages/label/edit/index` }) }} ></Tab>
  117. </View>
  118. }
  119. export default house