|
@@ -6,7 +6,6 @@ const { ObjectId } = require('mongoose').Types;
|
|
|
const { CrudService } = require('naf-framework-mongoose/lib/service');
|
|
|
const { BusinessError, ErrorCode } = require('naf-core').Error;
|
|
|
|
|
|
-// const Core = require('@alicloud/pop-core');
|
|
|
const sms = require('../util/aliMessage.js');
|
|
|
|
|
|
class PhoneMessageService extends CrudService {
|
|
@@ -27,41 +26,34 @@ class PhoneMessageService extends CrudService {
|
|
|
// });
|
|
|
}
|
|
|
}
|
|
|
- // 校验用户提交的验证码
|
|
|
- async verify(phone, code) {
|
|
|
- const isCodeRight = sms.verify(phone, code); // 返回true/false
|
|
|
- return isCodeRight;
|
|
|
- }
|
|
|
|
|
|
- // async send(phone) {
|
|
|
- // let res = '';
|
|
|
- // const client = new Core({
|
|
|
- // accessKeyId: '<accessKeyId>',
|
|
|
- // accessKeySecret: '<accessSecret>',
|
|
|
- // endpoint: 'https://dysmsapi.aliyuncs.com',
|
|
|
- // apiVersion: '2017-05-25',
|
|
|
- // });
|
|
|
- //
|
|
|
- // const params = {
|
|
|
- // RegionId: 'cn-hangzhou',
|
|
|
- // PhoneNumbers: phone,
|
|
|
- // SignName: '短信签名',
|
|
|
- // TemplateCode: '模板code',
|
|
|
- // TemplateParam: '模板变量', // 短信模板变量对应的实际值,JSON格式。
|
|
|
- // };
|
|
|
- //
|
|
|
- // const requestOption = {
|
|
|
- // method: 'POST',
|
|
|
- // };
|
|
|
- //
|
|
|
- // client.request('SendSms', params, requestOption).then(result => {
|
|
|
- // console.log(JSON.stringify(result));
|
|
|
- // res = result;
|
|
|
- // }, ex => {
|
|
|
- // console.log(ex);
|
|
|
- // res = ex;
|
|
|
- // });
|
|
|
- // }
|
|
|
+ async getMessage(data) {
|
|
|
+ const url = 'https://dm-58.data.aliyun.com/rest/160601/ocr/ocr_business_license.json';
|
|
|
+ const AppCode = '4638ef02c8e248e1b12d55b1170e4feb';
|
|
|
+ if (data.img) {
|
|
|
+
|
|
|
+ const bodys = { image: data.img };
|
|
|
+
|
|
|
+ const res = await this.ctx.curl(url, {
|
|
|
+ method: 'POST',
|
|
|
+ headers: { Authorization: 'APPCODE ' + AppCode },
|
|
|
+ contentType: 'application/json; charset=UTF-8',
|
|
|
+ data: JSON.stringify(bodys),
|
|
|
+ dataType: 'json',
|
|
|
+ });
|
|
|
+ // console.log('OCR返回结果========', res);
|
|
|
+ if (res.status == 200) {
|
|
|
+ return res.data;
|
|
|
+ } else if (res.status == 403) {
|
|
|
+ return '没有购买,或者购买次数用尽,或者URL错误';
|
|
|
+ } else if (res.status == 413) {
|
|
|
+ return '图片太大,超过1.5M';
|
|
|
+ }
|
|
|
+ return 'OCR 调用失败';
|
|
|
+
|
|
|
+ }
|
|
|
+ return '图片获取失败';
|
|
|
+ }
|
|
|
|
|
|
|
|
|
}
|