123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- <template>
- <view>
- <text>{{id}}</text>
- <text>{{name}}</text>
- <text>{{address}}</text>
- <text>{{sex}}</text>
- <text>{{time}}</text>
- <lzcOCR class="lzcOCR" @end="idcardEnd"></lzcOCR>
- <button @click="start">开始同步区县</button>
- </view>
- </template>
- <script>
- import lzcOCR from '@/components/lzc-OCR/lzc-OCR.vue';
- import config from '@/config.js';
- let jl = require('../../static/jl.json')
- export default {
- components: {
- lzcOCR
- },
- data() {
- return {
- id: '1',
- name: '2',
- address: '3',
- sex: '4',
- time: '5',
- client_id: config.face_client_id,
- client_secret: config.face_client_secret,
- token: '',
- groupId: '',
- }
- },
- methods: {
- getAccessToken(groupId) {
- uni.request({
- url: '/baiduApi/oauth/2.0/token',
- data: {
- grant_type: 'client_credentials',
- client_id: this.client_id,
- client_secret: this.client_secret
- },
- method: 'POST',
- header: {
- 'Content-Type': 'application/x-www-form-urlencoded'
- },
- success: (res) => {
- if (res.statusCode == 200) {
- this.token = res.data.access_token
- this.createGroup(groupId)
- }
- },
- error: (err) => {}
- })
- },
- createGroup(groupId) {
- uni.request({
- url: '/baiduApi/rest/2.0/face/v3/faceset/group/add?access_token=' + this.token,
- data: {
- group_id: groupId,
- },
- method: 'POST',
- header: {
- 'Content-Type': 'application/x-www-form-urlencoded'
- },
- success: (res) => {
- console.log("创建组返回,", groupId, res)
- },
- error: (err) => {}
- })
- },
- start() {
- let array = jl.RECORDS
- let shi = []
- jl.RECORDS.forEach(e => {
- // console.log(e.code.substring(0, 6));
- this.getAccessToken(e.code.substring(0, 6))
- })
- },
- idcardEnd(words) {
- console.log("www", words)
- alert(JSON.stringify(words))
- uni.showModal({
- content: words
- })
- this.id = words.words_result['公民身份号码'].words
- this.name = words.words_result['姓名'].words
- this.address = words.words_result['民族'].words
- this.sex = words.words_result['性别'].words
- this.time = words.words_result['出生'].words
- }
- }
- }
- </script>
- <style>
- .lzcOCR {
- width: 90%;
- display: flex;
- justify-content: center;
- }
- </style>
|