imageGalleryPage.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. <template>
  2. <view class="page">
  3. <u-sticky zIndex="999" customNavHeight="0">
  4. <uni-NavBar headerTitle="报价详情" background="#fff" borderBottom="1rpx solid #eee" :isSlot="false"
  5. :rightSlot="true">
  6. </uni-NavBar>
  7. </u-sticky>
  8. <view class="content">
  9. <imageDataVue @previewImage="previewImage" @delCheckImage="delCheckImage" :imageCollection="imageCollection"
  10. @chooseImage="chooseImage" :isUploadEnabled='true'></imageDataVue>
  11. </view>
  12. <view class="footer dis a-c j-s">
  13. <view class="btn btns dis a-c j-c" @click="cancel">
  14. 取消
  15. </view>
  16. <view class="btn dis a-c j-c " @click="submit">
  17. 确定
  18. </view>
  19. </view>
  20. <!-- 图片预览组件 -->
  21. <previewImage ref="previewImage" :opacity="0.8" :circular="true" :imgs="previewImgs"></previewImage>
  22. </view>
  23. </template>
  24. <script>
  25. import store from '@/store';
  26. import previewImage from '@/components/previewImage/previewImage.vue'; //引用插件
  27. import imageDataVue from './modules/imageData.vue'; //影像信息
  28. export default {
  29. components: {
  30. previewImage,
  31. imageDataVue
  32. },
  33. data() {
  34. return {
  35. modificationFlag: false, //影像修改标识
  36. previewImgs: [], //图片预览数组
  37. carImageListId: [], //车
  38. ownerImageListId: [], //车主
  39. policyHolderImageListId: [], //投保人
  40. insuredPersonImageListId: [], //被保人
  41. imageCollection: {
  42. imgList1: [],
  43. imgList2: [],
  44. imgList3: [],
  45. imgList4: [],
  46. imgList5: [],
  47. imgList6: [],
  48. imgList7: [],
  49. imgList8: [],
  50. },
  51. }
  52. },
  53. onShow() {
  54. },
  55. async onLoad(options) {
  56. if (options) {
  57. await this.imageEcho(options.quoteNo) // 影像获取
  58. console.log(this.imageCollection);
  59. }
  60. },
  61. methods: {
  62. //取消
  63. cancel() {
  64. uni.navigateBack(-1)
  65. },
  66. //确定
  67. submit() {
  68. let pages = getCurrentPages(); //获取所有页面栈实例列表
  69. let nowPage = pages[pages.length - 1]; //当前页页面实例
  70. let prevPage = pages[pages.length - 2]; //上一页页面实例
  71. if (this.modificationFlag) { //修改后替换上级页面内容
  72. prevPage.$vm.modificationFlag = this.modificationFlag; //修改影像标识
  73. prevPage.$vm.carImageListId = this.carImageListId;
  74. prevPage.$vm.ownerImageListId = this.ownerImageListId;
  75. prevPage.$vm.policyHolderImageListId = this.policyHolderImageListId;
  76. prevPage.$vm.insuredPersonImageListId = this.insuredPersonImageListId;
  77. }
  78. uni.navigateBack(-1)
  79. },
  80. //删除图片
  81. delCheckImage(param, IdList, srcList) {
  82. this[IdList].map((ele, index) => {
  83. if (param.imageId === ele.imageId) {
  84. this[IdList].splice(index, 1);
  85. }
  86. return ele;
  87. });
  88. this[srcList].map((ele, index) => {
  89. if (param.imageId === ele.imageId) {
  90. this[srcList].splice(index, 1);
  91. }
  92. return ele;
  93. });
  94. },
  95. //影像预览
  96. previewImage(e, type) {
  97. this.previewImgs = this.imageCollection[type];
  98. var current = e;
  99. this.$refs.previewImage.open(current); // 传入当前选中的图片地址或序号
  100. },
  101. async chooseImage(type, imageIdList, imgurl) {
  102. let [chooseImageErr, chooseImageRes] = await uni.chooseImage({
  103. count: 1,
  104. sizeType: ['compressed']
  105. });
  106. if (chooseImageRes) {
  107. let size = chooseImageRes.tempFiles[0].size / 1024 / 1024 < 5;
  108. if (!size) {
  109. this.$refs.uToast.show({
  110. title: '上传图片大小不能超过 5MB!',
  111. type: 'error',
  112. })
  113. return false
  114. };
  115. uni.uploadFile({
  116. url: this.$base.baseUrl + '/file/upload',
  117. filePath: chooseImageRes.tempFilePaths[0],
  118. name: "file",
  119. formData: {
  120. 'type': 'image',
  121. },
  122. header: {
  123. Authorization: store.state.token,
  124. system_code: store.state.system_code ? store.state.system_code : ''
  125. },
  126. success: async (imgRes) => {
  127. let data = JSON.parse(imgRes.data);
  128. if (data.code == "200") {
  129. if (this[imageIdList].some(v => v.imageCode == type)) {
  130. this[imageIdList].map(val => {
  131. if (val.imageCode == type) {
  132. val.imageBase64List[0].imageId = data.data.id;
  133. }
  134. })
  135. } else {
  136. this[imageIdList].push({
  137. imageBase64List: [{
  138. imageId: data.data.id
  139. }],
  140. imageCode: type,
  141. })
  142. }
  143. this.imageCollection[imgurl].push(data.data);
  144. this.modificationFlag = true;
  145. }
  146. }
  147. })
  148. }
  149. },
  150. //影像查询
  151. async imageEcho(quotenos) {
  152. this.imageCollection = {
  153. imgList1: [],
  154. imgList2: [],
  155. imgList3: [],
  156. imgList4: [],
  157. imgList5: [],
  158. imgList6: [],
  159. imgList7: [],
  160. imgList8: [],
  161. };
  162. let res = await this.$http.get('/order/taskImages/selectByQuoteNo?quoteNo=' + quotenos);
  163. if (res.code == "200") {
  164. res.data.images.forEach((keys) => {
  165. if (keys.downloadUrl) {
  166. switch (keys.imageType) {
  167. case 'C01':
  168. this.carImageListId.push({
  169. imageBase64List: [{
  170. imageId: keys.imageId
  171. }],
  172. imageCode: keys.imageType,
  173. })
  174. this.imageCollection.imgList1.push(keys);
  175. break;
  176. case 'D01':
  177. this.carImageListId.push({
  178. imageBase64List: [{
  179. imageId: keys.imageId
  180. }],
  181. imageCode: keys.imageType,
  182. })
  183. this.imageCollection.imgList2.push(keys);
  184. break;
  185. case 'C02':
  186. this.ownerImageListId.push({
  187. imageBase64List: [{
  188. imageId: keys.imageId
  189. }],
  190. imageCode: keys.imageType,
  191. })
  192. this.imageCollection.imgList3.push(keys);
  193. break;
  194. case 'D02':
  195. this.ownerImageListId.push({
  196. imageBase64List: [{
  197. imageId: keys.imageId
  198. }],
  199. imageCode: keys.imageType,
  200. })
  201. this.imageCollection.imgList4.push(keys);
  202. break;
  203. case 'C03':
  204. this.policyHolderImageListId.push({
  205. imageBase64List: [{
  206. imageId: keys.imageId
  207. }],
  208. imageCode: keys.imageType,
  209. })
  210. this.imageCollection.imgList5.push(keys);
  211. break;
  212. case 'D03':
  213. this.policyHolderImageListId.push({
  214. imageBase64List: [{
  215. imageId: keys.imageId
  216. }],
  217. imageCode: keys.imageType,
  218. })
  219. this.imageCollection.imgList6.push(keys);
  220. break;
  221. case 'C04':
  222. this.insuredPersonImageListId.push({
  223. imageBase64List: [{
  224. imageId: keys.imageId
  225. }],
  226. imageCode: keys.imageType,
  227. })
  228. this.imageCollection.imgList7.push(keys);
  229. break;
  230. case 'D04':
  231. this.insuredPersonImageListId.push({
  232. imageBase64List: [{
  233. imageId: keys.imageId
  234. }],
  235. imageCode: keys.imageType,
  236. })
  237. this.imageCollection.imgList8.push(keys);
  238. break;
  239. default:
  240. break;
  241. }
  242. }
  243. });
  244. }
  245. },
  246. }
  247. }
  248. </script>
  249. <style lang="scss" scoped>
  250. .content {
  251. padding: 30rpx 35rpx;
  252. box-sizing: border-box;
  253. }
  254. .footer {
  255. position: fixed;
  256. bottom: 0;
  257. left: 0;
  258. right: 0;
  259. padding: 25rpx 30rpx 55rpx;
  260. box-sizing: border-box;
  261. background: linear-gradient(0deg, #FFFFFF 0%, rgba(255, 254, 245, 0.7) 100%);
  262. border-radius: 0rpx 0rpx 0rpx 0rpx;
  263. backdrop-filter: blur(12rpx);
  264. .btn {
  265. width: 100%;
  266. background: #FDE935;
  267. padding: 25rpx 20rpx;
  268. box-sizing: border-box;
  269. border-radius: 58rpx 58rpx 58rpx 58rpx;
  270. font-size: 36rpx;
  271. color: #1F1F1F;
  272. margin: 0 10rpx;
  273. }
  274. //操作按钮特殊样式
  275. .btns {
  276. background: rgba(253, 233, 53, 0.2);
  277. border: 1rpx solid #FDE935;
  278. padding: 22rpx 20rpx;
  279. }
  280. }
  281. </style>