upcard.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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.$request.upload("/api/v1/common/uploadFile", this.imgList[this.imgList.length - 1], {}).then(data => {
  58. this.imgListpoint.push(JSON.parse(data).data)
  59. console.log(this.imgListpoint)
  60. })
  61. } else {
  62. this.imgList = res.tempFilePaths
  63. this.$request.upload("/api/v1/common/uploadFile", this.imgList[0], {}).then(data => {
  64. this.imgListpoint.push(JSON.parse(data).data)
  65. })
  66. }
  67. }
  68. });
  69. },
  70. DelImg(e) {
  71. uni.showModal({
  72. title: '提示',
  73. content: '确定要删除吗?',
  74. cancelText: '再想想',
  75. confirmText: '删除',
  76. success: res => {
  77. if (res.confirm) {
  78. this.imgListpoint.splice(e.currentTarget.dataset.index, 1);
  79. this.imgListpoint = this.imgListpoint
  80. }
  81. }
  82. })
  83. },
  84. upcard: async function() {
  85. if (this.imgListpoint.length != 0) {
  86. let res = await this.$request.post("/api/v1/patient/submitCardImg", {
  87. id: this.archivesId,
  88. card_img_url: this.imgListpoint[0].url,
  89. card_back_img_url: this.imgListpoint[1].url
  90. })
  91. if (res.status == 0) {
  92. uni.showToast({
  93. title: "上传成功",
  94. icon: "none",
  95. duration: 1500
  96. })
  97. setTimeout(() => {
  98. uni.navigateBack({
  99. delta: 1
  100. })
  101. }, 1500)
  102. }
  103. }
  104. }
  105. }
  106. };
  107. </script>
  108. <style lang="scss">
  109. page {
  110. background-color: #fff;
  111. height: 100%;
  112. }
  113. </style>