upcard.vue 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <template>
  2. <view class="main">
  3. <view class="padding-lr-sm margin-top-sm">
  4. <text class="text-black">上传被保人证件照片</text>
  5. </view>
  6. <view class="padding-lr-sm text-sm text-gray margin-top-sm margin-bottom-sm">
  7. 办理家医计划业务需上传被保人清晰证件照片(身份证正反面,护照,户口簿选择其中一种即可)
  8. </view>
  9. <u-upload ref="uUpload" :action="action" max-count="2"></u-upload>
  10. <view class="cu-bar bg-white tabbar" style="position: fixed;bottom: 0;width: 100%;">
  11. <view class="submit" style="background-color: #0B73B9;color: white;" @click="upcard">
  12. 提交审核
  13. </view>
  14. </view>
  15. </view>
  16. </template>
  17. <script>
  18. export default {
  19. onLoad(options) {
  20. if (options.id) {
  21. this.archivesId = options.id
  22. }
  23. },
  24. onShow() {
  25. },
  26. data() {
  27. return {
  28. action: "https://t5.9026.com/api/v1/common/uploadFile",
  29. filesArr: [],
  30. archivesId: ""
  31. }
  32. },
  33. methods: {
  34. upcard: async function() {
  35. let files = [];
  36. // 通过filter,筛选出上传进度为100的文件(因为某些上传失败的文件,进度值不为100,这个是可选的操作)
  37. files = this.$refs.uUpload.lists.filter(val => {
  38. return val.progress == 100;
  39. })
  40. files = files.map(item => {
  41. return item.response.data.url
  42. })
  43. // 如果您不需要进行太多的处理,直接如下即可
  44. // files = this.$refs.uUpload.lists;
  45. if (files.length != 0) {
  46. let res = await this.$request.post("/api/v1/patient/submitCardImg", {
  47. id: this.archivesId,
  48. card_img_url: files[0],
  49. card_back_img_url:files[1]
  50. })
  51. if (res.status == 0) {
  52. uni.showToast({
  53. title: "上传成功",
  54. icon: "none",
  55. duration: 1500
  56. })
  57. setTimeout(() => {
  58. uni.navigateBack({
  59. delta: 1
  60. })
  61. }, 1500)
  62. }
  63. }
  64. }
  65. }
  66. };
  67. </script>
  68. <style scoped lang="scss">
  69. .main {}
  70. </style>