ChooseAuth.js 8.6 KB

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