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 => 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(() => { - - - ); }); 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 ( { - handleClick(); - }} + // onClick={() => { + // handleClick(); + // }} > { classes={classes} hrs={hrs} handleSearch={handleSearch} + handleDelete={handleDelete} /> ); @@ -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 ? ( {classes.map((each) => ( @@ -127,7 +140,7 @@ const ConditionalRender = ({ isSpread, classes, hrs, handleSearch }) => { 历史搜索 - +