messageForm.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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" :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: 2,
  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. console.log(error)
  82. this.$refs.uTips.show({
  83. title: error.data.msg,
  84. type: 'warning',
  85. })
  86. })
  87. },
  88. },
  89. }
  90. </script>
  91. <style lang="less" scoped>
  92. page {
  93. width: 100%;
  94. height: 100%;
  95. }
  96. .container {
  97. width: 100%;
  98. height: 100%;
  99. float: left;
  100. box-sizing: border-box;
  101. background-color: #FFFFFF;
  102. padding-bottom: 70px;
  103. overflow-y: auto;
  104. .message-form {
  105. width: 100%;
  106. float: left;
  107. box-sizing: border-box;
  108. padding: 0 15px;
  109. background-color: #ffffff;
  110. /deep/.u-field {
  111. padding-left: 0px;
  112. padding-right: 0px;
  113. }
  114. /deep/.u-cell {
  115. padding-left: 0px;
  116. padding-right: 0px;
  117. }
  118. }
  119. .form-handle {
  120. width: calc(100% - 30px);
  121. height: 40px;
  122. position: fixed;
  123. bottom: 20px;
  124. left: 15px;
  125. .handle-custom {
  126. background-color: #51A539;
  127. /deep/button {
  128. background-color: #56a83a;
  129. }
  130. /deep/.u-btn--success--disabled {
  131. background-color: #74bd60 !important;
  132. }
  133. }
  134. }
  135. }
  136. </style>