ChooseAuth.js 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  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_9__ = __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_8__ = __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_10__ = __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 react__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! react */ "webpack/container/remote/react");
  22. /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_5__);
  23. /* harmony import */ var _services_user__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @/services/user */ "./src/services/user.tsx");
  24. /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! react/jsx-runtime */ "webpack/container/remote/react/jsx-runtime");
  25. /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__);
  26. function Page() {
  27. var dispatch = (0,react_redux__WEBPACK_IMPORTED_MODULE_4__.useDispatch)();
  28. var counter = (0,react_redux__WEBPACK_IMPORTED_MODULE_4__.useSelector)(function (state) {
  29. return state.counter.value;
  30. });
  31. var code = '';
  32. var user = (0,react_redux__WEBPACK_IMPORTED_MODULE_4__.useSelector)(function (state) {
  33. return state.user;
  34. });
  35. (0,react__WEBPACK_IMPORTED_MODULE_5__.useEffect)(function () {
  36. if (user.isLogin) {
  37. if (user.scenario_select_count > 0) {
  38. _tarojs_taro__WEBPACK_IMPORTED_MODULE_3___default().navigateBack({
  39. delta: 1
  40. });
  41. } else {
  42. _tarojs_taro__WEBPACK_IMPORTED_MODULE_3___default().redirectTo({
  43. url: '/pages/ChooseScenario'
  44. });
  45. }
  46. }
  47. }, [user.isLogin]);
  48. (0,_tarojs_taro__WEBPACK_IMPORTED_MODULE_3__.useReady)(function () {
  49. if (true) {
  50. _tarojs_taro__WEBPACK_IMPORTED_MODULE_3___default().login().then(function (res) {
  51. code = res.code;
  52. });
  53. }
  54. });
  55. function login() {
  56. return _login.apply(this, arguments);
  57. }
  58. function _login() {
  59. _login = (0,_Users_Work_hola2_node_modules_babel_runtime_helpers_esm_asyncToGenerator_js__WEBPACK_IMPORTED_MODULE_8__["default"])( /*#__PURE__*/(0,_Users_Work_hola2_node_modules_babel_runtime_helpers_esm_regeneratorRuntime_js__WEBPACK_IMPORTED_MODULE_9__["default"])().mark(function _callee() {
  60. var _yield$Taro$getUserPr, encryptedData, iv;
  61. return (0,_Users_Work_hola2_node_modules_babel_runtime_helpers_esm_regeneratorRuntime_js__WEBPACK_IMPORTED_MODULE_9__["default"])().wrap(function _callee$(_context) {
  62. while (1) switch (_context.prev = _context.next) {
  63. case 0:
  64. _context.prev = 0;
  65. _context.next = 3;
  66. return _tarojs_taro__WEBPACK_IMPORTED_MODULE_3___default().getUserProfile({
  67. desc: '获取用户信息'
  68. });
  69. case 3:
  70. _yield$Taro$getUserPr = _context.sent;
  71. encryptedData = _yield$Taro$getUserPr.encryptedData;
  72. iv = _yield$Taro$getUserPr.iv;
  73. dispatch((0,_services_user__WEBPACK_IMPORTED_MODULE_6__.wxLogin)(code, encryptedData, iv));
  74. // 在这里处理用户信息
  75. _context.next = 12;
  76. break;
  77. case 9:
  78. _context.prev = 9;
  79. _context.t0 = _context["catch"](0);
  80. console.log('获取用户信息失败:', _context.t0);
  81. case 12:
  82. case "end":
  83. return _context.stop();
  84. }
  85. }, _callee, null, [[0, 9]]);
  86. }));
  87. return _login.apply(this, arguments);
  88. }
  89. function createAccount() {
  90. _tarojs_taro__WEBPACK_IMPORTED_MODULE_3___default().navigateTo({
  91. url: '/pages/Auth'
  92. });
  93. }
  94. return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsxs)(_tarojs_components__WEBPACK_IMPORTED_MODULE_10__.View, {
  95. className: "container choose_container",
  96. children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)(_components_Texts__WEBPACK_IMPORTED_MODULE_1__["default"], {
  97. text: "App name",
  98. type: _utils_types__WEBPACK_IMPORTED_MODULE_2__.TextType.big
  99. }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)(_components_Texts__WEBPACK_IMPORTED_MODULE_1__["default"], {
  100. text: counter
  101. }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)(_tarojs_components__WEBPACK_IMPORTED_MODULE_10__.View, {
  102. style: {
  103. height: 100
  104. }
  105. }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)(_components_Buttons__WEBPACK_IMPORTED_MODULE_0__["default"], {
  106. title: "WeChat",
  107. onClick: login,
  108. style: {
  109. width: 289,
  110. marginBottom: 30
  111. }
  112. }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)(_components_Buttons__WEBPACK_IMPORTED_MODULE_0__["default"], {
  113. title: "Create account",
  114. type: _utils_types__WEBPACK_IMPORTED_MODULE_2__.ButtonType.outline,
  115. onClick: createAccount,
  116. style: {
  117. width: 289,
  118. marginBottom: 30
  119. }
  120. })]
  121. });
  122. }
  123. /***/ }),
  124. /***/ "./src/pages/ChooseAuth.tsx":
  125. /*!**********************************!*\
  126. !*** ./src/pages/ChooseAuth.tsx ***!
  127. \**********************************/
  128. /***/ (function(__unused_webpack_module, __unused_webpack___webpack_exports__, __webpack_require__) {
  129. /* harmony import */ var _tarojs_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tarojs/runtime */ "webpack/container/remote/@tarojs/runtime");
  130. /* harmony import */ var _tarojs_runtime__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_tarojs_runtime__WEBPACK_IMPORTED_MODULE_0__);
  131. /* 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");
  132. var config = {};
  133. 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 || {}))
  134. /* 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"]);
  135. /***/ })
  136. },
  137. /******/ function(__webpack_require__) { // webpackRuntimeModules
  138. /******/ var __webpack_exec__ = function(moduleId) { return __webpack_require__(__webpack_require__.s = moduleId); }
  139. /******/ __webpack_require__.O(0, ["taro","vendors","common"], function() { return __webpack_exec__("./src/pages/ChooseAuth.tsx"); });
  140. /******/ var __webpack_exports__ = __webpack_require__.O();
  141. /******/ }
  142. ]);
  143. //# sourceMappingURL=ChooseAuth.js.map