report.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  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="$u.throttle(submit, 1000)"></u-button>
  23. </view>
  24. </template>
  25. <script>
  26. import uploadImage from '@/components/ossutil/uploadFile.js';
  27. import permision from "@/js_sdk/wa-permission/permission.js";
  28. export default{
  29. data(){
  30. return{
  31. fileList1:[],
  32. content:"",
  33. textNumber:300,
  34. formData:{},
  35. fleetId:"",
  36. reportInfo:{},
  37. tipsShow:false,
  38. alertTitle:""
  39. }
  40. },
  41. onShow(){},
  42. onLoad(options){
  43. this.fleetId = options.id
  44. this.get_camera_permission()
  45. this.getList()
  46. },
  47. methods:{
  48. async get_camera_permission() {
  49. var photol=await permision.requestAndroidPermission("android.permission.CAMERA")
  50. if(photol == false){
  51. uni.showModal({
  52. title: '提示',
  53. content: '您已经关闭相册权限,去设置',
  54. success: function (res) {
  55. if (res.confirm) {
  56. permision.gotoAppPermissionSetting()
  57. // plus.runtime.openURL("app-settings:");
  58. } else if (res.cancel) {
  59. console.log('用户点击取消');
  60. }
  61. }
  62. });
  63. }
  64. },
  65. submit(){
  66. if (!this.reportInfo.content) {
  67. this.$refs.uToast.show({
  68. type: 'error',
  69. message: "请输入要举报的内容!",
  70. })
  71. return
  72. }
  73. if (this.reportInfo.content.length < 10) {
  74. this.$refs.uToast.show({
  75. type: 'error',
  76. message: "举报内容不能小于10个字!",
  77. })
  78. return
  79. }
  80. if (this.fileList1.length == 0) {
  81. this.$refs.uToast.show({
  82. type: 'error',
  83. message: "请上传图片!",
  84. })
  85. return
  86. }
  87. this.reportInfo.id = uni.getStorageSync("firstAuthentication").commonId
  88. this.reportInfo.name = uni.getStorageSync("firstAuthentication").driverName
  89. this.reportInfo.flag = 3
  90. this.alertTitle="确定要举报该车队"
  91. this.tipsShow = true
  92. },
  93. cancelClick(){
  94. this.tipsShow = false
  95. },
  96. confirmClick(){
  97. this.tipsShow = false
  98. this.$request.baseRequest('post', '/feedbackReport/api/addInfo', this.reportInfo).then(res => {
  99. if(res.code == 200){
  100. this.$refs.uToast.show({
  101. type: 'success',
  102. message: "队员删除成功!",
  103. complete() {
  104. uni.navigateBack({
  105. delta: 1
  106. });
  107. }
  108. })
  109. }else{
  110. this.$refs.uToast.show({
  111. type: 'error',
  112. message: res.message,
  113. })
  114. }
  115. })
  116. .catch(res => {
  117. uni.$u.toast(res.message);
  118. });
  119. },
  120. getList() {
  121. this.$request.baseRequest('get', '/fleetInfo/getFleetInfo', {
  122. id: this.fleetId
  123. }).then(res => {
  124. this.formData = res.data
  125. })
  126. .catch(res => {
  127. uni.$u.toast(res.message);
  128. });
  129. },
  130. // 删除图片
  131. deletePic(event) {
  132. console.log(this[`fileList${event.name}`])
  133. this[`fileList${event.name}`].splice(event.index, 1)
  134. },
  135. // 新增图片
  136. async afterRead(event) {
  137. // 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式
  138. let lists = [].concat(event.file)
  139. let fileListLen = this[`fileList${event.name}`].length
  140. lists.map((item) => {
  141. this[`fileList${event.name}`].push({
  142. ...item,
  143. status: 'uploading',
  144. message: '上传中'
  145. })
  146. })
  147. for (let i = 0; i < lists.length; i++) {
  148. const result = await this.uploadFilePromise(lists[i].url)
  149. let item = this[`fileList${event.name}`][fileListLen]
  150. this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
  151. status: 'success',
  152. message: '',
  153. url: result
  154. }))
  155. fileListLen++
  156. }
  157. },
  158. uploadFilePromise(url) {
  159. uploadImage('image',url, 'appData/',
  160. result => {
  161. // 上传成功回调函数
  162. this.reportInfo.url = result
  163. }
  164. )
  165. },
  166. }
  167. }
  168. </script>
  169. <style lang="scss" scoped>
  170. .center{
  171. padding: 30rpx;
  172. }
  173. .form_css {
  174. width: 100%;
  175. display: flex;
  176. margin: 30rpx 0;
  177. height: 80rpx;
  178. border-bottom: 1px solid #eeeeee;
  179. .left-text {
  180. width: 50%;
  181. text-align: left;
  182. }
  183. .right-text {
  184. width: 50%;
  185. justify-content: flex-end;
  186. display: flex;
  187. text-align: right;
  188. color: #363636;
  189. // font-size: 28rpx;
  190. .img_css{
  191. margin: 0 10rpx;
  192. }
  193. }
  194. }
  195. .textarea{
  196. margin: 30rpx 0;
  197. }
  198. .btn_css{
  199. margin-top: 40rpx;
  200. }
  201. </style>