MrShi
2025-06-16 a5f75b8c4acff2ffd49d490c314d95a8c5f5db7e
wx/pages/add_insured_personnel/add_insured_personnel.vue
@@ -20,7 +20,10 @@
               prop="idCard"
               borderBottom
            >
               <u--input v-model="model.idCard" maxlength="18" border="none" placeholder="请输入"></u--input>
               <view style="idth: 100%; position: relative;">
                  <u--input v-model="model.idCard" maxlength="18" border="none" placeholder="请输入"></u--input>
                  <button style="position: absolute; top: 0; right: 0; font-size: 22rpx;" @click="test">识别身份证</button>
               </view>
            </u-form-item>
            <u-form-item
               label="派遣单位:"
@@ -117,6 +120,39 @@
         this.getDispatchingUnit()
      },
      methods: {
         test() {
            var that = this;
            // 选择图片
            wx.chooseImage({
               count: 1,
               success: async function(res) {
                  try {
                     uni.showLoading({ title: '识别中' });
                     const invokeRes = await wx.serviceMarket.invokeService({
                        service: 'wx79ac3de8be320b71',
                        api: 'OcrAllInOne',
                        data: {
                           // 用 CDN 方法标记要上传并转换成 HTTP URL 的文件
                           img_url: new wx.serviceMarket.CDN({
                              type: 'filePath',
                              filePath: res.tempFilePaths[0],
                           }),
                           data_type: 3,
                           ocr_type: 1
                        },
                     })
                     that.model.idCard = invokeRes.data.idcard_res.id.text
                     that.model.name = invokeRes.data.idcard_res.name.text
                     uni.hideLoading();
                  } catch (err) {
                     wx.showModal({ title: 'fail', content: err })
                     uni.hideLoading();
                  }
               },
               fail: function(res) {},
               complete: function(res) {},
            })
         },
         // 派遣单位
         getDispatchingUnit() {
            this.$u.api.findListByDTO({