From 5e9b65100321dbd221d416d544819b7580b58669 Mon Sep 17 00:00:00 2001
From: eleliauk <2831336720@qq.com>
Date: Thu, 26 Dec 2024 00:32:35 +0800
Subject: [PATCH] =?UTF-8?q?fix(bugs):=20=E6=97=A0=E6=B3=95=E5=88=A0?=
 =?UTF-8?q?=E9=99=A4=E5=8E=86=E5=8F=B2=E8=AE=B0=E5=BD=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 src/common/utils/fetch.ts       |  4 +++-
 src/pages/editUser/index.tsx    | 27 +++++++++++++++++++++++++++
 src/pages/feedback/index.tsx    |  9 +++------
 src/pages/research/research.tsx | 31 ++++++++++++++++++++++---------
 4 files changed, 55 insertions(+), 16 deletions(-)

diff --git a/src/common/utils/fetch.ts b/src/common/utils/fetch.ts
index 071d33f..2f69a1c 100644
--- a/src/common/utils/fetch.ts
+++ b/src/common/utils/fetch.ts
@@ -55,7 +55,7 @@ const refreshToken = async () => {
 
 const request = async (
   url = '',
-  method: 'GET' | 'POST' = 'GET',
+  method: 'GET' | 'POST' | 'PUT' = 'GET',
   data = {},
   isToken = true
 ) => {
@@ -129,3 +129,5 @@ const request1 = async (url = '', method: 'GET' | 'POST' = 'GET', data = {}) =>
 //为了躲避审核
 export const postBool = (url = '', data = {}): Promise<unknown> =>
   request1(url, 'POST', data);
+
+export const put = (url = '', data = {}) => request(url, 'PUT', data, true);
diff --git a/src/pages/editUser/index.tsx b/src/pages/editUser/index.tsx
index 6de44d8..37a7943 100644
--- a/src/pages/editUser/index.tsx
+++ b/src/pages/editUser/index.tsx
@@ -25,6 +25,13 @@ const EditUser: React.FC = () => {
     KeStackPartner: false,
     None: false,
   });
+
+  const titleRequirements = {
+    CaringSenior: 80,
+    KeStackPartner: 150,
+    CCNUWithMe: 300,
+  };
+
   useEffect(() => {
     const fetchUser = async () => {
       try {
@@ -98,6 +105,26 @@ const EditUser: React.FC = () => {
   const handleTitleSelect = (title: string) => {
     if (titleOwnership[title]) {
       setSelectedTitle(title);
+    } else {
+      const requirement = titleRequirements[title];
+      let titleName = '';
+      switch (title) {
+        case 'CaringSenior':
+          titleName = '知心学长';
+          break;
+        case 'KeStackPartner':
+          titleName = '课栈合伙人';
+          break;
+        case 'CCNUWithMe':
+          titleName = '华师有我';
+          break;
+      }
+      void Taro.showModal({
+        title: '称号获取条件',
+        content: `经验值达到${requirement},可获得"${titleName}"称号`,
+        showCancel: false,
+        confirmText: '知道了',
+      });
     }
   };
   // Taro.redirectTo({url:'pages/login/index'});
diff --git a/src/pages/feedback/index.tsx b/src/pages/feedback/index.tsx
index 65ea3ef..335f800 100644
--- a/src/pages/feedback/index.tsx
+++ b/src/pages/feedback/index.tsx
@@ -1,11 +1,11 @@
-import { Button, Textarea, View } from '@tarojs/components';
+import { Textarea, View } from '@tarojs/components';
 import Taro from '@tarojs/taro';
-import React, { useState } from 'react';
+import React from 'react';
 
 import './index.scss';
 
 const Feedback: React.FC = React.memo(() => {
-  const [textareaValue, setTextareaValue] = useState('');
+  // const [textareaValue, setTextareaValue] = useState('');
   const copyText = '764752182';
 
   const handleCopy = () => {
@@ -43,9 +43,6 @@ const Feedback: React.FC = React.memo(() => {
           </View>
         </View>
       </View>
-      <View>
-        <Button>提交</Button>
-      </View>
     </>
   );
 });
diff --git a/src/pages/research/research.tsx b/src/pages/research/research.tsx
index f00e47c..796a089 100644
--- a/src/pages/research/research.tsx
+++ b/src/pages/research/research.tsx
@@ -16,6 +16,7 @@ import Label1 from '@/common/components/label1/label1';
 import Label2 from '@/common/components/label2/label2';
 import SearchInput from '@/common/components/SearchInput/SearchInput';
 import { get } from '@/common/utils';
+import { put } from '@/common/utils/fetch';
 
 export interface Course {
   id: number;
@@ -53,10 +54,21 @@ const Research: React.FC = () => {
     setSpread(false);
   };
 
-  const handleClick = () => {
-    // Taro.switchTab({
-    //   url: '/pages/main/index',
-    // });
+  const handleDelete = () => {
+    put('/search/history', {
+      remove_all: true,
+      remove_history_ids: [],
+      search_location: 'Home',
+    }).then((res) => {
+      console.log(res);
+      if (res.code === 0) {
+        setHrs([]);
+        Taro.showToast({
+          title: '删除成功',
+          icon: 'success',
+        });
+      }
+    });
   };
 
   const handleSearch = (searchText: string) => {
@@ -92,9 +104,9 @@ const Research: React.FC = () => {
   return (
     <View
       className="flex h-[100vh] w-[100vw] flex-col items-center overflow-auto"
-      onClick={() => {
-        handleClick();
-      }}
+      // onClick={() => {
+      //   handleClick();
+      // }}
     >
       <SearchInput
         autoFocus
@@ -109,6 +121,7 @@ const Research: React.FC = () => {
         classes={classes}
         hrs={hrs}
         handleSearch={handleSearch}
+        handleDelete={handleDelete}
       />
     </View>
   );
@@ -116,7 +129,7 @@ const Research: React.FC = () => {
 
 export default Research;
 
-const ConditionalRender = ({ isSpread, classes, hrs, handleSearch }) => {
+const ConditionalRender = ({ isSpread, classes, hrs, handleSearch, handleDelete }) => {
   return isSpread ? (
     <View className="tj">
       {classes.map((each) => (
@@ -127,7 +140,7 @@ const ConditionalRender = ({ isSpread, classes, hrs, handleSearch }) => {
     <View className="relative flex flex-col items-center">
       <View className="mt-[4vh] flex w-[80vw] flex-row justify-between">
         <Text className="lsss">历史搜索</Text>
-        <View className="button">
+        <View className="button" onClick={handleDelete}>
           <Image
             style={{ width: '29.37rpx', height: '30.83rpx' }}
             src="https://s2.loli.net/2023/08/26/3XBEGlN2UuJdejv.png"