init
This commit is contained in:
5
xhs-mini-demos/api-case/loading/loading.css
Normal file
5
xhs-mini-demos/api-case/loading/loading.css
Normal file
@@ -0,0 +1,5 @@
|
||||
|
||||
|
||||
.loading-container button {
|
||||
margin: 20px 0;
|
||||
}
|
||||
86
xhs-mini-demos/api-case/loading/loading.js
Normal file
86
xhs-mini-demos/api-case/loading/loading.js
Normal file
@@ -0,0 +1,86 @@
|
||||
const __templateJs = require("./templates.js");
|
||||
const __mergePageOptions = require("../../util/mergePageOptions.js");
|
||||
Page(__mergePageOptions({
|
||||
onShareAppMessage() {
|
||||
return {
|
||||
title: 'loading弹窗',
|
||||
path: 'packageAPI/pages/loading/loading'
|
||||
};
|
||||
},
|
||||
data: {
|
||||
apiData: {
|
||||
content: '',
|
||||
success: false,
|
||||
fail: false,
|
||||
complete: false
|
||||
}
|
||||
},
|
||||
resetApiData() {
|
||||
this.setData({
|
||||
apiData: {
|
||||
success: false,
|
||||
fail: false,
|
||||
complete: false,
|
||||
content: ''
|
||||
}
|
||||
});
|
||||
},
|
||||
updateApiData(type, content) {
|
||||
const apiData = {
|
||||
...this.data.apiData
|
||||
};
|
||||
apiData[type] = true;
|
||||
apiData.content = content;
|
||||
this.setData({
|
||||
apiData
|
||||
});
|
||||
},
|
||||
common(config) {
|
||||
this.resetApiData();
|
||||
xhs.showLoading({
|
||||
...config,
|
||||
success: res => {
|
||||
this.updateApiData('success', res);
|
||||
},
|
||||
fail: res => {
|
||||
this.updateApiData('fail', res);
|
||||
},
|
||||
complete: res => {
|
||||
this.updateApiData('complete', res);
|
||||
}
|
||||
});
|
||||
},
|
||||
title() {
|
||||
this.common({
|
||||
title: 'loading'
|
||||
});
|
||||
},
|
||||
fail() {
|
||||
this.common({
|
||||
title: '自定义文案'
|
||||
});
|
||||
},
|
||||
mask() {
|
||||
this.common({
|
||||
title: 'loading',
|
||||
mask: true
|
||||
});
|
||||
setTimeout(() => {
|
||||
xhs.hideLoading({});
|
||||
}, 2000);
|
||||
},
|
||||
hide() {
|
||||
this.resetApiData();
|
||||
xhs.hideLoading({
|
||||
success: res => {
|
||||
this.updateApiData('success', res);
|
||||
},
|
||||
fail: res => {
|
||||
this.updateApiData('fail', res);
|
||||
},
|
||||
complete: res => {
|
||||
this.updateApiData('complete', res);
|
||||
}
|
||||
});
|
||||
}
|
||||
}, __templateJs));
|
||||
8
xhs-mini-demos/api-case/loading/loading.json
Normal file
8
xhs-mini-demos/api-case/loading/loading.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"navigationBarTitleText": "加载动画框",
|
||||
"usingComponents": {
|
||||
"showbox": "../../common/component/showbox/index",
|
||||
"box": "../../common/component/container/index",
|
||||
"api-status": "../../common/component/api-status/index"
|
||||
}
|
||||
}
|
||||
13
xhs-mini-demos/api-case/loading/loading.xhsml
Normal file
13
xhs-mini-demos/api-case/loading/loading.xhsml
Normal file
@@ -0,0 +1,13 @@
|
||||
<view class="container">
|
||||
<showbox title="基础使用">
|
||||
<box>
|
||||
<view class="_ui-space">
|
||||
<button class="_ui-button" hover-class="_ui-button-hover" bindtap="title">显示加载动画</button>
|
||||
<button class="_ui-button" hover-class="_ui-button-hover" bindtap="fail">自定义加载文案</button>
|
||||
<button class="_ui-button" hover-class="_ui-button-hover" bindtap="mask">带有遮罩层(不可点击)</button>
|
||||
<button class="_ui-button" hover-class="_ui-button-hover" bindtap="hide">隐藏加载动画</button>
|
||||
</view>
|
||||
</box>
|
||||
</showbox>
|
||||
</view>
|
||||
<include src="templates.xhsml" />
|
||||
97
xhs-mini-demos/api-case/loading/templates.js
Normal file
97
xhs-mini-demos/api-case/loading/templates.js
Normal file
@@ -0,0 +1,97 @@
|
||||
/** 以下内容为自动生成,请勿手动修改 */
|
||||
|
||||
module.exports = {
|
||||
data: {
|
||||
page_data_0: "",
|
||||
|
||||
page_data_1: "",
|
||||
|
||||
page_data_2: false,
|
||||
|
||||
page_data_3: false,
|
||||
|
||||
page_data_4: false,
|
||||
|
||||
page_data_5: "",
|
||||
|
||||
page_data_6: false,
|
||||
|
||||
page_data_7: false,
|
||||
|
||||
page_data_8: false,
|
||||
|
||||
page_data_9: "",
|
||||
},
|
||||
|
||||
page_fun_1(e) {
|
||||
this.setData("page_data_0", e.detail.value);
|
||||
},
|
||||
|
||||
page_fun_2(e) {
|
||||
this.setData("page_data_1", e.detail.value);
|
||||
},
|
||||
|
||||
page_fun_0() {
|
||||
this.setData({
|
||||
page_data_2: false,
|
||||
page_data_3: false,
|
||||
page_data_4: false,
|
||||
});
|
||||
|
||||
xhs.showLoading({
|
||||
success: (res) => {
|
||||
console.log("success", res);
|
||||
this.setData({
|
||||
page_data_2: true,
|
||||
page_data_5: JSON.stringify(res),
|
||||
});
|
||||
},
|
||||
fail: (res) => {
|
||||
console.log("fail", res);
|
||||
this.setData({
|
||||
page_data_3: true,
|
||||
page_data_5: JSON.stringify(res),
|
||||
});
|
||||
},
|
||||
complete: (res) => {
|
||||
console.log("complete", res);
|
||||
this.setData({
|
||||
page_data_4: true,
|
||||
});
|
||||
},
|
||||
title: this.data.page_data_0,
|
||||
mask: this.data.page_data_1,
|
||||
});
|
||||
},
|
||||
|
||||
page_fun_3() {
|
||||
this.setData({
|
||||
page_data_6: false,
|
||||
page_data_7: false,
|
||||
page_data_8: false,
|
||||
});
|
||||
|
||||
xhs.hideLoading({
|
||||
success: (res) => {
|
||||
console.log("success", res);
|
||||
this.setData({
|
||||
page_data_6: true,
|
||||
page_data_9: JSON.stringify(res),
|
||||
});
|
||||
},
|
||||
fail: (res) => {
|
||||
console.log("fail", res);
|
||||
this.setData({
|
||||
page_data_7: true,
|
||||
page_data_9: JSON.stringify(res),
|
||||
});
|
||||
},
|
||||
complete: (res) => {
|
||||
console.log("complete", res);
|
||||
this.setData({
|
||||
page_data_8: true,
|
||||
});
|
||||
},
|
||||
});
|
||||
},
|
||||
};
|
||||
54
xhs-mini-demos/api-case/loading/templates.xhsml
Normal file
54
xhs-mini-demos/api-case/loading/templates.xhsml
Normal file
@@ -0,0 +1,54 @@
|
||||
<!-- 以下内容为自动生成,请勿手动修改 -->
|
||||
|
||||
<view class="container">
|
||||
<showbox title="showLoading演示">
|
||||
<box>
|
||||
<api-status
|
||||
success="{{page_data_2}}"
|
||||
complete="{{page_data_4}}"
|
||||
fail="{{page_data_3}}"
|
||||
text="{{page_data_5}}"
|
||||
>
|
||||
</api-status>
|
||||
<view class="_ui-space _mt8">
|
||||
<view class="_ui-input">
|
||||
<input placeholder="title" type="text" bindinput="page_fun_1" />
|
||||
</view>
|
||||
|
||||
<view class="_dflex _jc_space-between">
|
||||
<text class="_dflex _ai_center _px8">是否开启mask</text>
|
||||
<switch color="rgba(255, 36, 66, 1)" bindchange="page_fun_2" />
|
||||
</view>
|
||||
|
||||
<button
|
||||
class="_ui-button"
|
||||
hover-class="_ui-button-hover"
|
||||
bindtap="page_fun_0"
|
||||
>
|
||||
触发
|
||||
</button>
|
||||
</view>
|
||||
</box>
|
||||
</showbox>
|
||||
|
||||
<showbox title="hideLoading演示">
|
||||
<box>
|
||||
<api-status
|
||||
success="{{page_data_6}}"
|
||||
complete="{{page_data_8}}"
|
||||
fail="{{page_data_7}}"
|
||||
text="{{page_data_9}}"
|
||||
>
|
||||
</api-status>
|
||||
<view class="_ui-space _mt8">
|
||||
<button
|
||||
class="_ui-button"
|
||||
hover-class="_ui-button-hover"
|
||||
bindtap="page_fun_3"
|
||||
>
|
||||
触发
|
||||
</button>
|
||||
</view>
|
||||
</box>
|
||||
</showbox>
|
||||
</view>
|
||||
Reference in New Issue
Block a user