起步软件技术论坛
搜索
 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1610|回复: 2

[结贴] 调用justep.Shell.fireEvent 关闭页面,第二次的时候出现问题

[复制链接]

4

主题

6

帖子

30

积分

新手上路

Rank: 1

积分
30
QQ
发表于 2016-11-22 08:36:51 | 显示全部楼层 |阅读模式
我写了一个函数,调用justep.Shell.fireEvent关闭页面,
Model.prototype.backBtnClick = function(event) {


  justep.Shell.fireEvent('onPayPageClose');
};

关闭功能

Model.prototype.onPayPageClose = function(event){
  debugger
  if (this.params.paytype == 1) {
   
   justep.Shell.closePage();
  } else {
   // cancel order
   debugger
   this.comp('messageDialog1').show();
  }


Model.prototype.messageDialog1OK = function(event) {
  var self = this;
  justep.Baas.sendRequest({
   "url" : "/app/main",
   "action" : "cancelUserOrder",
   "async" : false,
   "params" : {
    "usertoken" : localStorage.getItem("usertoken"),
    "orderid" : self.orderid,
    "canceltype" : 0
   },
   "success" : function(data) {
       justep.Shell.closePage();
   },
   "error" : function() {
    // 失败
    justep.Util.hint("取消失败,请重试!");
   }
  });
};

}

第一次的时候,能正常弹出提示框,第二次的时候,则 this.comp('messageDialog1') 为null ,出现 cannot read property ‘show’ of null 的错误, wex5的版本是3.5,
各位大侠,怎么解决这个问题呀?

发表于 2016-11-22 10:26:20 | 显示全部楼层
justep.Shell.closePage();  换成 this.close()

第一个方法是关闭当前激活的页面!
this.close() 是关闭本页面!那个页面调用的就关闭哪个!!

this.comp('messageDialog1')  为,说明这个页面已经销毁了!组件就不存在了!

建议你再整理下思路吧!调用某个页面的方法!需要他是开着的!而不是关闭的!
qq:1912779713
WeX5教程--WeX5下载
回复 支持 反对

使用道具 举报

4

主题

6

帖子

30

积分

新手上路

Rank: 1

积分
30
QQ
 楼主| 发表于 2016-11-22 11:52:21 | 显示全部楼层
谢谢,找到原因了,justep.Shell.off("onPayPageClose", this.onPayPageClose); 改成justep.Shell.off("onPayPageClose", this.onPayPageClose,this);就好了
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|X3技术论坛|Justep Inc.    

GMT+8, 2025-6-23 00:08 , Processed in 0.068717 second(s), 23 queries .

Powered by Discuz! X3.4

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表