33 lines
527 B
JavaScript
33 lines
527 B
JavaScript
|
|
import { Subject } from "../lib/Rx";
|
||
|
|
|
||
|
|
const sub = new Subject();
|
||
|
|
|
||
|
|
let loading_count = 0;
|
||
|
|
|
||
|
|
export function OpenLoading() {
|
||
|
|
if (loading_count === 0)
|
||
|
|
wx.showLoading({
|
||
|
|
title: "正在加载...",
|
||
|
|
mask: true
|
||
|
|
});
|
||
|
|
loading_count++;
|
||
|
|
|
||
|
|
sub.next(loading_count);
|
||
|
|
}
|
||
|
|
|
||
|
|
export function CloseLoading() {
|
||
|
|
if (loading_count > 0) {
|
||
|
|
loading_count--;
|
||
|
|
}
|
||
|
|
|
||
|
|
// if (loading_count <= 0) wx.hideLoading();
|
||
|
|
|
||
|
|
sub.next(loading_count);
|
||
|
|
}
|
||
|
|
|
||
|
|
sub.debounceTime(500).subscribe(t => {
|
||
|
|
if (t === 0) {
|
||
|
|
wx.hideLoading();
|
||
|
|
}
|
||
|
|
});
|