component-shipinlv 0.1.8 → 0.1.10

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.
@@ -0,0 +1,2 @@
1
+ declare const h5WePublicLogin: () => Promise<void>;
2
+ export default h5WePublicLogin;
@@ -0,0 +1,42 @@
1
+ import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
2
+ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
3
+ // h5 页面 登录公众号
4
+ import * as WechatController from "../../service/api/WechatController";
5
+ import Tool from "../../lib/Tool";
6
+ var h5WePublicLogin = /*#__PURE__*/function () {
7
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
8
+ var domainUrl, redirectUrl, inviteUserId, loginResult;
9
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
10
+ while (1) switch (_context.prev = _context.next) {
11
+ case 0:
12
+ // 首先获取 登录跳转地址;
13
+ domainUrl = 'https://auth.shanren.wang';
14
+ redirectUrl = "".concat(domainUrl, "/h5-wechat-login-callback?");
15
+ inviteUserId = Tool.getInviteUserId();
16
+ _context.next = 5;
17
+ return WechatController.h5WePublicLogin({
18
+ redirectUrl: redirectUrl,
19
+ inviteUserId: inviteUserId
20
+ }).catch(function () {});
21
+ case 5:
22
+ loginResult = _context.sent;
23
+ if (loginResult) {
24
+ _context.next = 8;
25
+ break;
26
+ }
27
+ return _context.abrupt("return");
28
+ case 8:
29
+ // 因为 微信 会校验跳转域名,所以 用制定 中转;
30
+
31
+ document.location.href = loginResult.redirectUrl;
32
+ case 9:
33
+ case "end":
34
+ return _context.stop();
35
+ }
36
+ }, _callee);
37
+ }));
38
+ return function h5WePublicLogin() {
39
+ return _ref.apply(this, arguments);
40
+ };
41
+ }();
42
+ export default h5WePublicLogin;
@@ -19,6 +19,7 @@ var reTryTimeLoop = 1000; // ms
19
19
  var FromWhere = 'web';
20
20
  import QRCode from 'qrcode.react';
21
21
  import isInClient from "../../lib/isInClient";
22
+ import h5WePublicLogin from "./h5-we-public-login";
22
23
  import { jsx as _jsx } from "react/jsx-runtime";
23
24
  import { Fragment as _Fragment } from "react/jsx-runtime";
24
25
  import { jsxs as _jsxs } from "react/jsx-runtime";
@@ -144,7 +145,7 @@ var LoginQr = function LoginQr(_ref) {
144
145
  env: getApiEnv()
145
146
  });
146
147
  }, {
147
- manual: !isInClient() || defaultLoginType !== 'wechat',
148
+ manual: Platform.isWechat || !isInClient() || defaultLoginType !== 'wechat',
148
149
  onSuccess: function onSuccess(result) {
149
150
  setWeQrUrl(result.url);
150
151
  onRunCheck();
@@ -216,6 +217,25 @@ var LoginQr = function LoginQr(_ref) {
216
217
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
217
218
  while (1) switch (_context3.prev = _context3.next) {
218
219
  case 0:
220
+ if (!Platform.isWechat) {
221
+ _context3.next = 7;
222
+ break;
223
+ }
224
+ setLoading(true);
225
+ // jump
226
+ _context3.next = 4;
227
+ return h5WePublicLogin();
228
+ case 4:
229
+ setLoading(false);
230
+ _context3.next = 9;
231
+ break;
232
+ case 7:
233
+ _context3.next = 9;
234
+ return runWeLoginQr();
235
+ case 9:
236
+ _context3.next = 11;
237
+ return runWeLoginQr();
238
+ case 11:
219
239
  case "end":
220
240
  return _context3.stop();
221
241
  }
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ declare const _default: {
3
+ div: 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
+ div: styled.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n :global{\n .clientStatus{\n .loading{\n opacity: 0.7;\n }\n\n .downloading{\n margin-left: 12px;\n }\n\n .working{\n color: green;\n }\n }\n "])))
6
+ };
@@ -1,5 +1,4 @@
1
1
  import React from 'react';
2
- import './index.less';
3
2
  interface Props {
4
3
  productType: string;
5
4
  port?: number;
@@ -4,10 +4,10 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
4
4
  import React, { useEffect, useRef, useState } from 'react';
5
5
  import * as SubClientController from "../service/api/SubClientController";
6
6
  import { useRequest } from '@umijs/hooks';
7
- import "./index.less";
8
7
  import { CheckCircleFilled, ExclamationCircleFilled, LoadingOutlined, QuestionCircleOutlined, RedoOutlined } from "@ant-design/icons";
9
8
  import { Button, Divider, Tooltip } from "antd";
10
9
  import Tool from "../lib/Tool";
10
+ import styles from "./index.css";
11
11
  import { jsx as _jsx } from "react/jsx-runtime";
12
12
  import { Fragment as _Fragment } from "react/jsx-runtime";
13
13
  import { jsxs as _jsxs } from "react/jsx-runtime";
@@ -197,14 +197,16 @@ var JoinClient = function JoinClient(_ref) {
197
197
  useEffect(function () {
198
198
  onRunStatus(runStatus);
199
199
  }, [runStatus]);
200
- return /*#__PURE__*/_jsxs("div", {
201
- className: "clientStatus",
202
- children: [$status(), /*#__PURE__*/_jsx(Divider, {
203
- type: "vertical"
204
- }), /*#__PURE__*/_jsxs(Tooltip, {
205
- title: "\u672C\u9875\u9762\u529F\u80FD\u9700\u8981\u4F60\u7684\u7535\u8111\u4E0A\u5B89\u88C5\u4E13\u7528\u5BA2\u6237\u7AEF\u8F6F\u4EF6",
206
- children: [" ", /*#__PURE__*/_jsx(QuestionCircleOutlined, {})]
207
- })]
200
+ return /*#__PURE__*/_jsx(styles.div, {
201
+ children: /*#__PURE__*/_jsxs("div", {
202
+ className: "clientStatus",
203
+ children: [$status(), /*#__PURE__*/_jsx(Divider, {
204
+ type: "vertical"
205
+ }), /*#__PURE__*/_jsxs(Tooltip, {
206
+ title: "\u672C\u9875\u9762\u529F\u80FD\u9700\u8981\u4F60\u7684\u7535\u8111\u4E0A\u5B89\u88C5\u4E13\u7528\u5BA2\u6237\u7AEF\u8F6F\u4EF6",
207
+ children: [" ", /*#__PURE__*/_jsx(QuestionCircleOutlined, {})]
208
+ })]
209
+ })
208
210
  });
209
211
  };
210
212
  export default JoinClient;
@@ -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: "info" | "error" | "success" | "warning", message: string, description?: import("react").ReactNode, options?: NotificationOptions): void;
166
+ notification(type: "success" | "info" | "warning" | "error", 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,8 @@
1
+ export declare function share(body: {
2
+ url: string;
3
+ dealerId: number;
4
+ }, options?: ServicesApi.RequestOptions): Promise<Wechat.Share>;
5
+ export declare function h5WePublicLogin(body: {
6
+ redirectUrl: string;
7
+ inviteUserId: number;
8
+ }, options?: ServicesApi.RequestOptions): Promise<Wechat.H5WePublicLogin>;
@@ -0,0 +1,50 @@
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 share(_x, _x2) {
6
+ return _share.apply(this, arguments);
7
+ }
8
+ function _share() {
9
+ _share = _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("wechat/jsConfigByWechatAppId", _objectSpread({
14
+ method: 'POST',
15
+ headers: {
16
+ 'Content-Type': 'application/json'
17
+ },
18
+ data: body
19
+ }, options || {})));
20
+ case 1:
21
+ case "end":
22
+ return _context.stop();
23
+ }
24
+ }, _callee);
25
+ }));
26
+ return _share.apply(this, arguments);
27
+ }
28
+ export function h5WePublicLogin(_x3, _x4) {
29
+ return _h5WePublicLogin.apply(this, arguments);
30
+ }
31
+ function _h5WePublicLogin() {
32
+ _h5WePublicLogin = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(body, options) {
33
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
34
+ while (1) switch (_context2.prev = _context2.next) {
35
+ case 0:
36
+ return _context2.abrupt("return", request("wechat/h5WePublicLogin", _objectSpread({
37
+ method: 'POST',
38
+ headers: {
39
+ 'Content-Type': 'application/json'
40
+ },
41
+ data: body
42
+ }, options || {})));
43
+ case 1:
44
+ case "end":
45
+ return _context2.stop();
46
+ }
47
+ }, _callee2);
48
+ }));
49
+ return _h5WePublicLogin.apply(this, arguments);
50
+ }
@@ -0,0 +1,19 @@
1
+ declare namespace Wechat {
2
+ interface Share {
3
+ appId: string;
4
+ timestamp: string;
5
+ nonceStr: string;
6
+ signature: string;
7
+ }
8
+ interface H5WePublicLogin {
9
+ redirectUrl: string;
10
+ }
11
+ interface WeJsConfig {
12
+ debug: boolean;
13
+ jsApiList: string[];
14
+ appId: string;
15
+ nonceStr: string;
16
+ signature: string;
17
+ timestamp: number;
18
+ }
19
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "component-shipinlv",
3
- "version": "0.1.8",
3
+ "version": "0.1.10",
4
4
  "description": "",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,15 +0,0 @@
1
- .clientStatus{
2
-
3
- .loading{
4
- opacity: 0.7;
5
- }
6
-
7
- .downloading{
8
- margin-left: 12px;
9
- }
10
-
11
- .working{
12
- color: green;
13
- }
14
-
15
- }
File without changes