ChooseAuth.js 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. "use strict";
  2. (wx["webpackJsonp"] = wx["webpackJsonp"] || []).push([["pages/ChooseAuth"],{
  3. /***/ "./node_modules/babel-loader/lib/index.js??ruleSet[1].rules[5].use[0]!./src/pages/ChooseAuth.tsx":
  4. /*!*******************************************************************************************************!*\
  5. !*** ./node_modules/babel-loader/lib/index.js??ruleSet[1].rules[5].use[0]!./src/pages/ChooseAuth.tsx ***!
  6. \*******************************************************************************************************/
  7. /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
  8. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  9. /* harmony export */ "default": function() { return /* binding */ Page; }
  10. /* harmony export */ });
  11. /* harmony import */ var _Users_Work_hola2_node_modules_babel_runtime_helpers_esm_regeneratorRuntime_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./node_modules/@babel/runtime/helpers/esm/regeneratorRuntime.js */ "./node_modules/@babel/runtime/helpers/esm/regeneratorRuntime.js");
  12. /* harmony import */ var _Users_Work_hola2_node_modules_babel_runtime_helpers_esm_asyncToGenerator_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js */ "./node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js");
  13. /* harmony import */ var _tarojs_components__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! @tarojs/components */ "./node_modules/@tarojs/plugin-platform-weapp/dist/components-react.js");
  14. /* harmony import */ var _components_Buttons__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @components/Buttons */ "./src/components/Buttons.tsx");
  15. /* harmony import */ var _components_Texts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @components/Texts */ "./src/components/Texts.tsx");
  16. /* harmony import */ var _utils_types__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../utils/types */ "./src/utils/types.ts");
  17. /* harmony import */ var _tarojs_taro__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @tarojs/taro */ "webpack/container/remote/@tarojs/taro");
  18. /* harmony import */ var _tarojs_taro__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_tarojs_taro__WEBPACK_IMPORTED_MODULE_3__);
  19. /* harmony import */ var react_redux__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! react-redux */ "webpack/container/remote/react-redux");
  20. /* harmony import */ var react_redux__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(react_redux__WEBPACK_IMPORTED_MODULE_4__);
  21. /* harmony import */ var _services_user__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @/services/user */ "./src/services/user.tsx");
  22. /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! react/jsx-runtime */ "webpack/container/remote/react/jsx-runtime");
  23. /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__);
  24. function Page() {
  25. var dispatch = (0,react_redux__WEBPACK_IMPORTED_MODULE_4__.useDispatch)();
  26. var counter = (0,react_redux__WEBPACK_IMPORTED_MODULE_4__.useSelector)(function (state) {
  27. return state.counter.value;
  28. });
  29. var code = '';
  30. (0,_tarojs_taro__WEBPACK_IMPORTED_MODULE_3__.useReady)(function () {
  31. _tarojs_taro__WEBPACK_IMPORTED_MODULE_3___default().login().then(function (res) {
  32. code = res.code;
  33. // dispatch(wxLogin({code:res.code}) as any);
  34. });
  35. });
  36. function login() {
  37. return _login.apply(this, arguments);
  38. }
  39. function _login() {
  40. _login = (0,_Users_Work_hola2_node_modules_babel_runtime_helpers_esm_asyncToGenerator_js__WEBPACK_IMPORTED_MODULE_7__["default"])( /*#__PURE__*/(0,_Users_Work_hola2_node_modules_babel_runtime_helpers_esm_regeneratorRuntime_js__WEBPACK_IMPORTED_MODULE_8__["default"])().mark(function _callee() {
  41. var _yield$Taro$getUserPr, encryptedData, iv;
  42. return (0,_Users_Work_hola2_node_modules_babel_runtime_helpers_esm_regeneratorRuntime_js__WEBPACK_IMPORTED_MODULE_8__["default"])().wrap(function _callee$(_context) {
  43. while (1) switch (_context.prev = _context.next) {
  44. case 0:
  45. _context.prev = 0;
  46. _context.next = 3;
  47. return _tarojs_taro__WEBPACK_IMPORTED_MODULE_3___default().getUserProfile({
  48. desc: '获取用户信息'
  49. });
  50. case 3:
  51. _yield$Taro$getUserPr = _context.sent;
  52. encryptedData = _yield$Taro$getUserPr.encryptedData;
  53. iv = _yield$Taro$getUserPr.iv;
  54. dispatch((0,_services_user__WEBPACK_IMPORTED_MODULE_5__.wxLogin)(code, encryptedData, iv));
  55. setTimeout(function () {
  56. _tarojs_taro__WEBPACK_IMPORTED_MODULE_3___default().redirectTo({
  57. url: '/pages/ChooseScenario'
  58. });
  59. }, 1000);
  60. // 在这里处理用户信息
  61. _context.next = 13;
  62. break;
  63. case 10:
  64. _context.prev = 10;
  65. _context.t0 = _context["catch"](0);
  66. console.log('获取用户信息失败:', _context.t0);
  67. case 13:
  68. case "end":
  69. return _context.stop();
  70. }
  71. }, _callee, null, [[0, 10]]);
  72. }));
  73. return _login.apply(this, arguments);
  74. }
  75. function createAccount() {
  76. _tarojs_taro__WEBPACK_IMPORTED_MODULE_3___default().navigateTo({
  77. url: '/pages/Auth'
  78. });
  79. }
  80. return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsxs)(_tarojs_components__WEBPACK_IMPORTED_MODULE_9__.View, {
  81. className: "container choose_container",
  82. children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(_components_Texts__WEBPACK_IMPORTED_MODULE_1__["default"], {
  83. text: "App name",
  84. type: _utils_types__WEBPACK_IMPORTED_MODULE_2__.TextType.big
  85. }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(_components_Texts__WEBPACK_IMPORTED_MODULE_1__["default"], {
  86. text: counter
  87. }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(_tarojs_components__WEBPACK_IMPORTED_MODULE_9__.View, {
  88. style: {
  89. height: 100
  90. }
  91. }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(_components_Buttons__WEBPACK_IMPORTED_MODULE_0__["default"], {
  92. title: "WeChat",
  93. onClick: login,
  94. style: {
  95. width: 289,
  96. marginBottom: 30
  97. }
  98. }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(_components_Buttons__WEBPACK_IMPORTED_MODULE_0__["default"], {
  99. title: "Create account",
  100. type: _utils_types__WEBPACK_IMPORTED_MODULE_2__.ButtonType.outline,
  101. onClick: createAccount,
  102. style: {
  103. width: 289,
  104. marginBottom: 30
  105. }
  106. })]
  107. });
  108. }
  109. /***/ }),
  110. /***/ "./src/pages/ChooseAuth.tsx":
  111. /*!**********************************!*\
  112. !*** ./src/pages/ChooseAuth.tsx ***!
  113. \**********************************/
  114. /***/ (function(__unused_webpack_module, __unused_webpack___webpack_exports__, __webpack_require__) {
  115. /* harmony import */ var _tarojs_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tarojs/runtime */ "webpack/container/remote/@tarojs/runtime");
  116. /* harmony import */ var _tarojs_runtime__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_tarojs_runtime__WEBPACK_IMPORTED_MODULE_0__);
  117. /* harmony import */ var _node_modules_babel_loader_lib_index_js_ruleSet_1_rules_5_use_0_ChooseAuth_tsx__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../node_modules/babel-loader/lib/index.js??ruleSet[1].rules[5].use[0]!./ChooseAuth.tsx */ "./node_modules/babel-loader/lib/index.js??ruleSet[1].rules[5].use[0]!./src/pages/ChooseAuth.tsx");
  118. var config = {};
  119. var inst = Page((0,_tarojs_runtime__WEBPACK_IMPORTED_MODULE_0__.createPageConfig)(_node_modules_babel_loader_lib_index_js_ruleSet_1_rules_5_use_0_ChooseAuth_tsx__WEBPACK_IMPORTED_MODULE_1__["default"], 'pages/ChooseAuth', {root:{cn:[]}}, config || {}))
  120. /* unused harmony default export */ var __WEBPACK_DEFAULT_EXPORT__ = (_node_modules_babel_loader_lib_index_js_ruleSet_1_rules_5_use_0_ChooseAuth_tsx__WEBPACK_IMPORTED_MODULE_1__["default"]);
  121. /***/ })
  122. },
  123. /******/ function(__webpack_require__) { // webpackRuntimeModules
  124. /******/ var __webpack_exec__ = function(moduleId) { return __webpack_require__(__webpack_require__.s = moduleId); }
  125. /******/ __webpack_require__.O(0, ["taro","vendors","common"], function() { return __webpack_exec__("./src/pages/ChooseAuth.tsx"); });
  126. /******/ var __webpack_exports__ = __webpack_require__.O();
  127. /******/ }
  128. ]);
  129. //# sourceMappingURL=ChooseAuth.js.map