imageGalleryPage.vue 7.5 KB

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