商城测试版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) => {
|
||||
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()
|
||||
|
||||
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
|
||||
} else {
|
||||
@ -164,3 +159,16 @@ export const isLabImage = (imgurl, rgb, suffix="!w200") => {
|
||||
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 styles from './index.module.scss'
|
||||
import classnames from "classnames";
|
||||
import { numberWithCommas } from "@/common/fotmat";
|
||||
|
||||
type Param = {
|
||||
number: number, //数字
|
||||
@ -15,7 +16,7 @@ export default memo(({number = 0, status = 1}:Param) => {
|
||||
return (
|
||||
<>
|
||||
<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>
|
||||
</>
|
||||
)
|
||||
|
@ -178,7 +178,7 @@ import { throttle } from "@/common/util";
|
||||
</View>
|
||||
<View className={styles.submit_order}>
|
||||
<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>
|
||||
<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 => {
|
||||
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,7 +122,7 @@ export default memo(({order, comfirm = false}:Param) => {
|
||||
}, [order])
|
||||
//对应单价
|
||||
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])
|
||||
|
||||
//数量格式
|
||||
@ -137,7 +137,7 @@ export default memo(({order, comfirm = false}:Param) => {
|
||||
const comfirmPriceConDom = useMemo(() => {
|
||||
if(!order) return
|
||||
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])
|
||||
|
||||
//确认金额展示
|
||||
@ -148,7 +148,7 @@ export default memo(({order, comfirm = false}:Param) => {
|
||||
//颜色金额小计
|
||||
const colorPrice = useCallback((item) => {
|
||||
let res = item.total_sale_price||item.estimate_amount
|
||||
return formatPriceDiv(res).toLocaleString('en', {minimumFractionDigits: 2})
|
||||
return formatPriceDiv(res, 100, true)
|
||||
},[order])
|
||||
|
||||
|
||||
|
@ -5,8 +5,8 @@ import {
|
||||
import { AddShoppingCartApi } from "@/api/shopCart";
|
||||
import { SubscriptionMessageApi } from "@/api/user";
|
||||
import { alert, goLink } from "@/common/common";
|
||||
import { ORDER_STATUS, SUBSCRIPTION_MESSAGE_SCENE } from "@/common/enum";
|
||||
import { formatDateTime, formatImgUrl, formatPriceDiv } from "@/common/fotmat";
|
||||
import { ORDER_STATUS } from "@/common/enum";
|
||||
import { formatDateTime, formatImgUrl } from "@/common/fotmat";
|
||||
import OrderBtns from "@/components/orderBtns";
|
||||
import Popup from "@/components/popup";
|
||||
import SearchInput from "@/components/searchInput";
|
||||
|
@ -127,7 +127,7 @@ export default memo(({value, onClickBtn}: Param) => {
|
||||
</View>
|
||||
<View className={styles.color_count_num}>
|
||||
<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>
|
||||
<OrderBtns orderInfo={orderInfo} onClick={orderBtnsClick}/>
|
||||
|
@ -159,7 +159,7 @@ export default memo(({order, comfirm = false}:Param) => {
|
||||
<>
|
||||
{
|
||||
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