dev
This commit is contained in:
parent
860de7361e
commit
ddcae32b63
24
src/api/favorite.ts
Normal file
24
src/api/favorite.ts
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
import { useRequest } from "@/use/useHttp"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取收藏夹列表
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
export const FavoriteListApi = () => {
|
||||||
|
return useRequest({
|
||||||
|
url: `/v1/mall/favorite/list`,
|
||||||
|
method: "get",
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建收藏夹列表
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
export const CreateFavoriteApi = () => {
|
||||||
|
return useRequest({
|
||||||
|
url: `/v1/mall/favorite`,
|
||||||
|
method: "post",
|
||||||
|
})
|
||||||
|
}
|
@ -4,13 +4,13 @@
|
|||||||
// export const BASE_URL = `http://10.0.0.5:50001/lymarket`
|
// export const BASE_URL = `http://10.0.0.5:50001/lymarket`
|
||||||
// export const BASE_URL = `http://192.168.0.89:40001/lymarket`
|
// export const BASE_URL = `http://192.168.0.89:40001/lymarket`
|
||||||
// export const BASE_URL = `http://192.168.1.165:40001/lymarket` // 王霞
|
// export const BASE_URL = `http://192.168.1.165:40001/lymarket` // 王霞
|
||||||
export const BASE_URL = `https://test.zzfzyc.com/lymarket` // 测试环境
|
// export const BASE_URL = `https://test.zzfzyc.com/lymarket` // 测试环境
|
||||||
// export const BASE_URL = `http://192.168.1.30:40001/lymarket` // 发
|
// export const BASE_URL = `http://192.168.1.9:40001/lymarket` // 发
|
||||||
// export const BASE_URL = `http://192.168.1.30:50001/lymarket` // 发
|
// export const BASE_URL = `http://192.168.1.30:50001/lymarket` // 发
|
||||||
// export const BASE_URL = `https://dev.zzfzyc.com/lymarket` // 开发环境
|
// export const BASE_URL = `https://dev.zzfzyc.com/lymarket` // 开发环境
|
||||||
// export const BASE_URL = `https://www.zzfzyc.com/lymarket` // 正式环境
|
// export const BASE_URL = `https://www.zzfzyc.com/lymarket` // 正式环境
|
||||||
// export const BASE_URL = `http://192.168.1.5:40001/lymarket` // 王霞
|
// export const BASE_URL = `http://192.168.1.5:40001/lymarket` // 王霞
|
||||||
// export const BASE_URL = `http://192.168.1.7:50002/lymarket` // 添
|
export const BASE_URL = `http://192.168.1.7:50002/lymarket` // 添
|
||||||
// export const BASE_URL = `http://192.168.1.15:50001/lymarket` // 杰
|
// export const BASE_URL = `http://192.168.1.15:50001/lymarket` // 杰
|
||||||
|
|
||||||
// CDN
|
// CDN
|
||||||
|
@ -0,0 +1,66 @@
|
|||||||
|
|
||||||
|
.collection_con{
|
||||||
|
padding: 20px;
|
||||||
|
.title_item{
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
padding-bottom: 20px;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
.title{
|
||||||
|
font-size: $font_size;
|
||||||
|
font-weight: 700;
|
||||||
|
width: 60px;
|
||||||
|
}
|
||||||
|
.select{
|
||||||
|
flex:1;
|
||||||
|
height: 60px;
|
||||||
|
border: 2px solid #e6e6e6;
|
||||||
|
border-radius: 10px;
|
||||||
|
margin-left: 20px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
padding: 0 20px;
|
||||||
|
font-size: 26px;
|
||||||
|
color: $color_font_two;
|
||||||
|
.input{
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.desc_item{
|
||||||
|
display: flex;
|
||||||
|
.title{
|
||||||
|
font-size: $font_size;
|
||||||
|
font-weight: 700;
|
||||||
|
width: 60px;
|
||||||
|
padding-top: 20px;
|
||||||
|
}
|
||||||
|
.desc{
|
||||||
|
margin-left: 20px;
|
||||||
|
flex:1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.btns_con{
|
||||||
|
width: 100%;
|
||||||
|
bottom:0;
|
||||||
|
box-sizing: border-box;
|
||||||
|
margin-top: 50px;
|
||||||
|
.btns_two{
|
||||||
|
display: flex;
|
||||||
|
height: 82px;
|
||||||
|
font-size: $font_size_big;
|
||||||
|
border-radius: 40px;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
.verify_btn{
|
||||||
|
flex:1;
|
||||||
|
border-radius: 40px;
|
||||||
|
background: #007aff;
|
||||||
|
text-align: center;
|
||||||
|
line-height: 82px;
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
61
src/pages/collection/components/createPopup/index.tsx
Normal file
61
src/pages/collection/components/createPopup/index.tsx
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
import Popup from "@/components/popup";
|
||||||
|
import { Input, ScrollView, Text, View } from "@tarojs/components";
|
||||||
|
import { memo, useCallback, useMemo, useRef } from "react";
|
||||||
|
import classnames from "classnames";
|
||||||
|
import styles from './index.module.scss'
|
||||||
|
import TextareaEnhance from "@/components/textareaEnhance";
|
||||||
|
import { CreateFavoriteApi } from "@/api/favorite";
|
||||||
|
import { alert } from "@/common/common";
|
||||||
|
|
||||||
|
//原因选择
|
||||||
|
type ReasonInfoParam = {
|
||||||
|
show?: boolean, //显示
|
||||||
|
onClose?: () => void, //关闭
|
||||||
|
}
|
||||||
|
export default memo(({show = false, onClose}: ReasonInfoParam) => {
|
||||||
|
|
||||||
|
|
||||||
|
const submitData = useRef({
|
||||||
|
"name": '',
|
||||||
|
"remark": ''
|
||||||
|
})
|
||||||
|
|
||||||
|
const getOtherReason = useCallback((val) => {
|
||||||
|
submitData.current.remark = val
|
||||||
|
}, [])
|
||||||
|
|
||||||
|
const changeInput = useCallback((val) => {
|
||||||
|
submitData.current.remark = val.detail.value
|
||||||
|
}, [])
|
||||||
|
|
||||||
|
//创建
|
||||||
|
const {fetchData} = CreateFavoriteApi()
|
||||||
|
const onSubmit = async () => {
|
||||||
|
if(submitData.current.name) return alert.error('请输入收藏夹名称')
|
||||||
|
let res = await fetchData(submitData.current)
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<Popup show={show} title="新建收藏夹" onClose={onClose} >
|
||||||
|
<View className={styles.collection_con}>
|
||||||
|
<View className={styles.title_item}>
|
||||||
|
<View className={styles.title}>名称</View>
|
||||||
|
<View className={styles.select}>
|
||||||
|
<Input placeholder="请输入文件夹名称" className={styles.input} onInput={changeInput}/>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
<View className={styles.desc_item}>
|
||||||
|
<View className={styles.title}>简介</View>
|
||||||
|
<View className={styles.desc}>
|
||||||
|
<TextareaEnhance onChange={getOtherReason} placeholder="请输入简介"/>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
|
||||||
|
<View className={styles.btns_con}>
|
||||||
|
<View className={styles.btns_two}>
|
||||||
|
<View className={styles.verify_btn } onClick={() => onSubmit()}>确认</View>
|
||||||
|
</View >
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
</Popup>
|
||||||
|
)
|
||||||
|
})
|
@ -0,0 +1,47 @@
|
|||||||
|
|
||||||
|
.collection_main {
|
||||||
|
padding: 0 20px;
|
||||||
|
min-height: 100%;
|
||||||
|
background-color: #F8F8F8;
|
||||||
|
.class_list{
|
||||||
|
margin-top: 30px;
|
||||||
|
.class_item{
|
||||||
|
margin: 20px 0;
|
||||||
|
}
|
||||||
|
.class_title{
|
||||||
|
display: flex;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
.title{
|
||||||
|
flex: 1;
|
||||||
|
color: #000;
|
||||||
|
font-weight: 700;
|
||||||
|
font-size: 28px;
|
||||||
|
padding: 0 20px;
|
||||||
|
}
|
||||||
|
.fg{
|
||||||
|
padding: 0 10px;
|
||||||
|
}
|
||||||
|
.num, .fg{
|
||||||
|
color: #707070;
|
||||||
|
font-weight: normal;
|
||||||
|
}
|
||||||
|
.miconfont_left{
|
||||||
|
font-size: 30px;
|
||||||
|
color: #707070;
|
||||||
|
}
|
||||||
|
.miconfont_open{
|
||||||
|
transform: rotate(-90deg);
|
||||||
|
}
|
||||||
|
.miconfont_close {
|
||||||
|
transform: rotate(90deg);
|
||||||
|
}
|
||||||
|
.more{font-size: 26px;}
|
||||||
|
|
||||||
|
}
|
||||||
|
.class_con{
|
||||||
|
overflow: hidden;
|
||||||
|
transition: all 0.5s ease-in-out;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -1,12 +1,72 @@
|
|||||||
|
import { FavoriteListApi } from "@/api/favorite";
|
||||||
|
import Product from "@/components/product";
|
||||||
import Search from "@/components/search"
|
import Search from "@/components/search"
|
||||||
import { View } from "@tarojs/components"
|
import { Text, View } from "@tarojs/components"
|
||||||
|
import classnames from "classnames";
|
||||||
|
import { useCallback, useEffect, useState } from "react";
|
||||||
|
import CreatePopup from "./components/createPopup";
|
||||||
import styles from './index.module.scss'
|
import styles from './index.module.scss'
|
||||||
export default () => {
|
export default () => {
|
||||||
|
const changeOpenCon = (item) => {
|
||||||
|
item.openStatus = !item.openStatus
|
||||||
|
setList((e) => [...e])
|
||||||
|
}
|
||||||
|
|
||||||
|
//获取列表
|
||||||
|
const [list, setList] = useState([])
|
||||||
|
const {fetchData: fetchDataList} = FavoriteListApi()
|
||||||
|
const getFavoriteList = async () => {
|
||||||
|
let res = await fetchDataList()
|
||||||
|
console.log('res::', res)
|
||||||
|
}
|
||||||
|
useEffect(() => {
|
||||||
|
getFavoriteList()
|
||||||
|
let res:any = []
|
||||||
|
new Array(10).fill('').map(item => {
|
||||||
|
res.push(
|
||||||
|
{
|
||||||
|
"create_time": "string",
|
||||||
|
"create_user_name": "string",
|
||||||
|
"creator_id": 0,
|
||||||
|
"id": 0,
|
||||||
|
"name": `${item}- 收藏夹`,
|
||||||
|
"product_color_list": [
|
||||||
|
{
|
||||||
|
"product_code": "string",
|
||||||
|
"product_id": 0,
|
||||||
|
"product_name": "string"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"remark": "string",
|
||||||
|
"update_time": "string",
|
||||||
|
"update_user_name": "string",
|
||||||
|
"updater_id": 0
|
||||||
|
}
|
||||||
|
)
|
||||||
|
})
|
||||||
|
console.log('res33::', res)
|
||||||
|
setList(res)
|
||||||
|
}, [])
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View className={styles.main}>
|
<View className={styles.collection_main}>
|
||||||
<View className={styles.search}>
|
<View className={styles.search}>
|
||||||
<Search style={{width: '100%'}} debounceTime={300} changeOnSearch={(e) => console.log(e)} placeholder="请输入面料关键词" placeIcon="out" showBtn={true} />
|
<Search style={{width: '100%'}} debounceTime={300} changeOnSearch={(e) => console.log(e)} placeholder="请输入面料关键词" placeIcon="out" showBtn={true} />
|
||||||
</View>
|
</View>
|
||||||
|
<View className={styles.class_list}>
|
||||||
|
{list?.map((item:any) => <View className={styles.class_item}>
|
||||||
|
<View className={styles.class_title} onClick={() => changeOpenCon(item)}>
|
||||||
|
<Text className={classnames(styles.miconfont_left, 'iconfont icon-a-moreback', item.openStatus?styles.miconfont_open:styles.miconfont_close)}></Text>
|
||||||
|
<View className={styles.title}>默认收藏夹<Text className={styles.fg}>·</Text><Text className={styles.num}>11</Text></View>
|
||||||
|
<View className={styles.more}>更多</View>
|
||||||
|
</View>
|
||||||
|
<View className={styles.class_con} style={item.openStatus?{maxHeight: 10*260 + 'rpx'}:{maxHeight: 0}} >
|
||||||
|
<Product productList={new Array(10).fill('')}/>
|
||||||
|
</View>
|
||||||
|
</View>)}
|
||||||
|
</View>
|
||||||
|
<CreatePopup show={true}/>
|
||||||
</View>
|
</View>
|
||||||
)
|
)
|
||||||
}
|
}
|
@ -45,4 +45,20 @@
|
|||||||
height: 100%;
|
height: 100%;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.refresh{
|
||||||
|
position: absolute;
|
||||||
|
top: 23px;
|
||||||
|
right: 20px;
|
||||||
|
display: flex;
|
||||||
|
color: #dddddd;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
|
||||||
|
.mconfont{
|
||||||
|
font-size: 36px;
|
||||||
|
}
|
||||||
|
.refresh_text{
|
||||||
|
font-size: 25px;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,25 +1,74 @@
|
|||||||
import { formatImgUrl } from "@/common/fotmat";
|
import { formatImgUrl } from "@/common/fotmat";
|
||||||
import { Image, Text, View } from "@tarojs/components";
|
import { Image, Text, View } from "@tarojs/components";
|
||||||
import { memo } from "react";
|
import { memo, useEffect, useMemo, useRef, useState } from "react";
|
||||||
|
import classnames from "classnames";
|
||||||
import styles from './index.module.scss'
|
import styles from './index.module.scss'
|
||||||
|
import dayjs from "dayjs";
|
||||||
|
import { useTimeCountDown } from "@/use/useCommonData";
|
||||||
|
import { ORDER_STATUS, PAYMENT_METHOD, PAYMENT_METHOD_PARAM } from "@/common/enum";
|
||||||
|
|
||||||
|
type List = {
|
||||||
|
status: string,
|
||||||
|
time: string,
|
||||||
|
tag: string,
|
||||||
|
desc: string,
|
||||||
|
expire_time: string
|
||||||
|
}
|
||||||
|
|
||||||
|
type Param = {
|
||||||
|
onRefresh?: () => void,
|
||||||
|
orderInfo?: {
|
||||||
|
logistics_details:List[], //订单状态列表
|
||||||
|
payment_method: 0|PAYMENT_METHOD_PARAM, //支付方式
|
||||||
|
status: number, //订单状态
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export default memo(({orderInfo, onRefresh}:Param) => {
|
||||||
|
|
||||||
|
const {showTime, onStart, timeStatus} = useTimeCountDown()
|
||||||
|
|
||||||
|
//订单状态枚举
|
||||||
|
const {SaleorderstatusWaitingPrePayment} = ORDER_STATUS
|
||||||
|
|
||||||
|
//获取预付款最后时间
|
||||||
|
const endTime = useMemo(() => {
|
||||||
|
if(orderInfo?.status == SaleorderstatusWaitingPrePayment.value && orderInfo.logistics_details.length > 0) {
|
||||||
|
return orderInfo.logistics_details[0].expire_time
|
||||||
|
}
|
||||||
|
return ''
|
||||||
|
}, [orderInfo])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if(endTime) onStart(endTime)
|
||||||
|
}, [endTime])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if(timeStatus == 2) onRefresh?.()
|
||||||
|
}, [timeStatus])
|
||||||
|
|
||||||
|
|
||||||
export default memo(() => {
|
|
||||||
return (
|
return (
|
||||||
<View className={styles.advance_main}>
|
<View className={styles.advance_main}>
|
||||||
<View className={styles.time_con}>
|
<View className={styles.time_con}>
|
||||||
<View className={styles.times}>
|
<View className={styles.times}>
|
||||||
<Text className={styles.text}>剩</Text>
|
<Text className={styles.text}>剩</Text>
|
||||||
<Text className={styles.num}>23</Text>
|
<Text className={styles.num}>{showTime.HH}</Text>
|
||||||
<Text className={styles.separate}>:</Text>
|
<Text className={styles.separate}>:</Text>
|
||||||
<Text className={styles.num}>58</Text>
|
<Text className={styles.num}>{showTime.MM}</Text>
|
||||||
<Text className={styles.separate}>:</Text>
|
<Text className={styles.separate}>:</Text>
|
||||||
<Text className={styles.num}>55</Text>
|
<Text className={styles.num}>{showTime.SS}</Text>
|
||||||
</View>
|
</View>
|
||||||
<Text>支付关闭,订单自动取消</Text>
|
<Text>支付关闭,订单自动取消</Text>
|
||||||
</View>
|
</View>
|
||||||
<View className={styles.cardIcon}>
|
<View className={styles.cardIcon}>
|
||||||
<Image className={styles.image} src={formatImgUrl("/mall/my_cart.png", true)}/>
|
<Image className={styles.image} src={formatImgUrl("/mall/my_cart.png", true)}/>
|
||||||
</View>
|
</View>
|
||||||
|
<View className={styles.refresh} onClick={() => onRefresh?.()}>
|
||||||
|
<Text className={classnames(styles.mconfont, 'iconfont icon-xianxiahuikuan')}></Text>
|
||||||
|
<Text className={classnames(styles.refresh_text)}>刷新</Text>
|
||||||
|
</View>
|
||||||
</View>
|
</View>
|
||||||
)
|
)
|
||||||
})
|
})
|
@ -15,6 +15,7 @@ import ShopCart from "@/components/shopCart";
|
|||||||
import { Text, Textarea, View } from "@tarojs/components"
|
import { Text, Textarea, View } from "@tarojs/components"
|
||||||
import Taro, { useDidShow, usePullDownRefresh, useRouter } from "@tarojs/taro";
|
import Taro, { useDidShow, usePullDownRefresh, useRouter } from "@tarojs/taro";
|
||||||
import classnames from "classnames";
|
import classnames from "classnames";
|
||||||
|
import dayjs from "dayjs";
|
||||||
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
||||||
import AddressInfoDetail from "./components/addressInfoDetail";
|
import AddressInfoDetail from "./components/addressInfoDetail";
|
||||||
import AdvanceOrderState from "./components/advanceOrderState";
|
import AdvanceOrderState from "./components/advanceOrderState";
|
||||||
@ -191,7 +192,7 @@ import styles from './index.module.scss'
|
|||||||
}, [orderDetail])
|
}, [orderDetail])
|
||||||
|
|
||||||
//订单状态枚举
|
//订单状态枚举
|
||||||
const {SaleOrderStatusCancel} = ORDER_STATUS
|
const {SaleOrderStatusCancel, SaleorderstatusWaitingPrePayment} = ORDER_STATUS
|
||||||
|
|
||||||
//刷新页面
|
//刷新页面
|
||||||
const refresh = useCallback(() => {
|
const refresh = useCallback(() => {
|
||||||
@ -250,8 +251,8 @@ import styles from './index.module.scss'
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<View className={styles.order_main}>
|
<View className={styles.order_main}>
|
||||||
<OrderState orderInfo={orderDetail} onRefresh={refresh}/>
|
{(orderDetail?.status != SaleorderstatusWaitingPrePayment.value)&&<OrderState orderInfo={orderDetail}/>||
|
||||||
{/* <AdvanceOrderState orderInfo={orderDetail} onRefresh={refresh}/> */}
|
<AdvanceOrderState orderInfo={orderDetail} onRefresh={refresh}/>}
|
||||||
<View>
|
<View>
|
||||||
<AddressInfoDetail orderInfo={defaultAddress} onLogistics={getLogistics} onSelect={getAddress} onChangeShipmentMode={getShipmentMode} ref={addressRef} />
|
<AddressInfoDetail orderInfo={defaultAddress} onLogistics={getLogistics} onSelect={getAddress} onChangeShipmentMode={getShipmentMode} ref={addressRef} />
|
||||||
</View>
|
</View>
|
||||||
|
@ -249,13 +249,13 @@ const Assets = (props: any) => {
|
|||||||
</View>
|
</View>
|
||||||
<Text className={`${styles['assets-content-item-tips']}`}>预存款</Text>
|
<Text className={`${styles['assets-content-item-tips']}`}>预存款</Text>
|
||||||
</Navigator>
|
</Navigator>
|
||||||
<View>
|
{/* <View>
|
||||||
<View className={`${styles['assets-content-item-top']}`}>
|
<View className={`${styles['assets-content-item-top']}`}>
|
||||||
<Text className={`${styles['assets-content-item-top-content']}`}>{props.data.data.coupon_count || 0}</Text>
|
<Text className={`${styles['assets-content-item-top-content']}`}>{props.data.data.coupon_count || 0}</Text>
|
||||||
<Text className={`${styles['assets-content-item-top-after']}`}>张</Text>
|
<Text className={`${styles['assets-content-item-top-after']}`}>张</Text>
|
||||||
</View>
|
</View>
|
||||||
<Text className={`${styles['assets-content-item-tips']}`}>优惠券</Text>
|
<Text className={`${styles['assets-content-item-tips']}`}>优惠券</Text>
|
||||||
</View>
|
</View> */}
|
||||||
<Navigator hoverClass="none" onClick={() => props.checkShow()}>
|
<Navigator hoverClass="none" onClick={() => props.checkShow()}>
|
||||||
<View className={`${styles['assets-content-item-top']}`} >
|
<View className={`${styles['assets-content-item-top']}`} >
|
||||||
<Text className={`${styles['assets-content-item-top-before']}`}>¥</Text>
|
<Text className={`${styles['assets-content-item-top-before']}`}>¥</Text>
|
||||||
|
@ -1,23 +1,60 @@
|
|||||||
import { useDispatch } from 'react-redux'
|
import dayjs from "dayjs"
|
||||||
import {SET_COMMON, CLEAR_COMMON} from '@/constants/common'
|
import { useEffect, useRef, useState } from "react"
|
||||||
import {useSelector} from '@/reducers/hooks'
|
|
||||||
/**
|
|
||||||
* 这个hook 用来临时存储数据用
|
|
||||||
*/
|
|
||||||
export default () => {
|
|
||||||
const {common: commonData} = useSelector(state => state.commonData)
|
|
||||||
const dispatch = useDispatch()
|
|
||||||
const setCommonData = (val:any) => {
|
|
||||||
dispatch({type:SET_COMMON, data:val})
|
|
||||||
}
|
|
||||||
|
|
||||||
const removeCommonData = () => {
|
//倒计时hook
|
||||||
dispatch({type:CLEAR_COMMON})
|
export const useTimeCountDown = () => {
|
||||||
|
const [showTime, setShowTime] = useState({
|
||||||
|
DD: '',
|
||||||
|
HH: '',
|
||||||
|
MM: '',
|
||||||
|
SS: ''
|
||||||
|
})
|
||||||
|
const [timeStatus, setTimeStatus] = useState<0|1|2>(0) //倒计时状体 0:倒计时未开始 1:倒计时中, 2:倒计时已结束
|
||||||
|
const timeObj:any = useRef()
|
||||||
|
const endTime = useRef('')
|
||||||
|
const onStart = (val = '') => {
|
||||||
|
endTime.current = val
|
||||||
|
if(endTime.current) {
|
||||||
|
clearInterval(timeObj.current)
|
||||||
|
timeObj.current = setInterval(() => {
|
||||||
|
count_down()
|
||||||
|
}, 1000)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
useEffect(() => {
|
||||||
|
return () => {
|
||||||
|
clearInterval(timeObj.current)
|
||||||
|
}
|
||||||
|
}, [])
|
||||||
|
const count_down = () => {
|
||||||
|
var startData = dayjs();
|
||||||
|
var endDate = dayjs(endTime.current);
|
||||||
|
setTimeStatus(() => 1)
|
||||||
|
if(startData >= endDate) {
|
||||||
|
clearInterval(timeObj.current)
|
||||||
|
setShowTime((e) => ({...e, DD:'00', HH:'00', MM:'00', SS:'00'}))
|
||||||
|
setTimeStatus(() => 2)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
var _dd = endDate.diff(startData,'day');
|
||||||
|
var _hh = endDate.diff(startData,'hour');
|
||||||
|
var _mm = endDate.diff(startData,'minute');
|
||||||
|
var _ss = endDate.diff(startData,'second');
|
||||||
|
// 转换
|
||||||
|
var hh = _hh - (_dd*24);
|
||||||
|
var mm = _mm - (_hh*60);
|
||||||
|
var ss = _ss - (_mm*60);
|
||||||
|
// 格式化
|
||||||
|
var DD = ('00'+_dd).slice(-2);
|
||||||
|
var HH = ('00'+hh).slice(-2);
|
||||||
|
var MM = ('00'+mm).slice(-2);
|
||||||
|
var SS = ('00'+ss).slice(-2);
|
||||||
|
// console.log('endTime::', `${DD}-${HH}-${MM}-${SS}`)
|
||||||
|
setShowTime((e) => ({...e, DD, HH, MM, SS}))
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
setCommonData,
|
showTime,
|
||||||
removeCommonData,
|
onStart,
|
||||||
commonData
|
timeStatus
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -86,7 +86,7 @@ const showStatus = (status) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//登录状态
|
//登录状态
|
||||||
const loginStatus: false|true = false // true:登录中
|
let loginStatus: false|true = false // true:登录中
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* axios 请求状态封装,返回响应式数据 fetch(), loading, error, code, msg 等常用方法/状态
|
* axios 请求状态封装,返回响应式数据 fetch(), loading, error, code, msg 等常用方法/状态
|
||||||
@ -176,9 +176,13 @@ export const useRequest = (options:option = {
|
|||||||
stateRef.current.total = data?.list ? data?.total : 0
|
stateRef.current.total = data?.list ? data?.total : 0
|
||||||
}else{
|
}else{
|
||||||
if (statusCode === 401) {
|
if (statusCode === 401) {
|
||||||
removeToken()
|
if(!loginStatus) {
|
||||||
removeSessionKey()
|
removeToken()
|
||||||
login()
|
removeSessionKey()
|
||||||
|
login()
|
||||||
|
loginStatus = true
|
||||||
|
}
|
||||||
|
//todo 登录数据刷新次数问题
|
||||||
} else {
|
} else {
|
||||||
Taro.showToast({
|
Taro.showToast({
|
||||||
title: `错误:${showStatus(statusCode)}`,
|
title: `错误:${showStatus(statusCode)}`,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user