微信小游戏转发好友

一、使用egret wing 打开项目
1、查看是否有Platform.ts文件 (如果没有,在Main.ts同级的文件加下添加Platform.ts文件 )
Platform.ts文件内容如下:

/** 
 * 平台数据接口。
 * 由于每款游戏通常需要发布到多个平台上,所以提取出一个统一的接口用于开发者获取平台数据信息
 * 推荐开发者通过这种方式封装平台逻辑,以保证整体结构的稳定
 * 由于不同平台的接口形式各有不同,白鹭推荐开发者将所有接口封装为基于 Promise 的异步形式
 */
declare interface Platform {
    getUserInfo(): Promise<any>;
    login(): Promise<any>
}
class DebugPlatform implements Platform {
    async getUserInfo() {
        return { nickName: "username" }
    }
    async login() {
    }
}
if (!window.platform) {
    window.platform = new DebugPlatform();
}
declare let platform: Platform;
declare interface Window {
    platform: Platform
}

2、修改Platform.ts文件
添加showShareMenu方法
这里写图片描述
3、在Main.ts中调用showShareMenu
再runPlatform方法中调用showShareMenu, runPlatform方法调用位置依项目而定
这里写图片描述
二、使用egret Launcher 发布微信下游戏(如何发布这里写链接内容
1、使用微信web开发者工具打开发布的项目
2、在开发者工具中打开Platform.ts,添加showShareMenu方法
三、在web开发者工具中使用 模拟器 查看效果
这里写图片描述
这里写图片描述

猜你喜欢

转载自blog.csdn.net/RocketJ/article/details/82023297