init
This commit is contained in:
@@ -0,0 +1 @@
|
||||
|
||||
66
xhs-mini-demos/api-case/make-phone-call/make-phone-call.js
Normal file
66
xhs-mini-demos/api-case/make-phone-call/make-phone-call.js
Normal file
@@ -0,0 +1,66 @@
|
||||
const __templateJs = require("./templates.js");
|
||||
const __mergePageOptions = require("../../util/mergePageOptions.js");
|
||||
Page(__mergePageOptions({
|
||||
onShareAppMessage() {
|
||||
return {
|
||||
title: '打电话',
|
||||
path: 'packageAPI/pages/make-phone-call/make-phone-call'
|
||||
};
|
||||
},
|
||||
data: {
|
||||
disabled: true,
|
||||
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
|
||||
});
|
||||
},
|
||||
bindInput(e) {
|
||||
this.inputValue = e.detail.value;
|
||||
if (this.inputValue.length > 0) {
|
||||
this.setData({
|
||||
disabled: false
|
||||
});
|
||||
} else {
|
||||
this.setData({
|
||||
disabled: true
|
||||
});
|
||||
}
|
||||
},
|
||||
makePhoneCall() {
|
||||
this.resetApiData();
|
||||
xhs.makePhoneCall({
|
||||
phoneNumber: this.inputValue,
|
||||
success: e => {
|
||||
this.updateApiData('success', e);
|
||||
},
|
||||
fail: e => {
|
||||
this.updateApiData('fail', e);
|
||||
},
|
||||
complete: e => {
|
||||
this.updateApiData('complete', e);
|
||||
}
|
||||
});
|
||||
}
|
||||
}, __templateJs));
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"navigationBarTitleText": "打电话",
|
||||
"usingComponents": {
|
||||
"showbox": "../../common/component/showbox/index",
|
||||
"box": "../../common/component/container/index",
|
||||
"api-status": "../../common/component/api-status/index"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<view class="container">
|
||||
<showbox title="打电话">
|
||||
<box>
|
||||
<view class="page-section">
|
||||
<view class="desc">请在下方输入电话号码:</view>
|
||||
<view class="_ui-input _my8">
|
||||
<input type="number" name="input" bindinput="bindInput" />
|
||||
</view>
|
||||
<view>
|
||||
<button class="_ui-button" hover-class="_ui-button-hover" bindtap="makePhoneCall">拨打</button>
|
||||
</view>
|
||||
</view>
|
||||
</box>
|
||||
</showbox>
|
||||
</view>
|
||||
<include src="templates.xhsml" />
|
||||
51
xhs-mini-demos/api-case/make-phone-call/templates.js
Normal file
51
xhs-mini-demos/api-case/make-phone-call/templates.js
Normal file
@@ -0,0 +1,51 @@
|
||||
/** 以下内容为自动生成,请勿手动修改 */
|
||||
|
||||
module.exports = {
|
||||
data: {
|
||||
page_data_0: "",
|
||||
|
||||
page_data_1: false,
|
||||
|
||||
page_data_2: false,
|
||||
|
||||
page_data_3: false,
|
||||
|
||||
page_data_4: "",
|
||||
},
|
||||
|
||||
page_fun_1(e) {
|
||||
this.setData("page_data_0", e.detail.value);
|
||||
},
|
||||
|
||||
page_fun_0() {
|
||||
this.setData({
|
||||
page_data_1: false,
|
||||
page_data_2: false,
|
||||
page_data_3: false,
|
||||
});
|
||||
|
||||
xhs.makePhoneCall({
|
||||
success: (res) => {
|
||||
console.log("success", res);
|
||||
this.setData({
|
||||
page_data_1: true,
|
||||
page_data_4: JSON.stringify(res),
|
||||
});
|
||||
},
|
||||
fail: (res) => {
|
||||
console.log("fail", res);
|
||||
this.setData({
|
||||
page_data_2: true,
|
||||
page_data_4: JSON.stringify(res),
|
||||
});
|
||||
},
|
||||
complete: (res) => {
|
||||
console.log("complete", res);
|
||||
this.setData({
|
||||
page_data_3: true,
|
||||
});
|
||||
},
|
||||
phoneNumber: this.data.page_data_0,
|
||||
});
|
||||
},
|
||||
};
|
||||
28
xhs-mini-demos/api-case/make-phone-call/templates.xhsml
Normal file
28
xhs-mini-demos/api-case/make-phone-call/templates.xhsml
Normal file
@@ -0,0 +1,28 @@
|
||||
<!-- 以下内容为自动生成,请勿手动修改 -->
|
||||
|
||||
<view class="container">
|
||||
<showbox title="makePhoneCall演示">
|
||||
<box>
|
||||
<api-status
|
||||
success="{{page_data_1}}"
|
||||
complete="{{page_data_3}}"
|
||||
fail="{{page_data_2}}"
|
||||
text="{{page_data_4}}"
|
||||
>
|
||||
</api-status>
|
||||
<view class="_ui-space _mt8">
|
||||
<view class="_ui-input">
|
||||
<input placeholder="phoneNumber" type="text" bindinput="page_fun_1" />
|
||||
</view>
|
||||
|
||||
<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