ChooseAuth.js 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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_taro_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_taro_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 _store_user__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @/store/user */ "./src/store/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_taro_node_modules_babel_runtime_helpers_esm_asyncToGenerator_js__WEBPACK_IMPORTED_MODULE_7__["default"])( /*#__PURE__*/(0,_Users_Work_taro_node_modules_babel_runtime_helpers_esm_regeneratorRuntime_js__WEBPACK_IMPORTED_MODULE_8__["default"])().mark(function _callee() {
  41. var _yield$Taro$getUserPr, userInfo, encryptedData, iv;
  42. return (0,_Users_Work_taro_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. userInfo = _yield$Taro$getUserPr.userInfo;
  53. encryptedData = _yield$Taro$getUserPr.encryptedData;
  54. iv = _yield$Taro$getUserPr.iv;
  55. dispatch((0,_store_user__WEBPACK_IMPORTED_MODULE_5__.wxLogin)({
  56. code: code,
  57. encryptedData: encryptedData,
  58. iv: iv
  59. }));
  60. setTimeout(function () {
  61. _tarojs_taro__WEBPACK_IMPORTED_MODULE_3___default().redirectTo({
  62. url: '/pages/ChooseScenario'
  63. });
  64. }, 1000);
  65. // 在这里处理用户信息
  66. _context.next = 14;
  67. break;
  68. case 11:
  69. _context.prev = 11;
  70. _context.t0 = _context["catch"](0);
  71. console.log('获取用户信息失败:', _context.t0);
  72. case 14:
  73. case "end":
  74. return _context.stop();
  75. }
  76. }, _callee, null, [[0, 11]]);
  77. }));
  78. return _login.apply(this, arguments);
  79. }
  80. function createAccount() {
  81. _tarojs_taro__WEBPACK_IMPORTED_MODULE_3___default().navigateTo({
  82. url: '/pages/Auth'
  83. });
  84. }
  85. return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsxs)(_tarojs_components__WEBPACK_IMPORTED_MODULE_9__.View, {
  86. className: "container choose_container",
  87. children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(_components_Texts__WEBPACK_IMPORTED_MODULE_1__["default"], {
  88. text: "App name",
  89. type: _utils_types__WEBPACK_IMPORTED_MODULE_2__.TextType.big
  90. }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(_components_Texts__WEBPACK_IMPORTED_MODULE_1__["default"], {
  91. text: counter
  92. }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(_tarojs_components__WEBPACK_IMPORTED_MODULE_9__.View, {
  93. style: {
  94. height: 100
  95. }
  96. }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(_components_Buttons__WEBPACK_IMPORTED_MODULE_0__["default"], {
  97. title: "WeChat",
  98. onClick: login,
  99. style: {
  100. width: 289,
  101. marginBottom: 30
  102. }
  103. }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(_components_Buttons__WEBPACK_IMPORTED_MODULE_0__["default"], {
  104. title: "Create account",
  105. type: _utils_types__WEBPACK_IMPORTED_MODULE_2__.ButtonType.outline,
  106. onClick: createAccount,
  107. style: {
  108. width: 289,
  109. marginBottom: 30
  110. }
  111. })]
  112. });
  113. }
  114. /***/ }),
  115. /***/ "./src/pages/ChooseAuth.tsx":
  116. /*!**********************************!*\
  117. !*** ./src/pages/ChooseAuth.tsx ***!
  118. \**********************************/
  119. /***/ (function(__unused_webpack_module, __unused_webpack___webpack_exports__, __webpack_require__) {
  120. /* harmony import */ var _tarojs_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tarojs/runtime */ "webpack/container/remote/@tarojs/runtime");
  121. /* harmony import */ var _tarojs_runtime__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_tarojs_runtime__WEBPACK_IMPORTED_MODULE_0__);
  122. /* 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");
  123. var config = {};
  124. 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 || {}))
  125. /* 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"]);
  126. /***/ })
  127. },
  128. /******/ function(__webpack_require__) { // webpackRuntimeModules
  129. /******/ var __webpack_exec__ = function(moduleId) { return __webpack_require__(__webpack_require__.s = moduleId); }
  130. /******/ __webpack_require__.O(0, ["taro","vendors","common"], function() { return __webpack_exec__("./src/pages/ChooseAuth.tsx"); });
  131. /******/ var __webpack_exports__ = __webpack_require__.O();
  132. /******/ }
  133. ]);
  134. //# sourceMappingURL=ChooseAuth.js.map