Commit b2fe6d69 authored by westzmg's avatar westzmg

集成百度AI和原生对话框

parent c69c178f
......@@ -30,5 +30,7 @@ export default {
{ path: '/launchShare', component: '../pages/launchShare' },
{ path: '/getToken', component: '../pages/getToken' },
{ path: '/uploadImage', component: '../pages/uploadImage' },
{ path: '/dialog', component: '../pages/dialog' },
{ path: '/baiduAI', component: '../pages/baiduAI' },
]
}
......@@ -7,35 +7,248 @@ yarn add https://github.com/westzmg/zhu_wap_bridge.git
##引用方式
yarn add https://github.com/westzmg/zhu_wap_bridge.git
#
#
### 拍摄照片
##### await _Bridge.takePhoto(options)
##### options: {
# 拍摄照片
#### await _Bridge.takePhoto(options)
```
options: {
quality: 0.6, // 图片质量0 to 1
includeBase64: true, // 返回值内是否包含base64
}
```
##### 详情参考 https://github.com/react-native-image-picker/react-native-image-picker
#
#
### 录制视频
##### await _Bridge.recordVideo(options)
##### options: {
quality: 0.6, // 图片质量0 to 1
# 录制视频
### await _Bridge.recordVideo(options)
```
options: {
quality: 0.6, // 质量 0 to 1
}
```
##### 详情参考 https://github.com/react-native-image-picker/react-native-image-picker
#
#
### 扫描二维码
##### await _Bridge.barCodeScan(options)
##### options: {
quality: 0.6, // 图片质量0 to 1
includeBase64: true, // 返回值内是否包含base64
# 扫描二维码
### await _Bridge.barCodeScan(options)
```
options: {
}
```
##### 详情参考 https://github.com/react-native-image-picker/react-native-image-picker
#打开WebView
### openWindow(options)
```
options: {
url: "http://www.baidu.com
}
```
#关闭当前的WebView
### closeWindow()
```
options: {
}
```
#获取坐标信息
### getPosition()
```
options: {
}
```
#使用重庆电子签章(未完成)
### launchCQDigitalSign(options)
```
options: {
}
```
#使用手写板签名(未完成)
### launchFingerSign(options)
```
options: {
}
```
#社交应用分享
### launchShare(options)
```
options: {
message:string,
title:string,
url:string<base64>
}
refer https://react-native-share.github.io/react-native-share/docs/share-open
```
#获取token
### getToken()
```
```
#获取当前项目信息
### getCurrProject()
```
```
#获取当前项目信息
### previewImage([])
```
@params [imageUrl]
```
#获取上传图片以及文件的token
### getUpToken(options)
```
options: {
id, --必输项,如果是项目级应用则设置project_id,否则设置user_id
app_id="common", --逻辑必输项,设置为应用的code,如果没有设置系统默认为common,
signature=true, --是否需要签名访问
rename=true, --文件是否重命名
maxSize=1024*1024*10 --文件尺寸限制,默认为10M
}
```
#上传图片
### uploadImage(options)
```
options {
token: object, --从getUpToken中获取
photo: object, --选择或拍照的结果,主要会用到fileName,type,fileName,多数情况直接拿结果直接用就行了
onProgress: func, --图片上传的进度回调
}
```
#图片直传
### uploadImageThrough(options)
```
options {
photo: object, --选择或拍照的结果,主要会用到fileName,type,fileName,多数情况直接拿结果直接用就行了
tokenMode: string, --必输项,project or user
appId: string, --所属的app代码,默认为common
signature: false, --是否需要签名上传
rename=true, --是否重命名
maxSize=1024*10000 --最大尺寸
}
```
#拍照后直接上传
### takePhotoAndUpload(options)
```
options {
quality: 0.6,
includeBase64: true,
saveToPhotos: false,
uploadOptions: {
tokenMode: string, --必输项,project or user,默认为project
appId: string, --所属的app代码,默认为common
signature: false, --是否需要签名上传
} --图片上传的options
}
```
#选择文件后上传
### choosePhotoAndUpload(options)
```
options {
includeBase64: false,
uploadOptions: {
tokenMode: string, --必输项,project or user
appId: string, --所属的app代码,默认为common
signature: false, --是否需要签名上传
} --图片上传的options
}
```
#拍照或选择文件后上传
### getPhotoAndUpload(options)
```
options {
sourceType --['album', 'camera']相册选择和摄像头的选择,可二者同时
takeOptions: {
quality: 0.6,
includeBase64: true,
saveToPhotos: false,
} --拍照的options,无特殊情况几乎不用设置
chooseOptions:{
includeBase64: true,
} --拍照的options,无特殊情况几乎不用设置
uploadOptions: {
tokenMode: string, --归类方式 project or user,默认project
appId: string, --所属的app代码,默认为common,建议输入
signature: true, --是否需要签名上传,默认为true
} --图片上传的options
}
```
#信息提示对话框
### alertDialog(options)
```
options {
title, -- 标题
description, -- 描述内容
status, --状态 normal(默认),warning,error,success
}
```
#信息确认对话框
### await confirmDialog(options)
```
options {
title, -- 标题
description, -- 描述内容
}
@result 确认true, 放弃false
```
#文本输入对话框
### await inputDialog(options)
```
options {
title, -- 标题
description, -- 描述内容
}
@result
```
#人脸活体检测
### await liveDetect(options)
```
options {
includeBase64, --
scale, -- 尺寸
cropHeight, -- 图片高度
cropWidth, -- 图片宽度
}
@result {uri, type, fileName, base64}
```
#捕捉拍摄身份证
### await takeIdCard(options)
```
options {
includeBase64, --
quality, --
}
@result {uri, type, fileName, base64}
```
#识别车牌
### await scanCarNo(options)
```
options {
includeBase64, --
}
@result {uri, type, fileName, base64}
```
#识别营业执照
### await scanBusinessLicense(options)
```
options {
includeBase64, --
}
@result {uri, type, fileName, base64}
```
......@@ -158,6 +158,25 @@ export const getToken = async () => {
})
};
/*
* 获取当前项目信息
* @name getCurrProject
* @return
*/
export const getCurrProject = async () => {
return new Promise(async (resolve) => {
// invoke.define('getToken', async () => {resolve()});
invoke.define('getCurrProjectCompleted', async (result) => {resolve(result)});
await invoke.bind("getCurrProject")()
})
};
/*
* 预览图片
* @name previewImage
* @params [imageUrl]
* @return
*/
export const previewImage = async (opt) => {
return new Promise(async (resolve) => {
await invoke.bind("previewImage")(opt)
......@@ -280,7 +299,110 @@ export const getPhotoAndUpload = async (opt) => {
})
};
/*
* @name alertDialog 信息提示对话框
* options {
* title, -- 标题
* description, -- 描述内容
* status, --状态 normal(默认),warning,error,success
* }
*/
export const alertDialog = async (opt) => {
return new Promise(async (resolve) => {
invoke.define('alertDialogCompleted', async (result) => {resolve(result)});
await invoke.bind("alertDialog")(opt)
})
};
/*
* @name confirmDialog 信息确认对话框
* options {
* title, -- 标题
* description, -- 描述内容
* }
* @result 确认true, 放弃false
*/
export const confirmDialog = async (opt) => {
return new Promise(async (resolve) => {
invoke.define('confirmDialogCompleted', async (result) => {resolve(result)});
await invoke.bind("confirmDialog")(opt)
})
};
/*
* @name inputDialog 文本输入对话框
* options {
* title, -- 标题
* description, -- 描述内容
* }
* @result
*/
export const inputDialog = async (opt) => {
return new Promise(async (resolve) => {
invoke.define('inputDialogCompleted', async (result) => {resolve(result)});
await invoke.bind("inputDialog")(opt)
})
};
/*
* @name liveDetect 人脸活体检测
* options {
* includeBase64, --
* scale, --
* cropHeight, --
* cropWidth, --
* }
* @result {uri, type, fileName, base64}
*/
export const liveDetect = async (opt) => {
return new Promise(async (resolve) => {
invoke.define('liveDetectCompleted', async (result) => {resolve(result)});
await invoke.bind("liveDetect")(opt)
})
};
/*
* @name takeIdCard 捕捉拍摄身份证
* options {
* includeBase64, --
* quality, --
* }
* @result {uri, type, fileName, base64}
*/
export const takeIdCard = async (opt) => {
return new Promise(async (resolve) => {
invoke.define('takeIdCardCompleted', async (result) => {resolve(result)});
await invoke.bind("takeIdCard")(opt)
})
};
/*
* @name scanCarNo 识别车牌
* options {
* includeBase64, -- 标题
* }
* @result
*/
export const scanCarNo = async (opt) => {
return new Promise(async (resolve) => {
invoke.define('scanCarNoCompleted', async (result) => {resolve(result)});
await invoke.bind("scanCarNo")(opt)
})
};
/*
* @name scanBusinessLicense 识别营业执照
* options {
* includeBase64, -- 标题
* }
* @result
*/
export const scanBusinessLicense = async (opt) => {
return new Promise(async (resolve) => {
invoke.define('scanBusinessLicenseCompleted', async (result) => {resolve(result)});
await invoke.bind("scanBusinessLicense")(opt)
})
};
export const EVENTS_TYPE = {
keyboardWillShow: 'keyboardWillShow', // 键盘即将出现
......@@ -303,6 +425,7 @@ export default {
launchFingerSign,
launchShare,
getToken,
getCurrProject,
previewImage,
getUpToken,
......@@ -311,6 +434,15 @@ export default {
takePhotoAndUpload,
choosePhotoAndUpload,
getPhotoAndUpload,
alertDialog,
confirmDialog,
inputDialog,
liveDetect,
takeIdCard,
scanCarNo,
scanBusinessLicense,
}
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment