Leon há 2 anos atrás
pai
commit
58da1af3ff

+ 6 - 3
dist/common.js

@@ -498,9 +498,10 @@ function _request() {
 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
 /* harmony export */   clear: function() { return /* binding */ clear; },
 /* harmony export */   logout: function() { return /* binding */ logout; },
+/* harmony export */   register: function() { return /* binding */ register; },
 /* harmony export */   wxLogin: function() { return /* binding */ wxLogin; }
 /* harmony export */ });
-/* unused harmony exports loginSuccess, registerSuccess, logoutSuccess, getInfoSuccess, updateSuccess, clearSuccess, login, register, getInfo, update */
+/* unused harmony exports loginSuccess, registerSuccess, logoutSuccess, getInfoSuccess, updateSuccess, clearSuccess, login, getInfo, update */
 /* harmony import */ var _Users_Work_hola2_node_modules_babel_runtime_helpers_esm_regeneratorRuntime_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./node_modules/@babel/runtime/helpers/esm/regeneratorRuntime.js */ "./node_modules/@babel/runtime/helpers/esm/regeneratorRuntime.js");
 /* harmony import */ var _Users_Work_hola2_node_modules_babel_runtime_helpers_esm_asyncToGenerator_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js */ "./node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js");
 /* harmony import */ var _reduxjs_toolkit__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @reduxjs/toolkit */ "webpack/container/remote/@reduxjs/toolkit");
@@ -693,13 +694,15 @@ export const wxLogin = (code: string) => (dispatch: any) => {
     })
 }*/
 
-var register = function register(username, password) {
+var register = function register(name, email, password) {
   return function (dispatch) {
     (0,_services_http_request__WEBPACK_IMPORTED_MODULE_1__.request)({
       url: _services_http_api__WEBPACK_IMPORTED_MODULE_2__.API_REGISTER,
       method: 'POST',
       data: {
-        username: username,
+        client_type: 'IOS',
+        username: name,
+        email: email,
         password: password
       }
     }).then(function (res) {

Diff do ficheiro suprimidas por serem muito extensas
+ 0 - 0
dist/common.js.map


+ 87 - 26
dist/pages/Auth.js

@@ -78,15 +78,31 @@ function Component(props) {
 
 
 
-function Component(props) {
-  var _useState = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(false),
+function Component(_ref) {
+  var placeholder = _ref.placeholder,
+    value = _ref.value,
+    onChange = _ref.onChange,
+    disabled = _ref.disabled;
+  var _useState = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(value ? value : ''),
     _useState2 = (0,_Users_Work_hola2_node_modules_babel_runtime_helpers_esm_slicedToArray_js__WEBPACK_IMPORTED_MODULE_2__["default"])(_useState, 2),
-    isFocus = _useState2[0],
-    setIsFocus = _useState2[1];
+    inputValue = _useState2[0],
+    setInputValue = _useState2[1];
+  var _useState3 = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(false),
+    _useState4 = (0,_Users_Work_hola2_node_modules_babel_runtime_helpers_esm_slicedToArray_js__WEBPACK_IMPORTED_MODULE_2__["default"])(_useState3, 2),
+    isFocus = _useState4[0],
+    setIsFocus = _useState4[1];
+  var handleInputChange = function handleInputChange(e) {
+    var newValue = e.target.value;
+    setInputValue(newValue);
+    onChange(newValue);
+  };
   return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(_tarojs_components__WEBPACK_IMPORTED_MODULE_3__.View, {
     children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(_tarojs_components__WEBPACK_IMPORTED_MODULE_3__.Input, {
       className: isFocus ? "input input_focus" : "input",
-      placeholder: props.placeholder,
+      placeholder: placeholder ? placeholder : '',
+      value: inputValue,
+      onInput: handleInputChange,
+      disabled: disabled ? disabled : false,
       onFocus: function onFocus() {
         setIsFocus(true);
       },
@@ -108,7 +124,8 @@ function Component(props) {
 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
 /* harmony export */   "default": function() { return /* binding */ Auth; }
 /* harmony export */ });
-/* harmony import */ var _tarojs_components__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @tarojs/components */ "./node_modules/@tarojs/plugin-platform-weapp/dist/components-react.js");
+/* harmony import */ var _Users_Work_hola2_node_modules_babel_runtime_helpers_esm_slicedToArray_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./node_modules/@babel/runtime/helpers/esm/slicedToArray.js */ "./node_modules/@babel/runtime/helpers/esm/slicedToArray.js");
+/* harmony import */ var _tarojs_components__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! @tarojs/components */ "./node_modules/@tarojs/plugin-platform-weapp/dist/components-react.js");
 /* harmony import */ var _components_Texts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @components/Texts */ "./src/components/Texts.tsx");
 /* harmony import */ var _utils_types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @utils/types */ "./src/utils/types.ts");
 /* harmony import */ var _components_Box__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @components/Box */ "./src/components/Box.tsx");
@@ -117,8 +134,20 @@ function Component(props) {
 /* harmony import */ var _assets_svg_check_svg__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @assets/svg/check.svg */ "./src/assets/svg/check.svg");
 /* harmony import */ var react_i18next__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! react-i18next */ "webpack/container/remote/react-i18next");
 /* harmony import */ var react_i18next__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(react_i18next__WEBPACK_IMPORTED_MODULE_6__);
-/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! react/jsx-runtime */ "webpack/container/remote/react/jsx-runtime");
-/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__);
+/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! react */ "webpack/container/remote/react");
+/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_7__);
+/* harmony import */ var react_redux__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! react-redux */ "webpack/container/remote/react-redux");
+/* harmony import */ var react_redux__WEBPACK_IMPORTED_MODULE_8___default = /*#__PURE__*/__webpack_require__.n(react_redux__WEBPACK_IMPORTED_MODULE_8__);
+/* harmony import */ var _store_user__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! @/store/user */ "./src/store/user.tsx");
+/* harmony import */ var _tarojs_taro__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! @tarojs/taro */ "webpack/container/remote/@tarojs/taro");
+/* harmony import */ var _tarojs_taro__WEBPACK_IMPORTED_MODULE_10___default = /*#__PURE__*/__webpack_require__.n(_tarojs_taro__WEBPACK_IMPORTED_MODULE_10__);
+/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! react/jsx-runtime */ "webpack/container/remote/react/jsx-runtime");
+/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_11___default = /*#__PURE__*/__webpack_require__.n(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_11__);
+
+
+
+
+
 
 
 
@@ -133,21 +162,52 @@ function Component(props) {
 function Auth() {
   var _useTranslation = (0,react_i18next__WEBPACK_IMPORTED_MODULE_6__.useTranslation)(),
     t = _useTranslation.t;
+  var dispatch = (0,react_redux__WEBPACK_IMPORTED_MODULE_8__.useDispatch)();
+  var _useState = (0,react__WEBPACK_IMPORTED_MODULE_7__.useState)(''),
+    _useState2 = (0,_Users_Work_hola2_node_modules_babel_runtime_helpers_esm_slicedToArray_js__WEBPACK_IMPORTED_MODULE_12__["default"])(_useState, 2),
+    name = _useState2[0],
+    setName = _useState2[1];
+  var _useState3 = (0,react__WEBPACK_IMPORTED_MODULE_7__.useState)(''),
+    _useState4 = (0,_Users_Work_hola2_node_modules_babel_runtime_helpers_esm_slicedToArray_js__WEBPACK_IMPORTED_MODULE_12__["default"])(_useState3, 2),
+    email = _useState4[0],
+    setEmail = _useState4[1];
+  var handleNameChange = function handleNameChange(value) {
+    setName(value);
+  };
+  var handleEmailChange = function handleEmailChange(value) {
+    setEmail(value);
+  };
+  var isButtonDisabled = name === '' || email === '';
   function loginComponent() {
-    return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsxs)(_tarojs_components__WEBPACK_IMPORTED_MODULE_8__.View, {
-      children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)(_components_Inputs__WEBPACK_IMPORTED_MODULE_3__["default"], {
+    return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_11__.jsxs)(_tarojs_components__WEBPACK_IMPORTED_MODULE_13__.View, {
+      children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_11__.jsx)(_components_Inputs__WEBPACK_IMPORTED_MODULE_3__["default"], {
+        value: name,
+        onChange: handleNameChange,
         placeholder: t('feature.auth.create_account.input_username_placeholder')
-      }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)(_tarojs_components__WEBPACK_IMPORTED_MODULE_8__.View, {
+      }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_11__.jsx)(_tarojs_components__WEBPACK_IMPORTED_MODULE_13__.View, {
         style: {
           height: 20
         }
-      }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)(_components_Inputs__WEBPACK_IMPORTED_MODULE_3__["default"], {
+      }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_11__.jsx)(_components_Inputs__WEBPACK_IMPORTED_MODULE_3__["default"], {
+        value: email,
+        onChange: handleEmailChange,
         placeholder: t('feature.auth.create_account.input_email_placeholder')
       })]
     });
   }
-  function register() {}
-  return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsxs)(_tarojs_components__WEBPACK_IMPORTED_MODULE_8__.View, {
+  function registerF() {
+    if (isButtonDisabled) {
+      return;
+    }
+    dispatch((0,_store_user__WEBPACK_IMPORTED_MODULE_9__.register)(name, email, '123456'));
+    setTimeout(function () {
+      _tarojs_taro__WEBPACK_IMPORTED_MODULE_10___default().navigateBack();
+      _tarojs_taro__WEBPACK_IMPORTED_MODULE_10___default().redirectTo({
+        url: '/pages/ChooseScenario'
+      });
+    }, 1000);
+  }
+  return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_11__.jsxs)(_tarojs_components__WEBPACK_IMPORTED_MODULE_13__.View, {
     style: {
       backgroundColor: '#000',
       flex: 1,
@@ -155,15 +215,16 @@ function Auth() {
       display: 'flex',
       height: '100vh'
     },
-    children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)(_components_Texts__WEBPACK_IMPORTED_MODULE_0__["default"], {
+    children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_11__.jsx)(_components_Texts__WEBPACK_IMPORTED_MODULE_0__["default"], {
       text: t('feature.auth.create_account.title'),
       type: _utils_types__WEBPACK_IMPORTED_MODULE_1__.TextType.primary
-    }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)(_components_Texts__WEBPACK_IMPORTED_MODULE_0__["default"], {
+    }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_11__.jsx)(_components_Texts__WEBPACK_IMPORTED_MODULE_0__["default"], {
       text: t('feature.auth.create_account.sub_title'),
       type: _utils_types__WEBPACK_IMPORTED_MODULE_1__.TextType.secondary
-    }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)(_components_Box__WEBPACK_IMPORTED_MODULE_2__["default"], {
+    }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_11__.jsx)(_components_Box__WEBPACK_IMPORTED_MODULE_2__["default"], {
       child: loginComponent()
-    }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)(_components_Buttons__WEBPACK_IMPORTED_MODULE_4__["default"], {
+    }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_11__.jsx)(_components_Buttons__WEBPACK_IMPORTED_MODULE_4__["default"], {
+      onClick: registerF,
       title: t('feature.auth.create_account.btn_next'),
       style: {
         marginLeft: 23,
@@ -171,26 +232,26 @@ function Auth() {
         marginTop: 20,
         marginBottom: 20
       },
-      status: _utils_types__WEBPACK_IMPORTED_MODULE_1__.ComponentStatus.disable
-    }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsxs)(_tarojs_components__WEBPACK_IMPORTED_MODULE_8__.View, {
+      status: isButtonDisabled ? _utils_types__WEBPACK_IMPORTED_MODULE_1__.ComponentStatus.disable : _utils_types__WEBPACK_IMPORTED_MODULE_1__.ComponentStatus.enable
+    }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_11__.jsxs)(_tarojs_components__WEBPACK_IMPORTED_MODULE_13__.View, {
       className: "agree_view",
-      children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)(_tarojs_components__WEBPACK_IMPORTED_MODULE_8__.Image, {
+      children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_11__.jsx)(_tarojs_components__WEBPACK_IMPORTED_MODULE_13__.Image, {
         style: "width:12px;height:12px;",
         src: _assets_svg_check_svg__WEBPACK_IMPORTED_MODULE_5__
-      }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)(_tarojs_components__WEBPACK_IMPORTED_MODULE_8__.Text, {
+      }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_11__.jsx)(_tarojs_components__WEBPACK_IMPORTED_MODULE_13__.Text, {
         className: "agree_text",
         children: t('page.auth.agreement')
       })]
-    }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)(_tarojs_components__WEBPACK_IMPORTED_MODULE_8__.View, {
+    }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_11__.jsx)(_tarojs_components__WEBPACK_IMPORTED_MODULE_13__.View, {
       style: {
         flex: 1
       }
-    }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsxs)(_tarojs_components__WEBPACK_IMPORTED_MODULE_8__.View, {
+    }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_11__.jsxs)(_tarojs_components__WEBPACK_IMPORTED_MODULE_13__.View, {
       className: "footer",
-      children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)(_tarojs_components__WEBPACK_IMPORTED_MODULE_8__.Text, {
+      children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_11__.jsx)(_tarojs_components__WEBPACK_IMPORTED_MODULE_13__.Text, {
         className: "have_account",
         children: t('feature.auth.create_account.footer_desc')
-      }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)(_tarojs_components__WEBPACK_IMPORTED_MODULE_8__.Text, {
+      }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_11__.jsx)(_tarojs_components__WEBPACK_IMPORTED_MODULE_13__.Text, {
         className: "login",
         children: t('feature.auth.create_account.footer_login')
       })]

Diff do ficheiro suprimidas por serem muito extensas
+ 0 - 0
dist/pages/Auth.js.map


+ 31 - 9
src/components/Inputs.tsx

@@ -2,17 +2,39 @@ import { Input, View } from "@tarojs/components";
 import './Inputs.scss'
 import { useState } from "react";
 
-export default function Component(props:{placeholder:string}){
-    const [isFocus,setIsFocus] = useState(false)
+interface CustomInputProps {
+    placeholder?: string;
+    value: string;
+    onChange: (value: string) => void;
+    disabled?: boolean;
+}
+
+export default function Component({
+    placeholder,
+    value,
+    onChange,
+    disabled
+}: CustomInputProps) {
+    const [inputValue, setInputValue] = useState(value ? value : '');
+    const [isFocus, setIsFocus] = useState(false)
+    const handleInputChange = (e: any) => {
+        const newValue = e.target.value;
+        setInputValue(newValue);
+        onChange(newValue);
+    };
     return (
         <View>
-            <Input className={isFocus?"input input_focus":"input"} placeholder={props.placeholder}
-            onFocus={()=>{
-                setIsFocus(true)
-            }}
-            onBlur={()=>{
-                setIsFocus(false)
-            }}
+            <Input className={isFocus ? "input input_focus" : "input"}
+                placeholder={placeholder ? placeholder : ''}
+                value={inputValue}
+                onInput={handleInputChange}
+                disabled={disabled?disabled:false}
+                onFocus={() => {
+                    setIsFocus(true)
+                }}
+                onBlur={() => {
+                    setIsFocus(false)
+                }}
             />
         </View>
     )

+ 39 - 5
src/features/auth/components/Auth.tsx

@@ -7,28 +7,62 @@ import Buttons from '@components/Buttons'
 import check from '@assets/svg/check.svg'
 import { useTranslation } from 'react-i18next'
 import './Auth.scss'
+import { useState } from "react";
+import { useDispatch, useSelector } from "react-redux";
+import { register } from "@/store/user";
+import Taro from "@tarojs/taro";
 
 export default function Auth() {
     const { t } = useTranslation()
+    const dispatch = useDispatch();
+
+    const [name, setName] = useState('');
+    const [email, setEmail] = useState('');
+
+    const handleNameChange = (value: string) => {
+        setName(value);
+    };
+    const handleEmailChange = (value: string) => {
+        setEmail(value);
+    };
+
+    const isButtonDisabled = name === '' || email === '';
+
     function loginComponent() {
         return <View>
-            <Inputs placeholder={t('feature.auth.create_account.input_username_placeholder')}></Inputs>
+            <Inputs value={name} onChange={handleNameChange} placeholder={t('feature.auth.create_account.input_username_placeholder')}></Inputs>
             <View style={{ height: 20 }} />
-            <Inputs placeholder={t('feature.auth.create_account.input_email_placeholder')}></Inputs>
+            <Inputs value={email} onChange={handleEmailChange} placeholder={t('feature.auth.create_account.input_email_placeholder')}></Inputs>
         </View>
     }
 
-    function register() {
+    function registerF() {
+        if (isButtonDisabled) {
+            return;
+        }
+        dispatch(register(
+            name,
+            email,
+            '123456'
+        ) as any);
 
+        setTimeout(() => {
+            Taro.navigateBack()
+            Taro.redirectTo({
+                url: '/pages/ChooseScenario'
+            })
+        },1000)
     }
 
     return <View style={{ backgroundColor: '#000', flex: 1, flexDirection: 'column', display: 'flex', height: '100vh' }}>
         <Texts text={t('feature.auth.create_account.title')} type={TextType.primary}></Texts>
         <Texts text={t('feature.auth.create_account.sub_title')} type={TextType.secondary}></Texts>
         <Box child={loginComponent()}></Box>
-        <Buttons title={t('feature.auth.create_account.btn_next')}
+        <Buttons
+            onClick={registerF}
+            title={t('feature.auth.create_account.btn_next')}
             style={{ marginLeft: 23, marginRight: 23, marginTop: 20, marginBottom: 20 }}
-            status={ComponentStatus.disable}></Buttons>
+            status={isButtonDisabled ? ComponentStatus.disable : ComponentStatus.enable}></Buttons>
         <View className="agree_view">
             <Image style='width:12px;height:12px;' src={check} />
             <Text className='agree_text'>{t('page.auth.agreement')}</Text>

+ 2 - 2
src/store/user.tsx

@@ -127,9 +127,9 @@ export const wxLogin = (code: string) => (dispatch: any) => {
     })
 }*/
 
-export const register = (username: string, password: string) => (dispatch: any) => {
+export const register = (name: string,email:string, password: string) => (dispatch: any) => {
     request({
-        url: API_REGISTER, method: 'POST', data: { username, password }
+        url: API_REGISTER, method: 'POST', data: { client_type:'IOS',username:name,email:email, password:password }
     }).then(res => {
         dispatch(registerSuccess(res));
     })

Alguns ficheiros não foram mostrados porque muitos ficheiros mudaram neste diff