|
@@ -72,27 +72,66 @@ export class SdkUtil {
|
|
|
public static shareGame(title: string, imageUrl: string, videoPath: string) {
|
|
|
if(sys.platform == sys.Platform.BYTEDANCE_MINI_GAME) {
|
|
|
if(videoPath!="") {
|
|
|
- this.ttShareScreenRecordVideo(title,videoPath)
|
|
|
+ this.ttShareScreenRecordVideo(config.gameName,videoPath)
|
|
|
}
|
|
|
} else if(sys.platform == sys.Platform.WECHAT_GAME) {
|
|
|
- // 微信分享
|
|
|
+ title = title + '好刺激、好好玩'
|
|
|
+ this.wxShare(title, imageUrl)
|
|
|
}
|
|
|
- // //@ts-ignore
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 微信分享
|
|
|
+ *
|
|
|
+ * @static
|
|
|
+ * @param {string} title
|
|
|
+ * @param {string} imageUrl
|
|
|
+ * @returns
|
|
|
+ * @memberof SdkUtil
|
|
|
+ */
|
|
|
+ public static wxShare(title: string, imageUrl: string) {
|
|
|
+ // console.log('微信分享=',title, 'imageUrl=',imageUrl)
|
|
|
+ wx.showShareMenu({
|
|
|
+ withShareTicket: true,
|
|
|
+ // shareAppMessage(可以删除):显示分享给好友选项,shareTimeline(可以删除):显示分享至朋友圈选项
|
|
|
+ // 可以只开启前者。如果要开启后者,则两者必须都开启才能生效。
|
|
|
+ // menus: ['shareAppMessage', 'shareTimeline'],
|
|
|
+ menus: ['shareAppMessage'],
|
|
|
+ complete: () => {}
|
|
|
+ });
|
|
|
+
|
|
|
+ // 主动分享
|
|
|
+ wx.shareAppMessage({
|
|
|
+ title: title,
|
|
|
+ imageUrl: imageUrl
|
|
|
+ });
|
|
|
+
|
|
|
+ // 被动分享
|
|
|
+ // wx.onShareAppMessage( () => {
|
|
|
+ // return {
|
|
|
+ // // 标题,不传则默认使用小游戏的名称
|
|
|
+ // title: title,
|
|
|
+ // // 转发链接所显示的图片,比例5:4,资源可以是本地或远程。不传则默认使用游戏截图。
|
|
|
+ // imageUrl: imageUrl,
|
|
|
+ // }
|
|
|
+ // });
|
|
|
+
|
|
|
+ //@ts-ignore
|
|
|
// if (!window.wx) {
|
|
|
// return;
|
|
|
// }
|
|
|
-
|
|
|
- // //@ts-ignore
|
|
|
+ //
|
|
|
+ //@ts-ignore
|
|
|
// wx.showShareMenu({
|
|
|
// withShareTicket: true,
|
|
|
// complete: () => {
|
|
|
-
|
|
|
+ // console.log('')
|
|
|
// }
|
|
|
- // });
|
|
|
-
|
|
|
- // //@ts-ignore
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ //@ts-ignore
|
|
|
// if (wx.aldOnShareAppMessage) {
|
|
|
- // //@ts-ignore
|
|
|
+ // //@ts-ignore 被动分享
|
|
|
// wx.aldOnShareAppMessage(function () {
|
|
|
// // 用户点击了“转发”按钮
|
|
|
// return {
|
|
@@ -108,12 +147,10 @@ export class SdkUtil {
|
|
|
// return {
|
|
|
// title: title,
|
|
|
// imageUrl: imageUrl,
|
|
|
-
|
|
|
// };
|
|
|
// });
|
|
|
// }
|
|
|
}
|
|
|
-
|
|
|
|
|
|
/**
|
|
|
* 抖音/微信激励视频
|