init
This commit is contained in:
44
xhs-mini-demos/api-case/get-user-info/get-user-info.js
Normal file
44
xhs-mini-demos/api-case/get-user-info/get-user-info.js
Normal file
@@ -0,0 +1,44 @@
|
||||
const __templateJs = require("./templates.js");
|
||||
const __mergePageOptions = require("../../util/mergePageOptions.js");
|
||||
Page(__mergePageOptions({
|
||||
onShareAppMessage() {
|
||||
return {
|
||||
title: '获取用户信息',
|
||||
path: 'packageAPI/pages/get-user-info/get-user-info'
|
||||
};
|
||||
},
|
||||
data: {
|
||||
apiData: {
|
||||
content: '',
|
||||
success: false,
|
||||
fail: false,
|
||||
complete: false
|
||||
},
|
||||
info: ''
|
||||
},
|
||||
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
|
||||
});
|
||||
},
|
||||
getUserInfo(e) {
|
||||
this.setData({
|
||||
info: JSON.stringify(e)
|
||||
});
|
||||
}
|
||||
}, __templateJs));
|
||||
8
xhs-mini-demos/api-case/get-user-info/get-user-info.json
Normal file
8
xhs-mini-demos/api-case/get-user-info/get-user-info.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"
|
||||
}
|
||||
}
|
||||
16
xhs-mini-demos/api-case/get-user-info/get-user-info.xhsml
Normal file
16
xhs-mini-demos/api-case/get-user-info/get-user-info.xhsml
Normal file
@@ -0,0 +1,16 @@
|
||||
<view class="container">
|
||||
<showbox title="获取用户信息">
|
||||
<box>
|
||||
<view class="_ui-space">
|
||||
<view class="_text_wrap">
|
||||
用户信息:
|
||||
{{info}}
|
||||
</view>
|
||||
<view>
|
||||
<button class="_ui-button" hover-class="_ui-button-hover" open-type="getUserInfo" bindgetuserinfo="getUserInfo">获取用户信息</button>
|
||||
</view>
|
||||
</view>
|
||||
</box>
|
||||
</showbox>
|
||||
</view>
|
||||
<include src="templates.xhsml" />
|
||||
44
xhs-mini-demos/api-case/get-user-info/templates.js
Normal file
44
xhs-mini-demos/api-case/get-user-info/templates.js
Normal file
@@ -0,0 +1,44 @@
|
||||
/** 以下内容为自动生成,请勿手动修改 */
|
||||
|
||||
module.exports = {
|
||||
data: {
|
||||
page_data_0: false,
|
||||
|
||||
page_data_1: false,
|
||||
|
||||
page_data_2: false,
|
||||
|
||||
page_data_3: "",
|
||||
},
|
||||
|
||||
page_fun_0() {
|
||||
this.setData({
|
||||
page_data_0: false,
|
||||
page_data_1: false,
|
||||
page_data_2: false,
|
||||
});
|
||||
|
||||
xhs.getUserProfile({
|
||||
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,
|
||||
});
|
||||
},
|
||||
});
|
||||
},
|
||||
};
|
||||
24
xhs-mini-demos/api-case/get-user-info/templates.xhsml
Normal file
24
xhs-mini-demos/api-case/get-user-info/templates.xhsml
Normal file
@@ -0,0 +1,24 @@
|
||||
<!-- 以下内容为自动生成,请勿手动修改 -->
|
||||
|
||||
<view class="container">
|
||||
<showbox title="getUserProfile演示">
|
||||
<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>
|
||||
</view>
|
||||
Reference in New Issue
Block a user