This commit is contained in:
2025-09-14 00:21:54 +08:00
commit d40b3bbd62
766 changed files with 36275 additions and 0 deletions

View File

@@ -0,0 +1,98 @@
.img {
width: 100%;
height: 100%;
}
.view12 {
display: none;
font-size: larger;
background-color: aqua;
}
.container {
font-size: 32rpx;
}
.share-landing-showcase {
width: 100%;
margin-top: 10rpx;
border: 1rpx solid #ccc;
border-radius: 10rpx;
display: inline-block;
text-align: center;
}
.code {
background-color: #2d2d2d; /* 深色背景 */
color: #f8f8f2; /* 代码文本颜色 */
font-family: 'Courier New', Courier, monospace;
font-size: 14px;
line-height: 1.5;
white-space: pre-wrap; /* 保持换行 */
overflow-x: auto; /* 水平滚动条 */
}
.code-placeholader {
width: 22rpx;
display: inline-block;
}
.share-landing-showcase-image {
width: 50%;
}
.title {
font-weight: bold;
font-size: 26rpx;
color: #333;
margin-top: 20rpx;
}
.share-desc {
font-size: 28rpx;
color: var(--xhs-theme-color);
font-weight: bold;
font-style: italic;
margin-top: 20rpx;
}
.share-resp {
border: 1px solid rgab(0, 0, 0, 0.1);
background: #f2f2f2;
font-style: italic;
font-size: 24rpx;
padding: 10px;
color: rgba(0, 0, 0, 0.55);
min-height: 200rpx;
}
.share-resp-ticket {
font-size: 30rpx;
color: #a62222;
font-weight: bold;
margin-top: 20rpx;
}
.share-resp-ticket-sub {
margin-left: -10px;
margin-top: -2px;
text-align: start;
}
.sub_desc {
--grey-53: ;
font-size: 26rpx;
margin: 10rpx;
color: rgba(0, 0, 0, .53);
}
.share-input {
width: 100%;
border: 1px solid rgab(0, 0, 0, 0.1);
background: #f2f2f2;
font-style: italic;
font-size: 24rpx;
padding: 10px;
color: rgba(0, 0, 0, 0.55);
min-height: 100rpx;
}

View File

@@ -0,0 +1,57 @@
Page({
data: {
shareTicket: '',
shareInfo: null,
// launchOptions
launchOptions: null,
launchOptionKeys: [],
// entryOptions
entryOptions: null,
entryOptionKeys: [],
},
getLaunchOptions() {
const options = xhs.getLaunchOptionsSync();
this.setData({
launchOptions: options,
launchOptionKeys: Object.keys(options)
});
},
getEnterOptions() {
const options = xhs.getEnterOptionsSync();
this.setData({
entryOption: options,
entryOptionKeys: Object.keys(options)
});
},
copyShareTicket(e) {
console.log('====> 获取到的 shareTicket', e?.target?.dataset?.shareticket);
xhs.setClipboardData({ data: e?.target?.dataset?.shareticket || '未获取到 shareTicket' });
},
bindTextareaNoBindInput(e) {
this.setData({ shareTicket: e.detail.value });
},
getShareInfo() {
if (!this.data.shareTicket) {
xhs.showToast({ title: '请先获取 shareTicket' });
return;
}
let _this = this;
xhs.getShareInfo({
shareTicket: _this.data.shareTicket,
success(res) {
console.log('getShareInfo success', res);
_this.setData({ shareInfo: '获取 shareInfo 信息成功:' + JSON.stringify(res) });
},
fail(err) {
console.log('getShareInfo fail', err);
_this.setData({ shareInfo: '获取 shareInfo 信息失败:' + JSON.stringify(err) });
}
});
}
});

View File

@@ -0,0 +1,7 @@
{
"navigationBarTitleText": "站外分享(截屏能力)演示",
"usingComponents": {
"showbox": "../../common/component/showbox/index",
"box": "../../common/component/container/index"
}
}

View File

@@ -0,0 +1,97 @@
<view class="container">
<showbox title="当前页面用于演示 shareTicket 分享的用法">
<box class="box">
<view class="title">xhs.getLaunchOptionsSync()</view>
<button bindtap="getLaunchOptions">点进获取 launchOptions</button>
<view class="sub_desc">获取小程序启动时的参数。与 App.onLaunch 的回调参数一致。</view>
<view>
<view class="share-desc">
返回结果:
</view>
<view class="share-resp _mt8">
<block xhs:if="{{launchOptionKeys.length}}">
<view xhs:for="{{launchOptionKeys}}" xhs:key="{{item}}">
<text
bindtap="copyShareTicket"
xhs:if="{{item === 'shareTicket'}}"
class="share-resp-ticket"
data-shareticket="{{launchOptions[item]}}"
>
{{ item }}: {{ launchOptions[item] }},
</text>
<view
xhs:if="{{item === 'shareTicket'}}"
class="share-resp-ticket share-resp-ticket-sub"
>[点击文本复制并粘贴到下面的输入框中]</view>
<text xhs:else>
{{ item }}: {{ JSON.stringify(launchOptions[item], null, 2) }},
</text>
</view>
</block>
<block xhs:else>
暂无返回
</block>
</view>
</view>
</box>
<box class="box">
<view class="title">xhs.getEnterOptionsSync()</view>
<button bindtap="getEnterOptions">点进获取 entryOptions</button>
<view class="sub_desc">获取本次小程序启动时的参数。如果当前是冷启动,则返回值与 App.onLaunch 的回调参数一致;如果当前是热启动,则返回值与 App.onShow 一致。</view>
<view>
<view class="share-desc">
返回结果:
</view>
<view class="share-resp _mt8">
<block xhs:if="{{entryOptionKeys.length}}">
<view xhs:for="{{entryOptionKeys}}" xhs:key="{{item}}">
<text
bindtap="copyShareTicket"
xhs:if="{{item === 'shareTicket'}}"
class="share-resp-ticket"
data-shareticket="{{entryOption[item]}}"
>
{{ item }}: {{ entryOption[item] }},
</text>
<view
xhs:if="{{item === 'shareTicket'}}"
class="share-resp-ticket share-resp-ticket-sub"
>[点击文本复制并粘贴到下面的输入框中]</view>
<text xhs:else>
{{ item }}: {{ JSON.stringify(entryOption[item], null, 2) }},
</text>
</view>
</block>
<block xhs:else>
暂无返回
</block>
</view>
</view>
</box>
</showbox>
<showbox title="在此处获取shareTicket对应的分享信息">
<box class="box">
<view class="share-desc">
粘贴信息:
</view>
<textarea
class="share-input"
value="{{ shareTicket }}"
auto-height
placeholder="粘贴 shareTicket 到此处"
placeholder-style="color: #3333334D;"
bindinput="bindTextareaNoBindInput"
/>
<view class="share-desc">
分享信息:
</view>
<button bindtap="getShareInfo">点击获取分享信息</button>
<view class="share-resp _mt8">
{{ shareInfo ? JSON.stringify(shareInfo, null, 2) : '暂未获取到分享信息' }}
</view>
</box>
</showbox>
</view>