evaluateForm.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. <template>
  2. <view class="container">
  3. <view class="address-form">
  4. <u-cell-group :border="false">
  5. <u-cell-item title="评分" title-width="120" :arrow="false" :value-style="{textAlign: 'left'}">
  6. <u-rate v-model="formData.score" active-color="#FFAE21"></u-rate>
  7. </u-cell-item>
  8. <u-field type="textarea" placeholder="请对商品进行评价" v-model="formData.evaluateContent" label-width="0"></u-field>
  9. </u-cell-group>
  10. <u-upload :action="uploadUrl" :form-data="uploadData" @on-success="uploadSuccess" @on-error="uploadError" @on-remove="uploadRemove"></u-upload>
  11. </view>
  12. <view class="form-handle">
  13. <u-button type="success" shape="circle" :ripple="true" @click="submitData" class="handle-custom">提交</u-button>
  14. </view>
  15. <u-top-tips ref="uTips"></u-top-tips>
  16. </view>
  17. </template>
  18. <script>
  19. const NET = require('@/utils/request')
  20. const API = require('@/config/api')
  21. export default {
  22. data() {
  23. return {
  24. formData: {
  25. orderId: '',
  26. tenantCode: '',
  27. productIds: '',
  28. score: 5,
  29. evaluateContent: '',
  30. },
  31. uploadData: {
  32. folderId: 0,
  33. },
  34. uploadUrl: '',
  35. fileList: []
  36. }
  37. },
  38. onLoad(options) {
  39. this.uploadUrl = API.uploadFile
  40. this.formData.orderId = options.orderId
  41. this.formData.tenantCode = options.tenantCode
  42. this.formData.productIds = options.productIds
  43. },
  44. methods: {
  45. // 文件上传成功回调
  46. uploadSuccess(res, index, lists, name) {
  47. this.fileList.push(res.data.url)
  48. this.$refs.uTips.show({
  49. title: '文件上传成功',
  50. type: 'success',
  51. })
  52. return true
  53. },
  54. // 文件上传失败回调
  55. uploadError(res, index, lists, name) {
  56. this.$refs.uTips.show({
  57. title: '文件上传失败',
  58. type: 'warning',
  59. })
  60. },
  61. // 移除文件回调
  62. uploadRemove(index, lists, name) {
  63. this.fileList.splice(index, 1)
  64. },
  65. // 提交数据
  66. submitData() {
  67. NET.request(API.evaluateOrder, {
  68. ...this.formData,
  69. mid: uni.getStorageSync("userData").userId,
  70. nickname: uni.getStorageSync("userData").userName,
  71. evaluateImgs: this.fileList.map((site, index) => {
  72. return {
  73. imgUrl: site,
  74. sortOrder: index + 1,
  75. }
  76. })
  77. },
  78. 'POST').then(res => {
  79. this.$refs.uTips.show({
  80. title: '评价成功',
  81. type: 'success',
  82. })
  83. setTimeout(()=>{
  84. uni.reLaunch({
  85. url: '/pagesMain/orderList?type=5'
  86. });
  87. },1000)
  88. }).catch(error => {
  89. this.modalShow = false
  90. this.$refs.uTips.show({
  91. title: error.data.msg,
  92. type: 'warning',
  93. })
  94. })
  95. },
  96. },
  97. }
  98. </script>
  99. <style lang="less" scoped>
  100. page {
  101. width: 100%;
  102. height: 100%;
  103. }
  104. .container {
  105. width: 100%;
  106. height: 100%;
  107. float: left;
  108. box-sizing: border-box;
  109. background-color: #FFFFFF;
  110. padding-bottom: 70px;
  111. overflow-y: auto;
  112. .address-form {
  113. width: 100%;
  114. float: left;
  115. box-sizing: border-box;
  116. padding: 0 15px;
  117. background-color: #ffffff;
  118. /deep/.u-field {
  119. padding-left: 0px;
  120. padding-right: 0px;
  121. }
  122. /deep/.u-cell {
  123. padding-left: 0px;
  124. padding-right: 0px;
  125. }
  126. }
  127. .address-form-top {
  128. /deep/.u-cell_title {
  129. color: #999999;
  130. }
  131. /deep/.u-label-text {
  132. color: #999999;
  133. }
  134. }
  135. .address-form-bottom {
  136. margin-top: 10px;
  137. /deep/.u-cell_title {
  138. color: #333333;
  139. }
  140. /deep/.u-label-text {
  141. color: #333333;
  142. }
  143. }
  144. .form-handle {
  145. width: calc(100% - 30px);
  146. height: 40px;
  147. position: fixed;
  148. bottom: 20px;
  149. left: 15px;
  150. .handle-custom {
  151. background-color: #51A539;
  152. }
  153. }
  154. }
  155. </style>