商城测试版v6
This commit is contained in:
parent
861cc74545
commit
b9119c9f35
@ -42,7 +42,7 @@ export const weightDigit = 1000
|
|||||||
*/
|
*/
|
||||||
export const formatPriceDiv = (val, digit = Digit, priceStatus = false) => {
|
export const formatPriceDiv = (val, digit = Digit, priceStatus = false) => {
|
||||||
let res = strip(Number(val / digit)) || 0
|
let res = strip(Number(val / digit)) || 0
|
||||||
return priceStatus?res.toLocaleString('zh', {minimumFractionDigits: 2}):res
|
return priceStatus?numberWithCommas({number: res}):res
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* 乘以
|
* 乘以
|
||||||
@ -82,11 +82,6 @@ export const formatDateTime = (val, fmt = "YYYY-MM-DD HH:mm:ss") => {
|
|||||||
let s = time.getSeconds()
|
let s = time.getSeconds()
|
||||||
|
|
||||||
fmt = fmt.replace('YYYY', Y).replace('MM', M.toString().padStart(2, '0')).replace('DD', d.toString().padStart(2, '0')).replace('HH', h.toString().padStart(2, '0')).replace('mm', m.toString().padStart(2, '0')).replace('ss', s.toString().padStart(2, '0'))
|
fmt = fmt.replace('YYYY', Y).replace('MM', M.toString().padStart(2, '0')).replace('DD', d.toString().padStart(2, '0')).replace('HH', h.toString().padStart(2, '0')).replace('mm', m.toString().padStart(2, '0')).replace('ss', s.toString().padStart(2, '0'))
|
||||||
// fmt = fmt.replace('MM', M)
|
|
||||||
// fmt = fmt.replace('DD', d)
|
|
||||||
// fmt = fmt.replace('HH', h)
|
|
||||||
// fmt = fmt.replace('mm', m)
|
|
||||||
// fmt = fmt.replace('ss', s)
|
|
||||||
|
|
||||||
return fmt
|
return fmt
|
||||||
} else {
|
} else {
|
||||||
@ -164,3 +159,16 @@ export const isLabImage = (imgurl, rgb, suffix="!w200") => {
|
|||||||
return {status:3, value: IMG_CND_Prefix+'/mall/no_img.png'}
|
return {status:3, value: IMG_CND_Prefix+'/mall/no_img.png'}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param {千位分割付} number
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
export const numberWithCommas = ({number = 0, digit = 2}) => {
|
||||||
|
if(!isNaN(Number(number))) {
|
||||||
|
return parseFloat(number).toFixed(digit).replace(/\B(?<!\.\d*)(?=(\d{3})+(?!\d))/g, ",");
|
||||||
|
} else {
|
||||||
|
return 0.00
|
||||||
|
}
|
||||||
|
}
|
@ -2,6 +2,7 @@ import { Text, View } from "@tarojs/components";
|
|||||||
import { memo, useCallback } from "react";
|
import { memo, useCallback } from "react";
|
||||||
import styles from './index.module.scss'
|
import styles from './index.module.scss'
|
||||||
import classnames from "classnames";
|
import classnames from "classnames";
|
||||||
|
import { numberWithCommas } from "@/common/fotmat";
|
||||||
|
|
||||||
type Param = {
|
type Param = {
|
||||||
number: number, //数字
|
number: number, //数字
|
||||||
@ -15,7 +16,7 @@ export default memo(({number = 0, status = 1}:Param) => {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Text className={styles.price_text}>¥</Text>
|
<Text className={styles.price_text}>¥</Text>
|
||||||
<Text className={styles.price_text}>{Number(int_num).toLocaleString()}</Text>
|
<Text className={styles.price_text}>{numberWithCommas({number:int_num, digit:0})}</Text>
|
||||||
<Text className={styles.price_text}>.{decimals_num}</Text>
|
<Text className={styles.price_text}>.{decimals_num}</Text>
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
|
@ -131,7 +131,7 @@ import { throttle } from "@/common/util";
|
|||||||
const numText = useMemo(() => {
|
const numText = useMemo(() => {
|
||||||
if(formatPreViewOrder) {
|
if(formatPreViewOrder) {
|
||||||
let total_number = formatPreViewOrder?.sale_mode == 0?formatPreViewOrder?.total_number:(formatPreViewOrder?.total_number/100)
|
let total_number = formatPreViewOrder?.sale_mode == 0?formatPreViewOrder?.total_number:(formatPreViewOrder?.total_number/100)
|
||||||
return `${formatPreViewOrder?.total_fabrics} 种面料,${formatPreViewOrder?.total_colors} 种颜色,共 ${total_number}${formatPreViewOrder?.unit}`
|
return `${formatPreViewOrder?.total_fabrics} 种面料,${formatPreViewOrder?.total_colors} 种颜色,共 ${total_number} ${formatPreViewOrder?.unit}`
|
||||||
}
|
}
|
||||||
}, [formatPreViewOrder])
|
}, [formatPreViewOrder])
|
||||||
|
|
||||||
@ -178,7 +178,7 @@ import { throttle } from "@/common/util";
|
|||||||
</View>
|
</View>
|
||||||
<View className={styles.submit_order}>
|
<View className={styles.submit_order}>
|
||||||
<View className={styles.submit_order_number}>
|
<View className={styles.submit_order_number}>
|
||||||
<SubmitOrderBtn style={{color:'#007AFF'}} number={formatPriceDiv(preViewOrder?.sale_mode == 1?formatPreViewOrder?.total_should_collect_money:formatPreViewOrder?.estimate_amount) as number} priceTitle={preViewOrder?.sale_mode == 1?'合计金额':'预估金额'}/>
|
<SubmitOrderBtn style={{color:'#007AFF'}} number={(preViewOrder?.sale_mode == 1?formatPreViewOrder?.total_should_collect_money:formatPreViewOrder?.estimate_amount)/100} priceTitle={preViewOrder?.sale_mode == 1?'合计金额':'预估金额'}/>
|
||||||
<View className={styles.order_number_desc}>{numText}</View>
|
<View className={styles.order_number_desc}>{numText}</View>
|
||||||
</View>
|
</View>
|
||||||
<View className={classnames(styles.order_btn, btnStatus&&styles.ok_order_btn)} onClick={() => submitOrderEven()}>提交订单</View>
|
<View className={classnames(styles.order_btn, btnStatus&&styles.ok_order_btn)} onClick={() => submitOrderEven()}>提交订单</View>
|
||||||
|
@ -109,7 +109,7 @@ export default memo(({order, comfirm = false}:Param) => {
|
|||||||
<>
|
<>
|
||||||
{
|
{
|
||||||
priceList.map(item => {
|
priceList.map(item => {
|
||||||
return <>{item.validatarFunc(order)&&<EstimatedAmount key={item.id} number={formatPriceDiv(order[item.field]) as number} title={item.label} messageTitle={item.message} />}</>
|
return <>{item.validatarFunc(order)&&<EstimatedAmount key={item.id} number={order[item.field]/100} title={item.label} messageTitle={item.message} />}</>
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
</>
|
</>
|
||||||
@ -122,14 +122,14 @@ export default memo(({order, comfirm = false}:Param) => {
|
|||||||
}, [order])
|
}, [order])
|
||||||
//对应单价
|
//对应单价
|
||||||
const standardPrice = useCallback(price => {
|
const standardPrice = useCallback(price => {
|
||||||
return formatPriceDiv(price).toLocaleString() + '/' + (order?.sale_mode == 1?'m':'kg')
|
return formatPriceDiv(price, 100, true) + '/' + (order?.sale_mode == 1?'m':'kg')
|
||||||
}, [order])
|
}, [order])
|
||||||
|
|
||||||
//数量格式
|
//数量格式
|
||||||
const numText = useMemo(() => {
|
const numText = useMemo(() => {
|
||||||
if(order) {
|
if(order) {
|
||||||
let total_number = order?.sale_mode == 0?order?.total_number:(order?.total_number/100)
|
let total_number = order?.sale_mode == 0?order?.total_number:(order?.total_number/100)
|
||||||
return `${order?.total_fabrics} 种面料,${order?.total_colors} 种颜色,共 ${total_number}${order?.unit}`
|
return `${order?.total_fabrics} 种面料,${order?.total_colors} 种颜色,共 ${total_number} ${order?.unit}`
|
||||||
}
|
}
|
||||||
}, [order])
|
}, [order])
|
||||||
|
|
||||||
@ -137,7 +137,7 @@ export default memo(({order, comfirm = false}:Param) => {
|
|||||||
const comfirmPriceConDom = useMemo(() => {
|
const comfirmPriceConDom = useMemo(() => {
|
||||||
if(!order) return
|
if(!order) return
|
||||||
let item = order.sale_mode == 1?priceList[1]:priceList[0]
|
let item = order.sale_mode == 1?priceList[1]:priceList[0]
|
||||||
return<EstimatedAmount key={item.id} number={formatPriceDiv(order[item.field]) as number} title={item.label} />
|
return<EstimatedAmount key={item.id} number={order[item.field]/100} title={item.label} messageTitle={item.message}/>
|
||||||
}, [order])
|
}, [order])
|
||||||
|
|
||||||
//确认金额展示
|
//确认金额展示
|
||||||
@ -148,7 +148,7 @@ export default memo(({order, comfirm = false}:Param) => {
|
|||||||
//颜色金额小计
|
//颜色金额小计
|
||||||
const colorPrice = useCallback((item) => {
|
const colorPrice = useCallback((item) => {
|
||||||
let res = item.total_sale_price||item.estimate_amount
|
let res = item.total_sale_price||item.estimate_amount
|
||||||
return formatPriceDiv(res).toLocaleString('en', {minimumFractionDigits: 2})
|
return formatPriceDiv(res, 100, true)
|
||||||
},[order])
|
},[order])
|
||||||
|
|
||||||
|
|
||||||
|
@ -5,8 +5,8 @@ import {
|
|||||||
import { AddShoppingCartApi } from "@/api/shopCart";
|
import { AddShoppingCartApi } from "@/api/shopCart";
|
||||||
import { SubscriptionMessageApi } from "@/api/user";
|
import { SubscriptionMessageApi } from "@/api/user";
|
||||||
import { alert, goLink } from "@/common/common";
|
import { alert, goLink } from "@/common/common";
|
||||||
import { ORDER_STATUS, SUBSCRIPTION_MESSAGE_SCENE } from "@/common/enum";
|
import { ORDER_STATUS } from "@/common/enum";
|
||||||
import { formatDateTime, formatImgUrl, formatPriceDiv } from "@/common/fotmat";
|
import { formatDateTime, formatImgUrl } from "@/common/fotmat";
|
||||||
import OrderBtns from "@/components/orderBtns";
|
import OrderBtns from "@/components/orderBtns";
|
||||||
import Popup from "@/components/popup";
|
import Popup from "@/components/popup";
|
||||||
import SearchInput from "@/components/searchInput";
|
import SearchInput from "@/components/searchInput";
|
||||||
|
@ -127,7 +127,7 @@ export default memo(({value, onClickBtn}: Param) => {
|
|||||||
</View>
|
</View>
|
||||||
<View className={styles.color_count_num}>
|
<View className={styles.color_count_num}>
|
||||||
<Text>{numText}</Text>
|
<Text>{numText}</Text>
|
||||||
{(value.total_sale_price/100||value.estimate_amount/100)&& <Text className={styles.price}><Text>¥</Text>{formatPriceDiv(value.total_sale_price, 100, true)||formatPriceDiv(value.estimate_amount, 100, true)}</Text>}
|
<Text className={styles.price}><Text>¥</Text>{value.total_sale_price?formatPriceDiv(value.total_sale_price, 100, true):formatPriceDiv(value.estimate_amount, 100, true)}</Text>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
<OrderBtns orderInfo={orderInfo} onClick={orderBtnsClick}/>
|
<OrderBtns orderInfo={orderInfo} onClick={orderBtnsClick}/>
|
||||||
|
@ -159,7 +159,7 @@ export default memo(({order, comfirm = false}:Param) => {
|
|||||||
<>
|
<>
|
||||||
{
|
{
|
||||||
priceList.map(item => {
|
priceList.map(item => {
|
||||||
return <>{showPrice(item)&&<EstimatedAmount messageTitle={item.message} key={item.id} number={formatPriceDiv(order[item.field])} title={item.label} />}</>
|
return <>{showPrice(item)&&<EstimatedAmount messageTitle={item.message} key={item.id} number={order[item.field]} title={item.label} />}</>
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
</>
|
</>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user