upcard.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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. <view class="cu-form-group">
  10. <view class="grid col-4 grid-square flex-sub">
  11. <view class="bg-img" v-for="(item,index) in imgListpoint" :key="index" :data-url="imgListpoint[index]">
  12. <image :src="imgListpoint[index].url" mode='aspectFill'></image>
  13. <view class="cu-tag bg-red" @click="DelImg" :data-index="index">
  14. <text class="cuIcon-close"></text>
  15. </view>
  16. </view>
  17. <view class="solids" @click="ChooseImage" v-if="imgListpoint.length<2">
  18. <text class="cuIcon-cameraadd"></text>
  19. </view>
  20. </view>
  21. </view>
  22. <view class="cu-bar bg-white tabbar" style="position: fixed;bottom: 0;width: 100%;">
  23. <view class="submit" style="background-color: #0B73B9;color: white;" @click="upcard">
  24. 提交审核
  25. </view>
  26. </view>
  27. </view>
  28. </template>
  29. <script>
  30. export default {
  31. onLoad(options) {
  32. if (options.id != undefined) {
  33. this.archivesId = options.id
  34. if (JSON.parse(options.data)[0].url != "" && JSON.parse(options.data)[1].url != "") {
  35. this.imgListpoint = JSON.parse(options.data)
  36. }
  37. }
  38. },
  39. onShow() {
  40. },
  41. data() {
  42. return {
  43. archivesId: "",
  44. imgListpoint: [],
  45. imgList: []
  46. }
  47. },
  48. methods: {
  49. ChooseImage() {
  50. uni.chooseImage({
  51. count: 2, //默认9
  52. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  53. sourceType: ['album', 'camera'], //从相册选择
  54. success: (res) => {
  55. if (this.imgList.length != 0) {
  56. this.imgList = this.imgList.concat(res.tempFilePaths)
  57. this.imgList.forEach(item => {
  58. this.$request.upload("/api/v1/common/uploadFile", item, {}).then(data => {
  59. this.imgListpoint.push(JSON.parse(data).data)
  60. console.log(this.imgListpoint)
  61. })
  62. })
  63. } else {
  64. this.imgList = res.tempFilePaths
  65. this.imgList.forEach(item => {
  66. this.$request.upload("/api/v1/common/uploadFile", item, {}).then(data => {
  67. this.imgListpoint.push(JSON.parse(data).data)
  68. })
  69. })
  70. }
  71. }
  72. });
  73. },
  74. DelImg(e) {
  75. uni.showModal({
  76. title: '提示',
  77. content: '确定要删除吗?',
  78. cancelText: '再想想',
  79. confirmText: '删除',
  80. success: res => {
  81. if (res.confirm) {
  82. this.imgListpoint.splice(e.currentTarget.dataset.index, 1);
  83. this.imgListpoint = this.imgListpoint
  84. }
  85. }
  86. })
  87. },
  88. upcard: async function() {
  89. if (this.imgListpoint.length != 2) {
  90. uni.showToast({
  91. title: "请上传身份证完整",
  92. icon: "none"
  93. })
  94. return false
  95. }
  96. if (this.imgListpoint.length == 2) {
  97. let res = await this.$request.post("/api/v1/patient/submitCardImg", {
  98. id: this.archivesId,
  99. card_img_url: this.imgListpoint[0].url,
  100. card_back_img_url: this.imgListpoint[1].url
  101. })
  102. if (res.status == 0) {
  103. uni.showToast({
  104. title: "上传成功",
  105. icon: "none",
  106. duration: 1500
  107. })
  108. setTimeout(() => {
  109. uni.navigateBack({
  110. delta: 1
  111. })
  112. }, 1500)
  113. }
  114. }
  115. }
  116. }
  117. };
  118. </script>
  119. <style lang="scss">
  120. page {
  121. background-color: #fff;
  122. height: 100%;
  123. }
  124. </style>