提交 7700510d 编写于 作者: KK's avatar KK

重写第三方导航栏返回事件

上级 5c4c64bb
...@@ -68,6 +68,7 @@ export class DingTalkService { ...@@ -68,6 +68,7 @@ export class DingTalkService {
if (info.indexOf('DINGTALK') !== -1) { if (info.indexOf('DINGTALK') !== -1) {
dd.ready(() => { dd.ready(() => {
this.$isInit = true; this.$isInit = true;
this.navBack();
}); });
dd.error((err: any) => { dd.error((err: any) => {
alert(`dd加载错误:${JSON.stringify(err)}`); alert(`dd加载错误:${JSON.stringify(err)}`);
...@@ -176,4 +177,50 @@ export class DingTalkService { ...@@ -176,4 +177,50 @@ export class DingTalkService {
title : title, title : title,
}); });
} }
/**
* 设置钉钉导航栏返回按钮
*
* @static
* @returns {DingTalkService}
* @memberof DingTalkService
*/
private navBack(){
var u = navigator.userAgent;
var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端
if(isAndroid){
document.addEventListener('backbutton', (e:any)=> {
e.preventDefault();
this.backEvent();
},false)
}else{
dd.biz.navigation.setLeft({
control : true,//是否控制点击事件,true 控制,false 不控制, 默认false
text : '返回', //控制显示文本,空字符串表示显示默认文本
onSuccess : ()=>{
this.backEvent();
}
});
}
}
/**
* 钉钉导航栏返回事件
*
* @static
* @returns {DingTalkService}
* @memberof DingTalkService
*/
private backEvent:Function = ()=>{};
/**
* 设置钉钉导航栏返回事件
*
* @static
* @returns {DingTalkService}
* @memberof DingTalkService
*/
public setBackEvent(event:Function){
this.backEvent = event;
}
} }
...@@ -153,7 +153,7 @@ export class ThirdPartyService { ...@@ -153,7 +153,7 @@ export class ThirdPartyService {
} }
/** /**
* 设置钉钉标题 * 设置第三方标题
* *
* @static * @static
* @returns {DingTalkService} * @returns {DingTalkService}
...@@ -167,4 +167,19 @@ export class ThirdPartyService { ...@@ -167,4 +167,19 @@ export class ThirdPartyService {
} }
} }
/**
* 设置第三方容器导航栏返回事件
*
* @static
* @returns {DingTalkService}
* @memberof DingTalkService
*/
public setBackEvent(event:Function){
if (this.isDingTalk()) {
this.dd.setBackEvent(event);
} else if (this.isWeChat()) {
this.weChat.setBackEvent(event);
}
}
} }
\ No newline at end of file
...@@ -211,4 +211,24 @@ export class WeChatService { ...@@ -211,4 +211,24 @@ export class WeChatService {
public setTitle(title:string){ public setTitle(title:string){
// 设置标题 // 设置标题
} }
/**
* 微信导航栏返回事件
*
* @static
* @returns {DingTalkService}
* @memberof DingTalkService
*/
private backEvent:Function = ()=>{};
/**
* 设置微信导航栏返回事件
*
* @static
* @returns {DingTalkService}
* @memberof DingTalkService
*/
public setBackEvent(event:Function){
this.backEvent = event;
}
} }
\ No newline at end of file
...@@ -383,6 +383,9 @@ export class ViewTool { ...@@ -383,6 +383,9 @@ export class ViewTool {
/** /**
* 设置第三方服务视图标题 * 设置第三方服务视图标题
*
* @param {string} [title] 传入标题
* @memberof ViewTool
*/ */
public setViewTitleOfThirdParty(title:string) { public setViewTitleOfThirdParty(title:string) {
this.thirdPartyService.setTitle(title); this.thirdPartyService.setTitle(title);
...@@ -390,8 +393,20 @@ export class ViewTool { ...@@ -390,8 +393,20 @@ export class ViewTool {
/** /**
* 获取第三方服务名称 * 获取第三方服务名称
*
* @memberof ViewTool
*/ */
public getThirdPartyName(): any { public getThirdPartyName(): any {
return this.thirdPartyService.platform return this.thirdPartyService.platform;
}
/**
* 设置第三方导航栏返回事件
*
* @param {Function} [event] 传入事件
* @memberof ViewTool
*/
public setThirdPartyEvent(event:Function): void {
this.thirdPartyService.setBackEvent(event);
} }
} }
\ No newline at end of file
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册