weex接口基于h5接口补充修改(对内)
<script>
// 引入SDK system模块
const system = weex.requireModule('system')
export default {
methods: {
selectOrgMethod(){
//使用system的selectOrg方法
system.selectOrg('',function(data){
//成功回调
}, function(err){
//失败回调
})
}
}
}
</script>
设备基础接口(device模块)
获取网络信息
<script>
const modal = weex.requireModule('device')
export default {
methods: {
//网络
getNetworkTypeMethod(){
device.getNetworkType('', function(data){
modal.toast({
message: JSON.stringify(data),
duration: 1.3
})
})
}
}
}
</script>
选择照片
<script>
const system = weex.requireModule('system')
export default {
methods: {
selectPhotosMethod:function(e){
device.selectPhotos('', function(data){
console.log(data)
modal.toast({
message: JSON.stringify(data),
duration: 0.3
})
},function(err) {
console.log(err)
modal.toast({
message: JSON.stringify(err),
duration: 0.3
})
})
}
}
}
</script>
扫描二维码
<script>
const system = weex.requireModule('system')
export default {
methods: {
scanQRCodeMethod(){
device.scanQRCode('',function(data){
modal.toast({
message: JSON.stringify(data),
duration: 1.0
})
}, function(err){
})
}
}
}
</script>
平台功能调用(system模块)
获取用户ticket
<script>
const system = weex.requireModule('system')
export default {
methods: {
getTicketMethod(){
modal.toast({
message: JSON.stringify(system.getTicket()),
duration: 1.3
})
}
}
}
</script>
获取用户信息
<script>
const system = weex.requireModule('system')
export default {
methods: {
getUserInfoMethod(){
system.getUserInfo('',function(data){
modal.toast({
message: JSON.stringify(data),
duration: 1.3
})
},function(err){
})
},
}
}
</script>
选择组织
<script>
const system = weex.requireModule('system')
export default {
methods: {
selectOrgMethod(){
system.selectOrg('',function(data){
modal.toast({
message: JSON.stringify(data),
duration: 1.0
})
}, function(err){
})
}
}
}
</script>
选择用户
<script>
const system = weex.requireModule('system')
export default {
methods: {
selectUserMethod(){
system.selectUser('', function(data){
modal.toast({
message: JSON.stringify(data),
duration: 1.0
})
}, function(err){
})
}
}
}
</script>
分享到icome
<script>
const system = weex.requireModule('system')
export default {
methods: {
shareToICOMMethod(){
var icome=new Object();
icome.shareType=7;
icome.targetURL="http://www.baidu.com";
icome.title="分享的标题";
icome.imageURL="base64,";// base64,后面拼接base64的内容
icome.summary="分享内容摘要";
icome.appName="替换“返回”按钮文字,如果为空,用“返回”代替";
icome.extOption="1";
system.shareToICOM(icome, function(data){
modal.toast({
message: JSON.stringify(data),
duration: 1.0
})
}, function(err){
})
}
}
}
</script>
分享到微信
<script>
const system = weex.requireModule('system')
export default {
methods: {
shareToWechatMethod(){
var wechat=new Object();
wechat.type="1";//1好友,2朋友圈
wechat.shareType="1";//1文本,2图片,3网页
wechat.title="分享的标题";
wechat.imageUrl="url,可为空";
wechat.text="分享内容摘要";
wechat.url="跳转url"
system.shareToWechat(wechat, function(data){
modal.toast({
message: JSON.stringify(data),
duration: 1.0
})
}, function(err){
})
}
}
}
</script>
打开双人会话
<script>
const system = weex.requireModule('system')
export default {
methods: {
openChatMethod(){
var param=new Object();
param.userId="10045111";
param.userName="这是一个霜人会话的名字";
system.openChat(param,function(data){
}, function(err){
})
}
}
}
</script>
选择群组
<script>
const system = weex.requireModule('system')
export default {
methods: {
selectGroupMethod(){
system.selectGroup("", function(data){
modal.toast({
message: JSON.stringify(data),
duration: 1.0
})
},function(err){
})
}
}
}
</script>
打开会话
<script>
const system = weex.requireModule('system')
export default {
methods: {
openGroupChatMethod(){
var param=new Object();
param.groupId="10045111";//群id
system.openGroupChat(param,function(data){
modal.toast({
message: JSON.stringify(data),
duration: 1.0
})
},function(err){
})
}
}
}
</script>
创建多人会话
<script>
const system = weex.requireModule('system')
export default {
methods: {
createMultChatMethod(){
var info=new Object();
info.eId="10045111";//群主id
info.eName="群主姓名";//群主姓名
info.gName="群名称";//群名称
var eids=new Array("10045111","0000000","1111111")
info.eIds=eids;
system.createMultChat(info,function(data){
modal.toast({
message: JSON.stringify(data),
duration: 1.0
})
})
}
}
}
</script>
...缺少文件相关操作
页面跳转
遵从页面跳转协议 (http/icome/weixin)://... 如:icome://videoconf?key=1
<script>
const modal = weex.requireModule('device')
export default {
methods: {
// 打开网页
openWebAppMethod(){
console.log('will show toast')
device.openWebAppURL('http://www.baidu.com');
},
// 打开本地页面 如日程,会话等
openNativeAppMethod(){
device.openNativeAppURL('icome://videoconf?key=1');
},
// 按照协议打开任意页面
openCustomAppMethod(){
device.openCustomAppURL('icome://robot?eid=bot_10000001');
},
}
}
</script>
平台组件
请使用icome扫一扫功能扫描运行后的二维码
icome-web
<template>
<div class="wrapper">
<icome-web ref="webview" :src="url" class="webview" @pagestart="start" @pagefinish="finish" @error="error">
</icome-web>
</div>
</template>
<script>
const modal = weex.requireModule('icome-web')
</script>