From 1005fd07181164f35b6212eed3b1438f472b9dfb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E5=BF=A0=E6=9E=97?= <170083662@qq.com> Date: Tue, 7 Oct 2025 12:42:14 +0800 Subject: [PATCH] =?UTF-8?q?feat(shop):=20=E6=96=B0=E5=A2=9E=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E7=AE=A1=E7=90=86=E6=A8=A1=E5=9D=97-=20=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E7=94=A8=E6=88=B7=E8=AE=B0=E5=BD=95=E8=A1=A8=E6=A8=A1?= =?UTF-8?q?=E5=9E=8B=E5=AE=9A=E4=B9=89=EF=BC=8C=E5=8C=85=E5=90=AB=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E5=9F=BA=E6=9C=AC=E4=BF=A1=E6=81=AF=E3=80=81=E8=AE=A4?= =?UTF-8?q?=E8=AF=81=E4=BF=A1=E6=81=AF=E3=80=81=E7=BB=9F=E8=AE=A1=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E7=AD=89=E5=AD=97=E6=AE=B5=20-=20=E5=AE=9E=E7=8E=B0?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E8=AE=B0=E5=BD=95=E8=A1=A8=E7=9A=84=E5=A2=9E?= =?UTF-8?q?=E5=88=A0=E6=94=B9=E6=9F=A5=E6=8E=A5=E5=8F=A3=EF=BC=8C=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E5=88=86=E9=A1=B5=E6=9F=A5=E8=AF=A2=E5=92=8C=E6=89=B9?= =?UTF-8?q?=E9=87=8F=E5=88=A0=E9=99=A4=E5=8A=9F=E8=83=BD=20-=20=E5=9C=A8?= =?UTF-8?q?=E5=8C=BB=E7=94=9F=E7=94=B3=E8=AF=B7=E9=A1=B5=E9=9D=A2=E9=9B=86?= =?UTF-8?q?=E6=88=90=E7=94=A8=E6=88=B7=E4=BF=A1=E6=81=AF=E6=8F=90=E4=BA=A4?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=EF=BC=8C=E6=94=AF=E6=8C=81=E4=B8=AA=E4=BA=BA?= =?UTF-8?q?=E5=92=8C=E4=BC=81=E4=B8=9A=E7=94=A8=E6=88=B7=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?-=20=E4=BC=98=E5=8C=96=E7=94=A8=E6=88=B7=E8=A1=A8=E5=8D=95?= =?UTF-8?q?=E9=AA=8C=E8=AF=81=E9=80=BB=E8=BE=91=EF=BC=8C=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E5=B9=B4=E9=BE=84=E5=BF=85=E5=A1=AB=E6=A0=A1=E9=AA=8C-=20?= =?UTF-8?q?=E8=B0=83=E6=95=B4=E7=94=A8=E6=88=B7=E7=B1=BB=E5=9E=8B=E5=8D=95?= =?UTF-8?q?=E9=80=89=E6=A1=86=E9=BB=98=E8=AE=A4=E5=80=BC=E4=B8=BA=E4=B8=AA?= =?UTF-8?q?=E4=BA=BA=E7=94=A8=E6=88=B7=20-=20=E6=B7=BB=E5=8A=A0=E8=AF=81?= =?UTF-8?q?=E4=BB=B6=E4=B8=8A=E4=BC=A0=E5=8A=9F=E8=83=BD=EF=BC=8C=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E4=BC=81=E4=B8=9A=E7=94=A8=E6=88=B7=E4=B8=8A=E4=BC=A0?= =?UTF-8?q?=E8=B5=84=E8=B4=A8=E8=AF=81=E6=98=8E=20-=20=E7=A7=BB=E9=99=A4?= =?UTF-8?q?=E6=96=87=E7=AB=A0=E5=88=86=E7=B1=BB=E5=92=8C=E8=AF=A6=E6=83=85?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E9=A1=B5=E9=9D=A2=E7=BB=84=E4=BB=B6=20-=20?= =?UTF-8?q?=E8=B0=83=E6=95=B4=E8=AF=B7=E6=B1=82=E5=B7=A5=E5=85=B7=E4=B8=AD?= =?UTF-8?q?=E5=90=8E=E5=8F=B0=E9=85=8D=E7=BD=AEAPI=E5=9C=B0=E5=9D=80?= =?UTF-8?q?=E7=9A=84=E6=97=A5=E5=BF=97=E8=BE=93=E5=87=BA=E4=B8=BA=E6=B3=A8?= =?UTF-8?q?=E9=87=8A=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/shop/shopUser/index.ts | 105 +++++++++++ src/api/shop/shopUser/model/index.ts | 165 +++++++++++++++++ src/doctor/apply/add.tsx | 170 ++++++++---------- .../cms/category/components/ArticleList.tsx | 25 --- .../cms/category/components/ArticleTabs.tsx | 59 ------ src/pages/cms/category/components/Banner.tsx | 31 ---- src/pages/cms/category/index.config.ts | 4 - src/pages/cms/category/index.scss | 0 src/pages/cms/category/index.tsx | 71 -------- src/pages/cms/detail/index.config.ts | 3 - src/pages/cms/detail/index.scss | 0 src/pages/cms/detail/index.tsx | 53 ------ src/utils/request.ts | 4 +- 13 files changed, 351 insertions(+), 339 deletions(-) create mode 100644 src/api/shop/shopUser/index.ts create mode 100644 src/api/shop/shopUser/model/index.ts delete mode 100644 src/pages/cms/category/components/ArticleList.tsx delete mode 100644 src/pages/cms/category/components/ArticleTabs.tsx delete mode 100644 src/pages/cms/category/components/Banner.tsx delete mode 100644 src/pages/cms/category/index.config.ts delete mode 100644 src/pages/cms/category/index.scss delete mode 100644 src/pages/cms/category/index.tsx delete mode 100644 src/pages/cms/detail/index.config.ts delete mode 100644 src/pages/cms/detail/index.scss delete mode 100644 src/pages/cms/detail/index.tsx diff --git a/src/api/shop/shopUser/index.ts b/src/api/shop/shopUser/index.ts new file mode 100644 index 0000000..45184f8 --- /dev/null +++ b/src/api/shop/shopUser/index.ts @@ -0,0 +1,105 @@ +import request from '@/utils/request'; +import type { ApiResult, PageResult } from '@/api'; +import type { ShopUser, ShopUserParam } from './model'; + +/** + * 分页查询用户记录表 + */ +export async function pageShopUser(params: ShopUserParam) { + const res = await request.get>>( + '/shop/shop-user/page', + { + params + } + ); + if (res.code === 0) { + return res.data; + } + return Promise.reject(new Error(res.message)); +} + +/** + * 查询用户记录表列表 + */ +export async function listShopUser(params?: ShopUserParam) { + const res = await request.get>( + '/shop/shop-user', + { + params + } + ); + if (res.code === 0 && res.data) { + return res.data; + } + return Promise.reject(new Error(res.message)); +} + +/** + * 添加用户记录表 + */ +export async function addShopUser(data: ShopUser) { + const res = await request.post>( + 'http://127.0.0.1:9200/api/shop/shop-user', + data + ); + if (res.code === 0) { + return res.message; + } + return Promise.reject(new Error(res.message)); +} + +/** + * 修改用户记录表 + */ +export async function updateShopUser(data: ShopUser) { + const res = await request.put>( + '/shop/shop-user', + data + ); + if (res.code === 0) { + return res.message; + } + return Promise.reject(new Error(res.message)); +} + +/** + * 删除用户记录表 + */ +export async function removeShopUser(id?: number) { + const res = await request.del>( + '/shop/shop-user/' + id + ); + if (res.code === 0) { + return res.message; + } + return Promise.reject(new Error(res.message)); +} + +/** + * 批量删除用户记录表 + */ +export async function removeBatchShopUser(data: (number | undefined)[]) { + const res = await request.del>( + '/shop/shop-user/batch', + { + data + } + ); + if (res.code === 0) { + return res.message; + } + return Promise.reject(new Error(res.message)); +} + +/** + * 根据userId查询用户记录表 + */ +export async function getShopUser(userId: number) { + const res = await request.get>( + '/shop/shop-user/' + userId + ); + if (res.code === 0 && res.data) { + return res.data; + } + return Promise.reject(new Error(res.message)); +} diff --git a/src/api/shop/shopUser/model/index.ts b/src/api/shop/shopUser/model/index.ts new file mode 100644 index 0000000..30a0e16 --- /dev/null +++ b/src/api/shop/shopUser/model/index.ts @@ -0,0 +1,165 @@ +import type { PageParam } from '@/api'; + +/** + * 用户记录表 + */ +export interface ShopUser { + // 用户id + userId?: number; + // 用户类型 0个人用户 1企业用户 2其他 + type?: number; + // 账号 + username?: string; + // 密码 + password?: string; + // 昵称 + nickname?: string; + // 手机号 + phone?: string; + // 性别 1男 2女 + sex?: number; + // 职务 + position?: string; + // 注册来源客户端 (APP、H5、MP-WEIXIN等) + platform?: string; + // 邮箱 + email?: string; + // 邮箱是否验证, 0否, 1是 + emailVerified?: number; + // 别名 + alias?: string; + // 真实姓名 + realName?: string; + // 证件号码 + idCard?: string; + // 出生日期 + birthday?: string; + // 所在国家 + country?: string; + // 所在省份 + province?: string; + // 所在城市 + city?: string; + // 所在辖区 + region?: string; + // 街道地址 + address?: string; + // 经度 + longitude?: string; + // 纬度 + latitude?: string; + // 用户可用余额 + balance?: string; + // 已提现金额 + cashedMoney?: string; + // 用户可用积分 + points?: number; + // 用户总支付的金额 + payMoney?: string; + // 实际消费的金额(不含退款) + expendMoney?: string; + // 密码 + payPassword?: string; + // 会员等级ID + gradeId?: number; + // 行业分类 + category?: string; + // 个人简介 + introduction?: string; + // 机构id + organizationId?: number; + // 会员分组ID + groupId?: number; + // 头像 + avatar?: string; + // 背景图 + bgImage?: string; + // 用户编码 + userCode?: string; + // 是否已实名认证 + certification?: number; + // 年龄 + age?: number; + // 是否线下会员 + offline?: string; + // 关注数 + followers?: number; + // 粉丝数 + fans?: number; + // 点赞数 + likes?: number; + // 评论数 + commentNumbers?: number; + // 是否推荐 + recommend?: number; + // 微信openid + openid?: string; + // 微信公众号openid + officeOpenid?: string; + // 微信unionID + unionid?: string; + // 客户端ID + clientId?: string; + // 不允许办卡 + notAllowVip?: string; + // 是否管理员 + isAdmin?: string; + // 是否企业管理员 + isOrganizationAdmin?: string; + // 累计登录次数 + loginNum?: number; + // 企业ID + companyId?: number; + // 可管理的场馆 + merchants?: string; + // 商户ID + merchantId?: number; + // 商户名称 + merchantName?: string; + // 商户头像 + merchantAvatar?: string; + // 第三方系统的用户ID + uid?: number; + // 专家角色 + expertType?: string; + // 过期时间 + expireTime?: number; + // 最后结算时间 + settlementTime?: string; + // 资质 + aptitude?: string; + // 行业类型(父级) + industryParent?: string; + // 行业类型(子级) + industryChild?: string; + // 头衔 + title?: string; + // 安装的产品ID + templateId?: number; + // 插件安装状态(仅对超超管判断) 0未安装 1已安装 + installed?: number; + // 特长 + speciality?: string; + // 备注 + comments?: string; + // 状态, 0在线, 1离线 + status?: number; + // 是否删除, 0否, 1是 + deleted?: number; + // 租户id + tenantId?: number; + // 注册时间 + createTime?: string; + // 修改时间 + updateTime?: string; + // 上传证件1 + uploadImg1?: string; +} + +/** + * 用户记录表搜索条件 + */ +export interface ShopUserParam extends PageParam { + userId?: number; + keywords?: string; +} diff --git a/src/doctor/apply/add.tsx b/src/doctor/apply/add.tsx index 64c0558..d2f5f87 100644 --- a/src/doctor/apply/add.tsx +++ b/src/doctor/apply/add.tsx @@ -2,14 +2,14 @@ import {useEffect, useState, useRef} from "react"; import {Loading, CellGroup, Input, Form, Radio, InputNumber, TextArea, ConfigProvider} from '@nutui/nutui-react-taro' import {Edit} from '@nutui/icons-react-taro' import Taro from '@tarojs/taro' +import {Image} from '@tarojs/components'; import FixedButton from "@/components/FixedButton"; -import {useUser} from "@/hooks/useUser"; -import {updateUser} from "@/api/system/user"; -import {User} from "@/api/system/user/model"; -import {addShopDealerUser} from "@/api/shop/shopDealerUser"; -import {listUserRole, updateUserRole} from "@/api/system/userRole"; import {DictData} from "@/api/system/dict-data/model"; import {listDictData} from "@/api/system/dict-data"; +import {addShopUser, getShopUser} from "@/api/shop/shopUser"; +import {ShopUser} from "@/api/shop/shopUser/model"; +import {uploadFile} from "@/api/system/file"; +import {useUser} from "@/hooks/useUser"; const customTheme = { nutuiInputnumberButtonWidth: '30px', @@ -21,97 +21,49 @@ const customTheme = { } const AddApply = () => { - const {user, loginUser} = useUser() + const {user} = useUser() const [loading, setLoading] = useState(true) - const [FormData, setFormData] = useState() + const [FormData, setFormData] = useState() const [userType, setUserType] = useState() const formRef = useRef(null) const reload = async () => { - listDictData({dictCode: 'UserType'}).then((data) => { - setUserType(data) - }) + const userId = Taro.getStorageSync('UserId') + if(!userId || userId == '') return + const shopUser = await getShopUser(Number(Taro.getStorageSync('UserId'))) + if(shopUser){ + console.log(shopUser.type,'shopUsershopUsershopUsershopUsershopUsershopUsershopUser') + setFormData({ + ...shopUser, + type : Number(shopUser.type) + }) + } + const userType = await listDictData({dictCode: 'UserType'}) + if(userType){ + setUserType(userType) + } } // 提交表单 const submitSucceed = async (values: any) => { - try { - // 验证必填字段 - if (!values.phone && !FormData?.phone) { - Taro.showToast({ - title: '请先获取手机号', - icon: 'error' - }); - return; - } - - // 验证昵称:必须填写且不能是默认的微信昵称 - const nickname = values.realName || FormData?.nickname || ''; - if (!nickname || nickname.trim() === '') { - Taro.showToast({ - title: '请填写昵称', - icon: 'error' - }); - return; - } - - // 检查是否为默认的微信昵称(常见的默认昵称) - const defaultNicknames = ['微信用户', 'WeChat User', '微信昵称']; - if (defaultNicknames.includes(nickname.trim())) { - Taro.showToast({ - title: '请填写真实昵称,不能使用默认昵称', - icon: 'error' - }); - return; - } - - // 验证昵称长度 - if (nickname.trim().length < 2) { - Taro.showToast({ - title: '昵称至少需要2个字符', - icon: 'error' - }); - return; - } - - if (!values.avatar && !FormData?.avatar) { - Taro.showToast({ - title: '请上传头像', - icon: 'error' - }); - return; - } - console.log(values,FormData) - - const roles = await listUserRole({userId: user?.userId}) - console.log(roles, 'roles...') - - return false; - - // 准备提交的数据 - await updateUser({ - userId: user?.userId, - nickname: values.realName || FormData?.nickname, - phone: values.phone || FormData?.phone, - avatar: values.avatar || FormData?.avatar, - refereeId: values.refereeId || FormData?.refereeId + if (!FormData?.age || FormData?.age == 0) { + Taro.showToast({ + title: `请填写年龄`, + icon: 'error' }); - - await addShopDealerUser({ - userId: user?.userId, + return; + } + try { + // 准备提交的数据 + await addShopUser({ + userId: Taro.getStorageSync('UserId'), + type: values.type, + username: user?.username, + nickname: user?.nickname, realName: values.realName || FormData?.nickname, - mobile: values.phone || FormData?.phone, - refereeId: values.refereeId || FormData?.refereeId + phone: values.phone || FormData?.phone }) - if (roles.length > 0) { - await updateUserRole({ - ...roles[0], - roleId: 1848 - }) - } - - Taro.showToast({ title: `注册成功`, icon: 'success' @@ -136,17 +88,25 @@ const AddApply = () => { console.log(error, 'err...') } + const uploadImg1 = () => { + uploadFile().then(data => { + setFormData({ + ...FormData, + uploadImg1: data.url + }) + }); + } + useEffect(() => { reload().then(() => { setLoading(false) }) - }, [user?.userId]); // 依赖用户ID,当用户变化时重新加载 + }, []); // 依赖用户ID,当用户变化时重新加载 // 当FormData变化时,同步更新表单字段值 useEffect(() => { if (formRef.current && FormData) { formRef.current.setFieldsValue({ - refereeId: FormData.refereeId, phone: FormData.phone, avatar: FormData.avatar, realName: FormData.nickname @@ -172,7 +132,7 @@ const AddApply = () => { {JSON.stringify(FormData)} { @@ -193,10 +153,10 @@ const AddApply = () => { { + onChange={(value) => { setFormData({ ...FormData, - realName: e.detail.value + realName: value }) }} /> @@ -214,17 +174,17 @@ const AddApply = () => { - + { setFormData({ ...FormData, age: Number(value) }) }} - min={1} + min={0} max={120} step={1} /> @@ -240,6 +200,34 @@ const AddApply = () => { value={FormData?.introduction || ''} /> + {FormData?.type == 1 && ( + <> + + { + setFormData({ + ...FormData, + idCard: value + }) + }} + /> + + +
+ +
+
+ + )} + diff --git a/src/pages/cms/category/components/ArticleList.tsx b/src/pages/cms/category/components/ArticleList.tsx deleted file mode 100644 index 3f46857..0000000 --- a/src/pages/cms/category/components/ArticleList.tsx +++ /dev/null @@ -1,25 +0,0 @@ -import {Image, Cell} from '@nutui/nutui-react-taro' -import Taro from '@tarojs/taro' - -const ArticleList = (props: any) => { - - return ( - <> -
- {props.data.map((item, index) => { - return ( - - } - key={index} - onClick={() => Taro.navigateTo({url: '/cms/detail/index?id=' + item.articleId})} - /> - ) - })} -
- - ) -} -export default ArticleList diff --git a/src/pages/cms/category/components/ArticleTabs.tsx b/src/pages/cms/category/components/ArticleTabs.tsx deleted file mode 100644 index a995345..0000000 --- a/src/pages/cms/category/components/ArticleTabs.tsx +++ /dev/null @@ -1,59 +0,0 @@ -import {useEffect, useState} from "react"; -import {Tabs, Loading} from '@nutui/nutui-react-taro' -import {pageCmsArticle} from "@/api/cms/cmsArticle"; -import {CmsArticle} from "@/api/cms/cmsArticle/model"; -import ArticleList from "./ArticleList"; - -const ArticleTabs = (props: any) => { - const [loading, setLoading] = useState(true) - const [tab1value, setTab1value] = useState('0') - const [list, setList] = useState([]) - - const reload = async (value) => { - const {data} = props - pageCmsArticle({ - categoryId: data[value].navigationId, - page: 1, - status: 0, - limit: 10 - }).then((res) => { - res && setList(res?.list || []) - }) - .catch(err => { - console.log(err) - }) - .finally(() => { - setTab1value(value) - setLoading(false) - }) - } - - useEffect(() => { - reload(0).then() - }, []); - - if (loading) { - return ( - 加载中 - ) - } - - return ( - <> - { - reload(value).then() - }} - > - {props.data?.map((item, index) => { - return ( - - ) - })} - - - - ) -} -export default ArticleTabs diff --git a/src/pages/cms/category/components/Banner.tsx b/src/pages/cms/category/components/Banner.tsx deleted file mode 100644 index 7f3942d..0000000 --- a/src/pages/cms/category/components/Banner.tsx +++ /dev/null @@ -1,31 +0,0 @@ -import { useEffect, useState } from 'react' -import { Swiper } from '@nutui/nutui-react-taro' -import {CmsAd} from "@/api/cms/cmsAd/model"; -import {Image} from '@nutui/nutui-react-taro' -import {getCmsAd} from "@/api/cms/cmsAd"; - -const MyPage = () => { - const [item, setItem] = useState() - const reload = () => { - getCmsAd(439).then(data => { - setItem(data) - }) - } - - useEffect(() => { - reload() - }, []) - - return ( - <> - - {item?.imageList?.map((item) => ( - - - - ))} - - - ) -} -export default MyPage diff --git a/src/pages/cms/category/index.config.ts b/src/pages/cms/category/index.config.ts deleted file mode 100644 index 689ba07..0000000 --- a/src/pages/cms/category/index.config.ts +++ /dev/null @@ -1,4 +0,0 @@ -export default definePageConfig({ - navigationBarTitleText: '文章列表', - navigationBarTextStyle: 'black' -}) diff --git a/src/pages/cms/category/index.scss b/src/pages/cms/category/index.scss deleted file mode 100644 index e69de29..0000000 diff --git a/src/pages/cms/category/index.tsx b/src/pages/cms/category/index.tsx deleted file mode 100644 index 17a632b..0000000 --- a/src/pages/cms/category/index.tsx +++ /dev/null @@ -1,71 +0,0 @@ -import Taro from '@tarojs/taro' -import {useShareAppMessage} from "@tarojs/taro" -import {Loading} from '@nutui/nutui-react-taro' -import {useEffect, useState} from "react" -import {useRouter} from '@tarojs/taro' -import {getCmsNavigation, listCmsNavigation} from "@/api/cms/cmsNavigation"; -import {CmsNavigation} from "@/api/cms/cmsNavigation/model"; -import {pageCmsArticle} from "@/api/cms/cmsArticle"; -import {CmsArticle} from "@/api/cms/cmsArticle/model"; -import ArticleList from './components/ArticleList' -import ArticleTabs from "./components/ArticleTabs"; -import './index.scss' - -function Category() { - const {params} = useRouter(); - const [categoryId, setCategoryId] = useState(0) - const [category, setCategory] = useState([]) - const [loading, setLoading] = useState(true) - const [nav, setNav] = useState() - const [list, setList] = useState([]) - - const reload = async () => { - // 1.加载远程数据 - const id = Number(params.id || 4328) - const nav = await getCmsNavigation(id) - const categoryList = await listCmsNavigation({parentId: id}) - const shopGoods = await pageCmsArticle({categoryId: id}) - - // 2.赋值 - setCategoryId(id) - setNav(nav) - setList(shopGoods?.list || []) - setCategory(categoryList) - Taro.setNavigationBarTitle({ - title: `${nav?.categoryName}` - }) - }; - - useEffect(() => { - reload().then(() => { - setLoading(false) - }) - }, []); - - useShareAppMessage(() => { - return { - title: `${nav?.categoryName}_通源堂健康生态平台`, - path: `/shop/category/index?id=${categoryId}`, - success: function () { - console.log('分享成功'); - }, - fail: function () { - console.log('分享失败'); - } - }; - }); - - if (loading) { - return ( - 加载中 - ) - } - - if(category.length > 0){ - return - } - - return -} - -export default Category diff --git a/src/pages/cms/detail/index.config.ts b/src/pages/cms/detail/index.config.ts deleted file mode 100644 index d74c9f2..0000000 --- a/src/pages/cms/detail/index.config.ts +++ /dev/null @@ -1,3 +0,0 @@ -export default definePageConfig({ - navigationBarTitleText: '文章详情' -}) diff --git a/src/pages/cms/detail/index.scss b/src/pages/cms/detail/index.scss deleted file mode 100644 index e69de29..0000000 diff --git a/src/pages/cms/detail/index.tsx b/src/pages/cms/detail/index.tsx deleted file mode 100644 index f92c890..0000000 --- a/src/pages/cms/detail/index.tsx +++ /dev/null @@ -1,53 +0,0 @@ -import Taro from '@tarojs/taro' -import {useEffect, useState} from 'react' -import {useRouter} from '@tarojs/taro' -import {Loading} from '@nutui/nutui-react-taro' -import {View, RichText} from '@tarojs/components' -import {wxParse} from "@/utils/common"; -import {getCmsArticle} from "@/api/cms/cmsArticle"; -import {CmsArticle} from "@/api/cms/cmsArticle/model" -import Line from "@/components/Gap"; -import './index.scss' - -function Detail() { - const {params} = useRouter(); - const [loading, setLoading] = useState(true) - // 文章详情 - const [item, setItem] = useState() - const reload = async () => { - const item = await getCmsArticle(Number(params.id)) - - if (item) { - item.content = wxParse(item.content) - setItem(item) - Taro.setNavigationBarTitle({ - title: `${item?.categoryName}` - }) - } - } - - useEffect(() => { - reload().then(() => { - setLoading(false) - }); - }, []); - - if (loading) { - return ( - 加载中 - ) - } - - return ( -
-
{item?.title}
-
{item?.createTime}
- - - - -
- ) -} - -export default Detail diff --git a/src/utils/request.ts b/src/utils/request.ts index 202b57f..628a9d6 100644 --- a/src/utils/request.ts +++ b/src/utils/request.ts @@ -61,10 +61,10 @@ const getBaseUrl = (): string => { if (configStr) { // 如果是字符串,需要解析为对象 const config = typeof configStr === 'string' ? JSON.parse(configStr) : configStr; - console.log('获取后台配置API地址:', config); + // console.log('获取后台配置API地址:', config); // 注意属性名是 ApiUrl(首字母大写),不是 apiUrl if (config && config.ApiUrl) { - console.log('使用后台配置的API地址:', config.ApiUrl); + // console.log('使用后台配置的API地址:', config.ApiUrl); return config.ApiUrl; } }