component-shipinlv 1.0.0 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,6 +6,7 @@ interface Props {
6
6
  productKind: 'vip' | 'vip-card';
7
7
  showPrice?: number;
8
8
  disabled?: boolean;
9
+ payMethod?: Global.PayMethod;
9
10
  onBuySuccess?: () => void;
10
11
  children: React.ReactNode;
11
12
  }
package/dist/Buy/index.js CHANGED
@@ -16,6 +16,7 @@ var Buy = function Buy(_ref) {
16
16
  vipId = _ref$vipId === void 0 ? 0 : _ref$vipId,
17
17
  _ref$productCount = _ref.productCount,
18
18
  productCount = _ref$productCount === void 0 ? 1 : _ref$productCount,
19
+ payMethod = _ref.payMethod,
19
20
  _ref$disabled = _ref.disabled,
20
21
  disabled = _ref$disabled === void 0 ? false : _ref$disabled,
21
22
  showPrice = _ref.showPrice,
@@ -29,22 +30,23 @@ var Buy = function Buy(_ref) {
29
30
  while (1) switch (_context.prev = _context.next) {
30
31
  case 0:
31
32
  if (!disabled) {
32
- _context.next = 2;
33
+ _context.next = 3;
33
34
  break;
34
35
  }
36
+ console.log('buy disabled.');
35
37
  return _context.abrupt("return");
36
- case 2:
38
+ case 3:
37
39
  // 先要登录;
38
40
  userInfo = Tool.getLocalUserInfo();
39
41
  if (userInfo.isLogin) {
40
- _context.next = 6;
42
+ _context.next = 7;
41
43
  break;
42
44
  }
43
45
  console.log("not login");
44
46
  return _context.abrupt("return", Tool.onLogin());
45
- case 6:
47
+ case 7:
46
48
  if (!(showPrice === 0)) {
47
- _context.next = 9;
49
+ _context.next = 10;
48
50
  break;
49
51
  }
50
52
  // 直接开通
@@ -62,9 +64,9 @@ var Buy = function Buy(_ref) {
62
64
  width: Math.min(520, ((_ref3 = global || window) === null || _ref3 === void 0 ? void 0 : _ref3.innerWidth) * 0.95)
63
65
  });
64
66
  return _context.abrupt("return");
65
- case 9:
66
- onOpenVipQr();
67
67
  case 10:
68
+ onOpenVipQr();
69
+ case 11:
68
70
  case "end":
69
71
  return _context.stop();
70
72
  }
@@ -77,6 +79,7 @@ var Buy = function Buy(_ref) {
77
79
  var onOpenVipQr = function onOpenVipQr() {
78
80
  var _ref4;
79
81
  var userId = Tool.getLocalUserInfo().id;
82
+ console.log('onOpenVipQr.');
80
83
  if (Platform.isWechat || Platform.isH5) {
81
84
  Tool.h5Pay({
82
85
  productKind: productKind,
@@ -95,6 +98,7 @@ var Buy = function Buy(_ref) {
95
98
  productKind: productKind,
96
99
  vipId: vipId,
97
100
  productCount: productCount,
101
+ payMethod: payMethod,
98
102
  onHandlePaySuccess: function onHandlePaySuccess() {
99
103
  onBuySuccess();
100
104
  dialog.destroy();
package/dist/Buy/qr.d.ts CHANGED
@@ -4,6 +4,7 @@ interface Props {
4
4
  productKind: string;
5
5
  vipId: number;
6
6
  productCount: number;
7
+ payMethod?: Global.PayMethod;
7
8
  onHandlePaySuccess: () => void;
8
9
  }
9
10
  declare const VipQr: React.FC<Props>;
package/dist/Buy/qr.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
2
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
3
- import React, { useState } from 'react';
3
+ import React, { useEffect, useState } from 'react';
4
4
  import { Result, Button, Space, Divider, Tabs } from 'antd';
5
5
  import { AlipayCircleOutlined, CloseOutlined, LoadingOutlined, PauseOutlined, WechatOutlined } from '@ant-design/icons';
6
6
  import { useRequest } from '@umijs/hooks';
@@ -24,12 +24,14 @@ var VipQr = function VipQr(_ref) {
24
24
  productCount = _ref$productCount === void 0 ? 1 : _ref$productCount,
25
25
  _ref$vipId = _ref.vipId,
26
26
  vipId = _ref$vipId === void 0 ? 0 : _ref$vipId,
27
+ _ref$payMethod = _ref.payMethod,
28
+ payMethod = _ref$payMethod === void 0 ? ['wepay', 'alipay'] : _ref$payMethod,
27
29
  _ref$onHandlePaySucce = _ref.onHandlePaySuccess,
28
30
  onHandlePaySuccess = _ref$onHandlePaySucce === void 0 ? function () {} : _ref$onHandlePaySucce;
29
31
  var _useState = useState(Tool.getLocalUserInfo()),
30
32
  _useState2 = _slicedToArray(_useState, 1),
31
33
  userInfo = _useState2[0];
32
- var _useState3 = useState('wepay'),
34
+ var _useState3 = useState(payMethod === null || payMethod === void 0 ? void 0 : payMethod[0]),
33
35
  _useState4 = _slicedToArray(_useState3, 2),
34
36
  payChannel = _useState4[0],
35
37
  setPayChannel = _useState4[1];
@@ -103,6 +105,9 @@ var VipQr = function VipQr(_ref) {
103
105
  if (payOrderInfo[result.payChannel]) {
104
106
  payOrderInfo[result.payChannel].qrUrl = result.codeUrl || result.mWebUrl;
105
107
  setPayOrderInfo(_objectSpread({}, payOrderInfo));
108
+ console.log('payOrderInfo:', payOrderInfo);
109
+ setItemsTabs(getItemsTabs(payOrderInfo));
110
+
106
111
  // 五秒后自动弹出;
107
112
  setTimeout(function () {
108
113
  setPayResult(true);
@@ -138,93 +143,139 @@ var VipQr = function VipQr(_ref) {
138
143
  loading = _useRequest2.loading,
139
144
  run = _useRequest2.run,
140
145
  error = _useRequest2.error;
141
- var itemsTabs = [{
142
- key: 'wepay',
143
- label: '微信支付',
144
- icon: /*#__PURE__*/_jsx(WechatOutlined, {
145
- className: "tabIcon"
146
- }),
147
- disabled: loadingPay,
148
- children: payOrderInfo.wepay.message ? /*#__PURE__*/_jsx(Result, {
149
- status: "error",
150
- title: "\u4E0B\u5355\u53D1\u751F\u4E00\u4E9B\u95EE\u9898",
151
- subTitle: payOrderInfo.wepay.message,
152
- children: /*#__PURE__*/_jsx(Button, {
153
- type: "primary",
154
- children: "\u91CD\u8BD5"
155
- })
156
- }) : /*#__PURE__*/_jsxs(_Fragment, {
157
- children: [/*#__PURE__*/_jsx("div", {
158
- className: "qrImage",
159
- children: payOrderInfo.wepay.qrUrl ? /*#__PURE__*/_jsx(QRCode, {
160
- value: payOrderInfo.wepay.qrUrl,
161
- fgColor: "#0bc160",
162
- size: 180
163
- }) : /*#__PURE__*/_jsx(LoadingOutlined, {
164
- className: "loadingIcon"
165
- })
166
- }), /*#__PURE__*/_jsx("div", {
167
- className: "qrAlt",
168
- children: Platform.isH5 ? /*#__PURE__*/_jsxs("div", {
169
- className: "altInH5",
170
- children: ["\u957F\u6309\u4E8C\u7EF4\u7801\uFF0C\u53EF\u8BC6\u522B\u4E8C\u7EF4\u7801\u652F\u4ED8", /*#__PURE__*/_jsx("p", {
171
- className: "toFriend",
172
- children: "\u6216\u8005\u4FDD\u5B58\u56FE\u7247\u8BA9\u670B\u53CB\u626B\u7801\u4EE3\u4ED8"
173
- })]
174
- }) : /*#__PURE__*/_jsxs("div", {
175
- className: "alt",
176
- children: ["\u8BF7\u7528 ", /*#__PURE__*/_jsx(WechatOutlined, {
177
- className: "wechatIcon"
178
- }), " \u5FAE\u4FE1 \u626B\u7801\u652F\u4ED8 ", /*#__PURE__*/_jsx(Divider, {
179
- type: "vertical"
180
- }), " \u4E5F\u53EF\u4EE5\u8BA9\u670B\u53CB\u626B\u7801\u4EE3\u4ED8"]
146
+ var getPayMethodList = function getPayMethodList() {
147
+ var payInfo = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : payOrderInfo;
148
+ var payMethodList = [{
149
+ key: 'wepay',
150
+ label: '微信支付',
151
+ icon: /*#__PURE__*/_jsx(WechatOutlined, {
152
+ className: "tabIcon"
153
+ }),
154
+ disabled: loadingPay,
155
+ children: payInfo.wepay.message ? /*#__PURE__*/_jsx(Result, {
156
+ status: "error",
157
+ title: "\u4E0B\u5355\u53D1\u751F\u4E00\u4E9B\u95EE\u9898",
158
+ subTitle: payInfo.wepay.message,
159
+ children: /*#__PURE__*/_jsx(Button, {
160
+ type: "primary",
161
+ children: "\u91CD\u8BD5"
181
162
  })
182
- })]
183
- })
184
- }, {
185
- key: 'alipay',
186
- label: '支付宝',
187
- disabled: loadingPay,
188
- icon: /*#__PURE__*/_jsx(AlipayCircleOutlined, {
189
- className: "tabIcon"
190
- }),
191
- children: payOrderInfo.alipay.message ? /*#__PURE__*/_jsx(Result, {
192
- status: "error",
193
- title: "\u4E0B\u5355\u53D1\u751F\u4E00\u4E9B\u95EE\u9898",
194
- subTitle: payOrderInfo.alipay.message,
195
- children: /*#__PURE__*/_jsx(Button, {
196
- type: "primary",
197
- children: "\u91CD\u8BD5"
163
+ }) : /*#__PURE__*/_jsxs(_Fragment, {
164
+ children: [/*#__PURE__*/_jsx("div", {
165
+ className: "qrImage",
166
+ children: payInfo.wepay.qrUrl ? /*#__PURE__*/_jsx(QRCode, {
167
+ value: payInfo.wepay.qrUrl,
168
+ fgColor: "#0bc160",
169
+ size: 180
170
+ }) : /*#__PURE__*/_jsx(LoadingOutlined, {
171
+ className: "loadingIcon"
172
+ })
173
+ }), /*#__PURE__*/_jsx("div", {
174
+ className: "qrAlt",
175
+ children: Platform.isH5 ? /*#__PURE__*/_jsxs("div", {
176
+ className: "altInH5",
177
+ children: ["\u957F\u6309\u4E8C\u7EF4\u7801\uFF0C\u53EF\u8BC6\u522B\u4E8C\u7EF4\u7801\u652F\u4ED8", /*#__PURE__*/_jsx("p", {
178
+ className: "toFriend",
179
+ children: "\u6216\u8005\u4FDD\u5B58\u56FE\u7247\u8BA9\u670B\u53CB\u626B\u7801\u4EE3\u4ED8"
180
+ })]
181
+ }) : /*#__PURE__*/_jsxs("div", {
182
+ className: "alt",
183
+ children: ["\u8BF7\u7528 ", /*#__PURE__*/_jsx(WechatOutlined, {
184
+ className: "wechatIcon"
185
+ }), " \u5FAE\u4FE1 \u626B\u7801\u652F\u4ED8 ", /*#__PURE__*/_jsx(Divider, {
186
+ type: "vertical"
187
+ }), " \u4E5F\u53EF\u4EE5\u8BA9\u670B\u53CB\u626B\u7801\u4EE3\u4ED8"]
188
+ })
189
+ })]
198
190
  })
199
- }) : /*#__PURE__*/_jsxs(_Fragment, {
200
- children: [/*#__PURE__*/_jsx("div", {
201
- className: "qrImage",
202
- children: payOrderInfo.alipay.qrUrl ? /*#__PURE__*/_jsx(QRCode, {
203
- value: payOrderInfo.alipay.qrUrl,
204
- fgColor: "#1677ff",
205
- size: 180
206
- }) : /*#__PURE__*/_jsx(LoadingOutlined, {
207
- className: "loadingIcon"
208
- })
209
- }), /*#__PURE__*/_jsx("div", {
210
- className: "qrAlt",
211
- children: Platform.isH5 ? /*#__PURE__*/_jsxs("div", {
212
- className: "altInH5",
213
- children: ["\u957F\u6309\u4E8C\u7EF4\u7801\uFF0C\u53EF\u8BC6\u522B\u4E8C\u7EF4\u7801\u652F\u4ED8", /*#__PURE__*/_jsx("p", {
214
- className: "toFriend",
215
- children: "\u6216\u8005\u4FDD\u5B58\u56FE\u7247\u8BA9\u670B\u53CB\u626B\u7801\u4EE3\u4ED8"
216
- })]
217
- }) : /*#__PURE__*/_jsxs("div", {
218
- className: "alt",
219
- children: ["\u8BF7\u7528 ", /*#__PURE__*/_jsx(AlipayCircleOutlined, {
220
- className: "alipayIcon"
221
- }), " \u652F\u4ED8\u5B9D \u626B\u7801\u652F\u4ED8 ", /*#__PURE__*/_jsx(Divider, {
222
- type: "vertical"
223
- }), " \u4E5F\u53EF\u4EE5\u8BA9\u670B\u53CB\u626B\u7801\u4EE3\u4ED8"]
191
+ }, {
192
+ key: 'alipay',
193
+ label: '支付宝',
194
+ disabled: loadingPay,
195
+ icon: /*#__PURE__*/_jsx(AlipayCircleOutlined, {
196
+ className: "tabIcon"
197
+ }),
198
+ children: payInfo.alipay.message ? /*#__PURE__*/_jsx(Result, {
199
+ status: "error",
200
+ title: "\u4E0B\u5355\u53D1\u751F\u4E00\u4E9B\u95EE\u9898",
201
+ subTitle: payInfo.alipay.message,
202
+ children: /*#__PURE__*/_jsx(Button, {
203
+ type: "primary",
204
+ children: "\u91CD\u8BD5"
224
205
  })
225
- })]
226
- })
227
- }];
206
+ }) : /*#__PURE__*/_jsxs(_Fragment, {
207
+ children: [/*#__PURE__*/_jsx("div", {
208
+ className: "qrImage",
209
+ children: payInfo.alipay.qrUrl ? /*#__PURE__*/_jsx(QRCode, {
210
+ value: payInfo.alipay.qrUrl,
211
+ fgColor: "#1677ff",
212
+ size: 180
213
+ }) : /*#__PURE__*/_jsx(LoadingOutlined, {
214
+ className: "loadingIcon"
215
+ })
216
+ }), /*#__PURE__*/_jsx("div", {
217
+ className: "qrAlt",
218
+ children: Platform.isH5 ? /*#__PURE__*/_jsxs("div", {
219
+ className: "altInH5",
220
+ children: ["\u957F\u6309\u4E8C\u7EF4\u7801\uFF0C\u53EF\u8BC6\u522B\u4E8C\u7EF4\u7801\u652F\u4ED8", /*#__PURE__*/_jsx("p", {
221
+ className: "toFriend",
222
+ children: "\u6216\u8005\u4FDD\u5B58\u56FE\u7247\u8BA9\u670B\u53CB\u626B\u7801\u4EE3\u4ED8"
223
+ })]
224
+ }) : /*#__PURE__*/_jsxs("div", {
225
+ className: "alt",
226
+ children: ["\u8BF7\u7528 ", /*#__PURE__*/_jsx(AlipayCircleOutlined, {
227
+ className: "alipayIcon"
228
+ }), " \u652F\u4ED8\u5B9D \u626B\u7801\u652F\u4ED8 ", /*#__PURE__*/_jsx(Divider, {
229
+ type: "vertical"
230
+ }), " \u4E5F\u53EF\u4EE5\u8BA9\u670B\u53CB\u626B\u7801\u4EE3\u4ED8"]
231
+ })
232
+ })]
233
+ })
234
+ }];
235
+ return payMethodList;
236
+ };
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);
241
+ payMethod === null || payMethod === void 0 || payMethod.forEach(function (payMethod) {
242
+ var index = -1;
243
+ if (!payMethodList) {
244
+ return;
245
+ }
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]);
256
+ }
257
+ });
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
+ // }
277
+ };
278
+ useEffect(function () {}, []);
228
279
  return /*#__PURE__*/_jsx(PageContentWarp, {
229
280
  loading: loading,
230
281
  error: error
@@ -7,6 +7,7 @@ interface Props {
7
7
  applyDemoTitle?: string;
8
8
  tableOffsetHeader?: number;
9
9
  env?: Global.Env;
10
+ payMethod?: Global.PayMethod;
10
11
  tableScrollY?: number | string;
11
12
  onBuySuccess?: () => void;
12
13
  }
@@ -46,6 +46,7 @@ var VipList = function VipList(_ref) {
46
46
  _ref$tableScrollY = _ref.tableScrollY,
47
47
  tableScrollY = _ref$tableScrollY === void 0 ? '65vh' : _ref$tableScrollY,
48
48
  env = _ref.env,
49
+ payMethod = _ref.payMethod,
49
50
  _ref$tableOffsetHeade = _ref.tableOffsetHeader,
50
51
  tableOffsetHeader = _ref$tableOffsetHeade === void 0 ? 56 : _ref$tableOffsetHeade,
51
52
  _ref$onBuySuccess = _ref.onBuySuccess,
@@ -368,10 +369,11 @@ var VipList = function VipList(_ref) {
368
369
  },
369
370
  children: /*#__PURE__*/_jsx(Buy, {
370
371
  env: env,
371
- disabled: userVip,
372
+ disabled: userVip && item.price === 0,
372
373
  productKind: "vip",
373
374
  vipId: (item === null || item === void 0 ? void 0 : item.id) || 0,
374
375
  productCount: 1,
376
+ payMethod: payMethod,
375
377
  showPrice: item === null || item === void 0 ? void 0 : item.price,
376
378
  onBuySuccess: onBuySuccess,
377
379
  children: /*#__PURE__*/_jsx(Button, {
@@ -158,7 +158,7 @@ declare const Tool: {
158
158
  setTimeOffset(serverTime: number): void;
159
159
  getTime(): number;
160
160
  h5Pay(query: Pay.H5PayQuery): void;
161
- notification(type: "info" | "error" | "success" | "warning", message: string, description?: import("react").ReactNode, options?: NotificationOptions): void;
161
+ notification(type: "success" | "info" | "warning" | "error", message: string, description?: import("react").ReactNode, options?: NotificationOptions): void;
162
162
  notificationSuccess(message: string, description?: import("react").ReactNode, options?: NotificationOptions): void;
163
163
  notificationError(message: string, description?: import("react").ReactNode, options?: NotificationOptions): void;
164
164
  notificationWarning(message: string, description?: import("react").ReactNode, options?: NotificationOptions): void;
package/dist/lib/Tool.js CHANGED
@@ -7,6 +7,9 @@ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
7
7
  import { Modal, message, Tooltip } from 'antd';
8
8
  // const JrQrcode = require('jr-qrcode');
9
9
  import QRCode from 'qrcode.react';
10
+ if (!window.__events) {
11
+ window.__events = [];
12
+ }
10
13
 
11
14
  // import { history } from 'umi';
12
15
 
package/dist/typings.d.ts CHANGED
@@ -65,6 +65,8 @@ declare namespace Global {
65
65
  ws: string;
66
66
  authApi: string;
67
67
  }
68
+
69
+ type PayMethod = ( 'wepay' | 'alipay' )[];
68
70
  }
69
71
 
70
72
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "component-shipinlv",
3
- "version": "1.0.0",
3
+ "version": "1.0.3",
4
4
  "description": "",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",