| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- import { Notify, Uuid } from 'pc-component-v3';
- export default {
- /**
- * 打开一个新的窗口
- * @param {*} url 打开指定的页面的URL。
- * @param {*} name 窗口的名称
- */
- open: function (url, name, closeCallback) {
- if (window.dd.env.platform !== 'notInDingTalk') {
- // 方案一:打开模态框或侧边栏
- window.dd.biz.util.openModal({
- url: url,
- title: name,
- onSuccess: function (res) {
- // 调用成功时回调
- console.log(res);
- if(closeCallback != null){
- closeCallback();
- }
- },
- onFail: function (err) {
- // 调用失败时回调
- console.log(err);
- //Notify.error("页面打开失败", "页面(" + url + ")打开失败,失败原因:" + err, false);
- if(closeCallback != null){
- closeCallback();
- }
- },
- });
- } else {
- let winObj = window.open(url, '_blank');
- if(closeCallback != null){
- var loop = setInterval(function() {
- if(winObj.closed) {
- clearInterval(loop);
- closeCallback();
- }
- }, 1000);
- }
-
- }
- },
- /**
- * 关闭窗口
- */
- close: function () {
- if (window.dd.env.platform !== 'notInDingTalk') {
- // 方案一:关闭模态框或侧边栏
- // dd.biz.navigation.quit只在SlidePanel和Modal里起作用。
- window.dd.biz.navigation.quit({
- message: '',//退出信息,传递给openModal或者openSlidePanel的onSuccess函数的result参数
- onSuccess : function(result) {
- },
- onFail : function(err) {
- // 调用失败时回调
- console.log(err);
- //Notify.error("页面关闭失败", "页面关闭失败,失败原因:" + err, false);
- },
- });
- } else {
- window.close();
- }
- },
- };
|