init
This commit is contained in:
7
xhs-mini-demos/api-case/ext-config/ext-config.css
Normal file
7
xhs-mini-demos/api-case/ext-config/ext-config.css
Normal file
@@ -0,0 +1,7 @@
|
||||
|
||||
|
||||
._dflex button{
|
||||
margin: 10px 0;
|
||||
background-color: red;
|
||||
color: white;
|
||||
}
|
||||
23
xhs-mini-demos/api-case/ext-config/ext-config.js
Normal file
23
xhs-mini-demos/api-case/ext-config/ext-config.js
Normal file
@@ -0,0 +1,23 @@
|
||||
const __templateJs = require("./templates.js");
|
||||
const __mergePageOptions = require("../../util/mergePageOptions.js");
|
||||
Page(__mergePageOptions({
|
||||
data: {
|
||||
config: ''
|
||||
},
|
||||
getExtConfig() {
|
||||
xhs.getExtConfig({
|
||||
success: res => {
|
||||
this.setData({
|
||||
content: JSON.stringify(res)
|
||||
});
|
||||
},
|
||||
fail: res => {}
|
||||
});
|
||||
},
|
||||
getExtConfigSync() {
|
||||
const data = xhs.getExtConfigSync();
|
||||
this.setData({
|
||||
content: JSON.stringify(data)
|
||||
});
|
||||
}
|
||||
}, __templateJs));
|
||||
8
xhs-mini-demos/api-case/ext-config/ext-config.json
Normal file
8
xhs-mini-demos/api-case/ext-config/ext-config.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"
|
||||
}
|
||||
}
|
||||
12
xhs-mini-demos/api-case/ext-config/ext-config.xhsml
Normal file
12
xhs-mini-demos/api-case/ext-config/ext-config.xhsml
Normal file
@@ -0,0 +1,12 @@
|
||||
<view class="container">
|
||||
<showbox title="获取第三方平台定义的数据">
|
||||
<box>
|
||||
<view class="_ui-space">
|
||||
<view xhs:if="{{content}}">config: {{content}}</view>
|
||||
<button class="_ui-button" hover-class="_ui-button-hover" bindtap="getExtConfig">异步获取</button>
|
||||
<button class="_ui-button" hover-class="_ui-button-hover" bindtap="getExtConfigSync">同步获取</button>
|
||||
</view>
|
||||
</box>
|
||||
</showbox>
|
||||
</view>
|
||||
<include src="templates.xhsml" />
|
||||
84
xhs-mini-demos/api-case/ext-config/templates.js
Normal file
84
xhs-mini-demos/api-case/ext-config/templates.js
Normal file
@@ -0,0 +1,84 @@
|
||||
/** 以下内容为自动生成,请勿手动修改 */
|
||||
|
||||
module.exports = {
|
||||
data: {
|
||||
page_data_0: false,
|
||||
|
||||
page_data_1: false,
|
||||
|
||||
page_data_2: false,
|
||||
|
||||
page_data_3: "",
|
||||
|
||||
page_data_4: false,
|
||||
|
||||
page_data_5: false,
|
||||
|
||||
page_data_6: false,
|
||||
|
||||
page_data_7: "",
|
||||
},
|
||||
|
||||
page_fun_0() {
|
||||
this.setData({
|
||||
page_data_0: false,
|
||||
page_data_1: false,
|
||||
page_data_2: false,
|
||||
});
|
||||
|
||||
xhs.getExtConfig({
|
||||
success: (res) => {
|
||||
console.log("success", res);
|
||||
this.setData({
|
||||
page_data_0: true,
|
||||
page_data_3: JSON.stringify(res),
|
||||
});
|
||||
},
|
||||
fail: (res) => {
|
||||
console.log("fail", res);
|
||||
this.setData({
|
||||
page_data_1: true,
|
||||
page_data_3: JSON.stringify(res),
|
||||
});
|
||||
},
|
||||
complete: (res) => {
|
||||
console.log("complete", res);
|
||||
this.setData({
|
||||
page_data_2: true,
|
||||
});
|
||||
},
|
||||
});
|
||||
},
|
||||
|
||||
page_fun_1() {
|
||||
this.setData({
|
||||
page_data_4: false,
|
||||
page_data_5: false,
|
||||
page_data_6: false,
|
||||
});
|
||||
|
||||
let res;
|
||||
try {
|
||||
res = xhs.getExtConfigSync() ?? "无返回值";
|
||||
} catch (err) {
|
||||
console.log("fail", res);
|
||||
this.setData({
|
||||
page_data_5: true,
|
||||
page_data_7: JSON.stringify(res),
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
console.log("success", res);
|
||||
this.setData({
|
||||
page_data_4: true,
|
||||
page_data_7: JSON.stringify(res),
|
||||
});
|
||||
|
||||
console.log("complete", res);
|
||||
this.setData({
|
||||
page_data_6: true,
|
||||
});
|
||||
},
|
||||
};
|
||||
45
xhs-mini-demos/api-case/ext-config/templates.xhsml
Normal file
45
xhs-mini-demos/api-case/ext-config/templates.xhsml
Normal file
@@ -0,0 +1,45 @@
|
||||
<!-- 以下内容为自动生成,请勿手动修改 -->
|
||||
|
||||
<view class="container">
|
||||
<showbox title="getExtConfig演示">
|
||||
<box>
|
||||
<api-status
|
||||
success="{{page_data_0}}"
|
||||
complete="{{page_data_2}}"
|
||||
fail="{{page_data_1}}"
|
||||
text="{{page_data_3}}"
|
||||
>
|
||||
</api-status>
|
||||
<view class="_ui-space _mt8">
|
||||
<button
|
||||
class="_ui-button"
|
||||
hover-class="_ui-button-hover"
|
||||
bindtap="page_fun_0"
|
||||
>
|
||||
触发
|
||||
</button>
|
||||
</view>
|
||||
</box>
|
||||
</showbox>
|
||||
|
||||
<showbox title="getExtConfigSync演示">
|
||||
<box>
|
||||
<api-status
|
||||
success="{{page_data_4}}"
|
||||
complete="{{page_data_6}}"
|
||||
fail="{{page_data_5}}"
|
||||
text="{{page_data_7}}"
|
||||
>
|
||||
</api-status>
|
||||
<view class="_ui-space _mt8">
|
||||
<button
|
||||
class="_ui-button"
|
||||
hover-class="_ui-button-hover"
|
||||
bindtap="page_fun_1"
|
||||
>
|
||||
触发
|
||||
</button>
|
||||
</view>
|
||||
</box>
|
||||
</showbox>
|
||||
</view>
|
||||
Reference in New Issue
Block a user