1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- import { connect } from 'herculex';
- import request from "../../../../core/utils/request";
- Component(connect({
- mapStateToProps: {}
- })({
- data: {
- icon: 'https://intranetproxy.alipay.com/skylark/lark/0/2021/png/336036/1617850771006-06992055-9adf-4dce-af7f-08f5066feb99.png',
- tips: '扫码核验的目的\n方便商家核验用户身份的真实性'
- },
- props: {},
- didMount() {},
- methods: {
- async handleScan() {
- my.scan({
- success: res => {
- // console.log(res);
- if (!res || !res.qrCode) {
- return my.alert({
- title: '识别失败',
- content: '未识别到二维码参数',
- buttonText: '我知道了'
- });
- }
- this.recognizeQrCode(res.qrCode);
- },
- fail: error => {
- if (error.code === 11) {
- my.alert({
- title: '识别失败',
- content: '调用扫码失败',
- buttonText: '我知道了'
- });
- }
- }
- });
- },
- async recognizeQrCode(qrCode) {
- const params = {
- url: '/api/v1/proxy/soldier/recognizeCertQrCode',
- method: 'post',
- data: {
- qrCode
- },
- isShowError: true,
- isShowLoadig: true
- };
- const [err, res = {}] = await request(params);
- if (err || res.result !== 'suc') {
- const msg = res.recognizeRemark || '扫码识别失败';
- return my.alert({
- title: '识别失败',
- content: msg,
- buttonText: '我知道了'
- });
- }
- my.redirectTo({
- url: `/antbuilder/industry/soldier/pages/scan-result/index?query=${JSON.stringify(res)}`
- });
- }
- }
- }));
|