add-bank.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <template>
  2. <view class="bank-box">
  3. <en-input label="银行卡" v-model="number" type="number" placeholder="请输入银行卡号" rightText="识别银行卡" @addRight="showUploadingImg(true)" right-img="/static/img/new-add/add-bank.png"></en-input>
  4. <en-input label="所属银行" v-model="name" type="text" placeholder="请输入银行名称" ></en-input>
  5. <uni-popup ref="popup" :safeArea="false" type="bottom" @change="closePopup">
  6. <view class="popup-block">
  7. <view class="popup-row" @click="uploadingImg(1)">拍照</view>
  8. <view class="popup-row" @click="uploadingImg(2)">从手机里面选择</view>
  9. <view class="popup-row" @click="showUploadingImg(false,0)">取消</view>
  10. </view>
  11. </uni-popup>
  12. </view>
  13. </template>
  14. <script>
  15. import EnInput from "@/components/en-from/en-input/en-input";
  16. import {getBaiDuImgRecognition} from "@/api/common";
  17. import txUploadFile from "@/service/txOssSts";
  18. import tools from "@/service/tools";
  19. export default {
  20. name: "add-bank",
  21. components: {EnInput},
  22. props: {
  23. bankName:{
  24. default:''
  25. },
  26. bankNum:{
  27. default:''
  28. }
  29. },
  30. data() {
  31. return {
  32. number:'',
  33. name:'',
  34. isUploading:false,
  35. }
  36. },
  37. watch: {
  38. 'bankName':function (){
  39. console.log('bankName:'+this.bankName)
  40. if(this.bankName!==this.name){
  41. this.name=this.bankName
  42. }
  43. },
  44. 'bankNum':function (){
  45. console.log('bankNum:'+this.bankNum)
  46. if(this.bankNum!==this.number){
  47. this.number=this.bankNum
  48. }
  49. },
  50. 'name':function (){
  51. this.$emit('update:bankName',this.name)
  52. },
  53. 'number':function (){
  54. this.$emit('update:bankNum',this.number)
  55. }
  56. },
  57. mounted() {
  58. this.name=this.bankName
  59. this.number=this.bankNum
  60. },
  61. methods: {
  62. uploadingImg(sourceType) {
  63. uni.chooseMedia({
  64. mediaType: 'image',
  65. count: 1, //默认9
  66. sizeType: "compressed",
  67. sourceType: [sourceType === 1 ? 'camera' : 'album'],
  68. success: (res) => {
  69. if (res.tempFiles.length > 0) {
  70. res.tempFiles.forEach((tempFile) => {
  71. txUploadFile(tempFile.tempFilePath).then((data) => {
  72. if (!data) {
  73. tools.error('图片上传失败')
  74. tools.hideLoading()
  75. } else {
  76. tools.showLoading()
  77. getBaiDuImgRecognition({
  78. 'imgUrl': data.Location,
  79. 'imgType': '2'
  80. }).then((res) => {
  81. tools.hideLoading()
  82. if (res.code === 1) {
  83. this.name = res.data.bank_name;
  84. this.number = res.data.bank_card_number;
  85. } else {
  86. tools.error('银行卡识别识别')
  87. }
  88. })
  89. }
  90. })
  91. })
  92. this.showUploadingImg(false, 0);
  93. } else {
  94. tools.error("请选择上传的图片")
  95. }
  96. },
  97. });
  98. },
  99. showUploadingImg(showImg, uploadingType) {
  100. if (showImg) {
  101. if(this.isUploading){
  102. return
  103. }
  104. this.isUploading=true
  105. this.$refs.popup.open("bottom");
  106. } else {
  107. this.$refs.popup.close();
  108. this.isUploading=false
  109. }
  110. },
  111. closePopup(e){
  112. if(e.show===false){
  113. this.isUploading=false
  114. }
  115. },
  116. }
  117. }
  118. </script>
  119. <style scoped lang="scss">
  120. @import "@/static/css/wh-common";
  121. </style>