Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
IBMS
/
nativeview
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
1b2d6adb
authored
Feb 22, 2022
by
huangzhicong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
更新README
parent
ca390879
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
77 additions
and
155 deletions
+77
-155
README.md
+77
-155
No files found.
README.md
View file @
1b2d6adb
### 图片选择
### 图片选择
```
javascript
```
javascript
function
selectPhoto
({
/// 选择图片
// uri: 图片在设备中的协议地址
/// 返回格式为
// base64: 图片的base64编码
/// { uri: '', base64: '' }
success
:
function
(
uri
,
base64
)
{
async
function
pickerPhoto
()
{
try
{
},
const
res
=
await
jssdk
.
pickerPhoto
();
failed
:
function
()
{
document
.
getElementById
(
'img'
).
src
=
res
.
base64
;
}
catch
(
error
)
{
},
console
.
error
(
error
);
complete
:
function
()
{
}
}
})
}
```
/// 拍摄图片
### 拍摄
/// 返回格式为
/// { uri: '', base64: '' }
```
javascript
async
function
takePhotos
()
{
function
openCamera
({
try
{
// uri: 图片在设备中的协议地址
const
res
=
await
jssdk
.
takePhotos
();
// base64: 图片的base64编码
document
.
getElementById
(
'img'
).
src
=
res
.
base64
;
success
:
function
(
uri
,
base64
)
{
}
catch
(
error
)
{
console
.
error
(
error
);
},
failed
:
function
()
{
},
complete
:
function
()
{
}
}
})
}
```
/// 录制音频
### 图片裁剪
/// 返回格式为
/// { uri: '', base64: '' }
```
javascript
async
function
startRecordAudio
()
{
// srcUri: 待裁剪图片在设备中的协议地址,直接传递selectPhoto、openCamera方法success中返回的uri即可
try
{
function
cropPhoto
(
srcUri
,
{
const
res
=
await
jssdk
.
startRecordAudio
(
30
);
// uri: 图片在设备中的协议地址
alert
(
res
);
// base64: 图片的base64编码
document
.
getElementById
(
'audio'
).
src
=
res
.
base64
;
success
:
function
(
uri
,
base64
)
{
}
catch
(
error
)
{
console
.
error
(
error
);
},
failed
:
function
()
{
},
complete
:
function
()
{
}
}
})
}
```
/// 二维码扫描
### 音频录制
/// 返回格式为
/// { value: '' }
```
javascript
async
function
onQRCodeClick
()
{
// maxDuration: 录音限制时长(单位: 秒),sdk限制最大为5分钟
try
{
function
recordAudio
(
maxDuration
,
{
const
res
=
await
jssdk
.
onQRCodeClick
();
// uri: 音频在设备中的协议地址
document
.
getElementById
(
'text'
).
innerText
=
res
.
value
;
// base64: 音频的base64编码
}
catch
(
error
)
{
success
:
function
(
uri
,
base64
)
{
console
.
error
(
error
);
},
failed
:
function
()
{
},
complete
:
function
()
{
}
}
})
}
```
/// 保存字符串
### 视频录制
/// 返回格式为
/// { key: '', value: '' }
```
javascript
async
function
onSetLocalStorage
()
{
function
captureVideo
({
try
{
// uri: 视频在设备中的协议地址
const
res
=
await
jssdk
.
onSetLocalStorage
(
'maxrocky'
,
'测试'
);
// base64: 视频的base64编码
document
.
getElementById
(
'text'
).
innerText
=
'保存成功'
;
success
:
function
(
uri
,
base64
)
{
}
catch
(
error
)
{
console
.
error
(
error
);
},
failed
:
function
()
{
},
complete
:
function
()
{
}
}
})
}
```
/// 获取指定字符串
### 扫描二维码
/// 返回格式为
/// { key: '', value: '' }
```
javascript
async
function
onGetLocalStorage
()
{
function
qrcode
({
try
{
// content: 二维码被识别后的字符串
const
res
=
await
jssdk
.
onGetLocalStorage
(
'maxrocky'
);
success
:
function
(
content
)
{
document
.
getElementById
(
'text'
).
innerText
=
`本地记录内容:
${
res
.
value
}
`
;
}
catch
(
error
)
{
},
console
.
error
(
error
);
failed
:
function
()
{
},
complete
:
function
()
{
}
})
```
### 保存字符串到本地
```
javascript
// key: 字符串所关联的key,要求为字符串类型
// value: 要保存的字符串
function
storageValue
(
key
,
value
,
{
// key: 字符串所关联的key
// value: 要保存的字符串
success
:
function
(
key
,
value
)
{
},
failed
:
function
()
{
},
complete
:
function
()
{
}
}
})
}
```
/// 清理指定字符串
### 获取本地字符串
/// 返回格式为
/// { key: '', value: '' }
```
javascript
async
function
onRemoveLocalStorage
()
{
// key: 要获取的字符串所关联的key,要求为字符串类型
try
{
function
acquireValue
(
key
,
{
const
res
=
await
jssdk
.
onRemoveLocalStorage
(
'maxrocky'
);
// key: 字符串所关联的key
document
.
getElementById
(
'text'
).
innerText
=
'已清理本地记录'
;
// value: 要保存的字符串
}
catch
(
error
)
{
success
:
function
(
key
,
value
)
{
console
.
error
(
error
);
},
failed
:
function
()
{
},
complete
:
function
()
{
}
})
```
### 清除保存的字符串
```
javascript
// key: 要清除的字符串所关联的key,要求为字符串类型
function
clearValue
(
key
,
{
// key: 字符串所关联的key
// value: 要保存的字符串
success
:
function
(
key
,
value
)
{
},
failed
:
function
()
{
},
complete
:
function
()
{
}
}
}
)
}
```
```
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment