init
This commit is contained in:
7
xhs-mini-demos/api-case/share/share.css
Normal file
7
xhs-mini-demos/api-case/share/share.css
Normal file
@@ -0,0 +1,7 @@
|
||||
|
||||
|
||||
._dflex button {
|
||||
margin: 10px 0;
|
||||
color: white;
|
||||
background-color: red;
|
||||
}
|
||||
109
xhs-mini-demos/api-case/share/share.js
Normal file
109
xhs-mini-demos/api-case/share/share.js
Normal file
@@ -0,0 +1,109 @@
|
||||
const __templateJs = require("./templates.js");
|
||||
const __mergePageOptions = require("../../util/mergePageOptions.js");
|
||||
Page(__mergePageOptions({
|
||||
onShareAppMessage() {
|
||||
if (this.data.promise) {
|
||||
const promise = Promise.resolve({
|
||||
title: '自定义转发标题Promise',
|
||||
desc: '自定义转发描述Promise',
|
||||
path: '/api-case/share/share'
|
||||
});
|
||||
return {
|
||||
...this.data.shareData,
|
||||
promise
|
||||
};
|
||||
}
|
||||
return {
|
||||
...this.data.shareData
|
||||
};
|
||||
},
|
||||
data: {
|
||||
shareData: {
|
||||
title: '自定义转发标题',
|
||||
desc: '自定义转发描述',
|
||||
path: '/api-case/share/share',
|
||||
imageUrl: 'https://dss0.bdstatic.com/5aV1bjqh_Q23odCf/static/superman/img/topnav/baiduyun@2x-e0be79e69e.png'
|
||||
},
|
||||
apiData: {
|
||||
content: '',
|
||||
success: false,
|
||||
fail: false,
|
||||
complete: false
|
||||
},
|
||||
promise: 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
|
||||
});
|
||||
},
|
||||
showShareMenu() {
|
||||
this.resetApiData();
|
||||
xhs.showShareMenu({
|
||||
success: res => {
|
||||
console.log("%c Line:59 🥝 showShareMenu res", "color:#ffdd4d", res);
|
||||
this.updateApiData('success', res);
|
||||
},
|
||||
fail: res => {
|
||||
console.log("%c Line:59 🥝 showShareMenu err", "color:#ffdd4d", res);
|
||||
this.updateApiData('fail', res);
|
||||
},
|
||||
complete: res => {
|
||||
this.updateApiData('complete', res);
|
||||
}
|
||||
});
|
||||
},
|
||||
hideShareMenu() {
|
||||
this.resetApiData();
|
||||
xhs.hideShareMenu({
|
||||
shareTypes: 'normal',
|
||||
success: res => {
|
||||
console.log("%c Line:75 🍡 hideShareMenu res", "color:#93c0a4", res);
|
||||
this.updateApiData('success', res);
|
||||
},
|
||||
fail: res => {
|
||||
console.log("%c Line:79 🍩 hideShareMenu err", "color:#465975", res);
|
||||
this.updateApiData('fail', res);
|
||||
},
|
||||
complete: res => {
|
||||
this.updateApiData('complete', res);
|
||||
}
|
||||
});
|
||||
},
|
||||
handleTitle(e) {
|
||||
this.setData({
|
||||
shareData: {
|
||||
...this.data.shareData,
|
||||
title: e.detail.value
|
||||
}
|
||||
});
|
||||
},
|
||||
handleImageUrl(e) {
|
||||
this.setData({
|
||||
shareData: {
|
||||
...this.data.shareData,
|
||||
imageUrl: e.detail.value
|
||||
}
|
||||
});
|
||||
},
|
||||
handlePromise(e) {
|
||||
this.setData({
|
||||
promise: e.detail.value
|
||||
});
|
||||
}
|
||||
}, __templateJs));
|
||||
8
xhs-mini-demos/api-case/share/share.json
Normal file
8
xhs-mini-demos/api-case/share/share.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"
|
||||
}
|
||||
}
|
||||
33
xhs-mini-demos/api-case/share/share.xhsml
Normal file
33
xhs-mini-demos/api-case/share/share.xhsml
Normal file
@@ -0,0 +1,33 @@
|
||||
<view class="container">
|
||||
<showbox title="转发分享">
|
||||
<box>
|
||||
<view>
|
||||
<view>
|
||||
<label>title:</label>
|
||||
<view class="_ui-input _my8">
|
||||
<input type="text" value="{{shareData.title}}" bindinput="handleTitle" />
|
||||
</view>
|
||||
</view>
|
||||
<view>
|
||||
<label>imageUrl:</label>
|
||||
<view class="_ui-input _my8">
|
||||
<input type="text" value="{{shareData.imageUrl}}" bindinput="handleImageUrl" />
|
||||
</view>
|
||||
</view>
|
||||
<view>
|
||||
<label>webviewUrl:</label>
|
||||
<view class="_ui-input _my8">
|
||||
<input type="text" value="{{shareData.imageUrl}}" bindinput="handleImageUrl" />
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="_dflex _fd_column">
|
||||
<button class="_ui-button" hover-class="_ui-button-hover" bindtap="showShareMenu">显示分享</button>
|
||||
<button class="_ui-button" hover-class="_ui-button-hover" bindtap="hideShareMenu">隐藏按钮</button>
|
||||
<button class="_ui-button" hover-class="_ui-button-hover" open-type="share">分享open-type</button>
|
||||
</view>
|
||||
</view>
|
||||
</box>
|
||||
</showbox>
|
||||
</view>
|
||||
<include src="templates.xhsml" />
|
||||
143
xhs-mini-demos/api-case/share/templates.js
Normal file
143
xhs-mini-demos/api-case/share/templates.js
Normal file
@@ -0,0 +1,143 @@
|
||||
/** 以下内容为自动生成,请勿手动修改 */
|
||||
|
||||
module.exports = {
|
||||
data: {
|
||||
page_data_0: "",
|
||||
|
||||
page_data_1: "",
|
||||
|
||||
page_data_2: "",
|
||||
|
||||
page_data_3: false,
|
||||
|
||||
page_data_4: false,
|
||||
|
||||
page_data_5: false,
|
||||
|
||||
page_data_6: "",
|
||||
|
||||
page_data_7: false,
|
||||
|
||||
page_data_8: false,
|
||||
|
||||
page_data_9: false,
|
||||
|
||||
page_data_10: "",
|
||||
|
||||
page_data_11: false,
|
||||
|
||||
page_data_12: false,
|
||||
|
||||
page_data_13: false,
|
||||
|
||||
page_data_14: "",
|
||||
},
|
||||
|
||||
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_3(e) {
|
||||
this.setData("page_data_2", e.detail.value);
|
||||
},
|
||||
|
||||
page_fun_0() {
|
||||
this.setData({
|
||||
page_data_3: false,
|
||||
page_data_4: false,
|
||||
page_data_5: false,
|
||||
});
|
||||
|
||||
xhs.share({
|
||||
success: (res) => {
|
||||
console.log("success", res);
|
||||
this.setData({
|
||||
page_data_3: true,
|
||||
page_data_6: JSON.stringify(res),
|
||||
});
|
||||
},
|
||||
fail: (res) => {
|
||||
console.log("fail", res);
|
||||
this.setData({
|
||||
page_data_4: true,
|
||||
page_data_6: JSON.stringify(res),
|
||||
});
|
||||
},
|
||||
complete: (res) => {
|
||||
console.log("complete", res);
|
||||
this.setData({
|
||||
page_data_5: true,
|
||||
});
|
||||
},
|
||||
title: this.data.page_data_0,
|
||||
path: this.data.page_data_1,
|
||||
imageUrl: this.data.page_data_2,
|
||||
});
|
||||
},
|
||||
|
||||
page_fun_4() {
|
||||
this.setData({
|
||||
page_data_7: false,
|
||||
page_data_8: false,
|
||||
page_data_9: false,
|
||||
});
|
||||
|
||||
xhs.showShareMenu({
|
||||
success: (res) => {
|
||||
console.log("success", res);
|
||||
this.setData({
|
||||
page_data_7: true,
|
||||
page_data_10: JSON.stringify(res),
|
||||
});
|
||||
},
|
||||
fail: (res) => {
|
||||
console.log("fail", res);
|
||||
this.setData({
|
||||
page_data_8: true,
|
||||
page_data_10: JSON.stringify(res),
|
||||
});
|
||||
},
|
||||
complete: (res) => {
|
||||
console.log("complete", res);
|
||||
this.setData({
|
||||
page_data_9: true,
|
||||
});
|
||||
},
|
||||
});
|
||||
},
|
||||
|
||||
page_fun_5() {
|
||||
this.setData({
|
||||
page_data_11: false,
|
||||
page_data_12: false,
|
||||
page_data_13: false,
|
||||
});
|
||||
|
||||
xhs.hideShareMenu({
|
||||
success: (res) => {
|
||||
console.log("success", res);
|
||||
this.setData({
|
||||
page_data_11: true,
|
||||
page_data_14: JSON.stringify(res),
|
||||
});
|
||||
},
|
||||
fail: (res) => {
|
||||
console.log("fail", res);
|
||||
this.setData({
|
||||
page_data_12: true,
|
||||
page_data_14: JSON.stringify(res),
|
||||
});
|
||||
},
|
||||
complete: (res) => {
|
||||
console.log("complete", res);
|
||||
this.setData({
|
||||
page_data_13: true,
|
||||
});
|
||||
},
|
||||
});
|
||||
},
|
||||
};
|
||||
78
xhs-mini-demos/api-case/share/templates.xhsml
Normal file
78
xhs-mini-demos/api-case/share/templates.xhsml
Normal file
@@ -0,0 +1,78 @@
|
||||
<!-- 以下内容为自动生成,请勿手动修改 -->
|
||||
|
||||
<view class="container">
|
||||
<showbox title="share演示">
|
||||
<box>
|
||||
<api-status
|
||||
success="{{page_data_3}}"
|
||||
complete="{{page_data_5}}"
|
||||
fail="{{page_data_4}}"
|
||||
text="{{page_data_6}}"
|
||||
>
|
||||
</api-status>
|
||||
<view class="_ui-space _mt8">
|
||||
<view class="_ui-input">
|
||||
<input placeholder="title" type="text" bindinput="page_fun_1" />
|
||||
</view>
|
||||
|
||||
<view class="_ui-input">
|
||||
<input placeholder="path" type="text" bindinput="page_fun_2" />
|
||||
</view>
|
||||
|
||||
<view class="_ui-input">
|
||||
<input placeholder="imageUrl" type="text" bindinput="page_fun_3" />
|
||||
</view>
|
||||
|
||||
<button
|
||||
class="_ui-button"
|
||||
hover-class="_ui-button-hover"
|
||||
bindtap="page_fun_0"
|
||||
>
|
||||
触发
|
||||
</button>
|
||||
</view>
|
||||
</box>
|
||||
</showbox>
|
||||
|
||||
<showbox title="showShareMenu演示">
|
||||
<box>
|
||||
<api-status
|
||||
success="{{page_data_7}}"
|
||||
complete="{{page_data_9}}"
|
||||
fail="{{page_data_8}}"
|
||||
text="{{page_data_10}}"
|
||||
>
|
||||
</api-status>
|
||||
<view class="_ui-space _mt8">
|
||||
<button
|
||||
class="_ui-button"
|
||||
hover-class="_ui-button-hover"
|
||||
bindtap="page_fun_4"
|
||||
>
|
||||
触发
|
||||
</button>
|
||||
</view>
|
||||
</box>
|
||||
</showbox>
|
||||
|
||||
<showbox title="hideShareMenu演示">
|
||||
<box>
|
||||
<api-status
|
||||
success="{{page_data_11}}"
|
||||
complete="{{page_data_13}}"
|
||||
fail="{{page_data_12}}"
|
||||
text="{{page_data_14}}"
|
||||
>
|
||||
</api-status>
|
||||
<view class="_ui-space _mt8">
|
||||
<button
|
||||
class="_ui-button"
|
||||
hover-class="_ui-button-hover"
|
||||
bindtap="page_fun_5"
|
||||
>
|
||||
触发
|
||||
</button>
|
||||
</view>
|
||||
</box>
|
||||
</showbox>
|
||||
</view>
|
||||
Reference in New Issue
Block a user