jubao.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. <template>
  2. <view>
  3. <view class="Regular header-title">{{jubaolist.compName}}</view>
  4. <view class='content'>
  5. <view class='matter'>
  6. <view class="title Regular">举报事项<text style='color:#FB1E1E;'>*</text></view>
  7. <view style='position:relative;'>
  8. <textarea class='textarea Regular' maxlength="150" v-model='jubaolist.error' placeholder="请输入举报事项" placeholder-style="color:#AFB3BF;" />
  9. <view class='Regular words'>{{jubaolist.error.length}}/150个字</view>
  10. </view>
  11. </view>
  12. <view class="uploading">
  13. <view class="title Regular">上传图片</view>
  14. <upload :form-data="{companyId: pcUserInfo.compId,
  15. modelId: '',
  16. vesselId: ''}" class="upload" ref="upload" :action="action" :max-size="maxSize" :max-count="6"
  17. :size-type="['compressed']" :options="uploadOptions" @on-success="getImgUrl" @on-error="onError" @on-remove="onRemove"
  18. @on-uploaded="isAdd = true" :before-upload="filterFileType" @on-progress="onProgress"></upload>
  19. </view>
  20. </view>
  21. <view class="commitwrap">
  22. <view class='commit' @click='commit'>提交</view>
  23. </view>
  24. </view>
  25. </template>
  26. <script>
  27. import upload from '@/components/upload.vue';
  28. export default {
  29. components: {
  30. upload
  31. },
  32. data() {
  33. return {
  34. action: this.$uploadUrl,
  35. pcUserInfo :uni.getStorageSync('pcUserInfo'),
  36. maxSize: 50 * 1024 * 1024, //限制文件大小 50M
  37. btnLoading: false, //防止重复点击
  38. isAdd: true,
  39. imgUrls: [],
  40. status:'',
  41. fileList:[],
  42. jubaolist:{
  43. error:''
  44. },
  45. uploadOptions: {
  46. "text": "",
  47. "bgc": ""
  48. },
  49. }
  50. },
  51. onReady() {
  52. // 得到整个组件对象,内部图片列表变量为"lists"
  53. // this.fileList = this.$refs.uUpload.lists;
  54. },
  55. onLoad(options){
  56. this.jubaolist.id=options.id
  57. this.jubaolist.compName=options.compName
  58. },
  59. methods: {
  60. filterFileType(index, lists) {
  61. if (lists[index].fileType != 'jpg' && lists[index].fileType != 'png' && lists[index].fileType != 'gif') {
  62. lists.splice(index, 1);
  63. // 当前文件不支持
  64. uni.showModal({
  65. title: '暂不支持当前图片类型',
  66. showCancel: false
  67. });
  68. } else {
  69. this.isAdd = false;
  70. }
  71. },
  72. getImgUrl(res) {
  73. console.log(res)
  74. console.log('------------res-----------')
  75. this.imgUrls.push(res.data.appendixPath);
  76. },
  77. commit(){
  78. var that=this
  79. this.jubaolist.address=this.imgUrls.toString()
  80. uni.showModal({
  81. content: "确定提交举报内容?",
  82. showCancel: true,
  83. confirmText: '确定',
  84. success: function(res) {
  85. if (res.confirm) {
  86. that.$api.doRequest('post','/settledCompanyInfo/api/addSettledCompanyError',that.jubaolist).then(res => {
  87. if(res.data.code==200){
  88. uni.showToast({
  89. title: '感谢您的反馈,平台会尽快核实',
  90. icon: 'none',
  91. duration: 2000
  92. })
  93. uni.navigateBack({
  94. })
  95. }else{
  96. uni.showToast({
  97. title: res.message,
  98. icon: 'none',
  99. duration: 2000
  100. })
  101. }
  102. })
  103. }
  104. },
  105. })
  106. },
  107. //删除一张图片的回调,lists这是成功删除一个图片后,还剩余的图片集合
  108. onRemove(data, lists){
  109. //lists.length > 0说明删除之前已经上传了多余两张的图片
  110. if(lists.length > 0 ){
  111. var currentfileList = [];
  112. //遍历this.fileList 与剩余的lists进行匹配,来组成一个新的格式合适的剩余图片集合
  113. this.fileList.forEach((item, index)=>{
  114. lists.forEach((item1, index1)=>{
  115. if(item.name == JSON.parse(item1.response).name){
  116. currentfileList.push(item);
  117. }
  118. });
  119. })
  120. //删除后对图片集合及时冬天更新,即对this.fileList重新赋值
  121. this.fileList = currentfileList;
  122. }else{//说明删除之前只有一张图片,删除成功后把this.fileList清空即可
  123. this.fileList = [];
  124. }
  125. this.form.pictureUrl = JSON.stringify(this.fileList)
  126. //console.log("打印图片List:onRemove", this.fileList);
  127. }
  128. }
  129. }
  130. </script>
  131. <style lang="scss" scoped>
  132. page{
  133. background:#F5F6FA;
  134. }
  135. .header-title{
  136. margin:9.5px;
  137. padding:16.5px 12.5px;
  138. background:#fff;
  139. border-radius:10px;
  140. height:51px;
  141. }
  142. .content{
  143. padding:12.5px;margin:9px;
  144. background:#fff;
  145. border-radius:10px;
  146. }
  147. .matter .title{
  148. font-size:14px;
  149. margin-bottom:15px;
  150. }
  151. .uploading .title{
  152. font-size:14px;margin-top:13px;margin-bottom:13px;
  153. }
  154. .textarea{
  155. background:#F9F9FA;
  156. font-size:12px;
  157. padding:6.5px;
  158. width:326.5px;height:70px;
  159. border-radius:5px;
  160. }
  161. .words{
  162. font-size:10px;color:#AFB3BF;position: absolute;right:5px;
  163. bottom:8px;
  164. }
  165. .slot-btn{
  166. width: 70px;
  167. height: 70px;
  168. border-radius: 4px;
  169. border: 2px dashed #AFB3BF;
  170. text-align:center;
  171. }
  172. .commitwrap{
  173. position:fixed;bottom:0;left:0;
  174. width:100%;
  175. }
  176. .commit{
  177. background:#22C572;
  178. margin:10px 24px;
  179. text-align:center;
  180. height:46px;line-height:46px;
  181. color:#fff;
  182. font-size:17px;
  183. border-radius:20px;
  184. }
  185. /deep/.u-delete-icon{
  186. top:0;
  187. right:0;
  188. border-radius:0 0 0 15px;
  189. background:rgba(17, 26, 52, 0.5) !important;
  190. }
  191. </style>