@lemon-fe/mini-app 1.0.8 → 1.1.1-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -13,5 +13,6 @@ export declare const SET_CAPSULE = "SET_CAPSULE";
13
13
  export declare const SET_EXTRA_PAYLOAD = "SET_EXTRA_PAYLOAD";
14
14
  export declare const SYNC_ROUTES = "SYNC_ROUTES";
15
15
  export declare const NEXT_ACTION = "NEXT_ACTION";
16
+ export declare const REQUEST_PAYMENT = "REQUEST_PAYMENT";
16
17
  export declare const ACTION_CONTINUE = "ACTION_CONTINUE";
17
18
  export declare const ACTION_CANCEL = "ACTION_CANCEL";
@@ -13,7 +13,8 @@ export var CHECK_ACCESS_TOKEN = 'CHECK_ACCESS_TOKEN';
13
13
  export var SET_CAPSULE = 'SET_CAPSULE';
14
14
  export var SET_EXTRA_PAYLOAD = 'SET_EXTRA_PAYLOAD';
15
15
  export var SYNC_ROUTES = 'SYNC_ROUTES';
16
- export var NEXT_ACTION = 'NEXT_ACTION'; // actions
16
+ export var NEXT_ACTION = 'NEXT_ACTION';
17
+ export var REQUEST_PAYMENT = 'REQUEST_PAYMENT'; // actions
17
18
 
18
19
  export var ACTION_CONTINUE = 'ACTION_CONTINUE';
19
20
  export var ACTION_CANCEL = 'ACTION_CANCEL';
package/es/global.d.ts CHANGED
@@ -76,6 +76,18 @@ declare const bridge: {
76
76
  payload?: Record<string, any>;
77
77
  };
78
78
  }): void;
79
+ /**
80
+ * @param type 支付方式
81
+ * @param tradeNO 农行支付为token
82
+ */
83
+ requestPayment(opts: {
84
+ params: {
85
+ type?: 'bankabc';
86
+ tradeNO?: string;
87
+ };
88
+ success?: () => void;
89
+ fail?: () => void;
90
+ }): void;
79
91
  };
80
92
  export declare const mini: {
81
93
  getSystemInfoSync: () => {
@@ -134,6 +146,14 @@ export declare const mini: {
134
146
  payload?: Record<string, any>;
135
147
  };
136
148
  }) => void;
149
+ requestPayment: (opts: {
150
+ params: {
151
+ type?: 'bankabc';
152
+ tradeNO?: string;
153
+ };
154
+ success?: () => void;
155
+ fail?: () => void;
156
+ }) => void;
137
157
  loaded: boolean;
138
158
  };
139
159
  /**
package/es/global.js CHANGED
@@ -4,7 +4,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
4
4
 
5
5
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
6
 
7
- import { CHECK_ACCESS_TOKEN, EXIT, GET_ACCESS_TOKEN, GET_USER_INFO, INIT_IFRAME, LEMON_APP_EXTRA_PAYLOAD, METHOD, METHOD_CALLBACK, NEXT_ACTION, SCAN_CODE, SET_CAPSULE, SET_EXTRA_PAYLOAD, SET_STATUS_BAR_STYLE, SYNC_ROUTES } from './constants';
7
+ import { CHECK_ACCESS_TOKEN, EXIT, GET_ACCESS_TOKEN, GET_USER_INFO, INIT_IFRAME, LEMON_APP_EXTRA_PAYLOAD, METHOD, METHOD_CALLBACK, NEXT_ACTION, REQUEST_PAYMENT, SCAN_CODE, SET_CAPSULE, SET_EXTRA_PAYLOAD, SET_STATUS_BAR_STYLE, SYNC_ROUTES } from './constants';
8
8
  var whiteList = ['localhost', 'csp.nhsoft.cn', '127.0.0.1'];
9
9
  var methods = {};
10
10
  var listeners = [];
@@ -137,6 +137,14 @@ var bridge = {
137
137
  bridge.methodRegister(NEXT_ACTION, {
138
138
  params: opts
139
139
  });
140
+ },
141
+
142
+ /**
143
+ * @param type 支付方式
144
+ * @param tradeNO 农行支付为token
145
+ */
146
+ requestPayment: function requestPayment(opts) {
147
+ bridge.methodRegister(REQUEST_PAYMENT, opts);
140
148
  }
141
149
  };
142
150
  export var mini = _objectSpread(_objectSpread({
@@ -148,35 +156,38 @@ export var mini = _objectSpread(_objectSpread({
148
156
  */
149
157
 
150
158
  window.mini = mini;
151
- window.addEventListener('message', function (evt) {
152
- var result = /^(([^:\/\s]+):\/?\/?([^\/\s@]*@)?([^\/@:]*)?:?(\d+)?)?(\/[^?]*)?(\?([^#]*))?(#[\s\S]*)?$/.exec(evt.origin);
153
-
154
- if (result !== null && whiteList.includes(result[4])) {
155
- if (evt.data === INIT_IFRAME) {
156
- window.ReactNativeWebView = {
157
- postMessage: function postMessage(e) {
158
- window.parent.postMessage(e, '*');
159
- }
160
- };
161
- mini.loaded = true;
162
- var nodeList = document.getElementsByTagName('link');
163
- var favicon = undefined;
164
-
165
- for (var i = 0; i < nodeList.length; i++) {
166
- if (nodeList[i].getAttribute('rel') == 'icon' || nodeList[i].getAttribute('rel') == 'shortcut icon') {
167
- favicon = nodeList[i].getAttribute('href');
168
- break;
169
- }
170
- }
159
+ /**
160
+ * init web
161
+ */
171
162
 
172
- window.parent.postMessage(JSON.stringify({
173
- type: INIT_IFRAME,
174
- target: {
175
- title: document.title,
176
- icon: favicon
177
- }
178
- }), '*');
179
- } else {
163
+ if (new URLSearchParams(window.location.search).has('__APP_DEV_TOOLS__')) {
164
+ window.ReactNativeWebView = {
165
+ postMessage: function postMessage(e) {
166
+ window.parent.postMessage(e, '*');
167
+ }
168
+ };
169
+ mini.loaded = true;
170
+ var nodeList = document.getElementsByTagName('link');
171
+ var favicon = undefined;
172
+
173
+ for (var i = 0; i < nodeList.length; i++) {
174
+ if (nodeList[i].getAttribute('rel') == 'icon' || nodeList[i].getAttribute('rel') == 'shortcut icon') {
175
+ favicon = nodeList[i].getAttribute('href');
176
+ break;
177
+ }
178
+ }
179
+
180
+ window.parent.postMessage(JSON.stringify({
181
+ type: INIT_IFRAME,
182
+ target: {
183
+ title: document.title,
184
+ icon: favicon
185
+ }
186
+ }), '*');
187
+ window.addEventListener('message', function (evt) {
188
+ var result = /^(([^:\/\s]+):\/?\/?([^\/\s@]*@)?([^\/@:]*)?:?(\d+)?)?(\/[^?]*)?(\?([^#]*))?(#[\s\S]*)?$/.exec(evt.origin);
189
+
190
+ if (result !== null && whiteList.includes(result[4])) {
180
191
  var action = evt.data;
181
192
 
182
193
  switch (action.type) {
@@ -196,13 +207,14 @@ window.addEventListener('message', function (evt) {
196
207
  default:
197
208
  }
198
209
  }
199
- }
200
- }, false);
210
+ }, false);
211
+ }
201
212
  /**
202
213
  * deprecated
203
214
  * @param render () => void
204
215
  */
205
216
 
217
+
206
218
  export function createApp(render) {
207
219
  var count = 0;
208
220
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lemon-fe/mini-app",
3
- "version": "1.0.8",
3
+ "version": "1.1.1-alpha.0",
4
4
  "description": "> TODO: description",
5
5
  "author": "鲁盛杰 <lusj@cnlemon.net>",
6
6
  "homepage": "",
@@ -30,5 +30,6 @@
30
30
  "@types/react-transition-group": "^4.4.4",
31
31
  "react": "^17.0.2",
32
32
  "react-dom": "17.0.2"
33
- }
33
+ },
34
+ "gitHead": "19ee6e47e163799eb59019d79660b92c26f928dd"
34
35
  }