From 5d4dc4518f5630016dd2d659e3be9f921be508fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E5=BF=A0=E6=9E=97?= <170083662@qq.com> Date: Wed, 13 Aug 2025 10:44:27 +0800 Subject: [PATCH] =?UTF-8?q?refactor(user):=20=E4=BC=98=E5=8C=96=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E4=BC=98=E6=83=A0=E5=88=B8=E7=9B=B8=E5=85=B3=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 移除新增收货地址页面 - 删除 ShopArticle 相关代码 - 优化优惠券详情页面布局- 更新优惠券筛选和使用逻辑 - 调整 app配置,重新启用优惠券功能 - 优化 Tailwind CSS配置,禁用不必要功能 --- src/api/shop/shopCoupon/model/index.ts | 3 + src/app.config.ts | 4 +- src/user/coupon/add.config.ts | 4 - src/user/coupon/add.tsx | 323 ------------------------- src/user/coupon/detail.tsx | 2 +- src/user/coupon/index.tsx | 7 +- tailwind.config.js | 10 + 7 files changed, 20 insertions(+), 333 deletions(-) delete mode 100644 src/user/coupon/add.config.ts delete mode 100644 src/user/coupon/add.tsx diff --git a/src/api/shop/shopCoupon/model/index.ts b/src/api/shop/shopCoupon/model/index.ts index 13aaa22..a81755e 100644 --- a/src/api/shop/shopCoupon/model/index.ts +++ b/src/api/shop/shopCoupon/model/index.ts @@ -62,5 +62,8 @@ export interface ShopCoupon { */ export interface ShopCouponParam extends PageParam { id?: number; + status?: number; + isExpire?: number; + sortBy?: string; keywords?: string; } diff --git a/src/app.config.ts b/src/app.config.ts index 2709be9..30df9f2 100644 --- a/src/app.config.ts +++ b/src/app.config.ts @@ -38,8 +38,8 @@ export default defineAppConfig({ "help/index", "about/index", "wallet/wallet", - // "coupon/index", - // "points/points", + "coupon/index", + "points/points", "gift/index" ] }, diff --git a/src/user/coupon/add.config.ts b/src/user/coupon/add.config.ts deleted file mode 100644 index 5d97955..0000000 --- a/src/user/coupon/add.config.ts +++ /dev/null @@ -1,4 +0,0 @@ -export default definePageConfig({ - navigationBarTitleText: '新增收货地址', - navigationBarTextStyle: 'black' -}) diff --git a/src/user/coupon/add.tsx b/src/user/coupon/add.tsx deleted file mode 100644 index 0d85f74..0000000 --- a/src/user/coupon/add.tsx +++ /dev/null @@ -1,323 +0,0 @@ -import {useEffect, useState, useRef} from "react"; -import {useRouter} from '@tarojs/taro' -import {Button, Loading, CellGroup, Input, TextArea, Form, Switch, InputNumber, Radio, Image} from '@nutui/nutui-react-taro' -import {Edit, Upload as UploadIcon} from '@nutui/icons-react-taro' -import Taro from '@tarojs/taro' -import {View} from '@tarojs/components' -import {ShopArticle} from "@/api/shop/shopArticle/model"; -import {getShopArticle, addShopArticle, updateShopArticle} from "@/api/shop/shopArticle"; -import FixedButton from "@/components/FixedButton"; - -const AddShopArticle = () => { - const {params} = useRouter(); - const [loading, setLoading] = useState(true) - const [formData, setFormData] = useState({ - type: 0, // 默认常规文章 - status: 0, // 默认已发布 - permission: 0, // 默认所有人可见 - recommend: 0, // 默认不推荐 - showType: 10, // 默认小图展示 - virtualViews: 0, // 默认虚拟阅读量 - actualViews: 0, // 默认实际阅读量 - sortNumber: 0 // 默认排序 - }) - const formRef = useRef(null) - - // 判断是编辑还是新增模式 - const isEditMode = !!params.id - const articleId = params.id ? Number(params.id) : undefined - - // 文章类型选项 - const typeOptions = [ - { text: '常规文章', value: 0 }, - { text: '视频文章', value: 1 } - ] - - // 状态选项 - const statusOptions = [ - { text: '已发布', value: 0 }, - { text: '待审核', value: 1 }, - { text: '已驳回', value: 2 }, - { text: '违规内容', value: 3 } - ] - - // 可见性选项 - const permissionOptions = [ - { text: '所有人可见', value: 0 }, - { text: '登录可见', value: 1 }, - { text: '密码可见', value: 2 } - ] - - // 显示方式选项 - const showTypeOptions = [ - { text: '小图展示', value: 10 }, - { text: '大图展示', value: 20 } - ] - - const reload = async () => { - // 如果是编辑模式,加载文章数据 - if (isEditMode && articleId) { - try { - const article = await getShopArticle(articleId) - setFormData(article) - // 更新表单值 - if (formRef.current) { - formRef.current.setFieldsValue(article) - } - } catch (error) { - console.error('加载文章失败:', error) - Taro.showToast({ - title: '加载文章失败', - icon: 'error' - }); - } - } - } - - // 图片上传处理 - const handleImageUpload = async () => { - try { - const res = await Taro.chooseImage({ - count: 1, - sizeType: ['compressed'], - sourceType: ['album', 'camera'] - }); - - if (res.tempFilePaths && res.tempFilePaths.length > 0) { - // 这里应该调用上传接口,暂时使用本地路径 - const imagePath = res.tempFilePaths[0]; - setFormData({ - ...formData, - image: imagePath - }); - - Taro.showToast({ - title: '图片选择成功', - icon: 'success' - }); - } - } catch (error) { - Taro.showToast({ - title: '图片选择失败', - icon: 'error' - }); - } - }; - - // 提交表单 - const submitSucceed = async (values: any) => { - try { - // 准备提交的数据 - const submitData = { - ...formData, - ...values, - }; - - // 如果是编辑模式,添加id - if (isEditMode && articleId) { - submitData.articleId = articleId; - } - - // 执行新增或更新操作 - if (isEditMode) { - await updateShopArticle(submitData); - } else { - await addShopArticle(submitData); - } - - Taro.showToast({ - title: `${isEditMode ? '更新' : '保存'}成功`, - icon: 'success' - }); - - setTimeout(() => { - Taro.navigateBack(); - }, 1000); - - } catch (error) { - console.error('保存失败:', error); - Taro.showToast({ - title: `${isEditMode ? '更新' : '保存'}失败`, - icon: 'error' - }); - } - } - - const submitFailed = (error: any) => { - console.log(error, 'err...') - } - - useEffect(() => { - // 动态设置页面标题 - Taro.setNavigationBarTitle({ - title: isEditMode ? '编辑文章' : '新增文章' - }); - - reload().then(() => { - setLoading(false) - }) - }, [isEditMode]); - - if (loading) { - return 加载中 - } - - return ( - <> -
submitSucceed(values)} - onFinishFailed={(errors) => submitFailed(errors)} - > - {/* 基本信息 */} - - - - - - -