| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- var wechat_installed = false;
- const WeChat = {
- init: function() {
- try {
- this.checkInstall();
- } catch {
- console.log("Wechat is undefined !");
- }
- },
- checkInstall: function() {
- Wechat.isInstalled(
- function(installed) {
- wechat_installed = installed;
- console.log("Wechat installed: " + (installed ? "Yes" : "No"));
- },
- function(reason) {
- wechat_installed = false;
- console.log("Failed: " + reason);
- }
- );
- },
- shareText: function(text, callback, type) {
- if (!wechat_installed) return;
- if (type == undefined) type = Wechat.Scene.SESSION;
- else type = Wechat.Scene.TIMELINE;
- Wechat.share(
- {
- text: text,
- scene: type
- },
- function() {
- callback(true);
- },
- function(reason) {
- callback(false, reason);
- }
- );
- },
- // title: "这是分享的标题",
- // description: "这是分享的描述",
- // thumb: "www/assets/imgs/logo.png",
- // media: {
- // type: Wechat.Type.WEBPAGE,
- // webpageUrl: "https://www.jason-z.com"
- // }
- shareLink: function(message, callback, type) {
- if (!wechat_installed) return;
- if (type == undefined) type = Wechat.Scene.SESSION;
- else type = Wechat.Scene.TIMELINE;
- Wechat.share(
- {
- message: message,
- scene: type
- },
- function() {
- callback(true);
- },
- function(reason) {
- callback(false, reason);
- }
- );
- },
- // partnerid: '10000100', // merchant id
- // prepayid: 'wx201411101639507cbf6ffd8b0779950874', // prepay id
- // noncestr: '1add1a30ac87aa2db72f57a2375d8fec', // nonce
- // timestamp: '1439531364', // timestamp
- // sign: '0CB01533B8C1EF103065174F50BCA001', // signed string
- pay: function(params, callback) {
- if (!wechat_installed) return;
- Wechat.sendPaymentRequest(
- ret.data,
- function() {
- callback(true, ret.data);
- },
- function(reason) {
- callback(false, reason);
- }
- );
- }
- };
- const Alipay = {
- init: function() {},
- pay: function() {}
- };
- export default WeChat;
|