report.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. <template>
  2. <view class="center">
  3. <view class="flex row form_css">
  4. <view class="left-text">被举报车队</view>
  5. <view class="right-text">
  6. <u-avatar :src="formData.coverUrl" size="24" class="img_css"></u-avatar>
  7. <view class="">
  8. {{formData.fleetName}}
  9. </view>
  10. </view>
  11. </view>
  12. <!-- <view class="">被举报车队</view> -->
  13. <view class="">举报信息</view>
  14. <view class="textarea">
  15. <u--textarea v-model="reportInfo.content" placeholder="输入要举报的内容,10-300字" maxlength="300" height="100"></u--textarea>
  16. </view>
  17. <u-upload class="uview-upload" :fileList="fileList1" @afterRead="afterRead($event)" @delete="deletePic"
  18. name="1" multiple :maxCount="1" style="z-index: 9999;"></u-upload>
  19. <u-toast ref="uToast"></u-toast>
  20. <u-modal :show="tipsShow" :title="alertTitle" :closeOnClickOverlay='true' :showCancelButton='true'
  21. confirmColor='#2772FB' @confirm="confirmClick" @close="cancelClick" @cancel="cancelClick"></u-modal>
  22. <u-button type="primary" text="提交" class="btn_css" @click="submit"></u-button>
  23. </view>
  24. </template>
  25. <script>
  26. import uploadImage from '@/components/ossutil/uploadFile.js';
  27. export default{
  28. data(){
  29. return{
  30. fileList1:[],
  31. content:"",
  32. textNumber:300,
  33. formData:{},
  34. fleetId:"",
  35. reportInfo:{},
  36. tipsShow:false,
  37. alertTitle:""
  38. }
  39. },
  40. onShow(){},
  41. onLoad(options){
  42. this.fleetId = options.id
  43. this.getList()
  44. },
  45. methods:{
  46. submit(){
  47. if (!this.reportInfo.content) {
  48. this.$refs.uToast.show({
  49. type: 'error',
  50. message: "请输入要举报的内容!",
  51. })
  52. return
  53. }
  54. if (this.reportInfo.content.length < 10) {
  55. this.$refs.uToast.show({
  56. type: 'error',
  57. message: "举报内容不能小于10个字!",
  58. })
  59. return
  60. }
  61. if (this.fileList1.length == 0) {
  62. this.$refs.uToast.show({
  63. type: 'error',
  64. message: "请上传图片!",
  65. })
  66. return
  67. }
  68. this.reportInfo.id = uni.getStorageSync("firstAuthentication").commonId
  69. this.reportInfo.name = uni.getStorageSync("firstAuthentication").driverName
  70. this.reportInfo.flag = 3
  71. this.alertTitle="确定要举报该车队"
  72. this.tipsShow = true
  73. },
  74. cancelClick(){
  75. this.tipsShow = false
  76. },
  77. confirmClick(){
  78. this.tipsShow = false
  79. this.$request.baseRequest('post', '/feedbackReport/api/addInfo', this.reportInfo).then(res => {
  80. if(res.code == 200){
  81. this.$refs.uToast.show({
  82. type: 'success',
  83. message: "队员删除成功!",
  84. complete() {
  85. uni.navigateBack({
  86. delta: 1
  87. });
  88. }
  89. })
  90. }else{
  91. this.$refs.uToast.show({
  92. type: 'error',
  93. message: res.message,
  94. })
  95. }
  96. })
  97. .catch(res => {
  98. uni.$u.toast(res.message);
  99. });
  100. },
  101. getList() {
  102. this.$request.baseRequest('get', '/fleetInfo/getFleetInfo', {
  103. id: this.fleetId
  104. }).then(res => {
  105. this.formData = res.data
  106. })
  107. .catch(res => {
  108. uni.$u.toast(res.message);
  109. });
  110. },
  111. // 删除图片
  112. deletePic(event) {
  113. console.log(this[`fileList${event.name}`])
  114. this[`fileList${event.name}`].splice(event.index, 1)
  115. },
  116. // 新增图片
  117. async afterRead(event) {
  118. // 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式
  119. let lists = [].concat(event.file)
  120. let fileListLen = this[`fileList${event.name}`].length
  121. lists.map((item) => {
  122. this[`fileList${event.name}`].push({
  123. ...item,
  124. status: 'uploading',
  125. message: '上传中'
  126. })
  127. })
  128. for (let i = 0; i < lists.length; i++) {
  129. const result = await this.uploadFilePromise(lists[i].url)
  130. let item = this[`fileList${event.name}`][fileListLen]
  131. this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
  132. status: 'success',
  133. message: '',
  134. url: result
  135. }))
  136. fileListLen++
  137. }
  138. },
  139. uploadFilePromise(url) {
  140. uploadImage('image',url, 'appData/',
  141. result => {
  142. // 上传成功回调函数
  143. this.reportInfo.url = result
  144. }
  145. )
  146. },
  147. }
  148. }
  149. </script>
  150. <style lang="scss" scoped>
  151. .center{
  152. padding: 30rpx;
  153. }
  154. .form_css {
  155. width: 100%;
  156. display: flex;
  157. margin: 30rpx 0;
  158. height: 80rpx;
  159. border-bottom: 1px solid #eeeeee;
  160. .left-text {
  161. width: 50%;
  162. text-align: left;
  163. }
  164. .right-text {
  165. width: 50%;
  166. justify-content: flex-end;
  167. display: flex;
  168. text-align: right;
  169. color: #363636;
  170. // font-size: 28rpx;
  171. .img_css{
  172. margin: 0 10rpx;
  173. }
  174. }
  175. }
  176. .textarea{
  177. margin: 30rpx 0;
  178. }
  179. .btn_css{
  180. margin-top: 40rpx;
  181. }
  182. </style>