component-shipinlv 0.1.12 → 0.1.15

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,6 +4,7 @@ interface Props {
4
4
  vipId: number;
5
5
  productCount: number;
6
6
  productKind: 'vip' | 'vip-card';
7
+ showPrice?: number;
7
8
  disabled?: boolean;
8
9
  onBuySuccess?: () => void;
9
10
  children: React.ReactNode;
package/dist/Buy/index.js CHANGED
@@ -5,6 +5,7 @@ import Tool from "../lib/Tool";
5
5
  import styles from "./index.css";
6
6
  import VipQr from "./qr";
7
7
  import Platform from "../lib/platform";
8
+ import BuyTrialMember from "./trial-member";
8
9
  import { jsx as _jsx } from "react/jsx-runtime";
9
10
  var Buy = function Buy(_ref) {
10
11
  var _ref$env = _ref.env,
@@ -17,12 +18,13 @@ var Buy = function Buy(_ref) {
17
18
  productCount = _ref$productCount === void 0 ? 1 : _ref$productCount,
18
19
  _ref$disabled = _ref.disabled,
19
20
  disabled = _ref$disabled === void 0 ? false : _ref$disabled,
21
+ showPrice = _ref.showPrice,
20
22
  _ref$onBuySuccess = _ref.onBuySuccess,
21
23
  onBuySuccess = _ref$onBuySuccess === void 0 ? function () {} : _ref$onBuySuccess,
22
24
  children = _ref.children;
23
25
  var onBuy = /*#__PURE__*/function () {
24
26
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
25
- var userInfo;
27
+ var userInfo, _ref3, dialog;
26
28
  return _regeneratorRuntime().wrap(function _callee$(_context) {
27
29
  while (1) switch (_context.prev = _context.next) {
28
30
  case 0:
@@ -41,8 +43,28 @@ var Buy = function Buy(_ref) {
41
43
  console.log("not login");
42
44
  return _context.abrupt("return", Tool.onLogin());
43
45
  case 6:
46
+ if (!(showPrice === 0)) {
47
+ _context.next = 9;
48
+ break;
49
+ }
50
+ // 直接开通
51
+ dialog = Tool.drawer({
52
+ title: '开通',
53
+ content: /*#__PURE__*/_jsx(BuyTrialMember, {
54
+ env: env,
55
+ vipId: vipId,
56
+ onBack: function onBack() {
57
+ onBuySuccess();
58
+ dialog.destroy();
59
+ }
60
+ }),
61
+ zIndex: 1200,
62
+ width: Math.min(520, ((_ref3 = global || window) === null || _ref3 === void 0 ? void 0 : _ref3.innerWidth) * 0.95)
63
+ });
64
+ return _context.abrupt("return");
65
+ case 9:
44
66
  onOpenVipQr();
45
- case 7:
67
+ case 10:
46
68
  case "end":
47
69
  return _context.stop();
48
70
  }
@@ -53,7 +75,7 @@ var Buy = function Buy(_ref) {
53
75
  };
54
76
  }();
55
77
  var onOpenVipQr = function onOpenVipQr() {
56
- var _ref3;
78
+ var _ref4;
57
79
  var userId = Tool.getLocalUserInfo().id;
58
80
  if (Platform.isWechat || Platform.isH5) {
59
81
  Tool.h5Pay({
@@ -79,8 +101,8 @@ var Buy = function Buy(_ref) {
79
101
  Tool.toast('^_^,谢谢购买,祝您发财');
80
102
  }
81
103
  }),
82
- zIndex: 5000,
83
- width: Math.min(520, ((_ref3 = global || window) === null || _ref3 === void 0 ? void 0 : _ref3.innerWidth) * 0.95)
104
+ zIndex: 1200,
105
+ width: Math.min(520, ((_ref4 = global || window) === null || _ref4 === void 0 ? void 0 : _ref4.innerWidth) * 0.95)
84
106
  });
85
107
  // 广播,点击了 购买;
86
108
  Tool.event.run('vip-buy-click');
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ declare const _default: {
3
+ TrialMember: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>>;
4
+ };
5
+ export default _default;
@@ -0,0 +1,6 @@
1
+ import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
2
+ var _templateObject;
3
+ import styled from 'styled-components';
4
+ export default {
5
+ TrialMember: styled.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n :global{\n //.ktv-ai-vip-compare{\n // .vip-compare-price{\n // small{\n // color: #888;\n // vertical-align: middle;\n // }\n // }\n // .listMore{\n // position: absolute;\n // right: 10px;\n // top: 9px;\n // }\n //\n // .vipCompareListMoreContent{\n // width: 500px;\n // .ratioAlt{\n // padding: 6px 0;\n // font-size: 13px;\n // color: #777;\n // .vip-compare-alt{\n //\n // }\n // }\n // }\n //\n //}\n }\n "])))
6
+ };
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ interface Props {
3
+ env?: Global.Env;
4
+ vipId: number;
5
+ onBack?: () => void;
6
+ }
7
+ declare const BuyTrialMember: React.FC<Props>;
8
+ export default BuyTrialMember;
@@ -0,0 +1,45 @@
1
+ import React from 'react';
2
+ import styles from "./trial-member.css";
3
+ import { useRequest } from "@umijs/hooks";
4
+ import * as UserVipController from "../service/api/UserVipController";
5
+ import { Button, Result } from "antd";
6
+ import PageContentWarp from "../UI/PageContentWarp";
7
+ import { jsx as _jsx } from "react/jsx-runtime";
8
+ var BuyTrialMember = function BuyTrialMember(_ref) {
9
+ var _ref$env = _ref.env,
10
+ env = _ref$env === void 0 ? 'prod' : _ref$env,
11
+ _ref$vipId = _ref.vipId,
12
+ vipId = _ref$vipId === void 0 ? 0 : _ref$vipId,
13
+ _ref$onBack = _ref.onBack,
14
+ onBack = _ref$onBack === void 0 ? function () {} : _ref$onBack;
15
+ var _useRequest = useRequest(function () {
16
+ return UserVipController.trial({
17
+ vipId: vipId
18
+ }, {
19
+ env: env
20
+ });
21
+ }, {
22
+ onSuccess: function onSuccess(result) {}
23
+ }),
24
+ loading = _useRequest.loading,
25
+ run = _useRequest.run,
26
+ error = _useRequest.error;
27
+ return /*#__PURE__*/_jsx(styles.TrialMember, {
28
+ children: /*#__PURE__*/_jsx(PageContentWarp, {
29
+ loading: loading,
30
+ error: error,
31
+ onReload: run,
32
+ children: /*#__PURE__*/_jsx(Result, {
33
+ status: "success",
34
+ title: "\u5DF2\u5F00\u901A",
35
+ subTitle: "\u5FEB\u53BB\u8BD5\u7528\u5427",
36
+ extra: [/*#__PURE__*/_jsx(Button, {
37
+ type: "primary",
38
+ onClick: onBack,
39
+ children: "\u8FD4\u56DE"
40
+ }, "back")]
41
+ })
42
+ })
43
+ });
44
+ };
45
+ export default BuyTrialMember;
@@ -2,5 +2,5 @@ import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLit
2
2
  var _templateObject;
3
3
  import styled from 'styled-components';
4
4
  export default {
5
- pricingCompare: styled.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n th{\n font-size: 20px;\n padding: 20px 0 !important;\n font-weight: 400 !important;\n text-align: center !important;\n }\n\n .classifyKind{\n font-size: 18px;\n }\n\n .onBuy{\n padding: 16px 0;\n }\n\n .title{\n font-size: 16px;\n }\n .subtitle{\n margin: 1px 0 0;\n font-size: 12px;\n color: #999;\n font-weight: 300;\n }\n .value{\n text-align: center;\n font-size: 16px;\n .allow{\n color: #00b70d;\n font-size: 18px;\n }\n .notAllow{\n color: #C00;\n font-size: 18px;\n }\n small{\n color: #999;\n padding-left: 2px;\n }\n }\n "])))
5
+ pricingCompare: styled.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n th{\n font-size: 20px;\n padding: 20px 0 !important;\n font-weight: 400 !important;\n text-align: center !important;\n }\n\n .vipTitle{\n }\n\n .classifyKind{\n font-size: 18px;\n }\n\n .onBuy{\n //padding: 16px 0;\n text-align: center;\n }\n\n .title{\n font-size: 16px;\n }\n .subtitle{\n margin: 1px 0 0;\n font-size: 12px;\n color: #999;\n font-weight: 300;\n }\n .value{\n text-align: center;\n font-size: 16px;\n .allow{\n color: #00b70d;\n font-size: 18px;\n }\n .notAllow{\n color: #C00;\n font-size: 18px;\n }\n small{\n color: #999;\n padding-left: 2px;\n }\n }\n "])))
6
6
  };
@@ -1,10 +1,12 @@
1
1
  import React from "react";
2
2
  interface Props {
3
+ productType: string;
3
4
  disabledPrice?: boolean;
4
5
  disabledBuy?: boolean;
5
6
  applyDemoWechatUrl?: string;
6
7
  applyDemoTitle?: string;
7
8
  tableOffsetHeader?: number;
9
+ env?: Global.Env;
8
10
  tableScrollY?: number | string;
9
11
  onBuySuccess?: () => void;
10
12
  }
@@ -32,7 +32,8 @@ var ApplyColorDict = {
32
32
  }
33
33
  };
34
34
  var VipList = function VipList(_ref) {
35
- var _ref$disabledPrice = _ref.disabledPrice,
35
+ var productType = _ref.productType,
36
+ _ref$disabledPrice = _ref.disabledPrice,
36
37
  disabledPrice = _ref$disabledPrice === void 0 ? false : _ref$disabledPrice,
37
38
  _ref$disabledBuy = _ref.disabledBuy,
38
39
  disabledBuy = _ref$disabledBuy === void 0 ? false : _ref$disabledBuy,
@@ -42,15 +43,23 @@ var VipList = function VipList(_ref) {
42
43
  applyDemoTitle = _ref$applyDemoTitle === void 0 ? '预约演示' : _ref$applyDemoTitle,
43
44
  _ref$tableScrollY = _ref.tableScrollY,
44
45
  tableScrollY = _ref$tableScrollY === void 0 ? '65vh' : _ref$tableScrollY,
46
+ env = _ref.env,
45
47
  _ref$tableOffsetHeade = _ref.tableOffsetHeader,
46
48
  tableOffsetHeader = _ref$tableOffsetHeade === void 0 ? 56 : _ref$tableOffsetHeade,
47
49
  _ref$onBuySuccess = _ref.onBuySuccess,
48
50
  onBuySuccess = _ref$onBuySuccess === void 0 ? function () {} : _ref$onBuySuccess;
49
- var _useState = useState([]),
50
- _useState2 = _slicedToArray(_useState, 2),
51
- listData = _useState2[0],
52
- setListData = _useState2[1];
53
- var _useState3 = useState([{
51
+ var _useState = useState(Tool.getLocalUserInfo()),
52
+ _useState2 = _slicedToArray(_useState, 1),
53
+ userInfo = _useState2[0];
54
+ var _useState3 = useState([]),
55
+ _useState4 = _slicedToArray(_useState3, 2),
56
+ buyList = _useState4[0],
57
+ setBuyList = _useState4[1];
58
+ var _useState5 = useState([]),
59
+ _useState6 = _slicedToArray(_useState5, 2),
60
+ listData = _useState6[0],
61
+ setListData = _useState6[1];
62
+ var _useState7 = useState([{
54
63
  title: '功能',
55
64
  dataIndex: 'title',
56
65
  key: 'title',
@@ -71,30 +80,37 @@ var VipList = function VipList(_ref) {
71
80
  });
72
81
  }
73
82
  }]),
74
- _useState4 = _slicedToArray(_useState3, 2),
75
- columns = _useState4[0],
76
- setColumns = _useState4[1];
83
+ _useState8 = _slicedToArray(_useState7, 2),
84
+ columns = _useState8[0],
85
+ setColumns = _useState8[1];
77
86
  var _useRequest = useRequest(function () {
78
87
  return VipPowerController.list({
88
+ productType: productType,
79
89
  dealerId: Tool.getLocalSiteInfo().dealerId || 0
80
90
  }, {
81
- env: getApiEnv()
91
+ env: env
82
92
  });
83
93
  }, {
84
94
  onSuccess: function onSuccess(result) {
85
95
  var list = [];
86
96
  var listLen = result.vipList.length;
97
+ var buyList = [];
87
98
  result.vipList.forEach(function (item) {
99
+ buyList.push({
100
+ id: item.id,
101
+ price: item.price
102
+ });
88
103
  var dataIndex = "vipLevel".concat(item.vipLevel);
89
104
  var colorPrimary = ApplyColorDict[item.vipLevel].color || '#722ED1';
90
105
  list.push({
91
106
  title: /*#__PURE__*/_jsxs("div", {
92
107
  children: [/*#__PURE__*/_jsx("div", {
108
+ className: "vipTitle",
93
109
  style: {
94
110
  color: colorPrimary
95
111
  },
96
112
  children: item.title
97
- }), applyDemoWechatUrl && /*#__PURE__*/_jsx(ConfigProvider, {
113
+ }), applyDemoWechatUrl && item.price > 0 && /*#__PURE__*/_jsx(ConfigProvider, {
98
114
  theme: {
99
115
  components: {
100
116
  Button: {
@@ -117,42 +133,18 @@ var VipList = function VipList(_ref) {
117
133
  render: function render(value, record) {
118
134
  return /*#__PURE__*/_jsx("div", {
119
135
  className: "value",
120
- children: (record === null || record === void 0 ? void 0 : record.title) === ':buy' ? /*#__PURE__*/_jsx("div", {
121
- className: "onBuy",
122
- children: /*#__PURE__*/_jsx(ConfigProvider, {
123
- theme: {
124
- components: {
125
- Button: {
126
- colorPrimary: '#722ED1'
127
- }
128
- }
129
- },
130
- children: (item === null || item === void 0 ? void 0 : item.price) > 0 && /*#__PURE__*/_jsx(Buy, {
131
- env: getApiEnv(),
132
- productKind: "vip",
133
- vipId: (item === null || item === void 0 ? void 0 : item.id) || 0,
134
- productCount: 1,
135
- onBuySuccess: onBuySuccess,
136
- children: /*#__PURE__*/_jsx(Button, {
137
- type: "primary",
138
- icon: /*#__PURE__*/_jsx(ShoppingCartOutlined, {}),
139
- children: "\u8D2D\u4E70"
140
- })
141
- })
142
- })
143
- }) : /*#__PURE__*/_jsx(_Fragment, {
144
- children: ['true', 'false'].includes(value) ? /*#__PURE__*/_jsxs(_Fragment, {
145
- children: [value === 'true' && /*#__PURE__*/_jsx(CheckCircleFilled, {
146
- className: "allow"
147
- }), value === 'false' && /*#__PURE__*/_jsx(CloseCircleFilled, {
148
- className: "notAllow"
149
- })]
150
- }) : value
151
- })
136
+ children: ['true', 'false'].includes(value) ? /*#__PURE__*/_jsxs(_Fragment, {
137
+ children: [value === 'true' && /*#__PURE__*/_jsx(CheckCircleFilled, {
138
+ className: "allow"
139
+ }), value === 'false' && /*#__PURE__*/_jsx(CloseCircleFilled, {
140
+ className: "notAllow"
141
+ })]
142
+ }) : value
152
143
  });
153
144
  }
154
145
  });
155
146
  });
147
+ setBuyList([].concat(buyList));
156
148
  columns.push.apply(columns, list);
157
149
  setColumns(_toConsumableArray(columns));
158
150
 
@@ -201,16 +193,18 @@ var VipList = function VipList(_ref) {
201
193
  })
202
194
  });
203
195
  }
204
- if (!disabledBuy) {
205
- listDataValues.push({
206
- name: ':buy',
207
- classifyTitle: ':buy',
208
- classifySubtitle: '',
209
- classifyIndex: -1,
210
- classifyKind: '购买',
211
- list: []
212
- });
213
- }
196
+
197
+ // if( ! disabledBuy ){
198
+ // listDataValues.push({
199
+ // name: ':buy',
200
+ // classifyTitle: ':buy',
201
+ // classifySubtitle: '',
202
+ // classifyIndex: -1,
203
+ // classifyKind: '购买',
204
+ // list: [],
205
+ // });
206
+ // }
207
+
214
208
  var listData = [];
215
209
  listDataValues.forEach(function (items, index) {
216
210
  var onlyShowTitle = false;
@@ -299,7 +293,15 @@ var VipList = function VipList(_ref) {
299
293
  }
300
294
  Tool.pageDialog({
301
295
  title: applyDemoTitle,
302
- content: Tool.makeQr(applyDemoWechatUrl, '#29ae67', 220),
296
+ content: /*#__PURE__*/_jsxs("div", {
297
+ children: [Tool.makeQr(applyDemoWechatUrl, '#29ae67', 220), /*#__PURE__*/_jsx("p", {
298
+ style: {
299
+ textAlign: 'center',
300
+ color: '#999'
301
+ },
302
+ children: "\u5FAE\u4FE1\u626B\u4E00\u626B\uFF0C\u52A0\u597D\u53CB"
303
+ })]
304
+ }),
303
305
  width: 320,
304
306
  zIndex: 9999
305
307
  });
@@ -331,9 +333,54 @@ var VipList = function VipList(_ref) {
331
333
  },
332
334
  columns: columns,
333
335
  dataSource: listData,
334
- pagination: false,
335
- sticky: {
336
- offsetHeader: tableOffsetHeader
336
+ pagination: false
337
+ // sticky={{offsetHeader: tableOffsetHeader }}
338
+ ,
339
+ summary: function summary() {
340
+ return disabledBuy ? undefined : /*#__PURE__*/_jsx(Table.Summary, {
341
+ fixed: true,
342
+ children: /*#__PURE__*/_jsxs(Table.Summary.Row, {
343
+ children: [/*#__PURE__*/_jsx(Table.Summary.Cell, {
344
+ index: 0,
345
+ children: " "
346
+ }), buyList.map(function (item, i) {
347
+ var _userInfo$userVip;
348
+ // 从不是会员;
349
+ var userVip = !!((_userInfo$userVip = userInfo.userVip) !== null && _userInfo$userVip !== void 0 && _userInfo$userVip[productType]);
350
+ var colorPrimary = (item === null || item === void 0 ? void 0 : item.price) > 0 ? '#722ED1' : 'green';
351
+ return /*#__PURE__*/_jsx(Table.Summary.Cell, {
352
+ index: i,
353
+ children: /*#__PURE__*/_jsx("div", {
354
+ className: "onBuy",
355
+ children: /*#__PURE__*/_jsx(ConfigProvider, {
356
+ theme: {
357
+ components: {
358
+ Button: {
359
+ colorPrimary: colorPrimary
360
+ }
361
+ }
362
+ },
363
+ children: /*#__PURE__*/_jsx(Buy, {
364
+ env: getApiEnv(),
365
+ disabled: userVip,
366
+ productKind: "vip",
367
+ vipId: (item === null || item === void 0 ? void 0 : item.id) || 0,
368
+ productCount: 1,
369
+ showPrice: item === null || item === void 0 ? void 0 : item.price,
370
+ onBuySuccess: onBuySuccess,
371
+ children: /*#__PURE__*/_jsx(Button, {
372
+ disabled: userVip && item.price === 0,
373
+ type: "primary",
374
+ icon: /*#__PURE__*/_jsx(ShoppingCartOutlined, {}),
375
+ children: (item === null || item === void 0 ? void 0 : item.price) > 0 ? '购买' : '免费开通'
376
+ })
377
+ })
378
+ })
379
+ })
380
+ }, item.id);
381
+ })]
382
+ })
383
+ });
337
384
  }
338
385
  })
339
386
  })
@@ -1,5 +1,5 @@
1
1
  // 业务服务器 api
2
- export var currentEnv = 'local';
2
+ export var currentEnv = 'prod';
3
3
  var ApiUrls = {
4
4
  local: {
5
5
  api: 'http://localhost:9999/',
@@ -163,7 +163,7 @@ declare const Tool: {
163
163
  setTimeOffset(serverTime: number): void;
164
164
  getTime(): number;
165
165
  h5Pay(query: Pay.H5PayQuery): void;
166
- notification(type: "success" | "info" | "warning" | "error", message: string, description?: import("react").ReactNode, options?: NotificationOptions): void;
166
+ notification(type: "error" | "success" | "info" | "warning", message: string, description?: import("react").ReactNode, options?: NotificationOptions): void;
167
167
  notificationSuccess(message: string, description?: import("react").ReactNode, options?: NotificationOptions): void;
168
168
  notificationError(message: string, description?: import("react").ReactNode, options?: NotificationOptions): void;
169
169
  notificationWarning(message: string, description?: import("react").ReactNode, options?: NotificationOptions): void;
@@ -0,0 +1,3 @@
1
+ export declare function trial(body: {
2
+ vipId: number;
3
+ }, options?: Global.RequestOptions): Promise<Vip.List>;
@@ -0,0 +1,27 @@
1
+ import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
2
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
3
+ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
4
+ import request from "../../lib/request";
5
+ export function trial(_x, _x2) {
6
+ return _trial.apply(this, arguments);
7
+ }
8
+ function _trial() {
9
+ _trial = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(body, options) {
10
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
11
+ while (1) switch (_context.prev = _context.next) {
12
+ case 0:
13
+ return _context.abrupt("return", request("user/userVip/trial", _objectSpread({
14
+ method: 'POST',
15
+ headers: {
16
+ 'Content-Type': 'application/json'
17
+ },
18
+ data: _objectSpread({}, body)
19
+ }, options || {})));
20
+ case 1:
21
+ case "end":
22
+ return _context.stop();
23
+ }
24
+ }, _callee);
25
+ }));
26
+ return _trial.apply(this, arguments);
27
+ }
@@ -1,3 +1,4 @@
1
1
  export declare function list(body: {
2
+ productType: string;
2
3
  dealerId: number;
3
4
  }, options?: ServicesApi.RequestOptions): Promise<VipPower.ListResult>;
@@ -42,4 +42,8 @@ declare namespace VipPower {
42
42
  [vipLevel: string]: TypeCompareVipLevel;
43
43
  }
44
44
  type TypeCompareVipLevel = boolean | React.ReactNode;
45
+ interface BuyList {
46
+ id: number;
47
+ price: number;
48
+ }
45
49
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "component-shipinlv",
3
- "version": "0.1.12",
3
+ "version": "0.1.15",
4
4
  "description": "",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",