component-shipinlv 1.0.2 → 1.0.5

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.
package/dist/Buy/qr.js CHANGED
@@ -1,4 +1,3 @@
1
- import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
2
1
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
3
2
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
4
3
  import React, { useEffect, useState } from 'react';
@@ -32,7 +31,7 @@ var VipQr = function VipQr(_ref) {
32
31
  var _useState = useState(Tool.getLocalUserInfo()),
33
32
  _useState2 = _slicedToArray(_useState, 1),
34
33
  userInfo = _useState2[0];
35
- var _useState3 = useState('wepay'),
34
+ var _useState3 = useState(payMethod === null || payMethod === void 0 ? void 0 : payMethod[0]),
36
35
  _useState4 = _slicedToArray(_useState3, 2),
37
36
  payChannel = _useState4[0],
38
37
  setPayChannel = _useState4[1];
@@ -106,6 +105,9 @@ var VipQr = function VipQr(_ref) {
106
105
  if (payOrderInfo[result.payChannel]) {
107
106
  payOrderInfo[result.payChannel].qrUrl = result.codeUrl || result.mWebUrl;
108
107
  setPayOrderInfo(_objectSpread({}, payOrderInfo));
108
+ console.log('payOrderInfo:', payOrderInfo);
109
+ setItemsTabs(getItemsTabs(payOrderInfo));
110
+
109
111
  // 五秒后自动弹出;
110
112
  setTimeout(function () {
111
113
  setPayResult(true);
@@ -141,22 +143,19 @@ var VipQr = function VipQr(_ref) {
141
143
  loading = _useRequest2.loading,
142
144
  run = _useRequest2.run,
143
145
  error = _useRequest2.error;
144
- var _useState13 = useState([]),
145
- _useState14 = _slicedToArray(_useState13, 2),
146
- itemsTabs = _useState14[0],
147
- setItemsTabs = _useState14[1];
148
- var PayMethodList = {
149
- wepay: [{
146
+ var getPayMethodList = function getPayMethodList() {
147
+ var payInfo = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : payOrderInfo;
148
+ var payMethodList = [{
150
149
  key: 'wepay',
151
150
  label: '微信支付',
152
151
  icon: /*#__PURE__*/_jsx(WechatOutlined, {
153
152
  className: "tabIcon"
154
153
  }),
155
154
  disabled: loadingPay,
156
- children: payOrderInfo.wepay.message ? /*#__PURE__*/_jsx(Result, {
155
+ children: payInfo.wepay.message ? /*#__PURE__*/_jsx(Result, {
157
156
  status: "error",
158
157
  title: "\u4E0B\u5355\u53D1\u751F\u4E00\u4E9B\u95EE\u9898",
159
- subTitle: payOrderInfo.wepay.message,
158
+ subTitle: payInfo.wepay.message,
160
159
  children: /*#__PURE__*/_jsx(Button, {
161
160
  type: "primary",
162
161
  children: "\u91CD\u8BD5"
@@ -164,8 +163,8 @@ var VipQr = function VipQr(_ref) {
164
163
  }) : /*#__PURE__*/_jsxs(_Fragment, {
165
164
  children: [/*#__PURE__*/_jsx("div", {
166
165
  className: "qrImage",
167
- children: payOrderInfo.wepay.qrUrl ? /*#__PURE__*/_jsx(QRCode, {
168
- value: payOrderInfo.wepay.qrUrl,
166
+ children: payInfo.wepay.qrUrl ? /*#__PURE__*/_jsx(QRCode, {
167
+ value: payInfo.wepay.qrUrl,
169
168
  fgColor: "#0bc160",
170
169
  size: 180
171
170
  }) : /*#__PURE__*/_jsx(LoadingOutlined, {
@@ -189,18 +188,17 @@ var VipQr = function VipQr(_ref) {
189
188
  })
190
189
  })]
191
190
  })
192
- }],
193
- alipay: [{
191
+ }, {
194
192
  key: 'alipay',
195
193
  label: '支付宝',
196
194
  disabled: loadingPay,
197
195
  icon: /*#__PURE__*/_jsx(AlipayCircleOutlined, {
198
196
  className: "tabIcon"
199
197
  }),
200
- children: payOrderInfo.alipay.message ? /*#__PURE__*/_jsx(Result, {
198
+ children: payInfo.alipay.message ? /*#__PURE__*/_jsx(Result, {
201
199
  status: "error",
202
200
  title: "\u4E0B\u5355\u53D1\u751F\u4E00\u4E9B\u95EE\u9898",
203
- subTitle: payOrderInfo.alipay.message,
201
+ subTitle: payInfo.alipay.message,
204
202
  children: /*#__PURE__*/_jsx(Button, {
205
203
  type: "primary",
206
204
  children: "\u91CD\u8BD5"
@@ -208,8 +206,8 @@ var VipQr = function VipQr(_ref) {
208
206
  }) : /*#__PURE__*/_jsxs(_Fragment, {
209
207
  children: [/*#__PURE__*/_jsx("div", {
210
208
  className: "qrImage",
211
- children: payOrderInfo.alipay.qrUrl ? /*#__PURE__*/_jsx(QRCode, {
212
- value: payOrderInfo.alipay.qrUrl,
209
+ children: payInfo.alipay.qrUrl ? /*#__PURE__*/_jsx(QRCode, {
210
+ value: payInfo.alipay.qrUrl,
213
211
  fgColor: "#1677ff",
214
212
  size: 180
215
213
  }) : /*#__PURE__*/_jsx(LoadingOutlined, {
@@ -233,25 +231,51 @@ var VipQr = function VipQr(_ref) {
233
231
  })
234
232
  })]
235
233
  })
236
- }]
234
+ }];
235
+ return payMethodList;
237
236
  };
238
- var onInit = function onInit() {
237
+ var getItemsTabs = function getItemsTabs() {
238
+ var payInfo = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : payOrderInfo;
239
+ var itemsTabs = [];
240
+ var payMethodList = getPayMethodList(payInfo);
239
241
  payMethod === null || payMethod === void 0 || payMethod.forEach(function (payMethod) {
240
- var itemData = PayMethodList[payMethod];
241
- if (!itemData) {
242
+ var index = -1;
243
+ if (!payMethodList) {
242
244
  return;
243
245
  }
244
- if (itemsTabs) {
245
- itemsTabs.push(itemData[0]);
246
+ payMethodList === null || payMethodList === void 0 || payMethodList.some(function (item, i) {
247
+ if (item.key === payMethod) {
248
+ index = i;
249
+ }
250
+ });
251
+ if (index < 0) {
252
+ return;
253
+ }
254
+ if (payMethodList) {
255
+ itemsTabs.push(payMethodList[index]);
246
256
  }
247
257
  });
248
- if (itemsTabs) {
249
- setItemsTabs(_toConsumableArray(itemsTabs));
250
- }
258
+ return itemsTabs;
259
+ };
260
+ var _useState13 = useState(getItemsTabs()),
261
+ _useState14 = _slicedToArray(_useState13, 2),
262
+ itemsTabs = _useState14[0],
263
+ setItemsTabs = _useState14[1];
264
+ var onInit = function onInit() {
265
+ // payMethod?.forEach( payMethod => {
266
+ // const itemData = PayMethodList[ payMethod ];
267
+ // if( ! itemData){
268
+ // return;
269
+ // }
270
+ // if( itemsTabs ){
271
+ // itemsTabs.push( itemData[0] );
272
+ // }
273
+ // });
274
+ // if( itemsTabs ){
275
+ // setItemsTabs([...itemsTabs]);
276
+ // }
251
277
  };
252
- useEffect(function () {
253
- onInit();
254
- }, []);
278
+ useEffect(function () {}, []);
255
279
  return /*#__PURE__*/_jsx(PageContentWarp, {
256
280
  loading: loading,
257
281
  error: error
@@ -1,3 +1,4 @@
1
+ export declare const getMainPort: () => number;
1
2
  declare const getApiUrl: (apiName?: string, apiEnv?: Global.Env | '') => string;
2
3
  export declare const getApiEnv: (apiEnv?: Global.Env | '') => Global.Env;
3
4
  export declare const getEnv: (env?: Global.Env | '') => Global.Env;
@@ -7,6 +7,9 @@ var envData = function envData() {
7
7
  var _window3;
8
8
  return ((_window3 = window) === null || _window3 === void 0 || (_window3 = _window3.WebBaseConfig) === null || _window3 === void 0 ? void 0 : _window3.currentEnv) || currentEnv;
9
9
  };
10
+ export var getMainPort = function getMainPort() {
11
+ return window.__ShipinlvMainPort || 61800;
12
+ };
10
13
  var getApiUrl = function getApiUrl() {
11
14
  var _domain;
12
15
  var apiName = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
@@ -15,10 +18,11 @@ var getApiUrl = function getApiUrl() {
15
18
  if (/^https?:\/\//i.test(apiName)) {
16
19
  return apiName;
17
20
  }
21
+ var mainPort = getMainPort();
18
22
 
19
23
  // 主客户端
20
24
  if (/_main\//i.test(apiName)) {
21
- return "http://127.0.0.1:61800/".concat(apiName.replace(/^_main\//i, ''));
25
+ return "http://127.0.0.1:".concat(mainPort, "/").concat(apiName.replace(/^_main\//i, ''));
22
26
  }
23
27
 
24
28
  // 替换第一个 /
@@ -2,7 +2,7 @@ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
2
  // 二次封装 hooks request ;
3
3
  // 参数详见:https://github.com/umijs/umi-request/blob/master/README_zh-CN.md
4
4
  import request from 'umi-request';
5
- import getApiUrl, { getApiEnv } from "./getApiUrl";
5
+ import getApiUrl, { getApiEnv, getMainPort } from "./getApiUrl";
6
6
  import goAuth from "./goAuth";
7
7
  import Tool from "./Tool";
8
8
  var requestApi = function requestApi() {
@@ -67,7 +67,7 @@ var requestApi = function requestApi() {
67
67
  err = new Error();
68
68
  }
69
69
  console.log('request component shipinlv:', JSON.stringify(err), url);
70
- if (!((_err = err) !== null && _err !== void 0 && _err.response) && url.indexOf('http://127.0.0.1:61800') === 0) {
70
+ if (!((_err = err) !== null && _err !== void 0 && _err.response) && url.indexOf("http://127.0.0.1:".concat(getMainPort())) === 0) {
71
71
  err.name = "shipinlv-client-not-run";
72
72
  err.message = "\u8BF7\u5148\u6253\u5F00\u7535\u8111\u4E0A\u5DF2\u5B89\u88C5\u7684\uFF1A\u3010\u89C6\u9891\u9A74\u5DE5\u5177\u7BB1\u3011\uFF0C\u518D\u64CD\u4F5C";
73
73
  reject(err);
@@ -2,6 +2,7 @@ import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
2
2
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
3
3
  import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
4
4
  import request from "../../lib/request";
5
+ import { getMainPort } from "../../lib/getApiUrl";
5
6
  export function start(_x, _x2) {
6
7
  return _start.apply(this, arguments);
7
8
  }
@@ -33,7 +34,7 @@ function _runStatus() {
33
34
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
34
35
  while (1) switch (_context2.prev = _context2.next) {
35
36
  case 0:
36
- return _context2.abrupt("return", request("http://127.0.0.1:".concat((body === null || body === void 0 ? void 0 : body.port) || 61800, "/sub-client/runStatus"), _objectSpread({
37
+ return _context2.abrupt("return", request("http://127.0.0.1:".concat((body === null || body === void 0 ? void 0 : body.port) || getMainPort(), "/sub-client/runStatus"), _objectSpread({
37
38
  method: 'GET',
38
39
  params: _objectSpread({}, body)
39
40
  }, options || {})));
package/dist/window.d.ts CHANGED
@@ -5,5 +5,6 @@ declare interface Window{
5
5
  __onBindWindowError: boolean;
6
6
  __wxjs_environment: string;
7
7
  __recordError: any;
8
+ __ShipinlvMainPort: number;
8
9
  }
9
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "component-shipinlv",
3
- "version": "1.0.2",
3
+ "version": "1.0.5",
4
4
  "description": "",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",