forked from gxwebsoft/mp-10550
refactor(shop): 更新 API调用和页面逻辑
- 修改了多个文件中的 API调用路径 - 优化了部分组件的显示逻辑 - 添加了优惠券相关功能 -调整了环境变量配置
This commit is contained in:
@@ -2,13 +2,13 @@
|
|||||||
export const ENV_CONFIG = {
|
export const ENV_CONFIG = {
|
||||||
// 开发环境
|
// 开发环境
|
||||||
development: {
|
development: {
|
||||||
API_BASE_URL: 'http://127.0.0.1:9200/api',
|
API_BASE_URL: 'https://cms-api.websoft.top/api',
|
||||||
APP_NAME: '开发环境',
|
APP_NAME: '开发环境',
|
||||||
DEBUG: 'true',
|
DEBUG: 'true',
|
||||||
},
|
},
|
||||||
// 生产环境
|
// 生产环境
|
||||||
production: {
|
production: {
|
||||||
API_BASE_URL: 'https://cms-api.websoft.top/api',
|
API_BASE_URL: 'https://cms-api.s209.websoft.top/api',
|
||||||
APP_NAME: '时里院子市集',
|
APP_NAME: '时里院子市集',
|
||||||
DEBUG: 'false',
|
DEBUG: 'false',
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -8,9 +8,9 @@ import {SERVER_API_URL} from "@/utils/server";
|
|||||||
/**
|
/**
|
||||||
* 获取网站信息
|
* 获取网站信息
|
||||||
*/
|
*/
|
||||||
export async function getSiteInfo() {
|
export async function getShopInfo() {
|
||||||
const res = await request.get<ApiResult<CmsWebsite>>(
|
const res = await request.get<ApiResult<CmsWebsite>>(
|
||||||
'/cms/cms-website/getSiteInfo'
|
'/shop/getShopInfo'
|
||||||
);
|
);
|
||||||
if (res.code === 0 && res.data) {
|
if (res.code === 0 && res.data) {
|
||||||
return res.data;
|
return res.data;
|
||||||
|
|||||||
@@ -32,6 +32,8 @@ export interface ShopUserCoupon {
|
|||||||
endTime?: string;
|
endTime?: string;
|
||||||
// 使用状态(0未使用 1已使用 2已过期)
|
// 使用状态(0未使用 1已使用 2已过期)
|
||||||
status?: number;
|
status?: number;
|
||||||
|
// 是否过期, 0否, 1是
|
||||||
|
isExpire?: number;
|
||||||
// 使用时间
|
// 使用时间
|
||||||
useTime?: string;
|
useTime?: string;
|
||||||
// 使用订单ID
|
// 使用订单ID
|
||||||
@@ -57,5 +59,9 @@ export interface ShopUserCoupon {
|
|||||||
*/
|
*/
|
||||||
export interface ShopUserCouponParam extends PageParam {
|
export interface ShopUserCouponParam extends PageParam {
|
||||||
id?: number;
|
id?: number;
|
||||||
|
status?: number;
|
||||||
|
isExpire?: number;
|
||||||
|
sortBy?: string;
|
||||||
|
sortOrder?: string;
|
||||||
keywords?: string;
|
keywords?: string;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ const CouponStats: React.FC<CouponStatsProps> = ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View className="bg-white mx-4 my-3 rounded-xl p-4">
|
<View className="bg-white mx-4 my-3 rounded-xl p-4 hidden">
|
||||||
<Text className="font-semibold text-gray-800">优惠券统计</Text>
|
<Text className="font-semibold text-gray-800">优惠券统计</Text>
|
||||||
|
|
||||||
<View className="flex justify-between mt-2">
|
<View className="flex justify-between mt-2">
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import {useEffect, useState} from "react";
|
import {useEffect, useState} from "react";
|
||||||
import Taro, {useShareAppMessage, useShareTimeline} from '@tarojs/taro';
|
import Taro, {useShareAppMessage, useShareTimeline, useDidShow} from '@tarojs/taro';
|
||||||
import {
|
import {
|
||||||
NavBar,
|
NavBar,
|
||||||
Checkbox,
|
Checkbox,
|
||||||
@@ -25,7 +25,8 @@ function Cart() {
|
|||||||
cartCount,
|
cartCount,
|
||||||
updateQuantity,
|
updateQuantity,
|
||||||
removeFromCart,
|
removeFromCart,
|
||||||
clearCart
|
clearCart,
|
||||||
|
loadCartFromStorage
|
||||||
} = useCart();
|
} = useCart();
|
||||||
|
|
||||||
// InputNumber 主题配置
|
// InputNumber 主题配置
|
||||||
@@ -56,6 +57,11 @@ function Cart() {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 页面显示时刷新购物车数据
|
||||||
|
useDidShow(() => {
|
||||||
|
loadCartFromStorage();
|
||||||
|
});
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
Taro.getSystemInfo({
|
Taro.getSystemInfo({
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import {useEffect, useState} from "react";
|
import {useEffect, useState} from "react";
|
||||||
import {Image} from '@nutui/nutui-react-taro'
|
import {Image} from '@nutui/nutui-react-taro'
|
||||||
import {Share} from '@nutui/icons-react-taro'
|
import {Share} from '@nutui/icons-react-taro'
|
||||||
|
import {View, Text} from '@tarojs/components';
|
||||||
import Taro, {useShareAppMessage, useShareTimeline} from "@tarojs/taro";
|
import Taro, {useShareAppMessage, useShareTimeline} from "@tarojs/taro";
|
||||||
import {ShopGoods} from "@/api/shop/shopGoods/model";
|
import {ShopGoods} from "@/api/shop/shopGoods/model";
|
||||||
import {pageShopGoods} from "@/api/shop/shopGoods";
|
import {pageShopGoods} from "@/api/shop/shopGoods";
|
||||||
@@ -17,6 +18,42 @@ const BestSellers = () => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 处理分享点击
|
||||||
|
const handleShare = (item: ShopGoods) => {
|
||||||
|
setGoods(item);
|
||||||
|
|
||||||
|
// 显示分享选项菜单
|
||||||
|
Taro.showActionSheet({
|
||||||
|
itemList: ['分享给好友', '分享到朋友圈'],
|
||||||
|
success: (res) => {
|
||||||
|
if (res.tapIndex === 0) {
|
||||||
|
// 分享给好友 - 触发转发
|
||||||
|
Taro.showShareMenu({
|
||||||
|
withShareTicket: true,
|
||||||
|
success: () => {
|
||||||
|
// 提示用户点击右上角分享
|
||||||
|
Taro.showToast({
|
||||||
|
title: '请点击右上角分享给好友',
|
||||||
|
icon: 'none',
|
||||||
|
duration: 2000
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else if (res.tapIndex === 1) {
|
||||||
|
// 分享到朋友圈
|
||||||
|
Taro.showToast({
|
||||||
|
title: '请点击右上角分享到朋友圈',
|
||||||
|
icon: 'none',
|
||||||
|
duration: 2000
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
fail: (err) => {
|
||||||
|
console.log('显示分享菜单失败', err);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
reload()
|
reload()
|
||||||
}, [])
|
}, [])
|
||||||
@@ -57,52 +94,47 @@ const BestSellers = () => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className={'py-3'}>
|
<View className={'py-3'}>
|
||||||
<div className={'flex flex-col justify-between items-center rounded-lg px-2'}>
|
<View className={'flex flex-col justify-between items-center rounded-lg px-2'}>
|
||||||
{list?.map((item, index) => {
|
{list?.map((item, index) => {
|
||||||
return (
|
return (
|
||||||
<div key={index} className={'flex flex-col rounded-lg bg-white shadow-sm w-full mb-5'}>
|
<View key={index} className={'flex flex-col rounded-lg bg-white shadow-sm w-full mb-5'}>
|
||||||
<Image src={item.image} mode={'aspectFit'} lazyLoad={false}
|
<Image src={item.image} mode={'aspectFit'} lazyLoad={false}
|
||||||
radius="10px 10px 0 0" height="180"
|
radius="10px 10px 0 0" height="180"
|
||||||
onClick={() => Taro.navigateTo({url: '/shop/goodsDetail/index?id=' + item.goodsId})}/>
|
onClick={() => Taro.navigateTo({url: '/shop/goodsDetail/index?id=' + item.goodsId})}/>
|
||||||
<div className={'flex flex-col p-2 rounded-lg'}>
|
<View className={'flex flex-col p-2 rounded-lg'}>
|
||||||
<div>
|
<View>
|
||||||
<div className={'car-no text-sm'}>{item.name}</div>
|
<View className={'car-no text-sm'}>{item.name}</View>
|
||||||
<div className={'flex justify-between text-xs py-1'}>
|
<View className={'flex justify-between text-xs py-1'}>
|
||||||
<span className={'text-orange-500'}>{item.comments}</span>
|
<Text className={'text-orange-500'}>{item.comments}</Text>
|
||||||
<span className={'text-gray-400'}>已售 {item.sales}</span>
|
<Text className={'text-gray-400'}>已售 {item.sales}</Text>
|
||||||
</div>
|
</View>
|
||||||
<div className={'flex justify-between items-center py-2'}>
|
<View className={'flex justify-between items-center py-2'}>
|
||||||
<div className={'flex text-red-500 text-xl items-baseline'}>
|
<View className={'flex text-red-500 text-xl items-baseline'}>
|
||||||
<span className={'text-xs'}>¥</span>
|
<Text className={'text-xs'}>¥</Text>
|
||||||
<span className={'font-bold text-2xl'}>{item.price}</span>
|
<Text className={'font-bold text-2xl'}>{item.price}</Text>
|
||||||
</div>
|
</View>
|
||||||
<div className={'buy-btn'}>
|
<View className={'buy-btn'}>
|
||||||
<div className={'cart-icon flex items-center'}>
|
<View className={'cart-icon flex items-center'}>
|
||||||
<button
|
<View
|
||||||
className={'flex flex-col justify-center items-center text-gray-500 px-3 gap-1 text-nowrap whitespace-nowrap'}
|
className={'flex flex-col justify-center items-center text-white px-3 gap-1 text-nowrap whitespace-nowrap cursor-pointer'}
|
||||||
open-type="share"
|
onClick={() => handleShare(item)}
|
||||||
onClick={() => {
|
|
||||||
setGoods(item)
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
<Share className={'text-white'} size={20}/>
|
<Share size={20}/>
|
||||||
</button>
|
</View>
|
||||||
{/*<Share size={20} className={'mx-4 mt-2'}*/}
|
</View>
|
||||||
{/* onClick={() => Taro.navigateTo({url: '/shop/goodsDetail/index?id=' + item.goodsId})}/>*/}
|
<Text className={'text-white pl-4 pr-5'}
|
||||||
</div>
|
onClick={() => Taro.navigateTo({url: '/shop/goodsDetail/index?id=' + item.goodsId})}>购买
|
||||||
<div className={'text-white pl-4 pr-5'}
|
</Text>
|
||||||
onClick={() => Taro.navigateTo({url: '/shop/goodsDetail/index?id=' + item.goodsId})}>购买
|
</View>
|
||||||
</div>
|
</View>
|
||||||
</div>
|
</View>
|
||||||
</div>
|
</View>
|
||||||
</div>
|
</View>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)
|
)
|
||||||
})}
|
})}
|
||||||
</div>
|
</View>
|
||||||
</div>
|
</View>
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import Taro from '@tarojs/taro';
|
|||||||
import {Button, Space} from '@nutui/nutui-react-taro'
|
import {Button, Space} from '@nutui/nutui-react-taro'
|
||||||
import {TriangleDown} from '@nutui/icons-react-taro'
|
import {TriangleDown} from '@nutui/icons-react-taro'
|
||||||
import {Popup, Avatar, NavBar} from '@nutui/nutui-react-taro'
|
import {Popup, Avatar, NavBar} from '@nutui/nutui-react-taro'
|
||||||
import {getSiteInfo, getUserInfo, getWxOpenId} from "@/api/layout";
|
import {getShopInfo, getUserInfo, getWxOpenId} from "@/api/layout";
|
||||||
import {TenantId} from "@/config/app";
|
import {TenantId} from "@/config/app";
|
||||||
import {getOrganization} from "@/api/system/organization";
|
import {getOrganization} from "@/api/system/organization";
|
||||||
import {myUserVerify} from "@/api/system/userVerify";
|
import {myUserVerify} from "@/api/system/userVerify";
|
||||||
@@ -26,7 +26,7 @@ const Header = (props: any) => {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
// 获取站点信息
|
// 获取站点信息
|
||||||
getSiteInfo().then((data) => {
|
getShopInfo().then((data) => {
|
||||||
setConfig(data);
|
setConfig(data);
|
||||||
console.log(userInfo)
|
console.log(userInfo)
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import BestSellers from './BestSellers';
|
|||||||
import Taro from '@tarojs/taro';
|
import Taro from '@tarojs/taro';
|
||||||
import {useShareAppMessage, useShareTimeline} from "@tarojs/taro"
|
import {useShareAppMessage, useShareTimeline} from "@tarojs/taro"
|
||||||
import {useEffect, useState} from "react";
|
import {useEffect, useState} from "react";
|
||||||
import {getSiteInfo} from "@/api/layout";
|
import {getShopInfo} from "@/api/layout";
|
||||||
import {Sticky} from '@nutui/nutui-react-taro'
|
import {Sticky} from '@nutui/nutui-react-taro'
|
||||||
import Menu from "./Menu";
|
import Menu from "./Menu";
|
||||||
import Banner from "./Banner";
|
import Banner from "./Banner";
|
||||||
@@ -84,7 +84,7 @@ function Home() {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// 获取站点信息
|
// 获取站点信息
|
||||||
getSiteInfo().then(() => {
|
getShopInfo().then(() => {
|
||||||
|
|
||||||
})
|
})
|
||||||
// Taro.getSetting:获取用户的当前设置。返回值中只会出现小程序已经向用户请求过的权限。
|
// Taro.getSetting:获取用户的当前设置。返回值中只会出现小程序已经向用户请求过的权限。
|
||||||
|
|||||||
4
src/pages/order/order.scss
Normal file
4
src/pages/order/order.scss
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
// 订单页面样式
|
||||||
|
.order-page {
|
||||||
|
// 订单相关样式
|
||||||
|
}
|
||||||
@@ -237,8 +237,7 @@ function UserCard() {
|
|||||||
<span className={'text-sm text-gray-500'}>礼品卡</span>
|
<span className={'text-sm text-gray-500'}>礼品卡</span>
|
||||||
<span className={'text-xl'}>{giftCount}</span>
|
<span className={'text-xl'}>{giftCount}</span>
|
||||||
</div>
|
</div>
|
||||||
<div className={'item flex justify-center flex-col items-center'}
|
<div className={'item flex justify-center flex-col items-center'}>
|
||||||
onClick={() => navTo('/user/points/points', true)}>
|
|
||||||
<span className={'text-sm text-gray-500'}>积分</span>
|
<span className={'text-sm text-gray-500'}>积分</span>
|
||||||
<span className={'text-xl'}>{pointsCount}</span>
|
<span className={'text-xl'}>{pointsCount}</span>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import {Cell} from '@nutui/nutui-react-taro'
|
import {Cell} from '@nutui/nutui-react-taro'
|
||||||
import navTo from "@/utils/common";
|
import navTo from "@/utils/common";
|
||||||
import Taro from '@tarojs/taro'
|
import Taro from '@tarojs/taro'
|
||||||
|
import {View,Text} from '@tarojs/components'
|
||||||
import {ArrowRight, ShieldCheck, LogisticsError, Location, Reward, Tips, Ask} from '@nutui/icons-react-taro'
|
import {ArrowRight, ShieldCheck, LogisticsError, Location, Reward, Tips, Ask} from '@nutui/icons-react-taro'
|
||||||
|
|
||||||
const UserCell = () => {
|
const UserCell = () => {
|
||||||
@@ -25,25 +26,25 @@ const UserCell = () => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className={'px-4'}>
|
<View className={'px-4'}>
|
||||||
<Cell
|
<Cell
|
||||||
className="nutui-cell-clickable"
|
className="nutui-cell-clickable"
|
||||||
style={{
|
style={{
|
||||||
backgroundImage: 'linear-gradient(to right bottom, #54a799, #177b73)',
|
backgroundImage: 'linear-gradient(to right bottom, #54a799, #177b73)',
|
||||||
}}
|
}}
|
||||||
title={
|
title={
|
||||||
<div style={{display: 'inline-flex', alignItems: 'center'}} onClick={() => navTo('/dealer/index', true)}>
|
<View style={{display: 'inline-flex', alignItems: 'center'}} onClick={() => navTo('/dealer/index', true)}>
|
||||||
<Reward className={'text-orange-100 '} size={16}/>
|
<Reward className={'text-orange-100 '} size={16}/>
|
||||||
<span style={{fontSize: '16px'}} className={'pl-3 text-orange-100 font-medium'}>开通会员</span>
|
<Text style={{fontSize: '16px'}} className={'pl-3 text-orange-100 font-medium'}>开通会员</Text>
|
||||||
<span className={'text-white opacity-80 pl-3'}>享优惠</span>
|
<Text className={'text-white opacity-80 pl-3'}>享优惠</Text>
|
||||||
</div>
|
</View>
|
||||||
}
|
}
|
||||||
extra={<ArrowRight color="#cccccc" size={18}/>}
|
extra={<ArrowRight color="#cccccc" size={18}/>}
|
||||||
/>
|
/>
|
||||||
<Cell.Group divider={true} description={
|
<Cell.Group divider={true} description={
|
||||||
<div style={{display: 'inline-flex', alignItems: 'center'}}>
|
<View style={{display: 'inline-flex', alignItems: 'center'}}>
|
||||||
<span style={{marginTop: '12px'}}>我的服务</span>
|
<Text style={{marginTop: '12px'}}>我的服务</Text>
|
||||||
</div>
|
</View>
|
||||||
}>
|
}>
|
||||||
<Cell
|
<Cell
|
||||||
className="nutui-cell-clickable"
|
className="nutui-cell-clickable"
|
||||||
@@ -51,10 +52,10 @@ const UserCell = () => {
|
|||||||
display: 'none'
|
display: 'none'
|
||||||
}}
|
}}
|
||||||
title={
|
title={
|
||||||
<div style={{display: 'inline-flex', alignItems: 'center'}}>
|
<View style={{display: 'inline-flex', alignItems: 'center'}}>
|
||||||
<LogisticsError size={16}/>
|
<LogisticsError size={16}/>
|
||||||
<span className={'pl-3 text-sm'}>我的钱包</span>
|
<Text className={'pl-3 text-sm'}>我的钱包</Text>
|
||||||
</div>
|
</View>
|
||||||
}
|
}
|
||||||
align="center"
|
align="center"
|
||||||
extra={<ArrowRight color="#cccccc" size={18}/>}
|
extra={<ArrowRight color="#cccccc" size={18}/>}
|
||||||
@@ -65,10 +66,10 @@ const UserCell = () => {
|
|||||||
<Cell
|
<Cell
|
||||||
className="nutui-cell-clickable"
|
className="nutui-cell-clickable"
|
||||||
title={
|
title={
|
||||||
<div style={{display: 'inline-flex', alignItems: 'center'}}>
|
<View style={{display: 'inline-flex', alignItems: 'center'}}>
|
||||||
<Location size={16}/>
|
<Location size={16}/>
|
||||||
<span className={'pl-3 text-sm'}>收货地址</span>
|
<Text className={'pl-3 text-sm'}>收货地址</Text>
|
||||||
</div>
|
</View>
|
||||||
}
|
}
|
||||||
align="center"
|
align="center"
|
||||||
extra={<ArrowRight color="#cccccc" size={18}/>}
|
extra={<ArrowRight color="#cccccc" size={18}/>}
|
||||||
@@ -79,10 +80,10 @@ const UserCell = () => {
|
|||||||
<Cell
|
<Cell
|
||||||
className="nutui-cell-clickable"
|
className="nutui-cell-clickable"
|
||||||
title={
|
title={
|
||||||
<div style={{display: 'inline-flex', alignItems: 'center'}}>
|
<View style={{display: 'inline-flex', alignItems: 'center'}}>
|
||||||
<ShieldCheck size={16}/>
|
<ShieldCheck size={16}/>
|
||||||
<span className={'pl-3 text-sm'}>实名认证</span>
|
<Text className={'pl-3 text-sm'}>实名认证</Text>
|
||||||
</div>
|
</View>
|
||||||
}
|
}
|
||||||
align="center"
|
align="center"
|
||||||
extra={<ArrowRight color="#cccccc" size={18}/>}
|
extra={<ArrowRight color="#cccccc" size={18}/>}
|
||||||
@@ -93,10 +94,10 @@ const UserCell = () => {
|
|||||||
<Cell
|
<Cell
|
||||||
className="nutui-cell-clickable"
|
className="nutui-cell-clickable"
|
||||||
title={
|
title={
|
||||||
<div style={{display: 'inline-flex', alignItems: 'center'}}>
|
<View style={{display: 'inline-flex', alignItems: 'center'}}>
|
||||||
<Ask size={16}/>
|
<Ask size={16}/>
|
||||||
<span className={'pl-3 text-sm'}>常见问题</span>
|
<Text className={'pl-3 text-sm'}>常见问题</Text>
|
||||||
</div>
|
</View>
|
||||||
}
|
}
|
||||||
align="center"
|
align="center"
|
||||||
extra={<ArrowRight color="#cccccc" size={18}/>}
|
extra={<ArrowRight color="#cccccc" size={18}/>}
|
||||||
@@ -107,10 +108,10 @@ const UserCell = () => {
|
|||||||
<Cell
|
<Cell
|
||||||
className="nutui-cell-clickable"
|
className="nutui-cell-clickable"
|
||||||
title={
|
title={
|
||||||
<div style={{display: 'inline-flex', alignItems: 'center'}}>
|
<View style={{display: 'inline-flex', alignItems: 'center'}}>
|
||||||
<Tips size={16}/>
|
<Tips size={16}/>
|
||||||
<span className={'pl-3 text-sm'}>关于我们</span>
|
<Text className={'pl-3 text-sm'}>关于我们</Text>
|
||||||
</div>
|
</View>
|
||||||
}
|
}
|
||||||
align="center"
|
align="center"
|
||||||
extra={<ArrowRight color="#cccccc" size={18}/>}
|
extra={<ArrowRight color="#cccccc" size={18}/>}
|
||||||
@@ -120,9 +121,9 @@ const UserCell = () => {
|
|||||||
/>
|
/>
|
||||||
</Cell.Group>
|
</Cell.Group>
|
||||||
<Cell.Group divider={true} description={
|
<Cell.Group divider={true} description={
|
||||||
<div style={{display: 'inline-flex', alignItems: 'center'}}>
|
<View style={{display: 'inline-flex', alignItems: 'center'}}>
|
||||||
<span style={{marginTop: '12px'}}>账号管理</span>
|
<Text style={{marginTop: '12px'}}>账号管理</Text>
|
||||||
</div>
|
</View>
|
||||||
}>
|
}>
|
||||||
<Cell
|
<Cell
|
||||||
className="nutui-cell-clickable"
|
className="nutui-cell-clickable"
|
||||||
@@ -139,7 +140,7 @@ const UserCell = () => {
|
|||||||
onClick={onLogout}
|
onClick={onLogout}
|
||||||
/>
|
/>
|
||||||
</Cell.Group>
|
</Cell.Group>
|
||||||
</div>
|
</View>
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ import Taro, {useDidShow} from '@tarojs/taro'
|
|||||||
import {Button, Empty, ConfigProvider, SearchBar, InfiniteLoading, Loading, PullToRefresh, Tabs, TabPane} from '@nutui/nutui-react-taro'
|
import {Button, Empty, ConfigProvider, SearchBar, InfiniteLoading, Loading, PullToRefresh, Tabs, TabPane} from '@nutui/nutui-react-taro'
|
||||||
import {Plus, Filter} from '@nutui/icons-react-taro'
|
import {Plus, Filter} from '@nutui/icons-react-taro'
|
||||||
import {View} from '@tarojs/components'
|
import {View} from '@tarojs/components'
|
||||||
import {ShopCoupon} from "@/api/shop/shopCoupon/model";
|
import {ShopUserCoupon} from "@/api/shop/shopUserCoupon/model";
|
||||||
import {pageShopCoupon} from "@/api/shop/shopCoupon";
|
import {pageShopUserCoupon} from "@/api/shop/shopUserCoupon";
|
||||||
import CouponList from "@/components/CouponList";
|
import CouponList from "@/components/CouponList";
|
||||||
import CouponStats from "@/components/CouponStats";
|
import CouponStats from "@/components/CouponStats";
|
||||||
import CouponGuide from "@/components/CouponGuide";
|
import CouponGuide from "@/components/CouponGuide";
|
||||||
@@ -14,7 +14,7 @@ import {CouponCardProps} from "@/components/CouponCard";
|
|||||||
import dayjs from "dayjs";
|
import dayjs from "dayjs";
|
||||||
|
|
||||||
const CouponManage = () => {
|
const CouponManage = () => {
|
||||||
const [list, setList] = useState<ShopCoupon[]>([])
|
const [list, setList] = useState<ShopUserCoupon[]>([])
|
||||||
const [loading, setLoading] = useState(false)
|
const [loading, setLoading] = useState(false)
|
||||||
const [hasMore, setHasMore] = useState(true)
|
const [hasMore, setHasMore] = useState(true)
|
||||||
const [searchValue, setSearchValue] = useState('')
|
const [searchValue, setSearchValue] = useState('')
|
||||||
@@ -63,7 +63,7 @@ const CouponManage = () => {
|
|||||||
try {
|
try {
|
||||||
const currentPage = isRefresh ? 1 : page
|
const currentPage = isRefresh ? 1 : page
|
||||||
const statusFilter = getStatusFilter()
|
const statusFilter = getStatusFilter()
|
||||||
const res = await pageShopCoupon({
|
const res = await pageShopUserCoupon({
|
||||||
page: currentPage,
|
page: currentPage,
|
||||||
limit: 10,
|
limit: 10,
|
||||||
keywords: searchValue,
|
keywords: searchValue,
|
||||||
@@ -127,7 +127,7 @@ const CouponManage = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 转换优惠券数据为CouponCard组件所需格式
|
// 转换优惠券数据为CouponCard组件所需格式
|
||||||
const transformCouponData = (coupon: ShopCoupon): CouponCardProps => {
|
const transformCouponData = (coupon: ShopUserCoupon): CouponCardProps => {
|
||||||
// 判断优惠券状态
|
// 判断优惠券状态
|
||||||
let status: 0 | 1 | 2 = 0 // 默认未使用
|
let status: 0 | 1 | 2 = 0 // 默认未使用
|
||||||
if (coupon.isExpire === 1) {
|
if (coupon.isExpire === 1) {
|
||||||
@@ -176,7 +176,7 @@ const CouponManage = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 使用优惠券
|
// 使用优惠券
|
||||||
const handleUseCoupon = (coupon: ShopCoupon) => {
|
const handleUseCoupon = (coupon: ShopUserCoupon) => {
|
||||||
Taro.showModal({
|
Taro.showModal({
|
||||||
title: '使用优惠券',
|
title: '使用优惠券',
|
||||||
content: `确定要使用"${coupon.name}"吗?`,
|
content: `确定要使用"${coupon.name}"吗?`,
|
||||||
@@ -201,7 +201,7 @@ const CouponManage = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 显示优惠券详情
|
// 显示优惠券详情
|
||||||
const showCouponDetail = (coupon: ShopCoupon) => {
|
const showCouponDetail = (coupon: ShopUserCoupon) => {
|
||||||
// 跳转到优惠券详情页
|
// 跳转到优惠券详情页
|
||||||
Taro.navigateTo({
|
Taro.navigateTo({
|
||||||
url: `/user/coupon/detail?id=${coupon.id}`
|
url: `/user/coupon/detail?id=${coupon.id}`
|
||||||
@@ -213,9 +213,9 @@ const CouponManage = () => {
|
|||||||
try {
|
try {
|
||||||
// 并行获取各状态的优惠券数量
|
// 并行获取各状态的优惠券数量
|
||||||
const [availableRes, usedRes, expiredRes] = await Promise.all([
|
const [availableRes, usedRes, expiredRes] = await Promise.all([
|
||||||
pageShopCoupon({ page: 1, limit: 1, status: 0, isExpire: 0 }),
|
pageShopUserCoupon({ page: 1, limit: 1, status: 0, isExpire: 0 }),
|
||||||
pageShopCoupon({ page: 1, limit: 1, status: 1 }),
|
pageShopUserCoupon({ page: 1, limit: 1, status: 1 }),
|
||||||
pageShopCoupon({ page: 1, limit: 1, isExpire: 1 })
|
pageShopUserCoupon({ page: 1, limit: 1, isExpire: 1 })
|
||||||
])
|
])
|
||||||
|
|
||||||
setStats({
|
setStats({
|
||||||
@@ -248,7 +248,7 @@ const CouponManage = () => {
|
|||||||
const checkExpiringSoonCoupons = async () => {
|
const checkExpiringSoonCoupons = async () => {
|
||||||
try {
|
try {
|
||||||
// 获取即将过期的优惠券(3天内过期)
|
// 获取即将过期的优惠券(3天内过期)
|
||||||
const res = await pageShopCoupon({
|
const res = await pageShopUserCoupon({
|
||||||
page: 1,
|
page: 1,
|
||||||
limit: 50,
|
limit: 50,
|
||||||
status: 0, // 未使用
|
status: 0, // 未使用
|
||||||
@@ -277,6 +277,7 @@ const CouponManage = () => {
|
|||||||
.sort((a, b) => a.daysLeft - b.daysLeft)
|
.sort((a, b) => a.daysLeft - b.daysLeft)
|
||||||
|
|
||||||
if (expiringSoon.length > 0) {
|
if (expiringSoon.length > 0) {
|
||||||
|
// @ts-ignore
|
||||||
setExpiringSoonCoupons(expiringSoon)
|
setExpiringSoonCoupons(expiringSoon)
|
||||||
// 延迟显示提醒,避免与页面加载冲突
|
// 延迟显示提醒,避免与页面加载冲突
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user