Skip to content

Commit

Permalink
feat(Loading): 新增开放函数
Browse files Browse the repository at this point in the history
新增开放函数 linShow 和 linHide

close #1342
  • Loading branch information
juzi214032 committed Apr 5, 2021
1 parent 540b338 commit f1a6ec9
Showing 1 changed file with 68 additions and 6 deletions.
74 changes: 68 additions & 6 deletions src/loading/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,12 @@ Component({
type: String,
value: '1'
},
bgColor: String,
zIndex:{
type:String,
bgColor: {
type: String,
value: ''
},
zIndex: {
type: String,
value: '776'
},
// 类型
Expand All @@ -36,9 +39,15 @@ Component({
value: 'medium',
},
// 自定义
custom: Boolean,
custom: {
type: Boolean,
value: false
},
// 全屏模式
fullScreen: Boolean
fullScreen: {
type: Boolean,
value: false
}
},

attached() {
Expand All @@ -55,15 +64,24 @@ Component({
_init() {
wx.lin = wx.lin || {};
wx.lin.showLoading = (options) => {
console.warn('wx.lin 已废弃,请使用开放函数代替:https://doc.mini.talelin.com//start/open-function.html');
if (!options) {
options = {};
}

const {
custom = false,
fullScreen = false,
color = '',
type = 'rotate',
size = 'medium',
opacity = '1'
opacity = '1',
bgColor = '',
zIndex = '776',
} = { ...options };
this.setData({
bgColor,
zIndex,
custom,
fullScreen,
color,
Expand All @@ -74,6 +92,7 @@ Component({
});
};
wx.lin.hideLoading = () => {
console.warn('wx.lin 已废弃,请使用开放函数代替:https://doc.mini.talelin.com//start/open-function.html');
this.setData({
show: false
});
Expand All @@ -83,5 +102,48 @@ Component({
doNothingMove() {
// do nothing……
},

// ========== 开放函数 =============

/**
* 显示 Loading
* @param {*} options Loading 组件参数
*/
linShow(options) {
if (!options) {
options = {};
}

const {
custom = false,
fullScreen = false,
color = '',
type = 'rotate',
size = 'medium',
opacity = '1',
bgColor = '',
zIndex = '776',
} = { ...options };
this.setData({
bgColor,
zIndex,
custom,
fullScreen,
color,
type,
size,
opacity,
show: true
});
},

/**
* 隐藏 Loading
*/
linHide() {
this.setData({
show: false
});
}
}
});

0 comments on commit f1a6ec9

Please sign in to comment.