ith5 преди 4 месеца
родител
ревизия
2d2655b802

+ 2 - 0
src/app.config.ts

@@ -9,6 +9,8 @@ export default defineAppConfig({
     "pages/detail/index",
     "pages/login/index",
     "pages/publish/index",
+    "pages/gift/index",
+    "pages/self/setting/index",
   ],
   window: {
     backgroundTextStyle: "light",

+ 2 - 0
src/app.tsx

@@ -10,6 +10,8 @@ function App(props: { children: React.ReactNode }) {
     nutuiColorPrimaryStop1: "#606cd2",
     nutuiColorPrimaryStop2: "#606cd2",
     "--nutui-tabs-tabpane-padding": "0",
+    "--nutui-button-primary-disabled": "#b3b9e9",
+    "--nutui-color-primary-disabled": "#b3b9e9",
   };
   // 可以使用所有的 React Hooks
   useEffect(() => {});

+ 1 - 1
src/pages/act/index.tsx

@@ -41,7 +41,7 @@ export default function Act() {
           navigateBack({ delta: 1 });
         }}
       >
-        活动
+        积分中心
       </NavBar>
       <View>
         <iframe

+ 54 - 0
src/pages/gift/index.tsx

@@ -0,0 +1,54 @@
+import { NavBar } from "@nutui/nutui-react-taro";
+import { View } from "@tarojs/components";
+import { ArrowLeft } from "@nutui/icons-react-taro";
+import { navigateBack } from "@tarojs/taro";
+
+const Gift = () => {
+  return (
+    <View>
+      <NavBar
+        back={
+          <>
+            <ArrowLeft />
+            返回
+          </>
+        }
+        fixed
+        onBackClick={(e) => {
+          e.preventDefault();
+          navigateBack({ delta: 1 });
+        }}
+      >
+        礼包中心
+      </NavBar>
+      <View className="pt-[60px]">
+        <View className="flex items-center justify-between px-[10px] border-b-[1px] border-[#f2f2f2] pb-[10px] mb-[10px]">
+          <View className="text-[14px]">
+            <View>每日签到礼包</View>
+            <View className="text-[12px] text-[#999]">
+              钻石x50,强化合金x10000
+            </View>
+          </View>
+
+          <View className="text-center bg-[#f2f2f2] py-[4px] w-[60px] rounded-[10px] text-[14px] text-[#6069d9] font-[800]">
+            领 取
+          </View>
+        </View>
+        <View className="flex items-center justify-between px-[10px] border-b-[1px] border-[#f2f2f2] pb-[10px]">
+          <View className="text-[14px]">
+            <View>每日签到礼包</View>
+            <View className="text-[12px] text-[#999]">
+              钻石x50,强化合金x10000
+            </View>
+          </View>
+
+          <View className="text-center bg-[#f2f2f2] py-[4px] w-[60px] rounded-[10px] text-[14px]">
+            领 取
+          </View>
+        </View>
+      </View>
+    </View>
+  );
+};
+
+export default Gift;

+ 6 - 1
src/pages/index/index.tsx

@@ -132,7 +132,12 @@ function Index() {
             >
               积分中心
             </View>
-            <View className="text-[#fff] w-[28%] h-[30px] flex items-center justify-center text-center text-[12px] rounded-[5px]  font-[800] px-[10px] bg-[#5258acf0]">
+            <View
+              className="text-[#fff] w-[28%] h-[30px] flex items-center justify-center text-center text-[12px] rounded-[5px]  font-[800] px-[10px] bg-[#5258acf0]"
+              onClick={() => {
+                navigateTo({ url: "/pages/gift/index" });
+              }}
+            >
               <Gift size={16} />
               礼包中心
             </View>

+ 23 - 11
src/pages/self/index.tsx

@@ -6,6 +6,7 @@ import {
   Message,
   Notice,
   Plus,
+  Setting,
 } from "@nutui/icons-react-taro";
 import {
   Badge,
@@ -244,17 +245,28 @@ const Self = () => {
                 </View>
               </View>
             </View>
-            {userId ? (
-              <></>
-            ) : (
-              <Badge top="2" right="8" value={userInfo.notification_count}>
-                <Notice
-                  onClick={() => {
-                    navigateTo({ url: "/pages/message/index" });
-                  }}
-                />
-              </Badge>
-            )}
+            <View>
+              {userId ? (
+                <></>
+              ) : (
+                <>
+                  <Setting
+                    className="mr-[10px]"
+                    size={18}
+                    onClick={() => {
+                      navigateTo({ url: "/pages/self/setting/index" });
+                    }}
+                  />
+                  <Badge top="2" right="8" value={userInfo.notification_count}>
+                    <Notice
+                      onClick={() => {
+                        navigateTo({ url: "/pages/message/index" });
+                      }}
+                    />
+                  </Badge>
+                </>
+              )}
+            </View>
           </View>
           <View className="flex items-center justify-between text-[14px] mt-[10px]">
             <View className="flex">

+ 3 - 0
src/pages/self/setting/index.config.ts

@@ -0,0 +1,3 @@
+export default {
+  navigationBarTitleText: "设置",
+};

+ 0 - 0
src/pages/self/setting/index.scss


+ 164 - 0
src/pages/self/setting/index.tsx

@@ -0,0 +1,164 @@
+import {
+  Cell,
+  Form,
+  Input,
+  NavBar,
+  Popup,
+  Button,
+} from "@nutui/nutui-react-taro";
+import { View } from "@tarojs/components";
+import { ArrowLeft, ArrowRight } from "@nutui/icons-react-taro";
+import { getStorageSync, navigateBack, showToast } from "@tarojs/taro";
+import { sendCodeApi } from "../../../api/auth";
+import "./index.scss";
+import { useState } from "react";
+
+export default function Setting() {
+  const [showBottom, setShowBottom] = useState(false);
+  const [form] = Form.useForm();
+  const [formData, setFormData] = useState({
+    user_name: "",
+    user_pwd: "",
+    phone: "",
+    code: "",
+  });
+  const [countdown, setCountdown] = useState(0);
+
+  // 获取验证码
+  const handleGetCode = async () => {
+    if (countdown > 0) return;
+
+    if (!formData.phone) {
+      showToast({
+        icon: "none",
+        title: "请输入手机号码",
+        duration: 2000,
+      });
+      return;
+    }
+
+    // 校验手机号格式
+    const phoneRegex = /^1[3-9]\d{9}$/;
+    if (!phoneRegex.test(formData.phone)) {
+      showToast({
+        icon: "none",
+        title: "请输入正确的手机号",
+      });
+      return;
+    }
+    try {
+      // 调用发送验证码接口
+      await sendCodeApi(formData.phone);
+
+      // 这里可以调用发送验证码的API
+      showToast({
+        title: "验证码已发送",
+        duration: 2000,
+        icon: "none",
+      });
+      setCountdown(60);
+    } catch (error: any) {
+      showToast({
+        title: error.message,
+        duration: 2000,
+        icon: "none",
+      });
+    }
+  };
+  const userInfo = getStorageSync("User");
+  return (
+    <View>
+      <NavBar
+        back={
+          <>
+            <ArrowLeft />
+            返回
+          </>
+        }
+        fixed
+        onBackClick={(e) => {
+          e.preventDefault();
+          navigateBack({ delta: 1 });
+        }}
+      >
+        设置
+      </NavBar>
+      <Cell.Group className="pt-[40px]">
+        <Cell
+          className="nutui-cell-clickable"
+          title="修改密码"
+          align="center"
+          extra={<ArrowRight />}
+          onClick={() => {
+            setShowBottom(true);
+          }}
+        />
+      </Cell.Group>
+      <Popup
+        visible={showBottom}
+        position="bottom"
+        onClose={() => {
+          setShowBottom(false);
+        }}
+      >
+        <View>
+          <Form form={form}>
+            <Form.Item label="账号" name="user_name">
+              <Input
+                placeholder="请输入账号"
+                readOnly={true}
+                value={formData.user_name}
+                defaultValue={userInfo.username}
+                onChange={(value) =>
+                  setFormData({ ...formData, user_name: value })
+                }
+              />
+            </Form.Item>
+            <Form.Item label="新密码">
+              <Input
+                placeholder="请输入新密码"
+                value={formData.user_pwd}
+                onChange={(value) =>
+                  setFormData({ ...formData, user_pwd: value })
+                }
+              />
+            </Form.Item>
+            <Form.Item label="手机号码" name="phone">
+              <Input
+                placeholder="请输入手机号码"
+                readOnly={true}
+                value={formData.phone}
+                onChange={(value) => setFormData({ ...formData, phone: value })}
+              />
+            </Form.Item>
+            <Form.Item label="验证码" name="code">
+              <View className="flex items-center">
+                <Input
+                  placeholder="请输入验证码"
+                  value={formData.code}
+                  onChange={(value) =>
+                    setFormData({ ...formData, code: value })
+                  }
+                />
+                <Button
+                  className="w-[100px] h-[40px] text-[14px] text-[#333]"
+                  disabled={countdown > 0}
+                  onClick={handleGetCode}
+                  size="mini"
+                  type="primary"
+                >
+                  {countdown > 0 ? `${countdown}s` : "获取验证码"}
+                </Button>
+              </View>
+            </Form.Item>
+            <Form.Item>
+              <Button block type="primary" onClick={() => form.submit()}>
+                提交
+              </Button>
+            </Form.Item>
+          </Form>
+        </View>
+      </Popup>
+    </View>
+  );
+}