Bläddra i källkod

[add] wechat pay && android app icon

x 5 år sedan
förälder
incheckning
c27e8a2cc6

+ 9 - 3
cordova/config.xml

@@ -1,11 +1,11 @@
 <?xml version='1.0' encoding='utf-8'?>
 <widget id="com.shotshock.twong" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
-    <name>HelloCordova</name>
+    <name>美天旺</name>
     <description>
-        A sample Apache Cordova application that responds to the deviceready event.
+        美天旺是完璧时空旗下新型垂直电商App,专注于新经济下的购物服务!
     </description>
     <author email="dev@cordova.apache.org" href="http://cordova.io">
-        Apache Cordova Team
+        twong Team
     </author>
     <content src="index.html" />
     <access origin="*" />
@@ -15,8 +15,14 @@
     <allow-intent href="sms:*" />
     <allow-intent href="mailto:*" />
     <allow-intent href="geo:*" />
+
     <platform name="android">
         <allow-intent href="market:*" />
+        <icon src="res/android/mipmap-mdpi/ic_launcher.png" density="mdpi" />
+        <icon src="res/android/mipmap-hdpi/ic_launcher.png" density="hdpi" />
+        <icon src="res/android/mipmap-xhdpi/ic_launcher.png" density="xhdpi" />
+        <icon src="res/android/mipmap-xxhdpi/ic_launcher.png" density="xxhdpi" />
+        <icon src="res/android/mipmap-xxxhdpi/ic_launcher.png" density="xxxhdpi" />
     </platform>
     <platform name="ios">
         <allow-intent href="itms:*" />

+ 14 - 0
cordova/package-lock.json

@@ -175,6 +175,14 @@
       "integrity": "sha1-2VcRt6HiAEduQiTaw00ork594B8=",
       "dev": true
     },
+    "cordova-plugin-wechat": {
+      "version": "git+https://github.com/xu-li/cordova-plugin-wechat.git#82f4fbc259ea7371eed2eff57645b29fd76af718",
+      "from": "git+https://github.com/xu-li/cordova-plugin-wechat.git#develop",
+      "dev": true,
+      "requires": {
+        "shelljs": "^0.5.3"
+      }
+    },
     "cordova-plugin-whitelist": {
       "version": "1.3.4",
       "resolved": "https://registry.npm.taobao.org/cordova-plugin-whitelist/download/cordova-plugin-whitelist-1.3.4.tgz",
@@ -643,6 +651,12 @@
       "integrity": "sha1-rhbxZE2HPsrYQ7AwexQzYtTEIXI=",
       "dev": true
     },
+    "shelljs": {
+      "version": "0.5.3",
+      "resolved": "https://registry.npm.taobao.org/shelljs/download/shelljs-0.5.3.tgz?cache=0&sync_timestamp=1587787210621&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fshelljs%2Fdownload%2Fshelljs-0.5.3.tgz",
+      "integrity": "sha1-xUmCuZbHbvDB5rWfvcWCX1txMRM=",
+      "dev": true
+    },
     "signal-exit": {
       "version": "3.0.3",
       "resolved": "https://registry.npm.taobao.org/signal-exit/download/signal-exit-3.0.3.tgz",

+ 5 - 0
cordova/package.json

@@ -16,6 +16,7 @@
     "cordova-android": "^9.0.0",
     "cordova-plugin-device": "^2.0.3",
     "cordova-plugin-jcore": "^1.3.3",
+    "cordova-plugin-wechat": "git+https://github.com/xu-li/cordova-plugin-wechat.git#develop",
     "cordova-plugin-whitelist": "^1.3.4",
     "jpush-phonegap-plugin": "https://gitee.com/scnon/jpush-phonegap-plugin.git"
   },
@@ -25,6 +26,10 @@
       "jpush-phonegap-plugin": {
         "APP_KEY": "ab09fb9a832156e9c500ee68",
         "CHANNEL": "developer-default"
+      },
+      "cordova-plugin-wechat": {
+        "WECHATAPPID": "wx1bb4342986c22b28",
+        "UNIVERSALLINK": "https://www.shotshock.shop/ios/"
       }
     },
     "platforms": [

BIN
cordova/res/android/mipmap-hdpi/ic_launcher.png


BIN
cordova/res/android/mipmap-mdpi/ic_launcher.png


BIN
cordova/res/android/mipmap-xhdpi/ic_launcher.png


BIN
cordova/res/android/mipmap-xxhdpi/ic_launcher.png


BIN
cordova/res/android/mipmap-xxxhdpi/ic_launcher.png


+ 97 - 0
src/libs/pay.js

@@ -0,0 +1,97 @@
+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;