index.jsx 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. import { useState } from 'react'
  2. import ButtontWX from '@/components/ButtontWX'
  3. import { Textarea, View } from '@tarojs/components'
  4. import Taro from '@tarojs/taro'
  5. import starOn from '@/assets/icons/comm/starOn.png'
  6. import starOff from '@/assets/icons/comm/starOff.png'
  7. import Popup from '@/components/Popup'
  8. // import { saveEvaluate } from '@/services/mine'
  9. import { orderEvaluation } from '@/services/order'
  10. import './style.less'
  11. export default (props) => {
  12. const { showCutover, maskClosable, orderId, onClose, goBACK } = props
  13. const scoreList = new Array(5).fill(0)
  14. const [textAreaCentent, setTextAreaCentent] = useState('')
  15. const [evaluate, setEvaluate] = useState({
  16. sweetScore: 0,
  17. })
  18. const [kwCollectNub, setkwCollectNub] = useState(0)
  19. const kwChange = (e, val) => {
  20. e.stopPropagation();
  21. setkwCollectNub(val + 1)
  22. console.log("🚀 ~ file: index.jsx ~ line 49 ~ kwChange ~ val", e, val + 1)
  23. setEvaluate({ sweetScore: val + 1, })
  24. }
  25. const ButtonCancel = () => {
  26. onClose()
  27. }
  28. const ButtonOK = (e) => {
  29. if (evaluate.sweetScore == 0) {
  30. Taro.showToast({
  31. title: '您未评价哦',
  32. icon: 'none'
  33. })
  34. return;
  35. }
  36. else {
  37. orderEvaluation({ orderId: orderId, score: kwCollectNub, content: textAreaCentent }).then(() => {
  38. Taro.showToast({
  39. title: '评价成功',
  40. icon: 'success',
  41. duration: 2000
  42. }).then(() => {
  43. setTimeout(() => {
  44. onClose()
  45. }, 500);
  46. })
  47. })
  48. }
  49. }
  50. return (
  51. <>
  52. {
  53. showCutover ? <View className='modelBack' >
  54. <View className='assessModel-box'>
  55. <view className='item-center-Number' >
  56. <view className='card-box-star'>
  57. <text className='card-box-star-text' >满意度:</text>
  58. {
  59. scoreList.map((_, index) => {
  60. const src = index < kwCollectNub ? starOn : starOff
  61. return (
  62. <image className='card-star-image' key={index} src={src} onClick={(e) => kwChange(e, index)} />
  63. )
  64. })
  65. }
  66. </view>
  67. </view>
  68. <Textarea placeholder='请输入评价内容' onInput={(e) => setTextAreaCentent(e.detail.value)} />
  69. <View className='bottomButtomBox'>
  70. <ButtontWX onClick={ButtonOK} butText='提交' butWidth={80} butHeight={34} butFontSize={16} butBorderRadius={0} />
  71. </View>
  72. </View>
  73. </View> : <View></View>
  74. }
  75. </>
  76. )
  77. }