import CustomNav from '@/components/CustomNav'
import Taro from '@tarojs/taro'
import withLayout from '@/layouts'
import { Button} from '@tarojs/components'
import './style.less'
import {saveFeedback} from '@/services/mine'


export default withLayout((props) => {
  const { person } = props
  const {personId}=person
  const back = () => {
    Taro.navigateBack()
  }
  const submit=()=>{
    var content=document.getElementById('content').value
    if(content!=''){
      saveFeedback({
        personId,
        content
      }).then(()=>{
        // 成功返回一个模态框提醒用户
        wx.showModal({
          title: '提示',
          content: '反馈成功',
          showCancel:false,
          success (res) {
            if (res.confirm) {
              back()
            }
          }
        })             
      })
    }
    else{
      wx.showToast({
        title: '请重新输入',
        icon: 'none',
        duration: 2000
      }) 
    }
  }
  return (
    <view className='box-content'>
      <CustomNav title='联系我们' />
      <view style={{padding:'60rpx 30rpx'}}>
      <view class='section'>
        <textarea placeholder='请输入您的建议或意见!' id='content' />
      </view>
      <view className='button-info'>
        <Button className='button-box' onClick={submit}>提交</Button>
        <Button className='button-box-Cancel' onClick={back} >取消</Button>
      </view>
      </view>
    </view>
  )
})
