feat: 分享到朋友圈

This commit is contained in:
eric
2022-11-26 03:47:34 +08:00
parent 77d925c856
commit d98b4871a1
3 changed files with 44 additions and 3 deletions

View File

@@ -1,4 +1,6 @@
const config = {
enableShareTimeline: true,//允许分享到朋友圈
enableShareAppMessage: true,
projectName: "myApp",
date: "2022-11-13",
designWidth: 750,

File diff suppressed because one or more lines are too long

View File

@@ -16,7 +16,7 @@ import React, { useCallback, useEffect, useState } from "react";
import { Swiper, SwiperItem, Image } from "@antmjs/vantui";
import react from "react";
import { NoticeBar } from "@antmjs/vantui";
import Taro from "@tarojs/taro";
import Taro, { useShareTimeline } from "@tarojs/taro";
import { Tabbar, TabbarItem } from "@antmjs/vantui";
import TabbarCom from "../components/TabbarCom";
import {
@@ -51,6 +51,26 @@ const Home = () => {
const onChange = (e) => {};
Taro.useShareAppMessage((res) => {
if (res.from === "button") {
// 来自页面内转发按钮
console.log(res.target);
}
return {
title: "自定义转发标题",
path: "/page/user?id=123",
};
});
// 分享到朋友圈
useShareTimeline(() => {
return {
title: "分享朋友圈", //字符串 自定义标题
// query: `id=${this.data.shop.shop_id}`, //页面携带参数
// imageUrl: moments //图片地址
};
});
useEffect(() => {
// 设置标题
definePageConfig({
@@ -464,7 +484,8 @@ const Home = () => {
{/* 小红书图文/视频信息流 */}
{/* <View> 打开信息流</View> */}
<View style={{marginTop:'20px'}}>
{/* 扫码的场景(才会显示) */}
<View style={{ marginTop: "20px" }}>
{" "}
{/* 个人版本未生效 */}
<OfficialAccount
@@ -477,6 +498,24 @@ const Home = () => {
></OfficialAccount>
</View>
{/* 打开视频号主页-需要开放平台主主体认证 */}
{/* <View
onClick={() => {
Taro.openChannelsUserProfile({
finderUserName: "sphqzUmI0BlppCI", //视频号id
success: (res: any) => {
console.log("加载成功", res);
},
fail: (error: any) => {
console.log("加载成功", error);
},
});
}}
>
{" "}
打开视频号主页
</View> */}
<Toast id="vanToast-demo2" />
<TabbarCom active={0} />