evaluateForm.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  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" max-count="3" :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. uni.navigateTo({
  88. url: '/pagesMain/orderList?type=5'
  89. });
  90. },1000)
  91. }).catch(error => {
  92. this.modalShow = false
  93. this.$refs.uTips.show({
  94. title: error.data.msg,
  95. type: 'warning',
  96. })
  97. })
  98. },
  99. },
  100. }
  101. </script>
  102. <style lang="less" scoped>
  103. page {
  104. width: 100%;
  105. height: 100%;
  106. }
  107. .container {
  108. width: 100%;
  109. height: 100%;
  110. float: left;
  111. box-sizing: border-box;
  112. background-color: #FFFFFF;
  113. padding-bottom: 70px;
  114. overflow-y: auto;
  115. .address-form {
  116. width: 100%;
  117. float: left;
  118. box-sizing: border-box;
  119. padding: 0 15px;
  120. background-color: #ffffff;
  121. /deep/.u-field {
  122. padding-left: 0px;
  123. padding-right: 0px;
  124. }
  125. /deep/.u-cell {
  126. padding-left: 0px;
  127. padding-right: 0px;
  128. }
  129. }
  130. .address-form-top {
  131. /deep/.u-cell_title {
  132. color: #999999;
  133. }
  134. /deep/.u-label-text {
  135. color: #999999;
  136. }
  137. }
  138. .address-form-bottom {
  139. margin-top: 10px;
  140. /deep/.u-cell_title {
  141. color: #333333;
  142. }
  143. /deep/.u-label-text {
  144. color: #333333;
  145. }
  146. }
  147. .form-handle {
  148. width: calc(100% - 30px);
  149. height: 40px;
  150. position: fixed;
  151. bottom: 20px;
  152. left: 15px;
  153. .handle-custom {
  154. background-color: #51A539;
  155. /deep/button {
  156. background-color: #56a83a;
  157. }
  158. /deep/.u-btn--success--disabled {
  159. background-color: #74bd60 !important;
  160. }
  161. }
  162. }
  163. }
  164. </style>