Commit 30999c1ba75be7ebd3ce1679a63b72aff8be862c
Merge branch 'f-dev' into 'main'
fix:修复意见反馈图片上传大小 See merge request huang/thingskit-app!55
Showing
5 changed files
with
39 additions
and
15 deletions
| @@ -217,6 +217,7 @@ export default { | @@ -217,6 +217,7 @@ export default { | ||
| 217 | <style lang="scss" scoped> | 217 | <style lang="scss" scoped> |
| 218 | .command-record { | 218 | .command-record { |
| 219 | padding: 0 30rpx; | 219 | padding: 0 30rpx; |
| 220 | + background: #f8f9fa; | ||
| 220 | .filter-button { | 221 | .filter-button { |
| 221 | font-size: 12px; | 222 | font-size: 12px; |
| 222 | width: 160rpx; | 223 | width: 160rpx; |
| @@ -31,7 +31,8 @@ | @@ -31,7 +31,8 @@ | ||
| 31 | <view class="info" style="margin-top: 15rpx;background: rgba(1, 1, 1, 0);"> | 31 | <view class="info" style="margin-top: 15rpx;background: rgba(1, 1, 1, 0);"> |
| 32 | <view class="info-contain"> | 32 | <view class="info-contain"> |
| 33 | <u-form-item label="图片" prop="feedbackInfo.images" borderBottom ref="item1"> | 33 | <u-form-item label="图片" prop="feedbackInfo.images" borderBottom ref="item1"> |
| 34 | - <u-upload :sizeType="compressed" :fileList="fileList1" @afterRead="afterRead" @delete="deletePic" name="1" multiple :maxCount="6"></u-upload> | 34 | + <u-upload :sizeType="compressed" :fileList="fileList1" |
| 35 | + @afterRead="afterRead" @delete="deletePic" name="1" multiple :maxCount="6"></u-upload> | ||
| 35 | </u-form-item> | 36 | </u-form-item> |
| 36 | </view> | 37 | </view> |
| 37 | </view> | 38 | </view> |
| @@ -89,12 +90,14 @@ export default { | @@ -89,12 +90,14 @@ export default { | ||
| 89 | 'feedbackInfo.phone': { | 90 | 'feedbackInfo.phone': { |
| 90 | type: 'number', | 91 | type: 'number', |
| 91 | min: 11, | 92 | min: 11, |
| 93 | + max:11, | ||
| 92 | message: '请填写手机或者手机格式错误', | 94 | message: '请填写手机或者手机格式错误', |
| 93 | trigger: ['blur', 'change'] | 95 | trigger: ['blur', 'change'] |
| 94 | }, | 96 | }, |
| 95 | 'feedbackInfo.qq': { | 97 | 'feedbackInfo.qq': { |
| 96 | type: 'number', | 98 | type: 'number', |
| 97 | - min: 8, | 99 | + min: 5, |
| 100 | + max:10, | ||
| 98 | message: '请填写qq或者qq格式错误', | 101 | message: '请填写qq或者qq格式错误', |
| 99 | trigger: ['blur', 'change'] | 102 | trigger: ['blur', 'change'] |
| 100 | }, | 103 | }, |
| @@ -134,25 +137,38 @@ export default { | @@ -134,25 +137,38 @@ export default { | ||
| 134 | let lists = [].concat(event.file); | 137 | let lists = [].concat(event.file); |
| 135 | let fileListLen = this[`fileList${event.name}`].length; | 138 | let fileListLen = this[`fileList${event.name}`].length; |
| 136 | lists.map(item => { | 139 | lists.map(item => { |
| 140 | + if(item.size>5242880){ | ||
| 141 | + this[`fileList${event.name}`].push({ | ||
| 142 | + ...item, | ||
| 143 | + status: 'error', | ||
| 144 | + message: '上传失败' | ||
| 145 | + }); | ||
| 146 | + }else{ | ||
| 137 | this[`fileList${event.name}`].push({ | 147 | this[`fileList${event.name}`].push({ |
| 138 | ...item, | 148 | ...item, |
| 139 | status: 'uploading', | 149 | status: 'uploading', |
| 140 | message: '上传中' | 150 | message: '上传中' |
| 141 | }); | 151 | }); |
| 152 | + } | ||
| 142 | }); | 153 | }); |
| 143 | for (let i = 0; i < lists.length; i++) { | 154 | for (let i = 0; i < lists.length; i++) { |
| 144 | - const result = await this.uploadFilePromise(lists[i].url); | ||
| 145 | - let item = this[`fileList${event.name}`][fileListLen]; | ||
| 146 | - this[`fileList${event.name}`].splice( | ||
| 147 | - fileListLen, | ||
| 148 | - 1, | ||
| 149 | - Object.assign(item, { | ||
| 150 | - status: 'success', | ||
| 151 | - message: '', | ||
| 152 | - url: result | ||
| 153 | - }) | ||
| 154 | - ); | ||
| 155 | - fileListLen++; | 155 | + const judgeImageSize=lists[0].size |
| 156 | + if(judgeImageSize>5242880){ | ||
| 157 | + return uni.$u.toast('图片限定5M') | ||
| 158 | + }else{ | ||
| 159 | + const result = await this.uploadFilePromise(lists[i].url); | ||
| 160 | + let item = this[`fileList${event.name}`][fileListLen]; | ||
| 161 | + this[`fileList${event.name}`].splice( | ||
| 162 | + fileListLen, | ||
| 163 | + 1, | ||
| 164 | + Object.assign(item, { | ||
| 165 | + status: 'success', | ||
| 166 | + message: '', | ||
| 167 | + url: result | ||
| 168 | + }) | ||
| 169 | + ); | ||
| 170 | + fileListLen++; | ||
| 171 | + } | ||
| 156 | } | 172 | } |
| 157 | }, | 173 | }, |
| 158 | uploadFilePromise(url) { | 174 | uploadFilePromise(url) { |
| @@ -174,12 +190,16 @@ export default { | @@ -174,12 +190,16 @@ export default { | ||
| 174 | formData: {}, | 190 | formData: {}, |
| 175 | success: res => { | 191 | success: res => { |
| 176 | setTimeout(() => { | 192 | setTimeout(() => { |
| 177 | - if (res) { | 193 | + if(res.statusCode===200){ |
| 194 | + if(res.data){ | ||
| 178 | let objImage = JSON.parse(res.data); | 195 | let objImage = JSON.parse(res.data); |
| 179 | if (this.feedbackData.feedbackInfo.images.length < 6) { | 196 | if (this.feedbackData.feedbackInfo.images.length < 6) { |
| 180 | this.feedbackData.feedbackInfo.images.push(objImage.fileStaticUri); | 197 | this.feedbackData.feedbackInfo.images.push(objImage.fileStaticUri); |
| 181 | } | 198 | } |
| 182 | resolve(res.data?.fileStaticUri); | 199 | resolve(res.data?.fileStaticUri); |
| 200 | + } | ||
| 201 | + }else{ | ||
| 202 | + return uni.$u.toast('图片上传失败') | ||
| 183 | } | 203 | } |
| 184 | }, 1000); | 204 | }, 1000); |
| 185 | } | 205 | } |