component-shipinlv 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (100) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +4 -0
  3. package/dist/AuthClient/index.d.ts +10 -0
  4. package/dist/AuthClient/index.js +24 -0
  5. package/dist/AuthClient/login-reg.d.ts +9 -0
  6. package/dist/AuthClient/login-reg.js +62 -0
  7. package/dist/AuthClient/login-reg.less +13 -0
  8. package/dist/AuthClient/login.d.ts +7 -0
  9. package/dist/AuthClient/login.js +159 -0
  10. package/dist/AuthClient/login.less +52 -0
  11. package/dist/AuthClient/qr/index.d.ts +13 -0
  12. package/dist/AuthClient/qr/index.js +315 -0
  13. package/dist/AuthClient/qr/index.less +84 -0
  14. package/dist/AuthClient/qr/typings.d.ts +22 -0
  15. package/dist/AuthClient/qr/ws.d.ts +20 -0
  16. package/dist/AuthClient/qr/ws.js +253 -0
  17. package/dist/AuthClient/reg.d.ts +7 -0
  18. package/dist/AuthClient/reg.js +170 -0
  19. package/dist/AuthClient/reg.less +3 -0
  20. package/dist/Buy/index.d.ts +14 -0
  21. package/dist/Buy/index.js +91 -0
  22. package/dist/Buy/index.less +26 -0
  23. package/dist/Buy/qr.d.ts +11 -0
  24. package/dist/Buy/qr.js +185 -0
  25. package/dist/Buy/qr.less +69 -0
  26. package/dist/Login/index.d.ts +2 -0
  27. package/dist/Login/index.js +5 -0
  28. package/dist/Product/index.d.ts +4 -0
  29. package/dist/Product/index.js +34 -0
  30. package/dist/Product/index.less +84 -0
  31. package/dist/UI/DialogDrawer.d.ts +8 -0
  32. package/dist/UI/DialogDrawer.js +67 -0
  33. package/dist/UI/DialogDrawer.less +10 -0
  34. package/dist/UI/DialogDrawerFooter.d.ts +7 -0
  35. package/dist/UI/DialogDrawerFooter.js +23 -0
  36. package/dist/UI/DialogDrawerFooter.less +19 -0
  37. package/dist/UI/LoadError.d.ts +10 -0
  38. package/dist/UI/LoadError.js +37 -0
  39. package/dist/UI/LoadError.less +18 -0
  40. package/dist/UI/PageContentWarp.d.ts +16 -0
  41. package/dist/UI/PageContentWarp.js +46 -0
  42. package/dist/UI/PageContentWarp.less +11 -0
  43. package/dist/VipCompare/commend.d.ts +7 -0
  44. package/dist/VipCompare/commend.js +29 -0
  45. package/dist/VipCompare/commend.less +7 -0
  46. package/dist/VipCompare/index.d.ts +9 -0
  47. package/dist/VipCompare/index.js +320 -0
  48. package/dist/VipCompare/index.less +26 -0
  49. package/dist/component/product-dict.d.ts +10 -0
  50. package/dist/component/product-dict.js +11 -0
  51. package/dist/component/product-type.d.ts +6 -0
  52. package/dist/component/product-type.js +19 -0
  53. package/dist/component/websocket/index.d.ts +22 -0
  54. package/dist/component/websocket/index.js +139 -0
  55. package/dist/config/apiUrls.d.ts +9 -0
  56. package/dist/config/apiUrls.js +25 -0
  57. package/dist/index.d.ts +5 -0
  58. package/dist/index.js +5 -0
  59. package/dist/lib/Tool.d.ts +201 -0
  60. package/dist/lib/Tool.js +1086 -0
  61. package/dist/lib/call-mini-url.d.ts +2 -0
  62. package/dist/lib/call-mini-url.js +8 -0
  63. package/dist/lib/getApiUrl.d.ts +5 -0
  64. package/dist/lib/getApiUrl.js +56 -0
  65. package/dist/lib/goAuth.d.ts +1 -0
  66. package/dist/lib/goAuth.js +28 -0
  67. package/dist/lib/js-error.d.ts +2 -0
  68. package/dist/lib/js-error.js +27 -0
  69. package/dist/lib/notification.d.ts +9 -0
  70. package/dist/lib/notification.js +42 -0
  71. package/dist/lib/platform.d.ts +12 -0
  72. package/dist/lib/platform.js +48 -0
  73. package/dist/lib/postMessage.d.ts +3 -0
  74. package/dist/lib/postMessage.js +8 -0
  75. package/dist/lib/request.d.ts +3 -0
  76. package/dist/lib/request.js +97 -0
  77. package/dist/service/api/AuthController.d.ts +16 -0
  78. package/dist/service/api/AuthController.js +75 -0
  79. package/dist/service/api/JsErrorController.d.ts +5 -0
  80. package/dist/service/api/JsErrorController.js +27 -0
  81. package/dist/service/api/ProductController.d.ts +7 -0
  82. package/dist/service/api/ProductController.js +53 -0
  83. package/dist/service/api/TradeController.d.ts +7 -0
  84. package/dist/service/api/TradeController.js +52 -0
  85. package/dist/service/api/UserController.d.ts +2 -0
  86. package/dist/service/api/UserController.js +52 -0
  87. package/dist/service/api/VipController.d.ts +6 -0
  88. package/dist/service/api/VipController.js +50 -0
  89. package/dist/service/typing.d.ts +12 -0
  90. package/dist/typings/Product.d.ts +25 -0
  91. package/dist/typings/Product.js +0 -0
  92. package/dist/typings/Trade.d.ts +29 -0
  93. package/dist/typings/Trade.js +0 -0
  94. package/dist/typings/User.d.ts +54 -0
  95. package/dist/typings/User.js +0 -0
  96. package/dist/typings/Vip.d.ts +15 -0
  97. package/dist/typings/Vip.js +0 -0
  98. package/dist/typings.d.ts +66 -0
  99. package/dist/window.d.ts +9 -0
  100. package/package.json +88 -0
@@ -0,0 +1,320 @@
1
+ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
2
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
3
+ import _objectDestructuringEmpty from "@babel/runtime/helpers/esm/objectDestructuringEmpty";
4
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
5
+ import React, { useEffect, useState } from 'react';
6
+ import { Table, Popover, Tag } from 'antd';
7
+ import { useRequest } from '@umijs/hooks';
8
+ import * as VipController from "../service/api/VipController";
9
+ import Tool from "../lib/Tool";
10
+ import PageContentWarp from "../UI/PageContentWarp";
11
+ import "./index.less";
12
+ import { QuestionCircleFilled, LikeOutlined } from '@ant-design/icons';
13
+ import VipCommend from "./commend";
14
+ import * as UserController from "../service/api/UserController";
15
+ import * as ProductController from "../service/api/ProductController";
16
+ import Buy from "../Buy";
17
+ import { jsx as _jsx } from "react/jsx-runtime";
18
+ import { jsxs as _jsxs } from "react/jsx-runtime";
19
+ import { Fragment as _Fragment } from "react/jsx-runtime";
20
+ var VipCompare = function VipCompare(_ref) {
21
+ var _ref$productType = _ref.productType,
22
+ productType = _ref$productType === void 0 ? '' : _ref$productType,
23
+ env = _ref.env,
24
+ _ref$isShowToken = _ref.isShowToken,
25
+ isShowToken = _ref$isShowToken === void 0 ? false : _ref$isShowToken;
26
+ var _useState = useState({
27
+ name: '',
28
+ thumbUrl: '',
29
+ productType: '',
30
+ onlyBuyOne: false,
31
+ highIntroduction: '',
32
+ introduction: '',
33
+ content: '',
34
+ screenshotPreview: [],
35
+ tag: []
36
+ }),
37
+ _useState2 = _slicedToArray(_useState, 2),
38
+ productDetail = _useState2[0],
39
+ setProductDetail = _useState2[1];
40
+ var _useRequest = useRequest(function () {
41
+ return ProductController.detail({
42
+ productType: productType
43
+ }, {
44
+ env: env
45
+ });
46
+ }, {
47
+ onSuccess: function onSuccess(result) {
48
+ setProductDetail(result);
49
+ }
50
+ }),
51
+ loadingProduct = _useRequest.loading,
52
+ runProduct = _useRequest.run;
53
+ var columnsMore = [{
54
+ title: '说明',
55
+ dataIndex: 'monthTitle',
56
+ key: 'monthTitle',
57
+ render: function render(monthTitle) {
58
+ return /*#__PURE__*/_jsx(Tag, {
59
+ children: monthTitle
60
+ });
61
+ }
62
+ }, {
63
+ title: '价格',
64
+ dataIndex: 'price',
65
+ key: 'price',
66
+ render: function render(price) {
67
+ return /*#__PURE__*/_jsxs("div", {
68
+ className: "ktv-ai-vip-compare-price",
69
+ children: [/*#__PURE__*/_jsx("small", {
70
+ children: "\uFFE5"
71
+ }), price, /*#__PURE__*/_jsx("small", {
72
+ children: "\u5143"
73
+ })]
74
+ });
75
+ }
76
+ }, {
77
+ title: '一级好友',
78
+ dataIndex: 'ratioDownPercent1',
79
+ key: 'ratioDownPercent1',
80
+ render: function render(ratioDownPercent1) {
81
+ return /*#__PURE__*/_jsxs(_Fragment, {
82
+ children: [ratioDownPercent1, /*#__PURE__*/_jsx("small", {
83
+ children: "%"
84
+ })]
85
+ });
86
+ }
87
+ }, {
88
+ title: '二级好友',
89
+ dataIndex: 'ratioDownPercent2',
90
+ key: 'ratioDownPercent2',
91
+ render: function render(ratioDownPercent2) {
92
+ return /*#__PURE__*/_jsxs(_Fragment, {
93
+ children: [ratioDownPercent2, /*#__PURE__*/_jsx("small", {
94
+ children: "%"
95
+ })]
96
+ });
97
+ }
98
+ }, {
99
+ title: '说明',
100
+ dataIndex: 'alt',
101
+ key: 'alt',
102
+ render: function render(alt, record) {
103
+ return /*#__PURE__*/_jsxs("div", {
104
+ className: "alt",
105
+ children: [alt, Array(record === null || record === void 0 ? void 0 : record.recommend).map(function (num) {
106
+ return /*#__PURE__*/_jsx(LikeOutlined, {});
107
+ }), /*#__PURE__*/_jsx(VipCommend, {
108
+ commend: record === null || record === void 0 ? void 0 : record.recommend
109
+ })]
110
+ });
111
+ }
112
+ }];
113
+ var _useState3 = useState([{
114
+ title: '时间',
115
+ dataIndex: 'monthTitle',
116
+ key: 'monthTitle',
117
+ render: function render(monthTitle) {
118
+ return /*#__PURE__*/_jsx(Tag, {
119
+ children: monthTitle
120
+ });
121
+ }
122
+ }, {
123
+ title: '价格',
124
+ dataIndex: 'price',
125
+ key: 'price',
126
+ render: function render(price) {
127
+ return /*#__PURE__*/_jsxs("div", {
128
+ className: "vip-compare-price",
129
+ children: [/*#__PURE__*/_jsx("small", {
130
+ children: "\uFFE5"
131
+ }), price, /*#__PURE__*/_jsx("small", {
132
+ children: "\u5143"
133
+ })]
134
+ });
135
+ }
136
+ }, {
137
+ title: '提成',
138
+ dataIndex: 'price',
139
+ key: 'price',
140
+ render: function render(_, record) {
141
+ var all = ((record === null || record === void 0 ? void 0 : record.ratioDownPercent1) || 0) + ((record === null || record === void 0 ? void 0 : record.ratioDownPercent2) || 0);
142
+ return /*#__PURE__*/_jsx("div", {
143
+ className: "vip-compare-price",
144
+ children: all ? /*#__PURE__*/_jsxs(_Fragment, {
145
+ children: [all, /*#__PURE__*/_jsx("small", {
146
+ children: "%"
147
+ })]
148
+ }) : '-'
149
+ });
150
+ }
151
+ }]),
152
+ _useState4 = _slicedToArray(_useState3, 2),
153
+ columns = _useState4[0],
154
+ setColumns = _useState4[1];
155
+ var _useState5 = useState([]),
156
+ _useState6 = _slicedToArray(_useState5, 2),
157
+ listData = _useState6[0],
158
+ setListData = _useState6[1];
159
+ var _useRequest2 = useRequest(function () {
160
+ return VipController.list({
161
+ productType: productType
162
+ }, {
163
+ env: env
164
+ });
165
+ }, {
166
+ onSuccess: function onSuccess(result) {
167
+ setListData(result);
168
+ }
169
+ }),
170
+ loading = _useRequest2.loading,
171
+ run = _useRequest2.run,
172
+ error = _useRequest2.error;
173
+
174
+ // 购买信息
175
+ var _useState7 = useState({}),
176
+ _useState8 = _slicedToArray(_useState7, 2),
177
+ buyListData = _useState8[0],
178
+ setBuyListData = _useState8[1];
179
+ _objectDestructuringEmpty(useRequest(function () {
180
+ return UserController.userVipInfo();
181
+ }, {
182
+ manual: !Tool.getLocalUserInfo().isLogin,
183
+ onSuccess: function onSuccess(result) {
184
+ var dataDict = {};
185
+ result === null || result === void 0 || result.forEach(function (items) {
186
+ dataDict[items.productType] = items;
187
+ });
188
+ setBuyListData(_objectSpread({}, dataDict));
189
+ }
190
+ })); // const onBuy = async (id = 0) => {
191
+ // // 先要登录;
192
+ // const userInfo = Tool.getLocalUserInfo();
193
+ // if (!userInfo.isLogin) {
194
+ // console.log("not login")
195
+ // return Tool.onLogin()
196
+ // // const loginResult = await Tool.onLogin();
197
+ // // if ( ! loginResult ) {
198
+ // // return;
199
+ // // }
200
+ // }
201
+ // onOpenVipQr(id);
202
+ // };
203
+ // const onOpenVipQr = (id: number) => {
204
+ // const userId = Tool.getLocalUserInfo().id;
205
+ // if( ( Platform.isWechat || Platform.isH5 ) ){
206
+ // Tool.h5Pay( {
207
+ // productType: 'vip',
208
+ // productId: id,
209
+ // userId,
210
+ // wechatAppId: Tool.getLocalSiteInfo().wechatAppId,
211
+ // });
212
+ // return;
213
+ // }
214
+ //
215
+ // const dialog = Tool.drawer({
216
+ // title: '购买会员',
217
+ // content: (
218
+ // <VipQr
219
+ // productType="vip"
220
+ // vipId={ id }
221
+ // onHandlePaySuccess={() => {
222
+ // dialog.destroy();
223
+ // Tool.toast('^_^,谢谢购买,祝您发财');
224
+ // }}
225
+ // />
226
+ // ),
227
+ // width: Math.min( 520, window.innerWidth * 0.95 ),
228
+ // });
229
+ // // 广播,点击了 购买;
230
+ // Tool.event.run('vip-buy-click');
231
+ // };
232
+ useEffect(function () {
233
+ if (isShowToken) {
234
+ columns.push({
235
+ title: 'Token 数量',
236
+ dataIndex: 'maxToken',
237
+ key: 'maxToken',
238
+ render: function render(maxToken) {
239
+ return Tool.moneySimple(maxToken);
240
+ }
241
+ });
242
+ }
243
+ columns.push({
244
+ title: '操作',
245
+ key: 'option',
246
+ render: function render(_, record) {
247
+ if (!(record !== null && record !== void 0 && record.price) || (record === null || record === void 0 ? void 0 : record.price) <= 0) {
248
+ return /*#__PURE__*/_jsx("span", {
249
+ "data-price": record === null || record === void 0 ? void 0 : record.price
250
+ });
251
+ }
252
+ return /*#__PURE__*/_jsx(Buy, {
253
+ env: env,
254
+ vipId: (record === null || record === void 0 ? void 0 : record.id) || 0,
255
+ productCount: 1
256
+ // onlyBuyOne={ productDetail.onlyBuyOne }
257
+ // isVip={ buyListData[record?.productType|| '']?.isVip }
258
+ ,
259
+ title: "\u8D2D\u4E70",
260
+ productKind: "vip"
261
+ });
262
+ }
263
+ });
264
+ setColumns(_toConsumableArray(columns));
265
+ }, []);
266
+ return /*#__PURE__*/_jsxs(PageContentWarp, {
267
+ loading: loading,
268
+ error: error,
269
+ onReload: function onReload() {
270
+ return run();
271
+ },
272
+ className: "ktv-ai-vip-compare",
273
+ children: [/*#__PURE__*/_jsx("div", {
274
+ className: "listMore",
275
+ children: /*#__PURE__*/_jsx(Popover, {
276
+ title: "\u4F1A\u5458\u63D0\u6210\u4ECB\u7ECD",
277
+ placement: "topRight",
278
+ content: /*#__PURE__*/_jsxs("div", {
279
+ className: "vipCompareListMoreContent",
280
+ children: [/*#__PURE__*/_jsx("p", {
281
+ children: "\u60A8\u53EF\u4EE5\u8D2D\u4E70\u7684\u4F1A\u5458\u52A0\u901F\u5361\uFF0C\u63A8\u5E7F\u8D5A\u94B1\uFF1B\u4F1A\u5458\u7B49\u7EA7\u7B49\u7EA7\u8D8A\u9AD8\uFF0C\u6536\u76CA\u8D8A\u9AD8\uFF1B"
282
+ }), /*#__PURE__*/_jsx(Table, {
283
+ size: "small",
284
+ bordered: true,
285
+ rowKey: function rowKey(record) {
286
+ return "".concat(record.id);
287
+ },
288
+ loading: loading,
289
+ columns: columnsMore,
290
+ dataSource: listData,
291
+ pagination: false
292
+ }), /*#__PURE__*/_jsxs("div", {
293
+ className: ".vip-compare-ratioAlt",
294
+ children: [/*#__PURE__*/_jsx("strong", {
295
+ children: "\u4E00\u7EA7\u597D\u53CB"
296
+ }), "\u8868\u793A\u4F60\u9080\u8BF7\u7684\u597D\u53CB\uFF0C", /*#__PURE__*/_jsx("strong", {
297
+ children: "\u4E8C\u7EA7\u597D\u53CB"
298
+ }), "\u8868\u793A\u4F60\u7684\u597D\u53CB\u9080\u8BF7\u7684\u597D\u53CB\uFF1B\u597D\u53CB\u5728\u5E73\u53F0", /*#__PURE__*/_jsx("strong", {
299
+ children: "\u73B0\u5728\u3001\u672A\u6765"
300
+ }), "\u7684\u6240\u6709\u6D88\u8D39\u90FD\u6709\u5206\u6210\u3002"]
301
+ })]
302
+ }),
303
+ children: /*#__PURE__*/_jsxs("a", {
304
+ children: [/*#__PURE__*/_jsx(QuestionCircleFilled, {}), " \u8BF4\u660E"]
305
+ })
306
+ })
307
+ }), /*#__PURE__*/_jsx(Table, {
308
+ size: "small",
309
+ bordered: true,
310
+ rowKey: function rowKey(record) {
311
+ return "".concat(record.id);
312
+ },
313
+ loading: loading,
314
+ columns: columns,
315
+ dataSource: listData,
316
+ pagination: false
317
+ })]
318
+ });
319
+ };
320
+ export default VipCompare;
@@ -0,0 +1,26 @@
1
+ .ktv-ai-vip-compare{
2
+ .vip-compare-price{
3
+ small{
4
+ color: #888;
5
+ vertical-align: middle;
6
+ }
7
+ }
8
+ .listMore{
9
+ position: absolute;
10
+ right: 10px;
11
+ top: 9px;
12
+ }
13
+
14
+ .vipCompareListMoreContent{
15
+ width: 500px;
16
+ .ratioAlt{
17
+ padding: 6px 0;
18
+ font-size: 13px;
19
+ color: #777;
20
+ .vip-compare-alt{
21
+
22
+ }
23
+ }
24
+ }
25
+
26
+ }
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ interface ProductTypeDict {
3
+ [name: string]: {
4
+ title: string;
5
+ color?: string;
6
+ icon: React.ReactNode;
7
+ };
8
+ }
9
+ declare const ProductTypeDict: ProductTypeDict;
10
+ export default ProductTypeDict;
@@ -0,0 +1,11 @@
1
+ import { AndroidOutlined } from '@ant-design/icons';
2
+ import React from 'react';
3
+ import { jsx as _jsx } from "react/jsx-runtime";
4
+ var ProductTypeDict = {
5
+ 'chatGPT': {
6
+ title: 'ChatPGT AI',
7
+ color: '',
8
+ icon: /*#__PURE__*/_jsx(AndroidOutlined, {})
9
+ }
10
+ };
11
+ export default ProductTypeDict;
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ interface Props {
3
+ productType: string;
4
+ }
5
+ declare const ProductType: React.FC<Props>;
6
+ export default ProductType;
@@ -0,0 +1,19 @@
1
+ import React from 'react';
2
+ import ProductTypeDict from "./product-dict";
3
+ import { jsxs as _jsxs } from "react/jsx-runtime";
4
+ var ProductType = function ProductType(_ref) {
5
+ var _ref$productType = _ref.productType,
6
+ productType = _ref$productType === void 0 ? '' : _ref$productType;
7
+ var itemData = ProductTypeDict[productType] || {
8
+ color: '',
9
+ icon: '',
10
+ title: productType
11
+ };
12
+ return /*#__PURE__*/_jsxs("span", {
13
+ style: {
14
+ color: itemData.color
15
+ },
16
+ children: [itemData.icon, " ", itemData.title]
17
+ });
18
+ };
19
+ export default ProductType;
@@ -0,0 +1,22 @@
1
+ type EventName = 'connect-status' | 'message';
2
+ export type ConnectStatus = 'success' | 'error' | 'processing' | 'close';
3
+ declare class WS {
4
+ ws: WebSocket;
5
+ connectStatus: ConnectStatus;
6
+ private postEventsNeedData;
7
+ private url;
8
+ constructor(url?: string);
9
+ private events;
10
+ onConstructor(): void;
11
+ getDataUrl(): string;
12
+ onConnect(): void;
13
+ onStatusChange(status: ConnectStatus): void;
14
+ on(name: EventName, fn?: (data?: any) => void): void;
15
+ run(name: EventName, data?: any): void;
16
+ off(name: EventName): void;
17
+ onReConnect(): void;
18
+ send(data?: any): void;
19
+ private sendPost;
20
+ destroy(): void;
21
+ }
22
+ export default WS;
@@ -0,0 +1,139 @@
1
+ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
+ import _createClass from "@babel/runtime/helpers/esm/createClass";
3
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
4
+ import { getWsUrl } from "../../lib/getApiUrl";
5
+ import Tool from "../../lib/Tool";
6
+ var WS = /*#__PURE__*/function () {
7
+ function WS() {
8
+ var url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
9
+ _classCallCheck(this, WS);
10
+ // @ts-ignore
11
+ _defineProperty(this, "ws", void 0);
12
+ _defineProperty(this, "connectStatus", 'processing');
13
+ _defineProperty(this, "postEventsNeedData", []);
14
+ _defineProperty(this, "url", '');
15
+ _defineProperty(this, "events", []);
16
+ if (url) {
17
+ var fullUrl = url;
18
+ if (!/^wss?:/i.test(url)) {
19
+ var _getWsUrl;
20
+ fullUrl = ((_getWsUrl = getWsUrl()) === null || _getWsUrl === void 0 ? void 0 : _getWsUrl.replace(/\/$/, '')) + url;
21
+ }
22
+ // 携带 token
23
+ var token = Tool.getLocalUserInfo().sid || '';
24
+ // if( method === 'get'){
25
+ // params._token_ = token
26
+ // }else{
27
+ // data._token_ = token;
28
+ // }
29
+ fullUrl = fullUrl + (fullUrl.indexOf('?') === -1 ? '?' : '&') + '_token_=' + token;
30
+ this.url = fullUrl;
31
+ }
32
+ console.log('socket init!');
33
+ this.ws = new WebSocket(this.getDataUrl());
34
+ this.onConstructor();
35
+ }
36
+ _createClass(WS, [{
37
+ key: "onConstructor",
38
+ value: function onConstructor() {
39
+ var _this = this;
40
+ this.onStatusChange('processing');
41
+ this.ws.onopen = function (evt) {
42
+ _this.onStatusChange('success');
43
+ _this.postEventsNeedData.forEach(function (postData) {
44
+ _this.sendPost(postData);
45
+ });
46
+ };
47
+ this.ws.onerror = function (evt) {
48
+ _this.onStatusChange('error');
49
+ };
50
+ this.ws.onclose = function (evt) {
51
+ console.log("ws close !!!!!!!!!!!!!!!!!!!!!!!!!");
52
+ _this.onStatusChange('close');
53
+ };
54
+ this.ws.onmessage = function (evt) {
55
+ _this.run('message', evt);
56
+ };
57
+ }
58
+ }, {
59
+ key: "getDataUrl",
60
+ value: function getDataUrl() {
61
+ var wsUrl = getWsUrl().replace(/\/$/, '') + '/';
62
+ return this.url || "".concat(wsUrl, "joinVideo/ws").toLocaleLowerCase();
63
+ }
64
+ }, {
65
+ key: "onConnect",
66
+ value: function onConnect() {
67
+ this.ws = new WebSocket(this.getDataUrl());
68
+ this.onConstructor();
69
+ }
70
+ }, {
71
+ key: "onStatusChange",
72
+ value: function onStatusChange(status) {
73
+ this.run('connect-status', status);
74
+ this.connectStatus = status;
75
+ }
76
+ }, {
77
+ key: "on",
78
+ value: function on(name) {
79
+ var fn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function (data) {};
80
+ this.events.push({
81
+ name: name,
82
+ fn: fn
83
+ });
84
+ }
85
+ }, {
86
+ key: "run",
87
+ value: function run(name, data) {
88
+ this.events.forEach(function (items) {
89
+ if (name === items.name) {
90
+ items.fn(data);
91
+ }
92
+ });
93
+ }
94
+ }, {
95
+ key: "off",
96
+ value: function off(name) {
97
+ var _this2 = this;
98
+ this.events.forEach(function (items, index) {
99
+ if (name === items.name) {
100
+ _this2.events.splice(index, 1);
101
+ }
102
+ });
103
+ }
104
+ }, {
105
+ key: "onReConnect",
106
+ value: function onReConnect() {
107
+ this.onConnect();
108
+ }
109
+ }, {
110
+ key: "send",
111
+ value: function send() {
112
+ var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
113
+ console.log('on ws send:', data);
114
+ if (this.connectStatus === 'success') {
115
+ this.sendPost(data);
116
+ } else {
117
+ // 检查状态,缓存起来
118
+ this.postEventsNeedData.push(data);
119
+ }
120
+ }
121
+ }, {
122
+ key: "sendPost",
123
+ value: function sendPost() {
124
+ var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
125
+ this.ws.send(JSON.stringify(data));
126
+ }
127
+ }, {
128
+ key: "destroy",
129
+ value: function destroy() {
130
+ var _this$ws;
131
+ this.events = [];
132
+ this.postEventsNeedData = [];
133
+ (_this$ws = this.ws) === null || _this$ws === void 0 || _this$ws.close();
134
+ console.log("ws destroy.", this.ws);
135
+ }
136
+ }]);
137
+ return WS;
138
+ }();
139
+ export default WS;
@@ -0,0 +1,9 @@
1
+ export declare const currentEnv: Global.Env;
2
+ interface ApiUrls {
3
+ [name: string]: {
4
+ api: string;
5
+ ws: string;
6
+ };
7
+ }
8
+ declare const ApiUrls: ApiUrls;
9
+ export default ApiUrls;
@@ -0,0 +1,25 @@
1
+ // 业务服务器 api
2
+ export var currentEnv = 'prod';
3
+ var ApiUrls = {
4
+ local: {
5
+ api: 'http://localhost:9999/',
6
+ ws: 'ws://localhost:9999/'
7
+ },
8
+ dev: {
9
+ api: 'http://api.stock.net/',
10
+ ws: 'ws://localhost:9800/'
11
+ },
12
+ sit: {
13
+ api: 'http://api.stock.net/',
14
+ ws: 'ws://localhost:9999/'
15
+ },
16
+ pre: {
17
+ api: 'https://pre.api-chat.douzhuli.shop/',
18
+ ws: 'wss://pre.api-chat.douzhuli.shop/'
19
+ },
20
+ prod: {
21
+ api: 'https://api-ktv-ai.douzhuli.shop/',
22
+ ws: 'wss://api-ktv-ai.douzhuli.shop/'
23
+ }
24
+ };
25
+ export default ApiUrls;
@@ -0,0 +1,5 @@
1
+ export { default as VipCompare } from './VipCompare';
2
+ export { default as Buy } from './Buy';
3
+ export { default as Login } from './Login';
4
+ export { default as AuthClient } from './AuthClient';
5
+ export { default as Product } from './Product';
package/dist/index.js ADDED
@@ -0,0 +1,5 @@
1
+ export { default as VipCompare } from "./VipCompare";
2
+ export { default as Buy } from "./Buy";
3
+ export { default as Login } from "./Login";
4
+ export { default as AuthClient } from "./AuthClient";
5
+ export { default as Product } from "./Product";