component-shipinlv 1.0.0 → 1.0.2

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.
@@ -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,7 @@
1
+ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
1
2
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
3
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
3
- import React, { useState } from 'react';
4
+ import React, { useEffect, useState } from 'react';
4
5
  import { Result, Button, Space, Divider, Tabs } from 'antd';
5
6
  import { AlipayCircleOutlined, CloseOutlined, LoadingOutlined, PauseOutlined, WechatOutlined } from '@ant-design/icons';
6
7
  import { useRequest } from '@umijs/hooks';
@@ -24,6 +25,8 @@ var VipQr = function VipQr(_ref) {
24
25
  productCount = _ref$productCount === void 0 ? 1 : _ref$productCount,
25
26
  _ref$vipId = _ref.vipId,
26
27
  vipId = _ref$vipId === void 0 ? 0 : _ref$vipId,
28
+ _ref$payMethod = _ref.payMethod,
29
+ payMethod = _ref$payMethod === void 0 ? ['wepay', 'alipay'] : _ref$payMethod,
27
30
  _ref$onHandlePaySucce = _ref.onHandlePaySuccess,
28
31
  onHandlePaySuccess = _ref$onHandlePaySucce === void 0 ? function () {} : _ref$onHandlePaySucce;
29
32
  var _useState = useState(Tool.getLocalUserInfo()),
@@ -138,93 +141,117 @@ var VipQr = function VipQr(_ref) {
138
141
  loading = _useRequest2.loading,
139
142
  run = _useRequest2.run,
140
143
  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"]
144
+ var _useState13 = useState([]),
145
+ _useState14 = _slicedToArray(_useState13, 2),
146
+ itemsTabs = _useState14[0],
147
+ setItemsTabs = _useState14[1];
148
+ var PayMethodList = {
149
+ wepay: [{
150
+ key: 'wepay',
151
+ label: '微信支付',
152
+ icon: /*#__PURE__*/_jsx(WechatOutlined, {
153
+ className: "tabIcon"
154
+ }),
155
+ disabled: loadingPay,
156
+ children: payOrderInfo.wepay.message ? /*#__PURE__*/_jsx(Result, {
157
+ status: "error",
158
+ title: "\u4E0B\u5355\u53D1\u751F\u4E00\u4E9B\u95EE\u9898",
159
+ subTitle: payOrderInfo.wepay.message,
160
+ children: /*#__PURE__*/_jsx(Button, {
161
+ type: "primary",
162
+ children: "\u91CD\u8BD5"
181
163
  })
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"
164
+ }) : /*#__PURE__*/_jsxs(_Fragment, {
165
+ children: [/*#__PURE__*/_jsx("div", {
166
+ className: "qrImage",
167
+ children: payOrderInfo.wepay.qrUrl ? /*#__PURE__*/_jsx(QRCode, {
168
+ value: payOrderInfo.wepay.qrUrl,
169
+ fgColor: "#0bc160",
170
+ size: 180
171
+ }) : /*#__PURE__*/_jsx(LoadingOutlined, {
172
+ className: "loadingIcon"
173
+ })
174
+ }), /*#__PURE__*/_jsx("div", {
175
+ className: "qrAlt",
176
+ children: Platform.isH5 ? /*#__PURE__*/_jsxs("div", {
177
+ className: "altInH5",
178
+ children: ["\u957F\u6309\u4E8C\u7EF4\u7801\uFF0C\u53EF\u8BC6\u522B\u4E8C\u7EF4\u7801\u652F\u4ED8", /*#__PURE__*/_jsx("p", {
179
+ className: "toFriend",
180
+ children: "\u6216\u8005\u4FDD\u5B58\u56FE\u7247\u8BA9\u670B\u53CB\u626B\u7801\u4EE3\u4ED8"
181
+ })]
182
+ }) : /*#__PURE__*/_jsxs("div", {
183
+ className: "alt",
184
+ children: ["\u8BF7\u7528 ", /*#__PURE__*/_jsx(WechatOutlined, {
185
+ className: "wechatIcon"
186
+ }), " \u5FAE\u4FE1 \u626B\u7801\u652F\u4ED8 ", /*#__PURE__*/_jsx(Divider, {
187
+ type: "vertical"
188
+ }), " \u4E5F\u53EF\u4EE5\u8BA9\u670B\u53CB\u626B\u7801\u4EE3\u4ED8"]
189
+ })
190
+ })]
198
191
  })
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"
192
+ }],
193
+ alipay: [{
194
+ key: 'alipay',
195
+ label: '支付宝',
196
+ disabled: loadingPay,
197
+ icon: /*#__PURE__*/_jsx(AlipayCircleOutlined, {
198
+ className: "tabIcon"
199
+ }),
200
+ children: payOrderInfo.alipay.message ? /*#__PURE__*/_jsx(Result, {
201
+ status: "error",
202
+ title: "\u4E0B\u5355\u53D1\u751F\u4E00\u4E9B\u95EE\u9898",
203
+ subTitle: payOrderInfo.alipay.message,
204
+ children: /*#__PURE__*/_jsx(Button, {
205
+ type: "primary",
206
+ children: "\u91CD\u8BD5"
208
207
  })
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"]
224
- })
225
- })]
226
- })
227
- }];
208
+ }) : /*#__PURE__*/_jsxs(_Fragment, {
209
+ children: [/*#__PURE__*/_jsx("div", {
210
+ className: "qrImage",
211
+ children: payOrderInfo.alipay.qrUrl ? /*#__PURE__*/_jsx(QRCode, {
212
+ value: payOrderInfo.alipay.qrUrl,
213
+ fgColor: "#1677ff",
214
+ size: 180
215
+ }) : /*#__PURE__*/_jsx(LoadingOutlined, {
216
+ className: "loadingIcon"
217
+ })
218
+ }), /*#__PURE__*/_jsx("div", {
219
+ className: "qrAlt",
220
+ children: Platform.isH5 ? /*#__PURE__*/_jsxs("div", {
221
+ className: "altInH5",
222
+ children: ["\u957F\u6309\u4E8C\u7EF4\u7801\uFF0C\u53EF\u8BC6\u522B\u4E8C\u7EF4\u7801\u652F\u4ED8", /*#__PURE__*/_jsx("p", {
223
+ className: "toFriend",
224
+ children: "\u6216\u8005\u4FDD\u5B58\u56FE\u7247\u8BA9\u670B\u53CB\u626B\u7801\u4EE3\u4ED8"
225
+ })]
226
+ }) : /*#__PURE__*/_jsxs("div", {
227
+ className: "alt",
228
+ children: ["\u8BF7\u7528 ", /*#__PURE__*/_jsx(AlipayCircleOutlined, {
229
+ className: "alipayIcon"
230
+ }), " \u652F\u4ED8\u5B9D \u626B\u7801\u652F\u4ED8 ", /*#__PURE__*/_jsx(Divider, {
231
+ type: "vertical"
232
+ }), " \u4E5F\u53EF\u4EE5\u8BA9\u670B\u53CB\u626B\u7801\u4EE3\u4ED8"]
233
+ })
234
+ })]
235
+ })
236
+ }]
237
+ };
238
+ var onInit = function onInit() {
239
+ payMethod === null || payMethod === void 0 || payMethod.forEach(function (payMethod) {
240
+ var itemData = PayMethodList[payMethod];
241
+ if (!itemData) {
242
+ return;
243
+ }
244
+ if (itemsTabs) {
245
+ itemsTabs.push(itemData[0]);
246
+ }
247
+ });
248
+ if (itemsTabs) {
249
+ setItemsTabs(_toConsumableArray(itemsTabs));
250
+ }
251
+ };
252
+ useEffect(function () {
253
+ onInit();
254
+ }, []);
228
255
  return /*#__PURE__*/_jsx(PageContentWarp, {
229
256
  loading: loading,
230
257
  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.2",
4
4
  "description": "",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",