{"id":17101184,"url":"https://github.com/doabit/weex-wechat","last_synced_at":"2025-10-19T04:53:17.052Z","repository":{"id":138007609,"uuid":"108554967","full_name":"doabit/weex-wechat","owner":"doabit","description":"Weex plugin for wechat(auth, pay, share).","archived":false,"fork":false,"pushed_at":"2018-04-12T07:36:15.000Z","size":7,"stargazers_count":23,"open_issues_count":1,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-12T23:55:36.728Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/doabit.png","metadata":{"files":{"readme":"README-zh.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2017-10-27T14:17:23.000Z","updated_at":"2020-11-11T07:12:04.000Z","dependencies_parsed_at":null,"dependency_job_id":"7e0231d7-5680-403e-a142-607fdbe8d0b8","html_url":"https://github.com/doabit/weex-wechat","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/doabit/weex-wechat","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doabit%2Fweex-wechat","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doabit%2Fweex-wechat/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doabit%2Fweex-wechat/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doabit%2Fweex-wechat/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/doabit","download_url":"https://codeload.github.com/doabit/weex-wechat/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doabit%2Fweex-wechat/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261682926,"owners_count":23193680,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-14T15:24:13.281Z","updated_at":"2025-10-05T08:47:22.138Z","avatar_url":"https://github.com/doabit.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# weex-wechat\n\n\u003e Wechat(auth, pay, share) plugin for weex.\n\n## 准备工作\n\n```bash\nweexpack plugin install weex-wechat\n```\n\n## 使用方法\n\n```javascript\nvar wechat = weex.requireModule('wechat');\nvar stream = weex.requireModule('stream');\n\nwechat.registerApp(\"appid\", function(data) {\n  console.log(data, \"wx register\")\n})\n\nwechat.login({}, function(data) {\n  console.log(data)\n})\n\n// share text to timeline (share to session use shareToSession)\nwechat.shareToTimeLine({\n  type: \"text\",\n  content: \"text content\"\n}, function(data) {\n  console.log(\"text shared\", data)\n})\n\n// share image to timeline \nwechat.shareToTimeLine({\n  type: \"image\",\n  image: imageUrl\n}, function(data) {\n  console.log(\"image shared\", data)\n})\n\n// share video to timeline\nwechat.shareToTimeLine({\n  type: \"video\",\n  title: 'video title',\n  content: \"video content\",\n  image: imageUrl,\n  url: 'https://v.qq.com/x/cover/m4cz4v1n0av4a8k/x00223sb1nm.html?new=1'\n}, function(data) {\n  console.log(\"video shared\", data)\n})\n\n// share webpage to timeline\nwechat.shareToTimeLine({\n  type: \"webpage\",\n  title: 'vebpage title',\n  content: \"webpage content\",\n  image: imageUrl,\n  url: 'http://github.com/doabit'\n}, function(data) {\n  console.log(\"web page shared\", data)\n})\n\n// wxpay\nstream.fetch({\n  method: 'POST',\n  url: 'http://192.168.1.102:3000/wx_app_pay', //change to your wepay api\n  type: \"json\"\n}, function(resData){\n  if (resData.ok) {\n    var data = resData.data;\n    wechat.pay({\n        appid: data.appid,\n        sign: data.sign,\n        timestamp: data.timestamp,\n        noncestr: data.noncestr,\n        partnerid: data.partnerid,\n        prepayid: data.prepayid,\n        packageValue:data.package\n    }, function(resData){\n        console.log(resData)\n    })\n  } else {\n    console.log(resData)\n  }\n})\n```\n\n## android 配置\n\n### 添加 `jitpack.io` 到 android/build.gradle\n\n```gradle\nallprojects {\n    repositories {\n        mavenCentral()\n        jcenter()\n        maven { url 'https://jitpack.io' }\n    }\n}\n```\n\n### 集成微信登录和分享\n\n集成微信登录和分享，首先创建一个包名为 'wxapi'，并且添加一个名为 [WXEntryActivity](https://github.com/doabit/weex-wechat/blob/master/android/WXEntryActivity.java) 的类。\n\n添加下面代码到 `AndroidManifest.xml`:\n\n```xml\n\u003cmanifest\u003e\n  \u003capplication\u003e\n    \u003cactivity\n      android:name=\".wxapi.WXEntryActivity\"\n      android:label=\"@string/app_name\"\n      android:exported=\"true\"\n    /\u003e\n  \u003c/application\u003e\n\u003c/manifest\u003e\n```\n\n### 集成微信支付\n\n在 `wxapi`包中添加文件名为 [WXPayEntryActivity](https://github.com/doabit/weex-wechat/blob/master/android/WXPayEntryActivity.java) 的类\n\n添加下面代码到 `AndroidManifest.xml`:\n\n```xml\n\u003cmanifest\u003e\n  \u003capplication\u003e\n    \u003cactivity\n      android:name=\".wxapi.WXPayEntryActivity\"\n      android:label=\"@string/app_name\"\n      android:exported=\"true\"\n    /\u003e\n  \u003c/application\u003e\n\u003c/manifest\u003e\n```\n\n## IOS 配置\n\n在Xcode中，选择你的工程设置项，选中“TARGETS”一栏，在“info”标签栏的“URL type“添加“URL scheme”为你所注册的应用程序id（如下图所示）。\n\n![URL_TYPE](https://user-images.githubusercontent.com/330368/32264784-3cbe0b8a-beae-11e7-9c75-aab901b4cdab.jpg)\n\niOS 9 往后, 在 Targets \u003e info \u003e Custom iOS Target Properties 中 添加 wechat 和 weixin 到 LSApplicationQueriesSchemes. 或者 直接编辑 Info.plist:\n\n```plist\n\u003ckey\u003eLSApplicationQueriesSchemes\u003c/key\u003e\n\u003carray\u003e\n  \u003cstring\u003eweixin\u003c/string\u003e\n  \u003cstring\u003ewechat\u003c/string\u003e\n\u003c/array\u003e\n```\n\n添加如下代码到 AppDelegate.m:\n\n```objc\n- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {\n    return  [WXApi handleOpenURL:url delegate:[WeChatManager shareInstance]];\n}\n\n- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {\n    return [WXApi handleOpenURL:url delegate:[WeChatManager shareInstance]];\n}\n```\n\n## 参考资料\n\n[react-native-wechat](https://github.com/yorkie/react-native-wechat)\n\n[WeexErosFramework](https://github.com/aa453509345/WeexErosFramework)\n\n[微信开放平台](https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list\u0026t=resource/res_list\u0026verify=1\u0026id=1417674108\u0026token=\u0026lang=zh_CN)\n\n## Author\n\n[@doabit](https://github.com/doabit)\n\n## license\n\n[MIT](http://opensource.org/licenses/MIT)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdoabit%2Fweex-wechat","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdoabit%2Fweex-wechat","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdoabit%2Fweex-wechat/lists"}