messageForm.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. <template>
  2. <view class="container">
  3. <view class="message-form">
  4. <u-cell-group :border="false">
  5. <u-field type="textarea" placeholder="请输入留言" v-model="formData.leaMsgContent" label-width="0"></u-field>
  6. </u-cell-group>
  7. <!-- <u-upload :action="uploadUrl" max-count="5" :form-data="uploadData" @on-success="uploadSuccess" @on-error="uploadError" @on-remove="uploadRemove"></u-upload> -->
  8. </view>
  9. <view class="form-handle">
  10. <u-button type="success" shape="circle" :ripple="true" @click="submitData" class="handle-custom">发布</u-button>
  11. </view>
  12. <u-top-tips ref="uTips"></u-top-tips>
  13. </view>
  14. </template>
  15. <script>
  16. const NET = require('@/utils/request')
  17. const API = require('@/config/api')
  18. export default {
  19. data() {
  20. return {
  21. formData: {
  22. orderId: '',
  23. tenantCode: '',
  24. leaMsgContent: '',
  25. },
  26. uploadData: {
  27. folderId: 0,
  28. },
  29. uploadUrl: '',
  30. fileList: []
  31. }
  32. },
  33. onLoad(options) {
  34. this.uploadUrl = API.uploadFile
  35. this.formData.orderId = options.orderId
  36. this.formData.tenantCode = options.tenantCode
  37. },
  38. methods: {
  39. // 文件上传成功回调
  40. uploadSuccess(res, index, lists, name) {
  41. this.fileList.push(res.data.url)
  42. this.$refs.uTips.show({
  43. title: '文件上传成功',
  44. type: 'success',
  45. })
  46. return true
  47. },
  48. // 文件上传失败回调
  49. uploadError(res, index, lists, name) {
  50. this.$refs.uTips.show({
  51. title: '文件上传失败',
  52. type: 'warning',
  53. })
  54. },
  55. // 移除文件回调
  56. uploadRemove(index, lists, name) {
  57. this.fileList.splice(index, 1)
  58. },
  59. // 提交数据
  60. submitData() {
  61. NET.request(API.addMessage, {
  62. ...this.formData,
  63. leaMsgType: 1,
  64. mid: uni.getStorageSync("userData").userId,
  65. orderLeaImgResVOs: this.fileList.map((site, index) => {
  66. return {
  67. fileType: 1,
  68. imgUrl: site,
  69. sortOrder: index + 1,
  70. }
  71. })
  72. }, 'POST').then(res => {
  73. this.$refs.uTips.show({
  74. title: '留言成功',
  75. type: 'success',
  76. })
  77. setTimeout(() => {
  78. uni.navigateBack()
  79. }, 1000)
  80. }).catch(error => {
  81. this.$refs.uTips.show({
  82. title: error.data.msg,
  83. type: 'warning',
  84. })
  85. })
  86. },
  87. },
  88. }
  89. </script>
  90. <style lang="less" scoped>
  91. page {
  92. width: 100%;
  93. height: 100%;
  94. }
  95. .container {
  96. width: 100%;
  97. height: 100%;
  98. float: left;
  99. box-sizing: border-box;
  100. background-color: #FFFFFF;
  101. padding-bottom: 70px;
  102. overflow-y: auto;
  103. .message-form {
  104. width: 100%;
  105. float: left;
  106. box-sizing: border-box;
  107. padding: 0 15px;
  108. background-color: #ffffff;
  109. /deep/.u-field {
  110. padding-left: 0px;
  111. padding-right: 0px;
  112. }
  113. /deep/.u-cell {
  114. padding-left: 0px;
  115. padding-right: 0px;
  116. }
  117. }
  118. .form-handle {
  119. width: calc(100% - 30px);
  120. height: 40px;
  121. position: fixed;
  122. bottom: 20px;
  123. left: 15px;
  124. .handle-custom {
  125. background-color: #51A539;
  126. /deep/button {
  127. background-color: #56a83a;
  128. }
  129. /deep/.u-btn--success--disabled {
  130. background-color: #74bd60 !important;
  131. }
  132. }
  133. }
  134. }
  135. </style>