comment.vue 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <template>
  2. <view style="padding: 20rpx;">
  3. <view class="box" style="padding: 50rpx 20rpx;">
  4. <uni-forms :modelValue="form" :rules="rules" ref="formRef" label-width="140rpx" label-align="right">
  5. <uni-forms-item label="订单编号">
  6. <navigator :url="'/pages/detail/detail?orderId=' + orders.id" style="padding: 15rpx 0; color: dodgerblue;">{{ orders.orderNo }}</navigator>
  7. </uni-forms-item>
  8. <uni-forms-item label="内容" name="content" required>
  9. <uni-easyinput type="textarea" v-model="form.content" placeholder="请输入内容" />
  10. </uni-forms-item>
  11. <uni-forms-item label="评分" name="star" required>
  12. <view style="padding: 15rpx 0;">
  13. <uni-rate v-model="form.star" />
  14. </view>
  15. </uni-forms-item>
  16. <view style="margin-top: 20rpx;">
  17. <button type="primary" class="my-button-primary" @click="save">提 交</button>
  18. </view>
  19. </uni-forms>
  20. </view>
  21. </view>
  22. </template>
  23. <script>
  24. export default {
  25. data() {
  26. return {
  27. form: {},
  28. rules: {
  29. content: {
  30. rules: [{
  31. required: true,
  32. errorMessage: '请填写内容',
  33. }]
  34. },
  35. star: {
  36. rules: [{
  37. required: true,
  38. errorMessage: '请评分',
  39. }]
  40. }
  41. },
  42. orders: {},
  43. user: uni.getStorageSync('xm-user')
  44. }
  45. },
  46. onLoad(option) {
  47. this.load(option.orderId)
  48. },
  49. methods: {
  50. save() {
  51. this.form.userId = this.user.id
  52. this.form.orderId = this.orders.id
  53. this.form.acceptId = this.orders.acceptId
  54. this.$request.post('/comment/add', this.form).then(res => {
  55. if (res.code === '200') {
  56. uni.showToast({
  57. icon: 'success',
  58. title: '操作成功'
  59. })
  60. } else {
  61. uni.showToast({
  62. icon: 'none',
  63. title: res.msg
  64. })
  65. }
  66. // 延时跳转
  67. setTimeout(() => {
  68. uni.navigateBack()
  69. }, 500)
  70. })
  71. },
  72. load(orderId) {
  73. this.$request.get('/orders/selectById/' + orderId).then(res => {
  74. this.orders = res.data || {}
  75. })
  76. }
  77. }
  78. }
  79. </script>
  80. <style>
  81. </style>