From 2a3b661478e8c1f1c02a78d89f9c176b6be0b886 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E5=BF=A0=E6=9E=97?= <170083662@qq.com> Date: Thu, 5 Feb 2026 18:35:17 +0800 Subject: [PATCH] =?UTF-8?q?feat(ticket):=20=E7=A7=BB=E9=99=A4=E7=A4=BC?= =?UTF-8?q?=E5=93=81=E5=8D=A1=E7=9B=B8=E5=85=B3=E9=A1=B5=E9=9D=A2=E5=B9=B6?= =?UTF-8?q?=E8=B0=83=E6=95=B4=E8=B7=AF=E7=94=B1=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 删除 ticket/add.config.ts 和 ticket/add.tsx 页面文件 - 删除 ticket/detail.config.ts 和 ticket/detail.tsx 页面文件 - 删除 ticket/receive.config.ts 和 ticket/receive.tsx 页面文件 - 删除 ticket/redeem.config.ts 和 ticket/redeem.tsx 页面文件 - 将 app.config.ts 中的 ticket/detail 路由改为 ticket/use - 修改首页订单按钮跳转链接从 goodsDetail 到 ticket/use - 修改首页商品卡片按钮跳转从 coupon/index 到 ticket/index - 新增 ticket/use.config.ts 配置文件并设置页面标题为立即送水 --- src/app.config.ts | 2 +- src/pages/index/index.tsx | 4 +- src/user/ticket/add.config.ts | 4 - src/user/ticket/add.tsx | 323 ---------- src/user/ticket/detail.config.ts | 5 - src/user/ticket/detail.tsx | 335 ---------- src/user/ticket/receive.config.ts | 5 - src/user/ticket/receive.tsx | 247 ------- src/user/ticket/redeem.config.ts | 5 - src/user/ticket/redeem.tsx | 278 -------- src/user/ticket/use.config.ts | 5 +- src/user/ticket/use.scss | 116 ++++ src/user/ticket/use.tsx | 1001 ++++++++++++++++++++++------- 13 files changed, 885 insertions(+), 1445 deletions(-) delete mode 100644 src/user/ticket/add.config.ts delete mode 100644 src/user/ticket/add.tsx delete mode 100644 src/user/ticket/detail.config.ts delete mode 100644 src/user/ticket/detail.tsx delete mode 100644 src/user/ticket/receive.config.ts delete mode 100644 src/user/ticket/receive.tsx delete mode 100644 src/user/ticket/redeem.config.ts delete mode 100644 src/user/ticket/redeem.tsx create mode 100644 src/user/ticket/use.scss diff --git a/src/app.config.ts b/src/app.config.ts index e861ab7..035923d 100644 --- a/src/app.config.ts +++ b/src/app.config.ts @@ -54,7 +54,7 @@ export default { "coupon/index", "points/points", "ticket/index", - "ticket/detail", + "ticket/use", // "gift/index", // "gift/redeem", // "gift/detail", diff --git a/src/pages/index/index.tsx b/src/pages/index/index.tsx index 79de900..8adba04 100644 --- a/src/pages/index/index.tsx +++ b/src/pages/index/index.tsx @@ -207,7 +207,7 @@ function Home() { key: 'order', title: '立即送水', icon: , - onClick: () => Taro.navigateTo({ url: '/shop/goodsDetail/index?id=10074' }), + onClick: () => Taro.navigateTo({ url: '/user/ticket/use?goodsId=10074' }), }, { key: 'invite', @@ -313,7 +313,7 @@ function Home() { Taro.navigateTo({ url: '/user/coupon/index' })} + onClick={() => Taro.navigateTo({ url: '/user/ticket/index' })} > 买水票更优惠 diff --git a/src/user/ticket/add.config.ts b/src/user/ticket/add.config.ts deleted file mode 100644 index 5d97955..0000000 --- a/src/user/ticket/add.config.ts +++ /dev/null @@ -1,4 +0,0 @@ -export default definePageConfig({ - navigationBarTitleText: '新增收货地址', - navigationBarTextStyle: 'black' -}) diff --git a/src/user/ticket/add.tsx b/src/user/ticket/add.tsx deleted file mode 100644 index 493b1d3..0000000 --- a/src/user/ticket/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)} - > - {/* 基本信息 */} - - - - - - -