HTML 打开新页面 关闭,apiCloud如何打开新页面的同时,关掉当前页

方法很多,只要不同时open、close都可行。给你一个简单的方式:

api.addEventListener({

name:'viewdisappear'

},function(){

api.closeWin({

name:api.winName

});

});

谢谢官方提供的方案,棒棒的!

使用场景,选择好友加入群组!

群生成之后,关闭选择页面!

title

body{

}

取消

选择朋友

确定

apiready = function () {

fix_status_bar();

var header_height = $api.dom("header").offsetHeight;

api.openFrame({

name: 'message_choose_friends_frm',

url: 'message_choose_friends_frm.html',

rect: {

x: 0,

y: header_height,

w:'auto', //宽度,若传'auto',页面从x位置开始自动充满父页面宽度

h:api.winHeight - header_height //高度,若传'auto',页面从y位置开始自动充满父页面高度

},

bgColor:'rgba(0,0,0,0)',

bounces:false,

vScrollBarEnabled:false,

hScrollBarEnabled:false

});

// 监听页面消失的时候,关掉页面就可以了

api.addEventListener({

name:'viewdisappear'

},function(){

api.closeWin();

});

}

function confirmChooseEvent() {

api.sendEvent({

name: 'confirmChooseEvent',

extra: {

}

});

}

frm页面

content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0">

选择朋友

.s_mapul {

position: absolute;

top: 0;

left: 0;

100%;

max-height: 350px;

overflow: scroll;

background: #fff;

overflow-y: auto;

}

.s_mapul li {

border-bottom: 1px solid #ededed;

padding: 0.3rem 5%;

position: relative;

}

.s_mapul li h2 {

font-size: 0.8rem;

}

.s_mapul li h2 img {

position: absolute;

right: 5%;

height: 1rem;

}

.s_mapul li p {

font-size: 0.6rem;

color: #b0b0b0;

margin-top: 0.2rem;

}

var user;

var UIListCheck;

apiready = function () {

fix_status_bar();

user = $api.getStorage('user');

// 监听页面关闭

api.addEventListener({

name: 'confirmChooseEvent'

}, function (ret, err) {

getSelectedSync();

});

api.ajax({

url: BASE_URL_ACTION+'/RongCloud/GetFriends',

method: 'post',

data: {

values: {

customerId: user.person_id,

}

}

}, function (json, err) {

if (json.result) {

dealFriendsData(json.info,function(contacts) {

UIListCheck = api.require('UIListCheck');

UIListCheck.open({

rect: {

x: 0,

y: 22,

w: api.frameWidth,

h: api.frameHeight - 22

},

contacts: contacts,

fixedOn: 'message_choose_friends_frm'

}, function (ret) {

if (ret) {

}

});

});

} else {

toast('获取好友数据失败');

}

});

}

function dealFriendsData(data,callback) {

var contacts = [];

for (var i=0;i

var item = {};

item.employee_id = data[i].Id;

item.remark = data[i].NickName;

item.position = "";

item.phonetic = convertPinyin(data[i].NickName);

contacts[i] = item;

}

if (typeof callback == 'function') {

callback(contacts);

}

}

function getSelectedSync() {

var ret = UIListCheck.getSelectedSync();

var contacts = ret.contacts;

if (contacts.length == 0) {

toast('请选择好友');

return;

}

var values = {

systemName : 'yunlutong',

customerId : user.person_id

}

for(var i = 0;i

var key='contactIds['+i+']';

values[key]= contacts[i].employee_id;

}

api.ajax({

url : BASE_URL_ACTION+'/RongCloud/AddGroup',

method : 'post',

data : {

values : values

}

}, function(json, err) {

if (json.result) {

toast('创建成功');

setTimeout(openChatPage('',json.groupid,0,'群聊','GROUP','index',''),500);

// 本来想在这里处理的,发现不管用

} else {

toast('创建失败');

}

});

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值